From patchwork Fri Aug 23 14:29:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21003 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 348DDBDE17 for ; Fri, 23 Aug 2024 14:32:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ABCFF633CF; Fri, 23 Aug 2024 16:32:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mDObCun8"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D49F6633CB for ; Fri, 23 Aug 2024 16:32:09 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3719896b7c8so995207f8f.3 for ; Fri, 23 Aug 2024 07:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724423529; x=1725028329; 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=IDX86hfigYN0gC08TEOpl2L7+W79GzBQ1t4h96ImMug=; b=mDObCun8ewi3ZySg2kNfGt/Z/AelQwouR11+MNZQZlSYZnuiS4Ua4JjsnF6Q9NFtwv z3TfO9hLSzkSFAwmSYZJAvlHwUMrAtiTl8MYBcMIBiBMNF7NQMoaYHecP8sHRvr+EyCC xP9WYUKElzZvui6LAKlVE+j5m05KA/OHTw6xE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724423529; x=1725028329; 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=IDX86hfigYN0gC08TEOpl2L7+W79GzBQ1t4h96ImMug=; b=cagwVKYg7ZnCPb6j3N2+J2O7IKPgsuGnJAHVDcU9B4mGCTKM/ZoYPUk/HenDUoQzjk AceHwmVs/d4u1gwJY/fiZa+3pNPtnDLlg920LE/HMqBkHHD3wX6cN6EYG8CEpaIp+934 aXgoq9uhZNoSVCdxcjig2BqTuNr4azC+ZDipU4l6cw9lQXtc4QajNz58aPSxSKoSrTdr sUOGj8IY3LDCKyLAcfFgpQgFAYnaiV1rvtmmJmyfo+o2pZWLKpsWVPzQ9tVQuXieLiv6 2N13gIMuKcd807kMFSZXBudjuXqncIyZhVWtgizCNUlVPXoBLGvijsF0vmzNYe0JU5cD RMTA== X-Gm-Message-State: AOJu0YyJB1sfKd9/7x5TK0RAQBYrgOB7q223IWSfuH9yrVw/1LnNMfmb rZzDAfw9WZX89P7qv0eJ4O2aeWAfQbJlvzRaIeWDxz4JbnkhTFBKnShuhts6OovhUxTcx3diUEx aFA== X-Google-Smtp-Source: AGHT+IEsAu7rW+IxEVWVzL8BSpS0ALyOQzM6I1UwWj7bVrdTsy9JlEml6sCQmYLfI5w5tL16S9h6JA== X-Received: by 2002:a05:6000:e4f:b0:36d:2984:ef74 with SMTP id ffacd0b85a97d-37311863b12mr1598145f8f.35.1724423528844; Fri, 23 Aug 2024 07:32:08 -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-373081ffb66sm4300627f8f.84.2024.08.23.07.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 07:32:08 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Harvey Yang Subject: [PATCH v2 1/3] libcamera: Add rectangle two-point constructor Date: Fri, 23 Aug 2024 14:29:08 +0000 Message-ID: <20240823143205.2668765-2-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.295.g3b9ea8a38a-goog In-Reply-To: <20240823143205.2668765-1-chenghaoyang@google.com> References: <20240823143205.2668765-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 | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 3e6f0f5d7..978322a22 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -8,7 +8,9 @@ #pragma once #include +#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..86385ad35 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -5,13 +5,13 @@ * Geometry-related structures */ -#include - #include #include #include +#include + /** * \file geometry.h * \brief Data structures related to geometric objects @@ -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