{"id":8805,"url":"https://patchwork.libcamera.org/api/1.1/patches/8805/?format=json","web_url":"https://patchwork.libcamera.org/patch/8805/","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":"<20200714234009.16596-6-laurent.pinchart@ideasonboard.com>","date":"2020-07-14T23:40:09","name":"[libcamera-devel,5/5] libcamera: geometry: Make Size and Rectangle usable as constexpr","commit_ref":"b5f3b9915ca8bc049e1eec3e918c234330991a0e","pull_url":null,"state":"accepted","archived":false,"hash":"f92ea212cd9a6226fc5a6de763321924e0019e3e","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/8805/mbox/","series":[{"id":1107,"url":"https://patchwork.libcamera.org/api/1.1/series/1107/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1107","date":"2020-07-14T23:40:04","name":"libcamera: Various improvements to geometry classes","version":1,"mbox":"https://patchwork.libcamera.org/series/1107/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8805/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8805/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 BF026BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Jul 2020 23:40:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8BE8760932;\n\tWed, 15 Jul 2020 01:40:25 +0200 (CEST)","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 F282C60929\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 01:40:21 +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 913AF10F6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 01:40:21 +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=\"q6xSqenL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594770021;\n\tbh=xGr4RoikmEMcAebjYTKr1Ajk4ZADwnn3qHrk5k20Wkw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=q6xSqenLaoq7rSWXkxGHTyw4//pIgb4wIDCR78uDBeOxKgrbNmC3YrkEsPKalNUrb\n\tgBmwfI+WuEyp1ljmHGihKh7/h35dBc16c61I/oyME8MqxPNnpXfXy/rt9GOX8dJnaD\n\tQwrc0HJFs5Ey+TQpG1BMU1Rwxe0oqXqffDbeXPzw=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 15 Jul 2020 02:40:09 +0300","Message-Id":"<20200714234009.16596-6-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200714234009.16596-1-laurent.pinchart@ideasonboard.com>","References":"<20200714234009.16596-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 5/5] libcamera: geometry: Make Size and\n\tRectangle usable as constexpr","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":"There are use cases for declaring constexpr Size and Rectangle\ninstances. Make it possible.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/geometry.h | 20 +++++++++++---------\n 1 file changed, 11 insertions(+), 9 deletions(-)","diff":"diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex 16c94a4861d6..30aaa7a30fe2 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -16,12 +16,12 @@ namespace libcamera {\n class Size\n {\n public:\n-\tSize()\n+\tconstexpr Size()\n \t\t: Size(0, 0)\n \t{\n \t}\n \n-\tSize(unsigned int w, unsigned int h)\n+\tconstexpr Size(unsigned int w, unsigned int h)\n \t\t: width(w), height(h)\n \t{\n \t}\n@@ -32,7 +32,8 @@ public:\n \tbool isNull() const { return !width && !height; }\n \tconst std::string toString() const;\n \n-\tSize alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) const\n+\tconstexpr Size alignedDownTo(unsigned int hAlignment,\n+\t\t\t\t     unsigned int vAlignment) const\n \t{\n \t\treturn {\n \t\t\twidth / hAlignment * hAlignment,\n@@ -40,7 +41,8 @@ public:\n \t\t};\n \t}\n \n-\tSize alignedUpTo(unsigned int hAlignment, unsigned int vAlignment) const\n+\tconstexpr Size alignedUpTo(unsigned int hAlignment,\n+\t\t\t\t   unsigned int vAlignment) const\n \t{\n \t\treturn {\n \t\t\t(width + hAlignment - 1) / hAlignment * hAlignment,\n@@ -48,7 +50,7 @@ public:\n \t\t};\n \t}\n \n-\tSize boundedTo(const Size &bound) const\n+\tconstexpr Size boundedTo(const Size &bound) const\n \t{\n \t\treturn {\n \t\t\tstd::min(width, bound.width),\n@@ -56,7 +58,7 @@ public:\n \t\t};\n \t}\n \n-\tSize expandedTo(const Size &expand) const\n+\tconstexpr Size expandedTo(const Size &expand) const\n \t{\n \t\treturn {\n \t\t\tstd::max(width, expand.width),\n@@ -131,17 +133,17 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)\n class Rectangle\n {\n public:\n-\tRectangle()\n+\tconstexpr Rectangle()\n \t\t: Rectangle(0, 0, 0, 0)\n \t{\n \t}\n \n-\tRectangle(int xpos, int ypos, const Size &size)\n+\tconstexpr Rectangle(int xpos, int ypos, const Size &size)\n \t\t: x(xpos), y(ypos), width(size.width), height(size.height)\n \t{\n \t}\n \n-\tRectangle(int xpos, int ypos, unsigned int w, unsigned int h)\n+\tconstexpr Rectangle(int xpos, int ypos, unsigned int w, unsigned int h)\n \t\t: x(xpos), y(ypos), width(w), height(h)\n \t{\n \t}\n","prefixes":["libcamera-devel","5/5"]}