Patch Detail
Show a patch.
GET /api/1.1/patches/3263/?format=api
{ "id": 3263, "url": "https://patchwork.libcamera.org/api/1.1/patches/3263/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3263/", "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": "<20200323142205.28342-21-laurent.pinchart@ideasonboard.com>", "date": "2020-03-23T14:22:04", "name": "[libcamera-devel,20/21] qcam: viewfinder: Display icon when stopping capture", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "3eff9ba87fed1e4aa327ba8a7bd2bf8b01d78887", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/3263/mbox/", "series": [ { "id": 760, "url": "https://patchwork.libcamera.org/api/1.1/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/3263/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3263/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BC5562C90\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 15:22:25 +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 24E82308\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 15:22:25 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584973345;\n\tbh=wyjNonEx8jFAhcUPkQCz7VR6tyWoj/JFy6i6LmH5R/4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=aijlcRlBowSDsgzIzjvngr6ShRm4KNGrsXsMWtPH7CBs1IpUPMbAAdGHRzhtUvJZe\n\tvoEtgJvydhpXW1rbdN5wGTAtC0ys36AyK8nW3HEEeXIG188hPWKLkYsVL0849+Ca6U\n\tUugITBoFEHDYfawChO4XjG82BNlFjPcZnGcPER3A=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 23 Mar 2020 16:22:04 +0200", "Message-Id": "<20200323142205.28342-21-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 20/21] qcam: viewfinder: Display icon when\n\tstopping capture", "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:29 -0000" }, "content": "When stopping capture, display an icon instead of the last frame. This\nis required to be able to release the last buffer when the viewfinder\noperators in zero-copy mode.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/qcam/assets/feathericons/feathericons.qrc | 1 +\n src/qcam/main_window.cpp | 2 +\n src/qcam/viewfinder.cpp | 44 ++++++++++++++++++-\n src/qcam/viewfinder.h | 8 ++++\n 4 files changed, 54 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/qcam/assets/feathericons/feathericons.qrc b/src/qcam/assets/feathericons/feathericons.qrc\nindex 6ca3a846803c..c4eb7a0be688 100644\n--- a/src/qcam/assets/feathericons/feathericons.qrc\n+++ b/src/qcam/assets/feathericons/feathericons.qrc\n@@ -1,5 +1,6 @@\n <!DOCTYPE RCC><RCC version=\"1.0\">\n <qresource>\n+<file>./camera-off.svg</file>\n <file>./play-circle.svg</file>\n <file>./save.svg</file>\n <file>./stop-circle.svg</file>\ndiff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex b68e171c5e01..a77d10bb7076 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -412,6 +412,8 @@ void MainWindow::stopCapture()\n \tif (!isCapturing_)\n \t\treturn;\n \n+\tviewfinder_->stop();\n+\n \tint ret = camera_->stop();\n \tif (ret)\n \t\tqInfo() << \"Failed to stop capture\";\ndiff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp\nindex 4c35659e24aa..a40b2b400daa 100644\n--- a/src/qcam/viewfinder.cpp\n+++ b/src/qcam/viewfinder.cpp\n@@ -20,6 +20,7 @@\n ViewFinder::ViewFinder(QWidget *parent)\n \t: QWidget(parent), buffer_(nullptr)\n {\n+\ticon_ = QIcon(\":camera-off.svg\");\n }\n \n ViewFinder::~ViewFinder()\n@@ -89,6 +90,18 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)\n \t\trenderComplete(buffer);\n }\n \n+void ViewFinder::stop()\n+{\n+\timage_ = QImage();\n+\n+\tif (buffer_) {\n+\t\trenderComplete(buffer_);\n+\t\tbuffer_ = nullptr;\n+\t}\n+\n+\tupdate();\n+}\n+\n QImage ViewFinder::getCurrentImage()\n {\n \tQMutexLocker locker(&mutex_);\n@@ -99,7 +112,36 @@ QImage ViewFinder::getCurrentImage()\n void ViewFinder::paintEvent(QPaintEvent *)\n {\n \tQPainter painter(this);\n-\tpainter.drawImage(rect(), image_, image_.rect());\n+\n+\t/* If we have an image, draw it. */\n+\tif (!image_.isNull()) {\n+\t\tpainter.drawImage(rect(), image_, image_.rect());\n+\t\treturn;\n+\t}\n+\n+\t/*\n+\t * Otherwise, draw the camera stopped icon. Render it to the pixmap if\n+\t * the size has changed.\n+\t */\n+\tconstexpr int margin = 20;\n+\n+\tif (vfSize_ != size() || pixmap_.isNull()) {\n+\t\tvfSize_ = size();\n+\n+\t\tQSize pixmapSize{ 1, 1 };\n+\t\tpixmapSize.scale(vfSize_.shrunkBy({ margin, margin, margin, margin }),\n+\t\t\t\t Qt::KeepAspectRatio);\n+\t\tpixmap_ = icon_.pixmap(pixmapSize);\n+\t}\n+\n+\tQPoint point{ margin, margin };\n+\tif (pixmap_.width() < width() - 2 * margin)\n+\t\tpoint.setX((width() - pixmap_.width()) / 2);\n+\telse\n+\t\tpoint.setY((height() - pixmap_.height()) / 2);\n+\n+\tpainter.setBackgroundMode(Qt::OpaqueMode);\n+\tpainter.drawPixmap(point, pixmap_);\n }\n \n QSize ViewFinder::sizeHint() const\ndiff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\nindex b5153160f70e..1a27f99ea202 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 <QIcon>\n #include <QImage>\n #include <QMutex>\n #include <QSize>\n@@ -36,6 +37,7 @@ public:\n \n \tint setFormat(const libcamera::PixelFormat &format, const QSize &size);\n \tvoid render(libcamera::FrameBuffer *buffer, MappedBuffer *map);\n+\tvoid stop();\n \n \tQImage getCurrentImage();\n \n@@ -52,6 +54,12 @@ private:\n \tlibcamera::PixelFormat format_;\n \tQSize size_;\n \n+\t/* Camera stopped icon */\n+\tQSize vfSize_;\n+\tQIcon icon_;\n+\tQPixmap pixmap_;\n+\n+\t/* Buffer and render image */\n \tlibcamera::FrameBuffer *buffer_;\n \tQImage image_;\n \tQMutex mutex_; /* Prevent concurrent access to image_ */\n", "prefixes": [ "libcamera-devel", "20/21" ] }