From patchwork Tue Sep 15 02:46:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9610 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4B827C3B5D for ; Tue, 15 Sep 2020 02:47:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 181F162E10; Tue, 15 Sep 2020 04:47:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="s6sQ/57S"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C58462DF9 for ; Tue, 15 Sep 2020 04:46:57 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8C3C1275; Tue, 15 Sep 2020 04:46:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1600138016; bh=j+qUxXTjQsNxQPpNjNZoFEIMTLbzGMhnpCyMnLLHSew=; h=From:To:Subject:Date:In-Reply-To:References:From; b=s6sQ/57SoTmJFTmGm/1YOTkXe8utyv02/vh0gShAcAOEvSDRg/ZxIb2M3opsWRNVx GybM4vCxOF3kqld/wPm15HNae/DixN+c11KYGRYS06/KDsq6pmry6tVDL8dcBxU+Lw ennp6EQou67oaWAqMcrEZ4BhOZ68czCMEMHKKKts= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org, Show Liu Date: Tue, 15 Sep 2020 05:46:23 +0300 Message-Id: <20200915024623.30667-5-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 4/4] qcam: Add additional command line option to select the renderer type X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Show Liu 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 Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- 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 #include "dng_writer.h" +#include "viewfinder_gl.h" #include "viewfinder_qt.h" 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', };