[{"id":37050,"web_url":"https://patchwork.libcamera.org/comment/37050/","msgid":"<176408966697.567526.17917817525428179783@ping.linuxembedded.co.uk>","date":"2025-11-25T16:54:26","subject":"Re: [PATCH v3 22/29] libcamera: Add transpose() function to size","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-11-25 16:28:34)\n> Add a transpose() function to size that applies the\n> Transformation::Transpose operation in the size. This is useful when\n> handling orientation adjustments.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> ---\n> \n> Changes in v3:\n> - Added test case\n> ---\n>  include/libcamera/geometry.h |  6 ++++++\n>  src/libcamera/geometry.cpp   | 10 ++++++++++\n>  test/geometry.cpp            |  5 +++++\n>  3 files changed, 21 insertions(+)\n> \n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index d9378efeca8c..572a07e2cf92 100644\n> --- a/include/libcamera/geometry.h\n> +++ b/include/libcamera/geometry.h\n> @@ -108,6 +108,12 @@ public:\n>                 return *this;\n>         }\n>  \n> +       Size &transpose()\n> +       {\n> +               std::swap(width, height);\n> +               return *this;\n> +       }\n> +\n>         [[nodiscard]] constexpr Size alignedDownTo(unsigned int hAlignment,\n>                                                    unsigned int vAlignment) const\n>         {\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index de76d0c12a8c..2763967a6e57 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -209,6 +209,16 @@ std::string Size::toString() const\n>   * \\return A reference to this object\n>   */\n>  \n> +/**\n> + * \\fn Size::transpose()\n> + * \\brief Transpose the size in place\n> + *\n> + * This function swaps width and height of this size. This effectively applies\n> + * the \\a Transform::Transpose transformation on this size.\n> + *\n> + * \\return A reference to this object\n> + */\n> +\n>  /**\n>   * \\fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment)\n>   * \\brief Align the size down horizontally and vertically\n> diff --git a/test/geometry.cpp b/test/geometry.cpp\n> index 11df043b733b..a50b643b7ee6 100644\n> --- a/test/geometry.cpp\n> +++ b/test/geometry.cpp\n> @@ -203,6 +203,11 @@ protected:\n>                         return TestFail;\n>                 }\n>  \n> +               if (Size(200, 50).transpose() != Size(50, 200)) {\n> +                       cout << \"Size::transpose() test failed\" << endl;\n> +                       return TestFail;\n> +               }\n> +\n>                 /* Aspect ratio tests */\n>                 if (Size(0, 0).boundedToAspectRatio(Size(4, 3)) != Size(0, 0) ||\n>                     Size(1920, 1440).boundedToAspectRatio(Size(16, 9)) != Size(1920, 1080) ||\n> -- \n> 2.51.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CE1B8C3338\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Nov 2025 16:54:32 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EB63160A9E;\n\tTue, 25 Nov 2025 17:54:31 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 37CCD609D8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Nov 2025 17:54:30 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0D330524;\n\tTue, 25 Nov 2025 17:52:21 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"phbRH2M9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764089541;\n\tbh=EqbEgXq4gzAH8GLnFosgJwgdwj+PNaZVXF+w7e/pDeU=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=phbRH2M9ofFmR4a0GsGiVXpQqLeqRO3mn5KJukgy8vfQ9/0JNS3GPqgOJ9dbnDoTs\n\tCn5Q9Zv+YczrtzW4W159Q+8TiN7Fs8YOINKiuJgDYOv0P/AbaasBEDuhJKI7PRiUe4\n\tzDSuUUDz622tul3a41Q/gBHQfg+UCUHgZIbHMnZc=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251125162851.2301793-23-stefan.klug@ideasonboard.com>","References":"<20251125162851.2301793-1-stefan.klug@ideasonboard.com>\n\t<20251125162851.2301793-23-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v3 22/29] libcamera: Add transpose() function to size","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 25 Nov 2025 16:54:26 +0000","Message-ID":"<176408966697.567526.17917817525428179783@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]