[{"id":11402,"web_url":"https://patchwork.libcamera.org/comment/11402/","msgid":"<20200715063554.GH3051471@oden.dyn.berto.se>","date":"2020-07-15T06:35:54","subject":"Re: [libcamera-devel] [PATCH 5/5] libcamera: geometry: Make Size\n\tand Rectangle usable as constexpr","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your patch.\n\nOn 2020-07-15 02:40:09 +0300, Laurent Pinchart wrote:\n> There are use cases for declaring constexpr Size and Rectangle\n> instances. Make it possible.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  include/libcamera/geometry.h | 20 +++++++++++---------\n>  1 file changed, 11 insertions(+), 9 deletions(-)\n> \n> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 0D1C9BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 15 Jul 2020 06:35:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D02AC6092F;\n\tWed, 15 Jul 2020 08:35:56 +0200 (CEST)","from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F022460925\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 08:35:55 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id e8so1358421ljb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Jul 2020 23:35:55 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\t11sm258757lju.102.2020.07.14.23.35.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 14 Jul 2020 23:35:54 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"v1CztGb9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=vUrueMfIlnAUPivqIFoK4BJNO5hFEEzp67PSSCy1y/I=;\n\tb=v1CztGb9sewsTp3KlEf7tOmmHPpPxMyO4ohwyfzYTwgODFfk+sulAl4XceDZm4F6oz\n\tbhJPvVYrPNm/N7uvD7bQhTnjDdzHcXzNHtsLiQpnXs/4ogP1GWhv8SpI4nWBSITPP7Re\n\tk45s7A2Tn7XWUqWpN4zWvtoutTOjkMyC0DnmB3wOH5fz/LGmFIdrilBSxieqgz3sd+5Y\n\tzA8Ykn3CADw9qdvZFqEvS04aQADoSyl4TYk+B382D+Ihu0TxbkbQ/OvTdolY1MQVykW0\n\t5yBRnf8v1PFiLjg835Thl4h+CZiPYWaTnkTtgRflStHFS5+34BF6h6/Y8zvJoiocmO/r\n\ta6Zw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=vUrueMfIlnAUPivqIFoK4BJNO5hFEEzp67PSSCy1y/I=;\n\tb=tJTfh2ZTNNQrdF8FdalfkDfa8aUdHvNKBM96qxdh/uuEto2Ev6E5yV2GkB6SLN+QRE\n\tEQn6cp86aDyKiosE8HK9eLWzhQm4sVqW7QqvvtR7QsAOhtf66HO2+PQTf6y5578GU1pL\n\tpYfoZTkoWxlykV1J/89dGMH5/ID8R/RDL06THDSuMBACftG3bqxC0itx/MeuBGLLK9Y8\n\typq35CuDglT6cSAcFSt/Ub1KXqbavfIDb88FI1C8Ou+R7XgvB0NCn2rrqFgttdLeVGlE\n\tOADLh/9cdLw5dN1LpTmNd7x/lKMNssyU4O2skAORoRmHDf9sBN0LPy+2GAbsVqoCoyrj\n\taCCw==","X-Gm-Message-State":"AOAM532+snS+8dnonQ9rLErtlUrl9+7oIMfiX/i29Cdgr0B+seYpImDM\n\tWtwjW9DgkAkgT2iqCVRUlLdaymhESHk=","X-Google-Smtp-Source":"ABdhPJwFIw//0Uf05mWlP7sXWS7SukacY+5YWbiIn446tiFZ51RSwZmsKeOKcerFvZw/wcHAxJVTNg==","X-Received":"by 2002:a05:651c:3d9:: with SMTP id\n\tf25mr3783176ljp.454.1594794955311; \n\tTue, 14 Jul 2020 23:35:55 -0700 (PDT)","Date":"Wed, 15 Jul 2020 08:35:54 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200715063554.GH3051471@oden.dyn.berto.se>","References":"<20200714234009.16596-1-laurent.pinchart@ideasonboard.com>\n\t<20200714234009.16596-6-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200714234009.16596-6-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 5/5] libcamera: geometry: Make Size\n\tand Rectangle 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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]