[libcamera-devel] [PATCH v7 4/4] qcam: Add additional command line option to select the renderer type
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Tue Sep 15 04:53:45 CEST 2020
On Tue, Sep 15, 2020 at 05:46:23AM +0300, Laurent Pinchart wrote:
> From: Show Liu <show.liu at linaro.org>
>
> Add new option "--renderer=qt|gles" to select the renderer type,
> "--renderer=gles" to accelerate format conversion and rendering
> "--renderer=qt" is the original Qt rendering.
>
> Signed-off-by: Show Liu <show.liu at linaro.org>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/qcam/main.cpp | 3 +++
> src/qcam/main_window.cpp | 32 +++++++++++++++++++++++++++-----
> src/qcam/main_window.h | 1 +
> 3 files changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp
> index bae358df0877..f60d3cef0ecb 100644
> --- a/src/qcam/main.cpp
> +++ b/src/qcam/main.cpp
> @@ -33,6 +33,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[])
> ArgumentRequired, "camera");
> parser.addOption(OptHelp, OptionNone, "Display this help message",
> "help");
> + parser.addOption(OptRenderer, OptionString,
> + "Choose the renderer type {qt,gles} (default: qt)",
> + "renderer", ArgumentRequired, "renderer");
> parser.addOption(OptStream, &streamKeyValue,
> "Set configuration of a camera stream", "stream", true);
>
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index 7406f0bd4512..e5233f4fb706 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -28,6 +28,7 @@
> #include <libcamera/version.h>
>
> #include "dng_writer.h"
> +#include "viewfinder_gl.h"
> #include "viewfinder_qt.h"
This is missing
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
index e5233f4fb706..985743f32334 100644
--- a/src/qcam/main_window.cpp
+++ b/src/qcam/main_window.cpp
@@ -28,7 +28,9 @@
#include <libcamera/version.h>
#include "dng_writer.h"
+#ifndef QT_NO_OPENGL
#include "viewfinder_gl.h"
+#endif
#include "viewfinder_qt.h"
using namespace libcamera;
> using namespace libcamera;
> @@ -106,11 +107,32 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options)
> setWindowTitle(title_);
> connect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle()));
>
> - ViewFinderQt *viewfinder = new ViewFinderQt(this);
> - connect(viewfinder, &ViewFinderQt::renderComplete,
> - this, &MainWindow::queueRequest);
> - viewfinder_ = viewfinder;
> - setCentralWidget(viewfinder);
> + /* Renderer type Qt or GLES, select Qt by default. */
> + std::string renderType = "qt";
> + if (options_.isSet(OptRenderer))
> + renderType = options_[OptRenderer].toString();
> +
> + if (renderType == "qt") {
> + ViewFinderQt *viewfinder = new ViewFinderQt(this);
> + connect(viewfinder, &ViewFinderQt::renderComplete,
> + this, &MainWindow::queueRequest);
> + viewfinder_ = viewfinder;
> + setCentralWidget(viewfinder);
> +#ifndef QT_NO_OPENGL
> + } else if (renderType == "gles") {
> + ViewFinderGL *viewfinder = new ViewFinderGL(this);
> + connect(viewfinder, &ViewFinderGL::renderComplete,
> + this, &MainWindow::queueRequest);
> + viewfinder_ = viewfinder;
> + setCentralWidget(viewfinder);
> +#endif
> + } else {
> + qWarning() << "Invalid render type"
> + << QString::fromStdString(renderType);
> + quit();
> + return;
> + }
> +
> adjustSize();
>
> /* Hotplug/unplug support */
> diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h
> index 3d21779e3f4a..5c61a4dfce53 100644
> --- a/src/qcam/main_window.h
> +++ b/src/qcam/main_window.h
> @@ -37,6 +37,7 @@ class HotplugEvent;
> enum {
> OptCamera = 'c',
> OptHelp = 'h',
> + OptRenderer = 'r',
> OptStream = 's',
> };
>
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list