[{"id":31525,"web_url":"https://patchwork.libcamera.org/comment/31525/","msgid":"<20241002114507.GB10158@pendragon.ideasonboard.com>","date":"2024-10-02T11:45:07","subject":"Re: [PATCH v10 2/5] libcamera: geometry: Add two-point Rectangle\n\tconstructor","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Wed, Oct 02, 2024 at 07:49:59AM +0200, Jacopo Mondi wrote:\n> From: Yudhistira Erlandinata <yerlandinata@chromium.org>\n> \n> Add a constructor to the Rectangle class that accepts two points.\n> \n> The constructed Rectangle spans all the space between the two given\n> points.\n> \n> Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\n> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/geometry.h |  9 +++++++++\n>  src/libcamera/geometry.cpp   |  7 +++++++\n>  test/geometry.cpp            | 14 ++++++++++++++\n>  3 files changed, 30 insertions(+)\n> \n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index 3e6f0f5d7fab..9ca5865a3d0d 100644\n> --- a/include/libcamera/geometry.h\n> +++ b/include/libcamera/geometry.h\n> @@ -262,6 +262,15 @@ public:\n>  \t{\n>  \t}\n>  \n> +\tconstexpr Rectangle(const Point &point1, const Point &point2)\n> +\t\t: Rectangle(std::min(point1.x, point2.x), std::min(point1.y, point2.y),\n> +\t\t\t    static_cast<unsigned int>(std::max(point1.x, point2.x)) -\n> +\t\t\t    static_cast<unsigned int>(std::min(point1.x, point2.x)),\n> +\t\t\t    static_cast<unsigned int>(std::max(point1.y, point2.y)) -\n> +\t\t\t    static_cast<unsigned int>(std::min(point1.y, point2.y)))\n> +\t{\n> +\t}\n> +\n>  \tint x;\n>  \tint y;\n>  \tunsigned int width;\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index 85a7f53a6f6c..90ccf8c19f97 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -635,6 +635,13 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr)\n>   * \\param[in] size The desired Rectangle size\n>   */\n>  \n> +/**\n> + * \\fn Rectangle::Rectangle(const Point &point1, const Point &point2)\n> + * \\brief Construct a Rectangle from two opposite corners\n> + * \\param[in] point1 One of corners of the rectangle\n> + * \\param[in] point2 The opposite corner of \\a point1\n> + */\n> +\n>  /**\n>   * \\var Rectangle::x\n>   * \\brief The horizontal coordinate of the rectangle's top-left corner\n> diff --git a/test/geometry.cpp b/test/geometry.cpp\n> index 64169206ad16..5760fa3c885a 100644\n> --- a/test/geometry.cpp\n> +++ b/test/geometry.cpp\n> @@ -481,6 +481,20 @@ protected:\n>  \t\t\treturn TestFail;\n>  \t\t}\n>  \n> +\t\tPoint topLeft(3, 3);\n> +\t\tPoint bottomRight(30, 30);\n> +\t\tPoint topRight(30, 3);\n> +\t\tPoint bottomLeft(3, 30);\n> +\t\tRectangle rect1(topLeft, bottomRight);\n> +\t\tRectangle rect2(topRight, bottomLeft);\n> +\t\tRectangle rect3(bottomRight, topLeft);\n> +\t\tRectangle rect4(bottomLeft, topRight);\n> +\n> +\t\tif (rect1 != rect2 || rect1 != rect3 || rect1 != rect4) {\n> +\t\t\tcout << \"Point-to-point construction failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n>  \t\treturn TestPass;\n>  \t}\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 98314C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Oct 2024 11:45:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 423EF63527;\n\tWed,  2 Oct 2024 13:45:12 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B902263510\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Oct 2024 13:45:09 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 48A905A5;\n\tWed,  2 Oct 2024 13:43:37 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Omqp+2Xf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727869417;\n\tbh=wdt7sxMB9WkDgHFlzwnX/ILAPT7qfYLubNVO621jKK0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Omqp+2XfX/MpeYDH3aoUT55o93f5m8UiBSQPw1hKDuc2vG9tnrLOeOsxuJvwiSkft\n\t96ChbfNkOtEITXBlFrKrkYWpZapZ1pTvSF6+1sCC7S4rYr+Zsk/Us7uuR/dRB/fbcb\n\tkFoytB86+MaV4PD9p4obBra2fWyrD930DRkza2p0=","Date":"Wed, 2 Oct 2024 14:45:07 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tHarvey Yang <chenghaoyang@google.com>, \n\tYudhistira Erlandinata <yerlandinata@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>","Subject":"Re: [PATCH v10 2/5] libcamera: geometry: Add two-point Rectangle\n\tconstructor","Message-ID":"<20241002114507.GB10158@pendragon.ideasonboard.com>","References":"<20241001191354.55056-1-jacopo.mondi@ideasonboard.com>\n\t<20241002055002.6271-1-jacopo.mondi@ideasonboard.com>\n\t<20241002055002.6271-2-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20241002055002.6271-2-jacopo.mondi@ideasonboard.com>","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>"}}]