From patchwork Fri Sep 11 08:55:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Show Liu X-Patchwork-Id: 9571 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 6B9B8BDB1D for ; Fri, 11 Sep 2020 08:55:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 387DC62D81; Fri, 11 Sep 2020 10:55:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OPKwd4VK"; dkim-atps=neutral Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E2FF662D38 for ; Fri, 11 Sep 2020 10:55:48 +0200 (CEST) Received: by mail-pg1-x535.google.com with SMTP id f2so4149463pgd.3 for ; Fri, 11 Sep 2020 01:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pplAyIWzx/jJzkQ8ErheBqp/JOxZ8UPVrHihID0UcyI=; b=OPKwd4VKgIIIKRsjxFjXBz/Cx8xMaKCS7IMlPL6NmoZ+bvnl8Vt4g4oUxoPSwWP70k r3Bs9uNGFPxvwHwPxBLpd+BipXuQvOpq4/ydzLBNNDYoxrP7oVxNS1oyc/GMtpkgME6u jch0RJZ3VxGFVqcVvIZfciVmgqETiHv8AofTfxPrqU+WjJ2vRDtn99SpIwgo9kNKIIcC F11GjezY/rLuUmm+AoZgUKzhrUBa+DVL1WVQY1YmPngkXaBp+0tX3e0YueP9X+z08m3L zYgX5BI4uiXrwUNWhnhqmwCq09Dc7Xlv9r6j8xWTWipXH66nTp3k3f2divjoxW8cXREf Oo2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pplAyIWzx/jJzkQ8ErheBqp/JOxZ8UPVrHihID0UcyI=; b=d9ZVe/i7SUagwabulx8HjXj049yVPHDyfC/2PgrRWDVcxqb4VWrU/1AC7WFZ07+1+Y hcAmaCglDzG7vdjd/0QXWO3x2hI66vashIl4hI6qcFwuLMNT7+2JsaqbfP/MNwTv9wjW RApgh7DF3sEI2ZgK3KkoLYvfdw8PA+R58kK6ItMvSVDMIKx7Yy99PhRwaSYeTW36FaNY s7LxiKkUN2ey0lt8QB6cSlu5+uGMjuKqKVAdlTztru6xny9dxnzPugeplzNENg4xAnaj VHD5isQL8EqCddWCuIL2xKRQ3py5Hs/XtfwBX+7iZHzddpPTKsb2ly98EfAG56FU3m9k +6fA== X-Gm-Message-State: AOAM5303BNrBxZuCGMLjbE0h9NnjPkNbMW780s1Y+rUE8yThFpMl4O3x YdHBpKQSR+O6ztRW6C9St7VY45XBSETsrg== X-Google-Smtp-Source: ABdhPJxNpzy/hFw2SihqXYSN4Jiv3Fnl7fcsHMR1c4DvczcKMArA0UbcyT5HIDoKw9tA8ytJEJgxtA== X-Received: by 2002:a63:1356:: with SMTP id 22mr964104pgt.108.1599814547320; Fri, 11 Sep 2020 01:55:47 -0700 (PDT) Received: from localhost.localdomain (211-20-20-223.HINET-IP.hinet.net. [211.20.20.223]) by smtp.gmail.com with ESMTPSA id w192sm1616543pfd.156.2020.09.11.01.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2020 01:55:47 -0700 (PDT) From: Show Liu To: libcamera-devel@lists.libcamera.org Date: Fri, 11 Sep 2020 16:55:14 +0800 Message-Id: <20200911085514.30021-5-show.liu@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911085514.30021-1-show.liu@linaro.org> References: <20200911085514.30021-1-show.liu@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 4/4] qcam: add additional command line option to select the render 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" Add new option "--render=qt|gles" to select the render type, "--render=gles" to accelerate format conversion and rendering "--render=qt" is the original Qt rendering Signed-off-by: Show Liu Reviewed-by: Laurent Pinchart --- src/qcam/main.cpp | 3 +++ src/qcam/main_window.cpp | 31 +++++++++++++++++++++++++++---- src/qcam/main_window.h | 3 +++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp index bae358d..4b7d041 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(OptRendered, OptionString, + "Choose the renderer type {qt,gles} (default: qt)", "renderer", + ArgumentRequired, "render"); 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 612d978..315102c 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -95,6 +95,9 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) { int ret; + /* Render Type Qt or GLES, and set Qt by default */ + std::string renderType_ = "qt"; + /* * Initialize the UI: Create the toolbar, set the window title and * create the viewfinder widget. @@ -105,10 +108,30 @@ MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) setWindowTitle(title_); connect(&titleTimer_, SIGNAL(timeout()), this, SLOT(updateTitle())); - viewfinder_ = new ViewFinder(this); - connect(viewfinder_, &ViewFinder::renderComplete, - this, &MainWindow::queueRequest); - setCentralWidget(viewfinder_); + if (options_.isSet(OptRendered)) + renderType_ = options_[OptRendered].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 3d21779..251f78b 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -26,6 +26,8 @@ #include "../cam/stream_options.h" #include "viewfinder.h" +#include "viewfinder_gl.h" +#include "viewfinder_qt.h" using namespace libcamera; @@ -37,6 +39,7 @@ class HotplugEvent; enum { OptCamera = 'c', OptHelp = 'h', + OptRendered = 'r', OptStream = 's', };