Patch Detail
Show a patch.
GET /api/1.1/patches/3368/?format=api
{ "id": 3368, "url": "https://patchwork.libcamera.org/api/1.1/patches/3368/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3368/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200403104327.3409564-1-jacopo@jmondi.org>", "date": "2020-04-03T10:43:27", "name": "[libcamera-devel] libcamera: geometry: Rework Rectangle", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "1f829d07aff7490e17444ac9603898dad0e6c604", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/3368/mbox/", "series": [ { "id": 792, "url": "https://patchwork.libcamera.org/api/1.1/series/792/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=792", "date": "2020-04-03T10:43:27", "name": "[libcamera-devel] libcamera: geometry: Rework Rectangle", "version": 1, "mbox": "https://patchwork.libcamera.org/series/792/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3368/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3368/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 57C1F600FA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 3 Apr 2020 12:40:51 +0200 (CEST)", "from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id C7FFC200009;\n\tFri, 3 Apr 2020 10:40:50 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 3 Apr 2020 12:43:27 +0200", "Message-Id": "<20200403104327.3409564-1-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.26.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] libcamera: geometry: Rework 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>", "X-List-Received-Date": "Fri, 03 Apr 2020 10:40:51 -0000" }, "content": "The libcamera Rectangle struct has no constructor that allows to\nconstruct statically initialized instances. Furthermore, its class\nmembers that represents the rectangle horizontal and vertical sizes are\nnamed 'w' and 'h' compared to the Size and SizeRange classes which uses\nthe 'width' and 'height', which every time results in having to look at\nclass definition to know which name to use.\n\nAdd a constructor that takes the rectangle 4 sizes and force generation\nof a default constructor, and while at there rationalize class members\nnames to 'width' and 'height'.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/geometry.h | 10 ++++++++--\n src/libcamera/geometry.cpp | 22 ++++++++++++++++++----\n src/libcamera/pipeline/ipu3/ipu3.cpp | 7 +------\n src/libcamera/v4l2_subdevice.cpp | 8 ++++----\n src/libcamera/v4l2_videodevice.cpp | 8 ++++----\n 5 files changed, 35 insertions(+), 20 deletions(-)", "diff": "diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h\nindex 7f1b29fe8c19..5eb4e72e365c 100644\n--- a/include/libcamera/geometry.h\n+++ b/include/libcamera/geometry.h\n@@ -13,10 +13,16 @@\n namespace libcamera {\n \n struct Rectangle {\n+\tRectangle() = default;\n+\tRectangle(int x_, int y_, unsigned int width_, unsigned int height_)\n+\t\t: x(x_), y(y_), width(width_), height(height_)\n+\t{\n+\t}\n+\n \tint x;\n \tint y;\n-\tunsigned int w;\n-\tunsigned int h;\n+\tunsigned int width;\n+\tunsigned int height;\n \n \tconst std::string toString() const;\n };\ndiff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp\nindex 13f642be526f..97dbdcf301b9 100644\n--- a/src/libcamera/geometry.cpp\n+++ b/src/libcamera/geometry.cpp\n@@ -29,6 +29,20 @@ namespace libcamera {\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 sizes initialized to 0\n+ */\n+\n+/**\n+ * \\fn Rectangle::Rectangle(int x_, int y_, unsigned int width_, unsigned int height_)\n+ * \\brief Construct a Rectangle with its sizes initialized\n+ * \\param[in] x_: The Rectangle top-left corner horizontal displacement\n+ * \\param[in] y_: The Rectangle top-left corner vertical displacement\n+ * \\param[in] width_: The Rectangle horizontal size\n+ * \\param[in] height_: The Rectangle vertical size\n+ */\n+\n /**\n * \\var Rectangle::x\n * \\brief The horizontal coordinate of the rectangle's top-left corner\n@@ -40,12 +54,12 @@ namespace libcamera {\n */\n \n /**\n- * \\var Rectangle::w\n+ * \\var Rectangle::width\n * \\brief The distance between the left and right sides\n */\n \n /**\n- * \\var Rectangle::h\n+ * \\var Rectangle::height\n * \\brief The distance between the top and bottom sides\n */\n \n@@ -57,7 +71,7 @@ const std::string Rectangle::toString() const\n {\n \tstd::stringstream ss;\n \n-\tss << \"(\" << x << \"x\" << y << \")/\" << w << \"x\" << h;\n+\tss << \"(\" << x << \"x\" << y << \")/\" << width << \"x\" << height;\n \n \treturn ss.str();\n }\n@@ -69,7 +83,7 @@ const std::string Rectangle::toString() const\n bool operator==(const Rectangle &lhs, const Rectangle &rhs)\n {\n \treturn lhs.x == rhs.x && lhs.y == rhs.y &&\n-\t lhs.w == rhs.w && lhs.h == rhs.h;\n+\t lhs.width == rhs.width && lhs.height == rhs.height;\n }\n \n /**\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 1e114ca7ed10..7e15ad28bef2 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1129,12 +1129,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.w = inputFormat->size.width,\n-\t\t.h = inputFormat->size.height,\n-\t};\n+\tRectangle rect(0, 0, inputFormat->size.width, inputFormat->size.height);\n \tret = imgu_->setCrop(PAD_INPUT, &rect);\n \tif (ret)\n \t\treturn ret;\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 8b9da81e8ab3..50fd26d99d9c 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -339,8 +339,8 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n \n \tsel.r.left = rect->x;\n \tsel.r.top = rect->y;\n-\tsel.r.width = rect->w;\n-\tsel.r.height = rect->h;\n+\tsel.r.width = rect->width;\n+\tsel.r.height = rect->height;\n \n \tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n \tif (ret < 0) {\n@@ -352,8 +352,8 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n \n \trect->x = sel.r.left;\n \trect->y = sel.r.top;\n-\trect->w = sel.r.width;\n-\trect->h = sel.r.height;\n+\trect->width = sel.r.width;\n+\trect->height = sel.r.height;\n \n \treturn 0;\n }\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex eb33a68e50d6..6e8f230f593d 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1115,8 +1115,8 @@ int V4L2VideoDevice::setSelection(unsigned int target, Rectangle *rect)\n \n \tsel.r.left = rect->x;\n \tsel.r.top = rect->y;\n-\tsel.r.width = rect->w;\n-\tsel.r.height = rect->h;\n+\tsel.r.width = rect->width;\n+\tsel.r.height = rect->height;\n \n \tint ret = ioctl(VIDIOC_S_SELECTION, &sel);\n \tif (ret < 0) {\n@@ -1127,8 +1127,8 @@ int V4L2VideoDevice::setSelection(unsigned int target, Rectangle *rect)\n \n \trect->x = sel.r.left;\n \trect->y = sel.r.top;\n-\trect->w = sel.r.width;\n-\trect->h = sel.r.height;\n+\trect->width = sel.r.width;\n+\trect->height = sel.r.height;\n \n \treturn 0;\n }\n", "prefixes": [ "libcamera-devel" ] }