{"id":21467,"url":"https://patchwork.libcamera.org/api/patches/21467/?format=json","web_url":"https://patchwork.libcamera.org/patch/21467/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20241002055002.6271-2-jacopo.mondi@ideasonboard.com>","date":"2024-10-02T05:49:59","name":"[v10,2/5] libcamera: geometry: Add two-point Rectangle constructor","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"eff43a42c81d205db22fc302abf0d2b53865d3e7","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21467/mbox/","series":[{"id":4647,"url":"https://patchwork.libcamera.org/api/series/4647/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4647","date":"2024-10-01T19:13:44","name":"Add Face Detection Controls","version":10,"mbox":"https://patchwork.libcamera.org/series/4647/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21467/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21467/checks/","tags":{},"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 6E156BD80A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Oct 2024 05:50:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2BF0163524;\n\tWed,  2 Oct 2024 07:50:19 +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 502C163512\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Oct 2024 07:50:15 +0200 (CEST)","from ideasonboard.com (unknown [5.77.88.238])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C5E72741;\n\tWed,  2 Oct 2024 07:48:41 +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=\"ZgQ7nnBq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727848123;\n\tbh=Ap9U8t93dlAPWb1HEcjODNBNakr9/cjN29sKX2PRuqo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ZgQ7nnBqpDEHg3/sCrdjNjQR34DTpEOnks0TVOg4EavrJrUcxVQ2fpElDOcou0/mO\n\tcxUOp4CdJ8XOQS9P4y3YyPnPhP0SrF/XjcGGzTJB+5MxicupLjbl75UnqqxnS40PfK\n\t5NGdlRkghvQDR9k0lIY6iMB55gi/nEtyPGQS5Fvs=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Harvey Yang <chenghaoyang@google.com>,\n\tYudhistira Erlandinata <yerlandinata@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"[PATCH v10 2/5] libcamera: geometry: Add two-point Rectangle\n\tconstructor","Date":"Wed,  2 Oct 2024 07:49:59 +0200","Message-ID":"<20241002055002.6271-2-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.46.1","In-Reply-To":"<20241002055002.6271-1-jacopo.mondi@ideasonboard.com>","References":"<20241001191354.55056-1-jacopo.mondi@ideasonboard.com>\n\t<20241002055002.6271-1-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"From: Yudhistira Erlandinata <yerlandinata@chromium.org>\n\nAdd a constructor to the Rectangle class that accepts two points.\n\nThe constructed Rectangle spans all the space between the two given\npoints.\n\nSigned-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n include/libcamera/geometry.h |  9 +++++++++\n src/libcamera/geometry.cpp   |  7 +++++++\n test/geometry.cpp            | 14 ++++++++++++++\n 3 files changed, 30 insertions(+)","diff":"diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex 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;\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 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\ndiff --git a/test/geometry.cpp b/test/geometry.cpp\nindex 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 };\n","prefixes":["v10","2/5"]}