diff options
author | Show Liu <show.liu@linaro.org> | 2020-09-11 16:55:14 +0800 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-09-15 05:53:59 +0300 |
commit | 219cbfe76b5a7d9d8206c71aa6115ff8befcff9b (patch) | |
tree | 0dfe49d71cbb53567b5f13b6f8c56a8819c38b9f /src/qcam/main_window.cpp | |
parent | 9db6ce0ba499eba53db236558d783a4ff7aa3896 (diff) |
qcam: Add additional command line option to select the renderer type
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@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/qcam/main_window.cpp')
-rw-r--r-- | src/qcam/main_window.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 7406f0bd..985743f3 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -28,6 +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; @@ -106,11 +109,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 */ |