{"id":3287,"url":"https://patchwork.libcamera.org/api/1.1/patches/3287/?format=json","web_url":"https://patchwork.libcamera.org/patch/3287/","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":"<20200323173559.21109-21-laurent.pinchart@ideasonboard.com>","date":"2020-03-23T17:35:58","name":"[libcamera-devel,v2,20/21] qcam: viewfinder: Display icon when stopping capture","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"9c5f2758395e19a6b26c60078edf36ac719818b7","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/3287/mbox/","series":[{"id":762,"url":"https://patchwork.libcamera.org/api/1.1/series/762/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=762","date":"2020-03-23T17:35:38","name":"qcam: Bypass format conversion when not required","version":2,"mbox":"https://patchwork.libcamera.org/series/762/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3287/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3287/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 27FA562C9A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 18:36: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 C4E4EA31\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Mar 2020 18:36:22 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584984982;\n\tbh=Bk9RqVAYRV6bSXazONtXWPi5XHAba8loE+9oT3Xlh38=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=pHgxDY+EK1jPmK1DhaH3y+G9HqD+U+vCWihJRiU/slv60zxED7ID1UwQ24fObC6M3\n\timvZfnxVAB/WLqEMNoJmTiEdGrUf5TIuX4pKvlNeXDK+czUHTekclNaRE34Lb0LzV6\n\tFW40HpYlkEPn2d9CqO99/aNwwSXexd+0BlO++NbA=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 23 Mar 2020 19:35:58 +0200","Message-Id":"<20200323173559.21109-21-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200323173559.21109-1-laurent.pinchart@ideasonboard.com>","References":"<20200323173559.21109-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 20/21] qcam: viewfinder: Display icon\n\twhen stopping 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 17:36:26 -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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nChanges since v1:\n\n- Don't use QSize::shrunkBy() which was introduced in Qt 5.14\n- Move stop() function to previous commit\n---\n src/qcam/assets/feathericons/feathericons.qrc |  1 +\n src/qcam/viewfinder.cpp                       | 32 ++++++++++++++++++-\n src/qcam/viewfinder.h                         |  7 ++++\n 3 files changed, 39 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/viewfinder.cpp b/src/qcam/viewfinder.cpp\nindex 3f984efbf434..45e226b58135 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@@ -114,7 +115,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\tQSize vfSize = size() - QSize{ 2 * margin, 2 * margin };\n+\t\tQSize pixmapSize{ 1, 1 };\n+\t\tpixmapSize.scale(vfSize, Qt::KeepAspectRatio);\n+\t\tpixmap_ = icon_.pixmap(pixmapSize);\n+\n+\t\tvfSize_ = size();\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 4d0622a8e4ea..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@@ -53,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","v2","20/21"]}