From patchwork Thu Jul 9 08:41:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 8707 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 BEDFDBD790 for ; Thu, 9 Jul 2020 08:38:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8ABCE6120A; Thu, 9 Jul 2020 10:38:22 +0200 (CEST) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9077611A2 for ; Thu, 9 Jul 2020 10:38:19 +0200 (CEST) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id B25C7100002; Thu, 9 Jul 2020 08:38:18 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jul 2020 10:41:24 +0200 Message-Id: <20200709084128.5316-17-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200709084128.5316-1-jacopo@jmondi.org> References: <20200709084128.5316-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 16/20] libcamera: geometry: Add isNull() function to Rectangle class 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" It's common for code to check if a rectangle is null. Add a helper function to do so. Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/geometry.h | 1 + src/libcamera/geometry.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 7d4b8bcfe3d8..44561d9cc5a4 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -18,6 +18,7 @@ struct Rectangle { unsigned int width; unsigned int height; + bool isNull() const { return !width && !height; } const std::string toString() const; }; diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 24c44fb43acf..af29ed1119fe 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -49,6 +49,12 @@ namespace libcamera { * \brief The distance between the top and bottom sides */ +/** + * \fn bool Rectangle::isNull() const + * \brief Check if the rectangle is null + * \return True if both the width and height are 0, or false otherwise + */ + /** * \brief Assemble and return a string describing the rectangle * \return A string describing the Rectangle