diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-10-12 22:18:04 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-11-07 19:25:24 +0200 |
commit | 3b9a582f95981a1858ae13cbbc7a4adba652e91c (patch) | |
tree | 7510d5c3df27fd237f0954d2caeca5015a1605a8 | |
parent | 4b9a774a4c1c5fbefd056f2d1f617b657b7238b5 (diff) |
qcam: viewfinder_gl: Keep fragment shader when format doesn't change
When ViewFinderGL::setFormat() is called, the fragment shader is deleted
and recreated for the new format. This results in unnecessary shader
recompilation if only the size is changed and the pixel format remains
the same. Keep the existing shader in that case.
The null test for fragmentShader_ can be removed, as if the shader
program is linked, the fragment shader is guaranteed to exist.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Andrey Konovalov <andrey.konovalov@linaro.org>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
-rw-r--r-- | src/qcam/viewfinder_gl.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp index 03a576ba..c0729252 100644 --- a/src/qcam/viewfinder_gl.cpp +++ b/src/qcam/viewfinder_gl.cpp @@ -53,19 +53,23 @@ const QList<libcamera::PixelFormat> &ViewFinderGL::nativeFormats() const int ViewFinderGL::setFormat(const libcamera::PixelFormat &format, const QSize &size) { - /* If the fragment is created remove it and create a new one. */ - if (fragmentShader_) { + if (format != format_) { + /* + * If the fragment already exists, remove it and create a new + * one for the new format. + */ if (shaderProgram_.isLinked()) { shaderProgram_.release(); shaderProgram_.removeShader(fragmentShader_.get()); fragmentShader_.reset(); } - } - if (!selectFormat(format)) - return -1; + if (!selectFormat(format)) + return -1; + + format_ = format; + } - format_ = format; size_ = size; updateGeometry(); |