{"id":8803,"url":"https://patchwork.libcamera.org/api/1.1/patches/8803/?format=json","web_url":"https://patchwork.libcamera.org/patch/8803/","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-4-laurent.pinchart@ideasonboard.com>","date":"2020-07-14T23:40:07","name":"[libcamera-devel,3/5] libcamera: geometry: Give constructors to Rectangle","commit_ref":"4f509caa8ed0166ef2e99846f12b7997a37c3a7e","pull_url":null,"state":"accepted","archived":false,"hash":"f5e4ca8cf0df2d52db0de512b9c8e49f32384c73","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/8803/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/8803/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8803/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 F0C45BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Jul 2020 23:40:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BC72C60925;\n\tWed, 15 Jul 2020 01:40:24 +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 5B11460905\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 F06EA10F6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 01:40:20 +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=\"N10QWH/c\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1594770021;\n\tbh=waPAdl26c/ZnBNcOAGTj55qxffTbdd90yd6MIYQptEY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=N10QWH/cFeGe24Y/LvyoQH4BVSXm0bPrWFdcBR//QxDj5ZSvtjfyd7IStLeUSb69B\n\thNBE5QhOGam3V8rBpRRuTfY+XVEqlxuKloh6QXSrcDLALbLwc1XG1/5iJpxEdZew2S\n\tsJcoqbJXYIiCrwytj1wLsa+10j6icpEUcp5KNLQQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 15 Jul 2020 02:40:07 +0300","Message-Id":"<20200714234009.16596-4-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 3/5] libcamera: geometry: Give\n\tconstructors to Rectangle","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":"Rectangle, unlike Size, has no constructor, requiring the users to\nexplicitly initialize the instances. This is error-prone, add\nconstructors.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/geometry.h                  | 15 +++++++++++++\n src/libcamera/camera_sensor.cpp               |  2 +-\n src/libcamera/geometry.cpp                    | 22 +++++++++++++++++++\n src/libcamera/pipeline/ipu3/imgu.cpp          |  7 +-----\n .../pipeline/raspberrypi/raspberrypi.cpp      |  7 +-----\n src/libcamera/pipeline/vimc/vimc.cpp          |  7 +-----\n 6 files changed, 41 insertions(+), 19 deletions(-)","diff":"diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex f3088d33fa2c..380248ac9a50 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -127,6 +127,21 @@ static inline bool operator!=(const SizeRange &lhs, const SizeRange &rhs)\n }\n \n struct Rectangle {\n+\tRectangle()\n+\t\t: Rectangle(0, 0, 0, 0)\n+\t{\n+\t}\n+\n+\tRectangle(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+\t\t: x(xpos), y(ypos), width(w), height(h)\n+\t{\n+\t}\n+\n \tint x;\n \tint y;\n \tunsigned int width;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex b14b4051dca6..6e93cc51155b 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -487,7 +487,7 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const\n \tinfo->model = model();\n \n \t/* Get the active area size. */\n-\tRectangle rect = {};\n+\tRectangle rect;\n \tint ret = subdev_->getSelection(pad_, V4L2_SEL_TGT_CROP_DEFAULT, &rect);\n \tif (ret) {\n \t\tLOG(CameraSensor, Error)\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 5a0bcf7c1e12..3a3784df39e6 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -297,6 +297,28 @@ bool operator==(const SizeRange &lhs, const SizeRange &rhs)\n  * refers to, are defined by the context were rectangle is used.\n  */\n \n+/**\n+ * \\fn Rectangle::Rectangle()\n+ * \\brief Construct a Rectangle with all coordinates set to 0\n+ */\n+\n+/**\n+ * \\fn Rectangle::Rectangle(int x, int y, const Size &size)\n+ * \\brief Construct a Rectangle with the given position and size\n+ * \\param[in] x The horizontal coordinate of the top-left corner\n+ * \\param[in] y The vertical coordinate of the top-left corner\n+ * \\param[in] size The size\n+ */\n+\n+/**\n+ * \\fn Rectangle::Rectangle(int x, int y, unsigned int width, unsigned int height)\n+ * \\brief Construct a Rectangle with the given position and size\n+ * \\param[in] x The horizontal coordinate of the top-left corner\n+ * \\param[in] y The vertical coordinate of the top-left corner\n+ * \\param[in] width The width\n+ * \\param[in] height The height\n+ */\n+\n /**\n  * \\var Rectangle::x\n  * \\brief The horizontal coordinate of the rectangle's top-left corner\ndiff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp\nindex d7f4173d3607..4bec4b2f1a76 100644\n--- a/src/libcamera/pipeline/ipu3/imgu.cpp\n+++ b/src/libcamera/pipeline/ipu3/imgu.cpp\n@@ -100,12 +100,7 @@ int ImgUDevice::configureInput(const Size &size,\n \t * to configure the crop/compose rectangles, contradicting the\n \t * V4L2 specification.\n \t */\n-\tRectangle rect = {\n-\t\t.x = 0,\n-\t\t.y = 0,\n-\t\t.width = inputFormat->size.width,\n-\t\t.height = inputFormat->size.height,\n-\t};\n+\tRectangle rect{ 0, 0, inputFormat->size };\n \tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect);\n \tif (ret)\n \t\treturn ret;\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 009e502b288c..2d848ac3c735 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -752,12 +752,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config)\n \t}\n \n \t/* Adjust aspect ratio by providing crops on the input image. */\n-\tRectangle crop = {\n-\t\t.x = 0,\n-\t\t.y = 0,\n-\t\t.width = sensorFormat.size.width,\n-\t\t.height = sensorFormat.size.height\n-\t};\n+\tRectangle crop{ 0, 0, sensorFormat.size };\n \n \tint ar = maxSize.height * sensorFormat.size.width - maxSize.width * sensorFormat.size.height;\n \tif (ar > 0)\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex a6f457c71fb1..4f461b928514 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -256,12 +256,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)\n \t\treturn ret;\n \n \tif (data->media_->version() >= KERNEL_VERSION(5, 6, 0)) {\n-\t\tRectangle crop = {\n-\t\t\t.x = 0,\n-\t\t\t.y = 0,\n-\t\t\t.width = subformat.size.width,\n-\t\t\t.height = subformat.size.height,\n-\t\t};\n+\t\tRectangle crop{ 0, 0, subformat.size };\n \t\tret = data->scaler_->setSelection(0, V4L2_SEL_TGT_CROP, &crop);\n \t\tif (ret)\n \t\t\treturn ret;\n","prefixes":["libcamera-devel","3/5"]}