From patchwork Fri Aug 23 13:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 20999 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 87F2EC323E for ; Fri, 23 Aug 2024 13:11:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CD9D5633D5; Fri, 23 Aug 2024 15:11:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LGvp0TTp"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E2B5633CB for ; Fri, 23 Aug 2024 15:11:51 +0200 (CEST) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4281c164408so14729295e9.1 for ; Fri, 23 Aug 2024 06:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724418711; x=1725023511; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v9S+dT+RxEXLDnq2Dp9ErqErW7LwS5ZxIeDvscZGsxY=; b=LGvp0TTpZ74IuFT0ScsJ+UJlxEv0i1320iM3Dio93AZO6qGt+lzVW8RE4k02gA/mA1 WqvK4idQHE98aWLoNabJcWkp8ozWMUjq7L9qDB2LoXzXN4sq5S3yH1zrXncX4JTQ1O4E Jbpm43jg8vOw1y9YdWZdbuQBUGSVKznJ0q5bk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724418711; x=1725023511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v9S+dT+RxEXLDnq2Dp9ErqErW7LwS5ZxIeDvscZGsxY=; b=ERTF/m9OqBu35YHOTW90RUIATIniIpuNndnrhQ7sxUmJ9KMuYVwBH2VERuwTrciwHc vvJHeldfEGHDzyUwI9FsGeGfZWXE/KhXwf1wkBdCQxz7+roDfeJ07MXCfXUs6beUZv7N 9lClouqyWesgQZfbNqyYsxqqMdv4+09VtwItyPURg8uVUWdvlOO/sj3ZSgZw8G3SjYTp wGT/2z/9Thl6vovecSd/3DmnLEgwJ9Ds0y3BFfyhZwKfXhGcANbrqpKOgfQpisY/rH7Y 5dp2a+Op8mGWZtITfdtlZv0AmR+wRygpxz3JWJNNZxjdnP6jT6MdDLk1eqtd/aEGmJp1 UNxA== X-Gm-Message-State: AOJu0YwhtKVnHlSc+ZcIFq98FZTVKzmVrNmYvwiZWsIyIOP7pELhiypB zr2kjshXGN4SLQAbRoDADxhlz9G7ts8A/b7R+/SZsh4DVOGoZPsiB8YcbsxHj+nrqOFRmdARzcj NhRTf X-Google-Smtp-Source: AGHT+IElGzIrsoknnOi+u0wBQ+VkgKyTJufkGlbv0/IPfz74XIHiwb6Agx6yRpv7V4taVdKVb0kjig== X-Received: by 2002:a05:600c:4512:b0:427:fa39:b0a1 with SMTP id 5b1f17b1804b1-42acc9fee00mr12802495e9.36.1724418710497; Fri, 23 Aug 2024 06:11:50 -0700 (PDT) Received: from chenghaoyang-germany.c.googlers.com.com (161.126.77.34.bc.googleusercontent.com. [34.77.126.161]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3730810ffb9sm4185000f8f.7.2024.08.23.06.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 06:11:50 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Harvey Yang Subject: [PATCH v1 1/3] libcamera: Add rectangle two-point constructor Date: Fri, 23 Aug 2024 13:07:33 +0000 Message-ID: <20240823131148.2449434-2-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240823131148.2449434-1-chenghaoyang@google.com> References: <20240823131148.2449434-1-chenghaoyang@google.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Yudhistira Erlandinata Add a Rectangle constructor that accepts two points: topLeft and bottomRight. BUG=b:308714092 TEST=emerge-geralt libcamera-mtkisp7 Signed-off-by: Yudhistira Erlandinata Co-developed-by: Harvey Yang --- include/libcamera/geometry.h | 10 ++++++++++ src/libcamera/geometry.cpp | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 3e6f0f5d7..4566c95b3 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -8,6 +8,8 @@ #pragma once #include +#include +#include #include #include @@ -262,6 +264,14 @@ public: { } + constexpr Rectangle(const Point &topLeft, const Point &bottomRight) + : x(topLeft.x), y(topLeft.y), + width(bottomRight.x - x), + height(bottomRight.y - y) + { + assert(bottomRight.x >= x && bottomRight.y >= y); + } + int x; int y; unsigned int width; diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 000151364..008b8ea04 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -629,6 +629,13 @@ std::ostream &operator<<(std::ostream &out, const SizeRange &sr) * \param[in] size The desired Rectangle size */ +/** + * \fn Rectangle::Rectangle(const Point &topLeft, const Point &bottomRight) + * \brief Construct a Rectangle with the two given points. + * \param[in] topLeft The top-left corner + * \param[in] bottomRight The bottom-right corner + */ + /** * \var Rectangle::x * \brief The horizontal coordinate of the rectangle's top-left corner