Patch Detail
Show a patch.
GET /api/1.1/patches/9608/?format=api
{ "id": 9608, "url": "https://patchwork.libcamera.org/api/1.1/patches/9608/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9608/", "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": "<20200915024623.30667-3-laurent.pinchart@ideasonboard.com>", "date": "2020-09-15T02:46:21", "name": "[libcamera-devel,v7,2/4] qcam: New viewfinder hierarchy", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "2f2db3e9b9648ce28b108e9fd559c1188e369ad3", "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/9608/mbox/", "series": [ { "id": 1290, "url": "https://patchwork.libcamera.org/api/1.1/series/1290/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1290", "date": "2020-09-15T02:46:19", "name": "[libcamera-devel,v7,1/4] qcam: Add OpenGL shader code as Qt resource", "version": 7, "mbox": "https://patchwork.libcamera.org/series/1290/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9608/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9608/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 9F506C3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 15 Sep 2020 02:46:58 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 559F162E05;\n\tTue, 15 Sep 2020 04:46:57 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BCE0762D5B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Sep 2020 04:46:55 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4CB51AEA;\n\tTue, 15 Sep 2020 04:46:55 +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=\"CsG7VTnv\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1600138015;\n\tbh=w6o4nKMygS/L0eAQLoPuFVS6f+zH4jLajwK1pF6YWok=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=CsG7VTnv2daBXM3qaI97oOPrKIXZRdqwsxdMupGAd7yvbv+zrcaFjEIPEWtV9xbgv\n\tCJu04JCYm3dO7nuRo+isksFsghLucPYxqwTyqFrmjCcf9dQ07gwgkLEI1dRr4MV1G3\n\tY8gxmhDzef088A1MEkkwo7q3dKzG1UnjQjmrT3wk=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org,\n\tShow Liu <show.liu@linaro.org>", "Date": "Tue, 15 Sep 2020 05:46:21 +0300", "Message-Id": "<20200915024623.30667-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200915024623.30667-1-laurent.pinchart@ideasonboard.com>", "References": "<20200915024623.30667-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v7 2/4] qcam: New viewfinder hierarchy", "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": "From: Show Liu <show.liu@linaro.org>\n\nCreate ViewFinder base class and rename the original ViewFinder\nas QPainter-based ViewFinder.\n\nSigned-off-by: Show Liu <show.liu@linaro.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/qcam/main_window.cpp | 8 ++-\n src/qcam/meson.build | 4 +-\n src/qcam/viewfinder.h | 57 ++++-------------\n .../{viewfinder.cpp => viewfinder_qt.cpp} | 24 +++----\n src/qcam/viewfinder_qt.h | 64 +++++++++++++++++++\n 5 files changed, 94 insertions(+), 63 deletions(-)\n rename src/qcam/{viewfinder.cpp => viewfinder_qt.cpp} (86%)\n create mode 100644 src/qcam/viewfinder_qt.h", "diff": "diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp\nindex 612d978a73df..7406f0bd4512 100644\n--- a/src/qcam/main_window.cpp\n+++ b/src/qcam/main_window.cpp\n@@ -28,6 +28,7 @@\n #include <libcamera/version.h>\n \n #include \"dng_writer.h\"\n+#include \"viewfinder_qt.h\"\n \n using namespace libcamera;\n \n@@ -105,10 +106,11 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)\n \tsetWindowTitle(title_);\n \tconnect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle()));\n \n-\tviewfinder_ = new ViewFinder(this);\n-\tconnect(viewfinder_, &ViewFinder::renderComplete,\n+\tViewFinderQt *viewfinder = new ViewFinderQt(this);\n+\tconnect(viewfinder, &ViewFinderQt::renderComplete,\n \t\tthis, &MainWindow::queueRequest);\n-\tsetCentralWidget(viewfinder_);\n+\tviewfinder_ = viewfinder;\n+\tsetCentralWidget(viewfinder);\n \tadjustSize();\n \n \t/* Hotplug/unplug support */\ndiff --git a/src/qcam/meson.build b/src/qcam/meson.build\nindex e0c6f26dfef5..a4bad0a0659e 100644\n--- a/src/qcam/meson.build\n+++ b/src/qcam/meson.build\n@@ -6,12 +6,12 @@ qcam_sources = files([\n 'format_converter.cpp',\n 'main.cpp',\n 'main_window.cpp',\n- 'viewfinder.cpp',\n+ 'viewfinder_qt.cpp',\n ])\n \n qcam_moc_headers = files([\n 'main_window.h',\n- 'viewfinder.h',\n+ 'viewfinder_qt.h',\n ])\n \n qcam_resources = files([\ndiff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\nindex 26a1320537d2..67da1df26a0c 100644\n--- a/src/qcam/viewfinder.h\n+++ b/src/qcam/viewfinder.h\n@@ -2,70 +2,35 @@\n /*\n * Copyright (C) 2019, Google Inc.\n *\n- * viewfinder.h - qcam - Viewfinder\n+ * viewfinder.h - qcam - Viewfinder base class\n */\n #ifndef __QCAM_VIEWFINDER_H__\n #define __QCAM_VIEWFINDER_H__\n \n-#include <stddef.h>\n-\n-#include <QIcon>\n-#include <QList>\n #include <QImage>\n-#include <QMutex>\n+#include <QList>\n #include <QSize>\n-#include <QWidget>\n \n #include <libcamera/buffer.h>\n-#include <libcamera/pixel_format.h>\n-\n-#include \"format_converter.h\"\n-\n-class QImage;\n+#include <libcamera/formats.h>\n \n struct MappedBuffer {\n \tvoid *memory;\n \tsize_t size;\n };\n \n-class ViewFinder : public QWidget\n+class ViewFinder\n {\n-\tQ_OBJECT\n-\n public:\n-\tViewFinder(QWidget *parent);\n-\t~ViewFinder();\n+\tvirtual ~ViewFinder() {}\n \n-\tconst QList<libcamera::PixelFormat> &nativeFormats() const;\n+\tvirtual const QList<libcamera::PixelFormat> &nativeFormats() const = 0;\n \n-\tint setFormat(const libcamera::PixelFormat &format, const QSize &size);\n-\tvoid render(libcamera::FrameBuffer *buffer, MappedBuffer *map);\n-\tvoid stop();\n+\tvirtual int setFormat(const libcamera::PixelFormat &format, const QSize &size) = 0;\n+\tvirtual void render(libcamera::FrameBuffer *buffer, MappedBuffer *map) = 0;\n+\tvirtual void stop() = 0;\n \n-\tQImage getCurrentImage();\n-\n-Q_SIGNALS:\n-\tvoid renderComplete(libcamera::FrameBuffer *buffer);\n-\n-protected:\n-\tvoid paintEvent(QPaintEvent *) override;\n-\tQSize sizeHint() const override;\n-\n-private:\n-\tFormatConverter converter_;\n-\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+\tvirtual QImage getCurrentImage() = 0;\n };\n \n-#endif /* __QCAM_VIEWFINDER__ */\n+#endif /* __QCAM_VIEWFINDER_H__ */\ndiff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder_qt.cpp\nsimilarity index 86%\nrename from src/qcam/viewfinder.cpp\nrename to src/qcam/viewfinder_qt.cpp\nindex dcf8a15d2df6..e436714c6bdb 100644\n--- a/src/qcam/viewfinder.cpp\n+++ b/src/qcam/viewfinder_qt.cpp\n@@ -2,10 +2,10 @@\n /*\n * Copyright (C) 2019, Google Inc.\n *\n- * viewfinder.cpp - qcam - Viewfinder\n+ * viewfinder_qt.cpp - qcam - QPainter-based ViewFinder\n */\n \n-#include \"viewfinder.h\"\n+#include \"viewfinder_qt.h\"\n \n #include <stdint.h>\n #include <utility>\n@@ -33,24 +33,24 @@ static const QMap<libcamera::PixelFormat, QImage::Format> nativeFormats\n \t{ libcamera::formats::BGR888, QImage::Format_RGB888 },\n };\n \n-ViewFinder::ViewFinder(QWidget *parent)\n+ViewFinderQt::ViewFinderQt(QWidget *parent)\n \t: QWidget(parent), buffer_(nullptr)\n {\n \ticon_ = QIcon(\":camera-off.svg\");\n }\n \n-ViewFinder::~ViewFinder()\n+ViewFinderQt::~ViewFinderQt()\n {\n }\n \n-const QList<libcamera::PixelFormat> &ViewFinder::nativeFormats() const\n+const QList<libcamera::PixelFormat> &ViewFinderQt::nativeFormats() const\n {\n \tstatic const QList<libcamera::PixelFormat> formats = ::nativeFormats.keys();\n \treturn formats;\n }\n \n-int ViewFinder::setFormat(const libcamera::PixelFormat &format,\n-\t\t\t const QSize &size)\n+int ViewFinderQt::setFormat(const libcamera::PixelFormat &format,\n+\t\t\t const QSize &size)\n {\n \timage_ = QImage();\n \n@@ -78,7 +78,7 @@ int ViewFinder::setFormat(const libcamera::PixelFormat &format,\n \treturn 0;\n }\n \n-void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)\n+void ViewFinderQt::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)\n {\n \tif (buffer->planes().size() != 1) {\n \t\tqWarning() << \"Multi-planar buffers are not supported\";\n@@ -121,7 +121,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map)\n \t\trenderComplete(buffer);\n }\n \n-void ViewFinder::stop()\n+void ViewFinderQt::stop()\n {\n \timage_ = QImage();\n \n@@ -133,14 +133,14 @@ void ViewFinder::stop()\n \tupdate();\n }\n \n-QImage ViewFinder::getCurrentImage()\n+QImage ViewFinderQt::getCurrentImage()\n {\n \tQMutexLocker locker(&mutex_);\n \n \treturn image_.copy();\n }\n \n-void ViewFinder::paintEvent(QPaintEvent *)\n+void ViewFinderQt::paintEvent(QPaintEvent *)\n {\n \tQPainter painter(this);\n \n@@ -175,7 +175,7 @@ void ViewFinder::paintEvent(QPaintEvent *)\n \tpainter.drawPixmap(point, pixmap_);\n }\n \n-QSize ViewFinder::sizeHint() const\n+QSize ViewFinderQt::sizeHint() const\n {\n \treturn size_.isValid() ? size_ : QSize(640, 480);\n }\ndiff --git a/src/qcam/viewfinder_qt.h b/src/qcam/viewfinder_qt.h\nnew file mode 100644\nindex 000000000000..d755428887c0\n--- /dev/null\n+++ b/src/qcam/viewfinder_qt.h\n@@ -0,0 +1,64 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * viewfinder_qt.h - qcam - QPainter-based ViewFinder\n+ */\n+#ifndef __QCAM_VIEWFINDER_QT_H__\n+#define __QCAM_VIEWFINDER_QT_H__\n+\n+#include <QIcon>\n+#include <QImage>\n+#include <QList>\n+#include <QMutex>\n+#include <QSize>\n+#include <QWidget>\n+\n+#include <libcamera/buffer.h>\n+#include <libcamera/formats.h>\n+#include <libcamera/pixel_format.h>\n+\n+#include \"format_converter.h\"\n+#include \"viewfinder.h\"\n+\n+class ViewFinderQt : public QWidget, public ViewFinder\n+{\n+\tQ_OBJECT\n+\n+public:\n+\tViewFinderQt(QWidget *parent);\n+\t~ViewFinderQt();\n+\n+\tconst QList<libcamera::PixelFormat> &nativeFormats() const override;\n+\n+\tint setFormat(const libcamera::PixelFormat &format, const QSize &size) override;\n+\tvoid render(libcamera::FrameBuffer *buffer, MappedBuffer *map) override;\n+\tvoid stop() override;\n+\n+\tQImage getCurrentImage() override;\n+\n+Q_SIGNALS:\n+\tvoid renderComplete(libcamera::FrameBuffer *buffer);\n+\n+protected:\n+\tvoid paintEvent(QPaintEvent *) override;\n+\tQSize sizeHint() const override;\n+\n+private:\n+\tFormatConverter converter_;\n+\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+};\n+\n+#endif /* __QCAM_VIEWFINDER_QT_H__ */\n", "prefixes": [ "libcamera-devel", "v7", "2/4" ] }