From patchwork Thu Jun 25 00:25:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 4199 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 AA2DFC0101 for ; Thu, 25 Jun 2020 00:25:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 380E2609A5; Thu, 25 Jun 2020 02:25:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="V2LRndVG"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C0CA603BB for ; Thu, 25 Jun 2020 02:25:56 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C76FF2A8 for ; Thu, 25 Jun 2020 02:25:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593044755; bh=bwPrt1NPVIWX6KXXGXDFZX4qyR6IsLc0lpB3jbUf9CA=; h=From:To:Subject:Date:From; b=V2LRndVGB+/AOCFic9CJDDxLZQ+y27zbzx2CfjmuJhtiWwqaYIA0WBsvCMIu6yz0d Rs4BFiLtIK3TEvrxg3PZwaI4g9oBvM2udeovpJuSuL86eOn+ScsLMqlqlfBklZ3Ja1 YbHerwfJy/lImuVjMzo1ddAEfEFfPPGZhjnbV5M0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 25 Jun 2020 03:25:47 +0300 Message-Id: <20200625002547.20269-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: geometry: Add isNull() function to Size 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 size is null. Add a helper function to do so. Signed-off-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 edda42cf34cc..7d4b8bcfe3d8 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -41,6 +41,7 @@ struct Size { 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 fd78cf2c0ab7..24c44fb43acf 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -107,6 +107,12 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs) * \brief The Size height */ +/** + * \fn bool Size::isNull() const + * \brief Check if the size is null + * \return True if both the width and height are 0, or false otherwise + */ + /** * \brief Assemble and return a string describing the size * \return A string describing the size