{"id":21331,"url":"https://patchwork.libcamera.org/api/1.1/patches/21331/?format=json","web_url":"https://patchwork.libcamera.org/patch/21331/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20240923093317.3500444-2-chenghaoyang@google.com>","date":"2024-09-23T09:30:44","name":"[v5,1/3] libcamera: Add rectangle two-point constructor","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"215bfdb5245c964a10405bdcdd44e0940a736f19","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/1.1/people/117/?format=json","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21331/mbox/","series":[{"id":4614,"url":"https://patchwork.libcamera.org/api/1.1/series/4614/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4614","date":"2024-09-23T09:30:43","name":"Add Face Detection Controls","version":5,"mbox":"https://patchwork.libcamera.org/series/4614/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21331/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21331/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 508B7C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Sep 2024 09:33:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6B2A163511;\n\tMon, 23 Sep 2024 11:33:29 +0200 (CEST)","from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com\n\t[IPv6:2607:f8b0:4864:20::62c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D27ED6037E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Sep 2024 11:33:25 +0200 (CEST)","by mail-pl1-x62c.google.com with SMTP id\n\td9443c01a7336-2068bee21d8so40480015ad.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Sep 2024 02:33:25 -0700 (PDT)","from chenghaoyang-low.c.googlers.com.com\n\t(0.223.81.34.bc.googleusercontent.com. [34.81.223.0])\n\tby smtp.gmail.com with ESMTPSA id\n\td9443c01a7336-207946d6673sm129864995ad.158.2024.09.23.02.33.22\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 23 Sep 2024 02:33:23 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"S/cfbqZX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1727084004; x=1727688804;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=5+PG4w4fqPObQDpO2iRBORfJQmqvEOjWQ7wghuQIuCM=;\n\tb=S/cfbqZXsBs4ey33IDiIWG91t6mIneDP2DlPz2RG0/HqtCnab+BQnK6x8wrxXse2+S\n\tuWzeU5I4DYHpmtZutzbyLbjtUbeaOLy3mMH2kuHSdD7GyvC7IC59rnfSsXscKIOHoUg8\n\tjlYvmCyLWaT78Red7+bB9n3y9AwoD5ohZI+PE=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1727084004; x=1727688804;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=5+PG4w4fqPObQDpO2iRBORfJQmqvEOjWQ7wghuQIuCM=;\n\tb=Ij9iFUKXSqx/HndJdPyU/9mdKfexRVWiSNL3YesejAbwzZUs1RYMvigNdcKm9XsKTM\n\toCsTh9clXpAw4+cig2MI9JH+XsE4mE531tFdP4UyKAmCUnizt802JLWTeNTsq1wPRMBF\n\tRzGHUBK8GR9UYBzaYjT+w1L4vCZsPWucCcxxJR/TEJeaZ7yg5Bd0DoUKRjiVUvnl88ky\n\twNIogxAO8Ij+upuQga0tKcR/u0zZlmsXIUMaAsaOZhhX2t4DIaI1zCjGQJBT41Vhds/N\n\tMM48YoRm6V2SvWWEyey9sunksESahbBxnhrwhPYflJD8rlXhNI1E2jhOypHUxHnIlzOV\n\tBGKQ==","X-Gm-Message-State":"AOJu0YyQhBYqSEY/t5miKysCB5mam2qstX7RdBJzPSAfBU1MP2lL14rW\n\tkOto48dy/pRL+1QLG1O3nE0ZqIlMcqCehlnPdfK7VYcCzghU5Ps6FtFtk98pG0NWEw35T2oQ4yU\n\t=","X-Google-Smtp-Source":"AGHT+IHhmkt25rJXdm6nntouFJ0CvUSgVNvWVmX4qUGe6sXV0vepge2iRRfM8+GHlIApYh2N2TqF+g==","X-Received":"by 2002:a17:902:e88f:b0:207:1722:37d4 with SMTP id\n\td9443c01a7336-208d83db3c9mr149242845ad.33.1727084004101; \n\tMon, 23 Sep 2024 02:33:24 -0700 (PDT)","From":"Harvey Yang <chenghaoyang@chromium.org>","X-Google-Original-From":"Harvey Yang <chenghaoyang@google.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Yudhistira Erlandinata <yerlandinata@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"[PATCH v5 1/3] libcamera: Add rectangle two-point constructor","Date":"Mon, 23 Sep 2024 09:30:44 +0000","Message-ID":"<20240923093317.3500444-2-chenghaoyang@google.com>","X-Mailer":"git-send-email 2.46.0.792.g87dc391469-goog","In-Reply-To":"<20240923093317.3500444-1-chenghaoyang@google.com>","References":"<20240923093317.3500444-1-chenghaoyang@google.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 Rectangle constructor that accepts two points:\ntopLeft and bottomRight.\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>\n---\n include/libcamera/geometry.h |  7 +++++++\n src/libcamera/geometry.cpp   |  7 +++++++\n test/geometry.cpp            | 14 ++++++++++++++\n 3 files changed, 28 insertions(+)","diff":"diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex 3e6f0f5d..5949d55c 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -262,6 +262,13 @@ 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::max(point1.y, point2.y),\n+\t\t\t    std::max(point1.x, point2.x) - std::min(point1.x, point2.x),\n+\t\t\t    std::max(point1.y, point2.y) - 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 00015136..b608e4f0 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -629,6 +629,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 with the two given points\n+ * \\param[in] point1 One of the corner point of the rectangle\n+ * \\param[in] point2 The diagonal corner point from \\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 64169206..3ed2cc23 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-from-point construction failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n };\n","prefixes":["v5","1/3"]}