From patchwork Mon Mar 23 14:22:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3264 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D8F5962C71 for ; Mon, 23 Mar 2020 15:22:25 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 75D48A31 for ; Mon, 23 Mar 2020 15:22:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1584973345; bh=rOfyiGMGR0blr8uRS6jkzcG5eo47D2SsKERhXaNODds=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Fs4oRh73j3RUuyoKFwvTeS3oQ1zNZKkEX8kJf1Or7cqTjMd7Wf1kbyCDdmxT8YCB8 NgBQc5uPqQ/0QVgOa777jHwd3roDJo0MKsVJpqNkTSiuDB5ayRpZM1xWqr3WU2szZh ioiroaSoTGvgwSak817xcOQVtXT4dOU5MCPAO6AU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 23 Mar 2020 16:22:05 +0200 Message-Id: <20200323142205.28342-22-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200323142205.28342-1-laurent.pinchart@ideasonboard.com> References: <20200323142205.28342-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 21/21] qcam: viewfinder: Add support for more native formats 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: , X-List-Received-Date: Mon, 23 Mar 2020 14:22:29 -0000 Qt supports more 24-bit and 32-bit RGB formats for native painting. Disable the converter and create a QImage in the appropriate format. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/qcam/viewfinder.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp index a40b2b400daa..e5cfa45fc662 100644 --- a/src/qcam/viewfinder.cpp +++ b/src/qcam/viewfinder.cpp @@ -7,16 +7,26 @@ #include "viewfinder.h" +#include #include #include #include +#include #include #include #include #include "format_converter.h" +static const QMap formats{ + { DRM_FORMAT_ARGB8888, QImage::Format_RGB32 }, + { DRM_FORMAT_RGB888, QImage::Format_RGB888 }, +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + { DRM_FORMAT_BGR888, QImage::Format_BGR888 }, +#endif +}; + ViewFinder::ViewFinder(QWidget *parent) : QWidget(parent), buffer_(nullptr) { @@ -36,7 +46,7 @@ int ViewFinder::setFormat(const libcamera::PixelFormat &format, * If format conversion is needed, configure the converter and allocate * the destination image. */ - if (format != DRM_FORMAT_ARGB8888) { + if (!formats.contains(format)) { int ret = converter_.configure(format, size); if (ret < 0) return ret; @@ -64,7 +74,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map) { QMutexLocker locker(&mutex_); - if (format_ == DRM_FORMAT_ARGB8888) { + if (formats.contains(format_)) { /* * If the frame format is identical to the display * format, create a QImage that references the frame @@ -73,7 +83,7 @@ void ViewFinder::render(libcamera::FrameBuffer *buffer, MappedBuffer *map) * released. */ image_ = QImage(memory, size_.width(), size_.height(), - size / size_.height(), QImage::Format_RGB32); + size / size_.height(), formats[format_]); std::swap(buffer, buffer_); } else { /*