[{"id":1912,"web_url":"https://patchwork.libcamera.org/comment/1912/","msgid":"<20190618222709.GJ23556@pendragon.ideasonboard.com>","date":"2019-06-18T22:27:09","subject":"Re: [libcamera-devel] [PATCH v3 04/16] libcamera: geometry:\n\tSizeRange: Add contains()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Sun, Jun 16, 2019 at 03:33:50PM +0200, Niklas Söderlund wrote:\n> Add a method to check if a Size can fit inside a SizeRange. When\n> determining if a size is containable take step values into account if\n> they are not set to 0.\n\nAren't step values guaranteed to be non-zero now ?\n\nApart from that,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  include/libcamera/geometry.h |  2 ++\n>  src/libcamera/geometry.cpp   | 16 ++++++++++++++++\n>  2 files changed, 18 insertions(+)\n> \n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index 03962d7d09fac2b0..52f4d010de76f840 100644\n> --- a/include/libcamera/geometry.h\n> +++ b/include/libcamera/geometry.h\n> @@ -92,6 +92,8 @@ public:\n>  \t{\n>  \t}\n>  \n> +\tbool contains(const Size &size) const;\n> +\n>  \tstd::string toString() const;\n>  \n>  \tSize min;\n> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> index 895861eb0678181b..ef919cb6beb19864 100644\n> --- a/src/libcamera/geometry.cpp\n> +++ b/src/libcamera/geometry.cpp\n> @@ -261,6 +261,22 @@ bool operator<(const Size &lhs, const Size &rhs)\n>   * \\brief The vertical step\n>   */\n>  \n> +/**\n> + * \\brief Test if a size is contained in the range\n> + * \\param[in] size Size to check\n> + * \\returns True if \\a size can be contained\n\n\"True if \\a size is contained in the range\"\n\n> + */\n> +bool SizeRange::contains(const Size &size) const\n> +{\n> +\tif (size.width < min.width || size.width > max.width ||\n> +\t    size.height < min.height || size.height > max.height ||\n> +\t    (hStep && (size.width - min.width) % hStep) ||\n> +\t    (vStep && (size.height - min.height) % vStep))\n> +\t\treturn false;\n> +\n> +\treturn true;\n> +}\n> +\n>  /**\n>   * \\brief Assemble and return a string describing the size range\n>   * \\return A string describing the SizeRange","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1029560BE4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jun 2019 00:27:27 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C90ED5;\n\tWed, 19 Jun 2019 00:27:26 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560896846;\n\tbh=QPNwhuo7qMz/z5408VpNWmOt4XcF3HQit8QMyxe6SKo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=jERoEarnCm3FxaDhl8xb0Ccu6qf0XhLjEUrTeNW7vNvnxC7TDZV0Ih6FwrmLhDHwR\n\tG9ugtqJ74oVc05IVjvkNykX0zxwF77BAqwSBwY3zxT6s1Jmg0wppjl5aqsqi2Zaat0\n\tDJqiB42JRMw9mu53Fh6TyjK+FVArWasmIIDhALI4=","Date":"Wed, 19 Jun 2019 01:27:09 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190618222709.GJ23556@pendragon.ideasonboard.com>","References":"<20190616133402.21934-1-niklas.soderlund@ragnatech.se>\n\t<20190616133402.21934-5-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190616133402.21934-5-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 04/16] libcamera: geometry:\n\tSizeRange: Add contains()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 18 Jun 2019 22:27:27 -0000"}},{"id":1920,"web_url":"https://patchwork.libcamera.org/comment/1920/","msgid":"<20190618233919.GR23556@pendragon.ideasonboard.com>","date":"2019-06-18T23:39:19","subject":"Re: [libcamera-devel] [PATCH v3 04/16] libcamera: geometry:\n\tSizeRange: Add contains()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nOn Wed, Jun 19, 2019 at 01:27:09AM +0300, Laurent Pinchart wrote:\n> On Sun, Jun 16, 2019 at 03:33:50PM +0200, Niklas Söderlund wrote:\n> > Add a method to check if a Size can fit inside a SizeRange. When\n> > determining if a size is containable take step values into account if\n> > they are not set to 0.\n> \n> Aren't step values guaranteed to be non-zero now ?\n\nNo they're not. Please disregard this comment.\n\n> Apart from that,\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  include/libcamera/geometry.h |  2 ++\n> >  src/libcamera/geometry.cpp   | 16 ++++++++++++++++\n> >  2 files changed, 18 insertions(+)\n> > \n> > diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> > index 03962d7d09fac2b0..52f4d010de76f840 100644\n> > --- a/include/libcamera/geometry.h\n> > +++ b/include/libcamera/geometry.h\n> > @@ -92,6 +92,8 @@ public:\n> >  \t{\n> >  \t}\n> >  \n> > +\tbool contains(const Size &size) const;\n> > +\n> >  \tstd::string toString() const;\n> >  \n> >  \tSize min;\n> > diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\n> > index 895861eb0678181b..ef919cb6beb19864 100644\n> > --- a/src/libcamera/geometry.cpp\n> > +++ b/src/libcamera/geometry.cpp\n> > @@ -261,6 +261,22 @@ bool operator<(const Size &lhs, const Size &rhs)\n> >   * \\brief The vertical step\n> >   */\n> >  \n> > +/**\n> > + * \\brief Test if a size is contained in the range\n> > + * \\param[in] size Size to check\n> > + * \\returns True if \\a size can be contained\n> \n> \"True if \\a size is contained in the range\"\n> \n> > + */\n> > +bool SizeRange::contains(const Size &size) const\n> > +{\n> > +\tif (size.width < min.width || size.width > max.width ||\n> > +\t    size.height < min.height || size.height > max.height ||\n> > +\t    (hStep && (size.width - min.width) % hStep) ||\n> > +\t    (vStep && (size.height - min.height) % vStep))\n> > +\t\treturn false;\n> > +\n> > +\treturn true;\n> > +}\n> > +\n> >  /**\n> >   * \\brief Assemble and return a string describing the size range\n> >   * \\return A string describing the SizeRange","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB39061A27\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Jun 2019 01:39:36 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F471D5;\n\tWed, 19 Jun 2019 01:39:36 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560901176;\n\tbh=MsXtKCFICYMs1u6HxwpmD9ZIevskLULbF1oMM3VuS+I=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=MXA9jRFpi5uxtjIiJg/P04+NyZjns/HwWjzCd2DmxvBXtvEUj1Qbt+VGxMnq2PV6z\n\tTVgCy/CQBDVeKM/96uYH00sG1Sk9sne3/8VE7aiXiDi/zYGbAlOFcIkooOR3SSjUXJ\n\te33LNgqgjYA6Oy3t2Cpd93xJA+GpxtH9bbhb17sU=","Date":"Wed, 19 Jun 2019 02:39:19 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190618233919.GR23556@pendragon.ideasonboard.com>","References":"<20190616133402.21934-1-niklas.soderlund@ragnatech.se>\n\t<20190616133402.21934-5-niklas.soderlund@ragnatech.se>\n\t<20190618222709.GJ23556@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190618222709.GJ23556@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 04/16] libcamera: geometry:\n\tSizeRange: Add contains()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Tue, 18 Jun 2019 23:39:37 -0000"}}]