{"id":4200,"url":"https://patchwork.libcamera.org/api/1.1/patches/4200/?format=json","web_url":"https://patchwork.libcamera.org/patch/4200/","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":"<20200625012330.7639-1-laurent.pinchart@ideasonboard.com>","date":"2020-06-25T01:23:30","name":"[libcamera-devel,v2] libcamera: geometry: Add isNull() function to Size class","commit_ref":"7fc65e9680f604099d5d4f294b37fe7eb93acb03","pull_url":null,"state":"accepted","archived":false,"hash":"1295e3e25f266a4e4bd22552ff1e0c39536ec223","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/4200/mbox/","series":[{"id":1037,"url":"https://patchwork.libcamera.org/api/1.1/series/1037/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1037","date":"2020-06-25T01:23:30","name":"[libcamera-devel,v2] libcamera: geometry: Add isNull() function to Size class","version":2,"mbox":"https://patchwork.libcamera.org/series/1037/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/4200/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/4200/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 431CAC0100\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 25 Jun 2020 01:23:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C19B9609A5;\n\tThu, 25 Jun 2020 03:23:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC134603BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Jun 2020 03:23:35 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 551152A8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 25 Jun 2020 03:23:35 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"iB/ormJo\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593048215;\n\tbh=rFMVBSEfvpD9njOdgvuBduHjh3ZbpjtCllsIrcBilfI=;\n\th=From:To:Subject:Date:From;\n\tb=iB/ormJo7JYd2Js9cHBcOUHmu4J93ilji80DdRpZ2EJk9745KAtpwCGdqLXEVkf5J\n\tCGZXZKqaSkcoef7OQqqUwwpIBtGTvMlM6BaNFYtD5uTdFTxjOa4MgXKHZsegakwA2O\n\tk9qCZI359uetKbw6CboMAf2KNySyfrNXNQYhZvIs=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 25 Jun 2020 04:23:30 +0300","Message-Id":"<20200625012330.7639-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2] libcamera: geometry: Add isNull()\n\tfunction to Size class","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"It's common for code to check if a size is null. Add a helper function\nto do so.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Add test\n---\n include/libcamera/geometry.h |  1 +\n src/libcamera/geometry.cpp   |  6 ++++++\n test/geometry.cpp            | 10 ++++++++++\n 3 files changed, 17 insertions(+)","diff":"diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex edda42cf34cc..7d4b8bcfe3d8 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -41,6 +41,7 @@ struct Size {\n \tunsigned int width;\n \tunsigned int height;\n \n+\tbool isNull() const { return !width && !height; }\n \tconst std::string toString() const;\n };\n \ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex fd78cf2c0ab7..24c44fb43acf 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -107,6 +107,12 @@ bool operator==(const Rectangle &lhs, const Rectangle &rhs)\n  * \\brief The Size height\n  */\n \n+/**\n+ * \\fn bool Size::isNull() const\n+ * \\brief Check if the size is null\n+ * \\return True if both the width and height are 0, or false otherwise\n+ */\n+\n /**\n  * \\brief Assemble and return a string describing the size\n  * \\return A string describing the size\ndiff --git a/test/geometry.cpp b/test/geometry.cpp\nindex 27e65565d7c6..904ad92c9448 100644\n--- a/test/geometry.cpp\n+++ b/test/geometry.cpp\n@@ -36,6 +36,16 @@ protected:\n \n \tint run()\n \t{\n+\t\tif (!Size().isNull() || !Size(0, 0).isNull()) {\n+\t\t\tcout << \"Null size incorrectly reported as not null\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (Size(0, 100).isNull() || Size(100, 0).isNull() || Size(100, 100).isNull()) {\n+\t\t\tcout << \"Non-null size incorrectly reported as null\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\t/* Test Size equality and inequality. */\n \t\tif (!compare(Size(100, 100), Size(100, 100), &operator==, \"==\", true))\n \t\t\treturn TestFail;\n","prefixes":["libcamera-devel","v2"]}