[libcamera-devel] [PATCH 21/21] qcam: viewfinder: Add support for more native formats
Kieran Bingham
kieran.bingham at ideasonboard.com
Mon Mar 23 18:30:14 CET 2020
Hi Laurent,
On 23/03/2020 14:22, Laurent Pinchart wrote:
> Qt supports more 24-bit and 32-bit RGB formats for native painting.
> Disable the converter and create a QImage in the appropriate format.
Aha, I think this answers an earlier question. ...
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> 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 <stdint.h>
> #include <utility>
>
> #include <QImage>
> #include <QImageWriter>
> +#include <QMap>
> #include <QMutexLocker>
> #include <QPainter>
> #include <QtDebug>
>
> #include "format_converter.h"
>
> +static const QMap<uint32_t, QImage::Format> formats{
There are lots of formats, but which are these :)
/formats/nativeFormats/ ?
> + { 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 {
> /*
>
--
Regards
--
Kieran
More information about the libcamera-devel
mailing list