[{"id":10950,"web_url":"https://patchwork.libcamera.org/comment/10950/","msgid":"<20200629073208.m77ykclvzneaxsyn@uno.localdomain>","date":"2020-06-29T07:32:08","subject":"Re: [libcamera-devel] [PATCH v3 1/2] libcamera: geometry: Add\n\tisNull() function to Size class","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hello,\n\nOn Sun, Jun 28, 2020 at 09:09:19PM +0200, Niklas Söderlund wrote:\n> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> It's common for code to check if a size is null. Add a helper function\n> to do so.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Umang Jain <email@uajain.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  include/libcamera/geometry.h |  1 +\n>  src/libcamera/geometry.cpp   |  6 ++++++\n>  test/geometry.cpp            | 10 ++++++++++\n>  3 files changed, 17 insertions(+)\n>\n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index edda42cf34ccbaf0..7d4b8bcfe3d8179e 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>\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index fd78cf2c0ab79f8a..24c44fb43acf66ef 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\nBikeshedding on name apart, would it bring any value describing here\nwhen a size is 'null' ? I think it would..\n\n> + * \\brief Check if the size is null\n\n      A Size is null when both its horizontal and vertical dimensions\n      are 0.\n\n> + * \\return True if both the width and height are 0, or false otherwise\n\nIt's also said here, so it might not matter much\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> + */\n> +\n>  /**\n>   * \\brief Assemble and return a string describing the size\n>   * \\return A string describing the size\n> diff --git a/test/geometry.cpp b/test/geometry.cpp\n> index 27e65565d7c60b47..904ad92c944816b4 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> --\n> 2.27.0\n>","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 D8FE0C2E66\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2020 07:28:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4D59D609C9;\n\tMon, 29 Jun 2020 09:28:43 +0200 (CEST)","from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E3C0603BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2020 09:28:41 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 44AD4C0007;\n\tMon, 29 Jun 2020 07:28:39 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Mon, 29 Jun 2020 09:32:08 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200629073208.m77ykclvzneaxsyn@uno.localdomain>","References":"<20200628190920.3206340-1-niklas.soderlund@ragnatech.se>\n\t<20200628190920.3206340-2-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200628190920.3206340-2-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v3 1/2] libcamera: geometry: Add\n\tisNull() function 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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":10954,"web_url":"https://patchwork.libcamera.org/comment/10954/","msgid":"<20200629082040.GB6012@pendragon.ideasonboard.com>","date":"2020-06-29T08:20:40","subject":"Re: [libcamera-devel] [PATCH v3 1/2] libcamera: geometry: Add\n\tisNull() function to Size class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, Jun 29, 2020 at 09:32:08AM +0200, Jacopo Mondi wrote:\n> On Sun, Jun 28, 2020 at 09:09:19PM +0200, Niklas Söderlund wrote:\n> > From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > It's common for code to check if a size is null. Add a helper function\n> > to do so.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: Umang Jain <email@uajain.com>\n> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  include/libcamera/geometry.h |  1 +\n> >  src/libcamera/geometry.cpp   |  6 ++++++\n> >  test/geometry.cpp            | 10 ++++++++++\n> >  3 files changed, 17 insertions(+)\n> >\n> > diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> > index edda42cf34ccbaf0..7d4b8bcfe3d8179e 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> >\n> > diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> > index fd78cf2c0ab79f8a..24c44fb43acf66ef 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> \n> Bikeshedding on name apart, would it bring any value describing here\n> when a size is 'null' ? I think it would..\n> \n> > + * \\brief Check if the size is null\n> \n>       A Size is null when both its horizontal and vertical dimensions\n>       are 0.\n\nMaybe s/horizontal and vertical dimensions/width and height/ ?\n\n> \n> > + * \\return True if both the width and height are 0, or false otherwise\n> \n> It's also said here, so it might not matter much\n\nI'd usually say we should add it, but the documentation is so short and\nthe return statement explains it that I don't mind much either way.\n\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> > + */\n> > +\n> >  /**\n> >   * \\brief Assemble and return a string describing the size\n> >   * \\return A string describing the size\n> > diff --git a/test/geometry.cpp b/test/geometry.cpp\n> > index 27e65565d7c60b47..904ad92c944816b4 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;","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 21CE6C2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Jun 2020 08:20:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A24FF609DD;\n\tMon, 29 Jun 2020 10:20:44 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B1572603B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Jun 2020 10:20:43 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 261B32B3;\n\tMon, 29 Jun 2020 10:20:43 +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=\"LsSI6eOc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593418843;\n\tbh=UJI5IeQPlh/FsWkadtLWyf3tbaD/D0k5V4IH36QLGd0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LsSI6eOcjok8faNYjGgbaFXEraK2CTb0BS3A9Rni5jtdWc8Tz6xobCnothzMHWIuw\n\tI+d10+GZocKYJXo7SYshOXfwOr3f3ytq1d8I07RPzaYEvNxFdSHkaz6OKfnPrjCckv\n\t4dz3qZVtrfW2Lx4b9u1bUUTn0sMt9xII8tQJQGAM=","Date":"Mon, 29 Jun 2020 11:20:40 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200629082040.GB6012@pendragon.ideasonboard.com>","References":"<20200628190920.3206340-1-niklas.soderlund@ragnatech.se>\n\t<20200628190920.3206340-2-niklas.soderlund@ragnatech.se>\n\t<20200629073208.m77ykclvzneaxsyn@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200629073208.m77ykclvzneaxsyn@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH v3 1/2] libcamera: geometry: Add\n\tisNull() function 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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]