[libcamera-devel,v5,7/9] qcam: viewfinder_gl: set the vertex shader file name in selectFormat()
diff mbox series

Message ID 20210622134652.1279260-8-andrey.konovalov@linaro.org
State Accepted
Headers show
Series
  • qcam: viewfinder_gl: add RAW8, RAW10P and RAW12P formats
Related show

Commit Message

Andrey Konovalov June 22, 2021, 1:46 p.m. UTC
In preparation to extend the supported formats, make it possible
to use different vertex fragment files depending on the format.
Make "identity.vert" the default choice.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
 src/qcam/viewfinder_gl.cpp | 5 ++++-
 src/qcam/viewfinder_gl.h   | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Paul Elder June 28, 2021, 10:27 a.m. UTC | #1
Hi Andrey,

On Tue, Jun 22, 2021 at 04:46:50PM +0300, Andrey Konovalov wrote:
> In preparation to extend the supported formats, make it possible
> to use different vertex fragment files depending on the format.
> Make "identity.vert" the default choice.
> 
> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/qcam/viewfinder_gl.cpp | 5 ++++-
>  src/qcam/viewfinder_gl.h   | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp
> index a6aa2b44..6d1d80bd 100644
> --- a/src/qcam/viewfinder_gl.cpp
> +++ b/src/qcam/viewfinder_gl.cpp
> @@ -131,6 +131,9 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)
>  	/* Set min/mag filters to GL_LINEAR by default. */
>  	textureMinMagFilters_ = GL_LINEAR;
>  
> +	/* Use identity.vert as the default vertex shader. */
> +	vertexShaderFile_ = ":identity.vert";
> +
>  	fragmentShaderDefines_.clear();
>  
>  	switch (format) {
> @@ -292,7 +295,7 @@ bool ViewFinderGL::createVertexShader()
>  	vertexShader_ = std::make_unique<QOpenGLShader>(QOpenGLShader::Vertex, this);
>  
>  	/* Compile the vertex shader */
> -	if (!vertexShader_->compileSourceFile(":identity.vert")) {
> +	if (!vertexShader_->compileSourceFile(vertexShaderFile_)) {
>  		qWarning() << "[ViewFinderGL]:" << vertexShader_->log();
>  		return false;
>  	}
> diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h
> index 508155b1..bce94c87 100644
> --- a/src/qcam/viewfinder_gl.h
> +++ b/src/qcam/viewfinder_gl.h
> @@ -73,6 +73,7 @@ private:
>  	QOpenGLShaderProgram shaderProgram_;
>  	std::unique_ptr<QOpenGLShader> vertexShader_;
>  	std::unique_ptr<QOpenGLShader> fragmentShader_;
> +	QString vertexShaderFile_;
>  	QString fragmentShaderFile_;
>  	QStringList fragmentShaderDefines_;
>  
> -- 
> 2.25.1
>
Laurent Pinchart June 30, 2021, 1:07 a.m. UTC | #2
Hi Andrey,

Thank you for the patch.

On Tue, Jun 22, 2021 at 04:46:50PM +0300, Andrey Konovalov wrote:
> In preparation to extend the supported formats, make it possible
> to use different vertex fragment files depending on the format.
> Make "identity.vert" the default choice.
> 
> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/qcam/viewfinder_gl.cpp | 5 ++++-
>  src/qcam/viewfinder_gl.h   | 1 +
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp
> index a6aa2b44..6d1d80bd 100644
> --- a/src/qcam/viewfinder_gl.cpp
> +++ b/src/qcam/viewfinder_gl.cpp
> @@ -131,6 +131,9 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)
>  	/* Set min/mag filters to GL_LINEAR by default. */
>  	textureMinMagFilters_ = GL_LINEAR;
>  
> +	/* Use identity.vert as the default vertex shader. */
> +	vertexShaderFile_ = ":identity.vert";
> +
>  	fragmentShaderDefines_.clear();
>  
>  	switch (format) {
> @@ -292,7 +295,7 @@ bool ViewFinderGL::createVertexShader()
>  	vertexShader_ = std::make_unique<QOpenGLShader>(QOpenGLShader::Vertex, this);
>  
>  	/* Compile the vertex shader */
> -	if (!vertexShader_->compileSourceFile(":identity.vert")) {
> +	if (!vertexShader_->compileSourceFile(vertexShaderFile_)) {
>  		qWarning() << "[ViewFinderGL]:" << vertexShader_->log();
>  		return false;
>  	}
> diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h
> index 508155b1..bce94c87 100644
> --- a/src/qcam/viewfinder_gl.h
> +++ b/src/qcam/viewfinder_gl.h
> @@ -73,6 +73,7 @@ private:
>  	QOpenGLShaderProgram shaderProgram_;
>  	std::unique_ptr<QOpenGLShader> vertexShader_;
>  	std::unique_ptr<QOpenGLShader> fragmentShader_;
> +	QString vertexShaderFile_;
>  	QString fragmentShaderFile_;
>  	QStringList fragmentShaderDefines_;
>

Patch
diff mbox series

diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp
index a6aa2b44..6d1d80bd 100644
--- a/src/qcam/viewfinder_gl.cpp
+++ b/src/qcam/viewfinder_gl.cpp
@@ -131,6 +131,9 @@  bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format)
 	/* Set min/mag filters to GL_LINEAR by default. */
 	textureMinMagFilters_ = GL_LINEAR;
 
+	/* Use identity.vert as the default vertex shader. */
+	vertexShaderFile_ = ":identity.vert";
+
 	fragmentShaderDefines_.clear();
 
 	switch (format) {
@@ -292,7 +295,7 @@  bool ViewFinderGL::createVertexShader()
 	vertexShader_ = std::make_unique<QOpenGLShader>(QOpenGLShader::Vertex, this);
 
 	/* Compile the vertex shader */
-	if (!vertexShader_->compileSourceFile(":identity.vert")) {
+	if (!vertexShader_->compileSourceFile(vertexShaderFile_)) {
 		qWarning() << "[ViewFinderGL]:" << vertexShader_->log();
 		return false;
 	}
diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h
index 508155b1..bce94c87 100644
--- a/src/qcam/viewfinder_gl.h
+++ b/src/qcam/viewfinder_gl.h
@@ -73,6 +73,7 @@  private:
 	QOpenGLShaderProgram shaderProgram_;
 	std::unique_ptr<QOpenGLShader> vertexShader_;
 	std::unique_ptr<QOpenGLShader> fragmentShader_;
+	QString vertexShaderFile_;
 	QString fragmentShaderFile_;
 	QStringList fragmentShaderDefines_;