From patchwork Fri Sep 4 08:43:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Show Liu X-Patchwork-Id: 9485 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 49588BE174 for ; Fri, 4 Sep 2020 08:43:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 12E9E62B5E; Fri, 4 Sep 2020 10:43:52 +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="JabvbRHE"; dkim-atps=neutral Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C5AA62B29 for ; Fri, 4 Sep 2020 10:43:50 +0200 (CEST) Received: by mail-pg1-x52f.google.com with SMTP id 67so3964126pgd.12 for ; Fri, 04 Sep 2020 01:43:50 -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=gn2JH7tF1O7M0KrQ6KFsWgs+zDBHROUzYsKfAYJPK6Y=; b=JabvbRHEOcBM2+jzz/4sbu6nPlczB1VWPQ3mJfoAyKdPcMWf7GNT2j5onThx1Ryd+M k+xE908vL5GS6BLyqFs04197oqBk4RlZc1U35Bxe7IZS4pSwwR7KPTb5bXqD7JId1TJ1 8reYn+2ZVRzTsRmdQnZ/G3SOY7/oWdPhe0UpE10IITHxYZhKO2GBSTU2M98vBICQChey jOMCI5rvZ+btZIkj70ACiyaX7UFxoCn8wjuUh9AMnP45z0EscbUv/bRYGPz0NoUmD5f/ tntp0lCsdGGZe4RasoZ6BnGqj2UT+m4s62JyLVe92UetxoFBJv7HJyd1bFgGDgqqwlNh pMKA== 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=gn2JH7tF1O7M0KrQ6KFsWgs+zDBHROUzYsKfAYJPK6Y=; b=OlEsYuUpJ0Q/AFoRUkeSVpZPEaI0hDeiPcFifidtwSwMNx+FrIPGAVKCAu9PBx4pie I4vSDXKX4PlPUnr9wZEu5UWwlQ6VqCa/oJNIWAIIZ8EoHKnGoQr3dXpFrxe5KZlB0mcy NBwCNABXbE+LyJuC0s2EU8hG/XM8drFCdRnNCbTbcqFZdAXOPHWFt5rl5f/l4sEnHiaU jMaNwWI55cTXYonDzSJ1+XElU8Efhlzk2TxHtSBhDwkXGNlTWDLzDmM8RhYXvrnHmBxC KTk5sFbjhvqLe8D/m8G1A4Dn6x30sGiALPB0t4NNGzML0/vf30H2tA7OE1+NJbyiw1Zk XtiA== X-Gm-Message-State: AOAM53166+w5El60hJQJxkrbvdr2oyWJ5D6XuDc4v0bCqqo41zM0wLxc W5BQ/tE9Jo1Gesq537s9q7feKfApqEnw/Q== X-Google-Smtp-Source: ABdhPJw/oXxecjyH1fXNVR9uOE7TaAPHBKzLqBSEretmTyQkGWJhXHJuI/c8c5znb1KgwqBKd/ysiQ== X-Received: by 2002:a63:26c6:: with SMTP id m189mr6393156pgm.68.1599209029032; Fri, 04 Sep 2020 01:43:49 -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 a6sm5202148pgt.70.2020.09.04.01.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 01:43:48 -0700 (PDT) From: Show Liu To: libcamera-devel@lists.libcamera.org Date: Fri, 4 Sep 2020 16:43:16 +0800 Message-Id: <20200904084316.7319-6-show.liu@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200904084316.7319-1-show.liu@linaro.org> References: <20200904084316.7319-1-show.liu@linaro.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 | 29 ++++++++++++++++++++++++----- src/qcam/main_window.h | 6 ++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/qcam/main.cpp b/src/qcam/main.cpp index bae358d..19d0559 100644 --- a/src/qcam/main.cpp +++ b/src/qcam/main.cpp @@ -35,6 +35,9 @@ OptionsParser::Options parseOptions(int argc, char *argv[]) "help"); parser.addOption(OptStream, &streamKeyValue, "Set configuration of a camera stream", "stream", true); + parser.addOption(OptRender, OptionString, + "Choose the render type use qt|gles", "render", + ArgumentRequired, "render"); OptionsParser::Options options = parser.parse(argc, argv); if (options.isSet(OptHelp)) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 612d978..467cc74 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -91,7 +91,7 @@ private: MainWindow::MainWindow(CameraManager *cm, const OptionsParser::Options &options) : saveRaw_(nullptr), options_(options), cm_(cm), allocator_(nullptr), - isCapturing_(false), captureRaw_(false) + isCapturing_(false), captureRaw_(false), renderType_("qt") { int ret; @@ -105,10 +105,29 @@ 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(OptRender)) + renderType_ = options_[OptRender].toString().c_str(); + + if (renderType_ == "qt") { + viewfinder_ = new ViewFinderQt(this); + ViewFinderQt *vf = dynamic_cast(viewfinder_); + connect(vf, &ViewFinderQt::renderComplete, + this, &MainWindow::queueRequest); + setCentralWidget(vf); + } else if (renderType_ == "gles") { + viewfinder_ = new ViewFinderGL(this); + ViewFinderGL *vf = dynamic_cast(viewfinder_); + connect(vf, &ViewFinderGL::renderComplete, + this, &MainWindow::queueRequest); + setCentralWidget(vf); + } else { + qWarning() << "Render Type:" + << QString::fromStdString(renderType_) + << " is not support."; + quit(); + return; + } + adjustSize(); /* Hotplug/unplug support */ diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 3d21779..a69b399 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; @@ -38,6 +40,7 @@ enum { OptCamera = 'c', OptHelp = 'h', OptStream = 's', + OptRender = 'r', }; class CaptureRequest @@ -134,6 +137,9 @@ private: QElapsedTimer frameRateInterval_; uint32_t previousFrames_; uint32_t framesCaptured_; + + /* Render Type Qt or GLES */ + std::string renderType_; }; #endif /* __QCAM_MAIN_WINDOW__ */