Patch Detail
Show a patch.
GET /api/patches/3259/?format=api
{ "id": 3259, "url": "https://patchwork.libcamera.org/api/patches/3259/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3259/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20200323142205.28342-17-laurent.pinchart@ideasonboard.com>", "date": "2020-03-23T14:22:00", "name": "[libcamera-devel,16/21] qcam: viewfinder: Embed QImage in ViewFinder", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "257b15bbcaa676bab2372cf9b7daabaad68ef941", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3259/mbox/", "series": [ { "id": 760, "url": "https://patchwork.libcamera.org/api/series/760/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=760", "date": "2020-03-23T14:21:44", "name": "qcam: Bypass format conversion when not required", "version": 1, "mbox": "https://patchwork.libcamera.org/series/760/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3259/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3259/checks/", "tags": {}, "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 E298A62C0E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 15:22:23 +0100 (CET)", "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 79AC5308\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 15:22:23 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584973343;\n\tbh=SQpup1GvmigzZjuo3rNPDe1Qr86L5ep1mOvu+Nb2uWI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=v1dQ3Bo35QlkI8Iqqks0ZwxcN+tei7vhErzYOlWmx+bb8OG8rBOtkVbXrVOLF2JuX\n\tdIouXiej2LgpLoal3iLsk+r/kGSyj+JOsh0W1M7zsQN1zZB7zlp4Lhe2+25xja7aOV\n\tFBG94Sa44Duzb5NCB5u2lhTLLfiffDT/iexLduH4=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 23 Mar 2020 16:22:00 +0200", "Message-Id": "<20200323142205.28342-17-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200323142205.28342-1-laurent.pinchart@ideasonboard.com>", "References": "<20200323142205.28342-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 16/21] qcam: viewfinder: Embed QImage in\n\tViewFinder", "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": "Mon, 23 Mar 2020 14:22:28 -0000" }, "content": "The QImage class is a thin wrapper that uses implicit sharing. We can\nthus embed it in the ViewFinder class instead of allocating it\ndynamically, and assign it at runtime. This simplifies the code.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/qcam/viewfinder.cpp | 12 +++++-------\n src/qcam/viewfinder.h | 3 ++-\n 2 files changed, 7 insertions(+), 8 deletions(-)", "diff": "diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp\nindex 2a35932e0b79..e7b12015d8f6 100644\n--- a/src/qcam/viewfinder.cpp\n+++ b/src/qcam/viewfinder.cpp\n@@ -16,13 +16,12 @@\n #include \"format_converter.h\"\n \n ViewFinder::ViewFinder(QWidget *parent)\n-\t: QWidget(parent), format_(0), image_(nullptr)\n+\t: QWidget(parent), format_(0)\n {\n }\n \n ViewFinder::~ViewFinder()\n {\n-\tdelete image_;\n }\n \n void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)\n@@ -41,7 +40,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)\n \t */\n \n \tconverter_.convert(static_cast<unsigned char *>(map->memory),\n-\t\t\t buffer->metadata().planes[0].bytesused, image_);\n+\t\t\t buffer->metadata().planes[0].bytesused, &image_);\n \tupdate();\n \n \trenderComplete(buffer);\n@@ -51,7 +50,7 @@ QImage ViewFinder::getCurrentImage()\n {\n \tQMutexLocker locker(&mutex_);\n \n-\treturn image_->copy();\n+\treturn image_.copy();\n }\n \n int ViewFinder::setFormat(const libcamera::PixelFormat &format,\n@@ -66,8 +65,7 @@ int ViewFinder::setFormat(const libcamera::PixelFormat &format,\n \tformat_ = format;\n \tsize_ = size;\n \n-\tdelete image_;\n-\timage_ = new QImage(size_, QImage::Format_RGB32);\n+\timage_ = QImage(size_, QImage::Format_RGB32);\n \n \tupdateGeometry();\n \treturn 0;\n@@ -76,7 +74,7 @@ int ViewFinder::setFormat(const libcamera::PixelFormat &format,\n void ViewFinder::paintEvent(QPaintEvent *)\n {\n \tQPainter painter(this);\n-\tpainter.drawImage(rect(), *image_, image_->rect());\n+\tpainter.drawImage(rect(), image_, image_.rect());\n }\n \n QSize ViewFinder::sizeHint() const\ndiff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\nindex 784fcceda5bd..54c0fa9dd7a0 100644\n--- a/src/qcam/viewfinder.h\n+++ b/src/qcam/viewfinder.h\n@@ -9,6 +9,7 @@\n \n #include <stddef.h>\n \n+#include <QImage>\n #include <QMutex>\n #include <QSize>\n #include <QWidget>\n@@ -51,7 +52,7 @@ private:\n \tlibcamera::PixelFormat format_;\n \tQSize size_;\n \n-\tQImage *image_;\n+\tQImage image_;\n \tQMutex mutex_; /* Prevent concurrent access to image_ */\n };\n \n", "prefixes": [ "libcamera-devel", "16/21" ] }