[{"id":13622,"web_url":"https://patchwork.libcamera.org/comment/13622/","msgid":"<20201106005229.GA3013826@oden.dyn.berto.se>","date":"2020-11-06T00:52:29","subject":"Re: [libcamera-devel] [PATCH v1.1 6/7] qcam: viewfinder_gl: Store\n\ttextures in an array","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-11-04 04:17:25 +0200, Laurent Pinchart wrote:\n> In preparation for RGB formats support, store the three Y, U and V\n> textures in an array. This makes the code more generic, and will avoid\n> referring to an RGB texture as textureY_.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n> Changes since v1:\n> \n> - Reorganize texture fields in the ViewFinderGL class\n> ---\n>  src/qcam/viewfinder_gl.cpp | 37 +++++++++++++++++--------------------\n>  src/qcam/viewfinder_gl.h   |  9 +++++----\n>  2 files changed, 22 insertions(+), 24 deletions(-)\n> \n> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp\n> index e6625cac9795..cbc1365500f5 100644\n> --- a/src/qcam/viewfinder_gl.cpp\n> +++ b/src/qcam/viewfinder_gl.cpp\n> @@ -33,10 +33,7 @@ static const QList<libcamera::PixelFormat> supportedFormats{\n>  \n>  ViewFinderGL::ViewFinderGL(QWidget *parent)\n>  \t: QOpenGLWidget(parent), buffer_(nullptr), data_(nullptr),\n> -\t  vertexBuffer_(QOpenGLBuffer::VertexBuffer),\n> -\t  textureU_(QOpenGLTexture::Target2D),\n> -\t  textureV_(QOpenGLTexture::Target2D),\n> -\t  textureY_(QOpenGLTexture::Target2D)\n> +\t  vertexBuffer_(QOpenGLBuffer::VertexBuffer)\n>  {\n>  }\n>  \n> @@ -263,14 +260,14 @@ bool ViewFinderGL::createFragmentShader()\n>  \ttextureUniformV_ = shaderProgram_.uniformLocation(\"tex_v\");\n>  \ttextureUniformStepX_ = shaderProgram_.uniformLocation(\"tex_stepx\");\n>  \n> -\tif (!textureY_.isCreated())\n> -\t\ttextureY_.create();\n> +\t/* Create the textures. */\n> +\tfor (std::unique_ptr<QOpenGLTexture> &texture : textures_) {\n> +\t\tif (texture)\n> +\t\t\tcontinue;\n>  \n> -\tif (!textureU_.isCreated())\n> -\t\ttextureU_.create();\n> -\n> -\tif (!textureV_.isCreated())\n> -\t\ttextureV_.create();\n> +\t\ttexture = std::make_unique<QOpenGLTexture>(QOpenGLTexture::Target2D);\n> +\t\ttexture->create();\n> +\t}\n>  \n>  \treturn true;\n>  }\n> @@ -337,7 +334,7 @@ void ViewFinderGL::doRender()\n>  \tcase libcamera::formats::NV42:\n>  \t\t/* Activate texture Y */\n>  \t\tglActiveTexture(GL_TEXTURE0);\n> -\t\tconfigureTexture(textureY_);\n> +\t\tconfigureTexture(*textures_[0]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -351,7 +348,7 @@ void ViewFinderGL::doRender()\n>  \n>  \t\t/* Activate texture UV/VU */\n>  \t\tglActiveTexture(GL_TEXTURE1);\n> -\t\tconfigureTexture(textureU_);\n> +\t\tconfigureTexture(*textures_[1]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RG,\n> @@ -367,7 +364,7 @@ void ViewFinderGL::doRender()\n>  \tcase libcamera::formats::YUV420:\n>  \t\t/* Activate texture Y */\n>  \t\tglActiveTexture(GL_TEXTURE0);\n> -\t\tconfigureTexture(textureY_);\n> +\t\tconfigureTexture(*textures_[0]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -381,7 +378,7 @@ void ViewFinderGL::doRender()\n>  \n>  \t\t/* Activate texture U */\n>  \t\tglActiveTexture(GL_TEXTURE1);\n> -\t\tconfigureTexture(textureU_);\n> +\t\tconfigureTexture(*textures_[1]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -395,7 +392,7 @@ void ViewFinderGL::doRender()\n>  \n>  \t\t/* Activate texture V */\n>  \t\tglActiveTexture(GL_TEXTURE2);\n> -\t\tconfigureTexture(textureV_);\n> +\t\tconfigureTexture(*textures_[2]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -411,7 +408,7 @@ void ViewFinderGL::doRender()\n>  \tcase libcamera::formats::YVU420:\n>  \t\t/* Activate texture Y */\n>  \t\tglActiveTexture(GL_TEXTURE0);\n> -\t\tconfigureTexture(textureY_);\n> +\t\tconfigureTexture(*textures_[0]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -425,7 +422,7 @@ void ViewFinderGL::doRender()\n>  \n>  \t\t/* Activate texture V */\n>  \t\tglActiveTexture(GL_TEXTURE2);\n> -\t\tconfigureTexture(textureV_);\n> +\t\tconfigureTexture(*textures_[2]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -439,7 +436,7 @@ void ViewFinderGL::doRender()\n>  \n>  \t\t/* Activate texture U */\n>  \t\tglActiveTexture(GL_TEXTURE1);\n> -\t\tconfigureTexture(textureU_);\n> +\t\tconfigureTexture(*textures_[1]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RED,\n> @@ -462,7 +459,7 @@ void ViewFinderGL::doRender()\n>  \t\t * The texture width is thus half of the image with.\n>  \t\t */\n>  \t\tglActiveTexture(GL_TEXTURE0);\n> -\t\tconfigureTexture(textureY_);\n> +\t\tconfigureTexture(*textures_[0]);\n>  \t\tglTexImage2D(GL_TEXTURE_2D,\n>  \t\t\t     0,\n>  \t\t\t     GL_RGBA,\n> diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h\n> index b3e36514d3d4..150fa4ae94da 100644\n> --- a/src/qcam/viewfinder_gl.h\n> +++ b/src/qcam/viewfinder_gl.h\n> @@ -8,6 +8,7 @@\n>  #ifndef __VIEWFINDER_GL_H__\n>  #define __VIEWFINDER_GL_H__\n>  \n> +#include <array>\n>  #include <memory>\n>  \n>  #include <QImage>\n> @@ -77,14 +78,14 @@ private:\n>  \t/* Vertex buffer */\n>  \tQOpenGLBuffer vertexBuffer_;\n>  \n> -\t/* YUV texture planars and parameters */\n> +\t/* Textures */\n> +\tstd::array<std::unique_ptr<QOpenGLTexture>, 3> textures_;\n> +\n> +\t/* YUV texture parameters */\n>  \tGLuint textureUniformU_;\n>  \tGLuint textureUniformV_;\n>  \tGLuint textureUniformY_;\n>  \tGLuint textureUniformStepX_;\n> -\tQOpenGLTexture textureU_;\n> -\tQOpenGLTexture textureV_;\n> -\tQOpenGLTexture textureY_;\n>  \tunsigned int horzSubSample_;\n>  \tunsigned int vertSubSample_;\n>  \n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 04FFEBDB89\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Nov 2020 00:52:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6DAF762D0E;\n\tFri,  6 Nov 2020 01:52:32 +0100 (CET)","from mail-lf1-x144.google.com (mail-lf1-x144.google.com\n\t[IPv6:2a00:1450:4864:20::144])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 519F562CAF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Nov 2020 01:52:31 +0100 (CET)","by mail-lf1-x144.google.com with SMTP id l2so5020623lfk.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 05 Nov 2020 16:52:31 -0800 (PST)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\to4sm285596ljp.92.2020.11.05.16.52.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 05 Nov 2020 16:52:29 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"J+LaHwsL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=6JK1OU18Ae46OyUW1ZUiqIu162nlrfS4gP++jGlWvF4=;\n\tb=J+LaHwsLTcyO1DS6ZceaASTZnK+QIOZKc0295bIz276lOhogqJsLF9FAAA4ORoWCt5\n\teaWiFnDULf4YwCJ1MQ0sL0u7IXf2/2cenFazliquAv0bcO7eeVc+EZTzGW+LdEk0JKOZ\n\tzAqFRvMwSDA3hzpfHo+/+n7NUPZQmNQKFoy4SPO+xGRrYvg3xRMSLdwVFlfz+DpinAXz\n\tiYwKIBc+bezhwrErCqFhY39Xt7KTnFu+Xqp8WfRu4+wzCHxF5ZWfe7QVNK81xgf42NLl\n\tjLKhslFQu2KmMVj5kqzj6ikjx6l84wYBYL5AGCrUbfEGaYby9rU/WrXVVlUB+9Q4DsUa\n\tnq4g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=6JK1OU18Ae46OyUW1ZUiqIu162nlrfS4gP++jGlWvF4=;\n\tb=RnP2dXF/eSn5VEnPGZue5fdcCyqdVhjp4QqUZDjgg3dG+4OkxQ9h+u/P9/Pe6fglO0\n\tWNGd+WQmS/Ged0mR4wwRQlKokmZE9rKmbQ7IzYJFDTDe8v02E2QV7qR5+1W6A6bhQbv7\n\tFBQ66W61SvijVjnatJ+a2tcVbP6oveVdoJxsVDOd0eZoTmshPqLPPZszK8gqbG8M0yLe\n\tFqwOCP+C8XR+QO0TSIt388dYk22m4GTgQLYZQQWCk8akrLua3/qmXtSTZndwkJVA/xeV\n\t1HYYze522/QipKu2WBpupSerJ86LrN1cwsn9zKq6RK8hY8xYPIaFg14nz3gw4o+XTpbv\n\tq1hQ==","X-Gm-Message-State":"AOAM531e0SquxepGtdrtQRZwyx134nuH2t9NBxtJp3B2gY2/0Nb6mjxF\n\t4AfH1bJK3THL+Rq6BVCyIiBLDg==","X-Google-Smtp-Source":"ABdhPJwO/Z9zROKQoIuxy2dSp3Ziv1fGcCEDXOtvhkQ7z3gk6/3jTTVvjEHjdJLGPtSYR2DnL2QfMA==","X-Received":"by 2002:a19:42d3:: with SMTP id\n\tp202mr2039939lfa.85.1604623950734; \n\tThu, 05 Nov 2020 16:52:30 -0800 (PST)","Date":"Fri, 6 Nov 2020 01:52:29 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20201106005229.GA3013826@oden.dyn.berto.se>","References":"<99ef4bf5-5e13-2264-de05-c550b20d3977@linaro.org>\n\t<20201104021725.32361-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201104021725.32361-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v1.1 6/7] qcam: viewfinder_gl: Store\n\ttextures in an array","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]