Message ID | 20200916145254.1644-3-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Commit | 52f2581709365992ae54430f2b9563269c2fbfce |
Headers | show |
Series |
|
Related | show |
Hi Laurent, Thanks for your patch. On 2020-09-16 17:52:49 +0300, Laurent Pinchart wrote: > The texture IDs can easily and cheaply be retrieved from the textures, > there's no need to store them in class members. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > --- > src/qcam/viewfinder_gl.cpp | 23 ++++++++++------------- > src/qcam/viewfinder_gl.h | 5 +---- > 2 files changed, 11 insertions(+), 17 deletions(-) > > diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp > index fbe21dcf1ad2..18ebe46fe2f9 100644 > --- a/src/qcam/viewfinder_gl.cpp > +++ b/src/qcam/viewfinder_gl.cpp > @@ -229,15 +229,12 @@ bool ViewFinderGL::createFragmentShader() > if (!textureV_.isCreated()) > textureV_.create(); > > - id_y_ = textureY_.textureId(); > - id_u_ = textureU_.textureId(); > - id_v_ = textureV_.textureId(); > return true; > } > > -void ViewFinderGL::configureTexture(unsigned int id) > +void ViewFinderGL::configureTexture(QOpenGLTexture &texture) > { > - glBindTexture(GL_TEXTURE_2D, id); > + glBindTexture(GL_TEXTURE_2D, texture.textureId()); > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); > glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); > @@ -303,7 +300,7 @@ void ViewFinderGL::doRender() > case libcamera::formats::NV42: > /* Activate texture Y */ > glActiveTexture(GL_TEXTURE0); > - configureTexture(id_y_); > + configureTexture(textureY_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > @@ -317,7 +314,7 @@ void ViewFinderGL::doRender() > > /* Activate texture UV/VU */ > glActiveTexture(GL_TEXTURE1); > - configureTexture(id_u_); > + configureTexture(textureU_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RG, > @@ -333,7 +330,7 @@ void ViewFinderGL::doRender() > case libcamera::formats::YUV420: > /* Activate texture Y */ > glActiveTexture(GL_TEXTURE0); > - configureTexture(id_y_); > + configureTexture(textureY_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > @@ -347,7 +344,7 @@ void ViewFinderGL::doRender() > > /* Activate texture U */ > glActiveTexture(GL_TEXTURE1); > - configureTexture(id_u_); > + configureTexture(textureU_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > @@ -361,7 +358,7 @@ void ViewFinderGL::doRender() > > /* Activate texture V */ > glActiveTexture(GL_TEXTURE2); > - configureTexture(id_v_); > + configureTexture(textureV_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > @@ -377,7 +374,7 @@ void ViewFinderGL::doRender() > case libcamera::formats::YVU420: > /* Activate texture Y */ > glActiveTexture(GL_TEXTURE0); > - configureTexture(id_y_); > + configureTexture(textureY_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > @@ -391,7 +388,7 @@ void ViewFinderGL::doRender() > > /* Activate texture V */ > glActiveTexture(GL_TEXTURE2); > - configureTexture(id_v_); > + configureTexture(textureV_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > @@ -405,7 +402,7 @@ void ViewFinderGL::doRender() > > /* Activate texture U */ > glActiveTexture(GL_TEXTURE1); > - configureTexture(id_u_); > + configureTexture(textureU_); > glTexImage2D(GL_TEXTURE_2D, > 0, > GL_RED, > diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h > index 69502b7a543e..825af1c13cb7 100644 > --- a/src/qcam/viewfinder_gl.h > +++ b/src/qcam/viewfinder_gl.h > @@ -53,7 +53,7 @@ protected: > private: > bool selectFormat(const libcamera::PixelFormat &format); > > - void configureTexture(unsigned int id); > + void configureTexture(QOpenGLTexture &texture); > bool createFragmentShader(); > bool createVertexShader(); > void removeShader(); > @@ -78,9 +78,6 @@ private: > QString vertexShaderSrc_; > > /* YUV texture planars and parameters */ > - GLuint id_u_; > - GLuint id_v_; > - GLuint id_y_; > GLuint textureUniformU_; > GLuint textureUniformV_; > GLuint textureUniformY_; > -- > Regards, > > Laurent Pinchart > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/qcam/viewfinder_gl.cpp b/src/qcam/viewfinder_gl.cpp index fbe21dcf1ad2..18ebe46fe2f9 100644 --- a/src/qcam/viewfinder_gl.cpp +++ b/src/qcam/viewfinder_gl.cpp @@ -229,15 +229,12 @@ bool ViewFinderGL::createFragmentShader() if (!textureV_.isCreated()) textureV_.create(); - id_y_ = textureY_.textureId(); - id_u_ = textureU_.textureId(); - id_v_ = textureV_.textureId(); return true; } -void ViewFinderGL::configureTexture(unsigned int id) +void ViewFinderGL::configureTexture(QOpenGLTexture &texture) { - glBindTexture(GL_TEXTURE_2D, id); + glBindTexture(GL_TEXTURE_2D, texture.textureId()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -303,7 +300,7 @@ void ViewFinderGL::doRender() case libcamera::formats::NV42: /* Activate texture Y */ glActiveTexture(GL_TEXTURE0); - configureTexture(id_y_); + configureTexture(textureY_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, @@ -317,7 +314,7 @@ void ViewFinderGL::doRender() /* Activate texture UV/VU */ glActiveTexture(GL_TEXTURE1); - configureTexture(id_u_); + configureTexture(textureU_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RG, @@ -333,7 +330,7 @@ void ViewFinderGL::doRender() case libcamera::formats::YUV420: /* Activate texture Y */ glActiveTexture(GL_TEXTURE0); - configureTexture(id_y_); + configureTexture(textureY_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, @@ -347,7 +344,7 @@ void ViewFinderGL::doRender() /* Activate texture U */ glActiveTexture(GL_TEXTURE1); - configureTexture(id_u_); + configureTexture(textureU_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, @@ -361,7 +358,7 @@ void ViewFinderGL::doRender() /* Activate texture V */ glActiveTexture(GL_TEXTURE2); - configureTexture(id_v_); + configureTexture(textureV_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, @@ -377,7 +374,7 @@ void ViewFinderGL::doRender() case libcamera::formats::YVU420: /* Activate texture Y */ glActiveTexture(GL_TEXTURE0); - configureTexture(id_y_); + configureTexture(textureY_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, @@ -391,7 +388,7 @@ void ViewFinderGL::doRender() /* Activate texture V */ glActiveTexture(GL_TEXTURE2); - configureTexture(id_v_); + configureTexture(textureV_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, @@ -405,7 +402,7 @@ void ViewFinderGL::doRender() /* Activate texture U */ glActiveTexture(GL_TEXTURE1); - configureTexture(id_u_); + configureTexture(textureU_); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, diff --git a/src/qcam/viewfinder_gl.h b/src/qcam/viewfinder_gl.h index 69502b7a543e..825af1c13cb7 100644 --- a/src/qcam/viewfinder_gl.h +++ b/src/qcam/viewfinder_gl.h @@ -53,7 +53,7 @@ protected: private: bool selectFormat(const libcamera::PixelFormat &format); - void configureTexture(unsigned int id); + void configureTexture(QOpenGLTexture &texture); bool createFragmentShader(); bool createVertexShader(); void removeShader(); @@ -78,9 +78,6 @@ private: QString vertexShaderSrc_; /* YUV texture planars and parameters */ - GLuint id_u_; - GLuint id_v_; - GLuint id_y_; GLuint textureUniformU_; GLuint textureUniformV_; GLuint textureUniformY_;
The texture IDs can easily and cheaply be retrieved from the textures, there's no need to store them in class members. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/qcam/viewfinder_gl.cpp | 23 ++++++++++------------- src/qcam/viewfinder_gl.h | 5 +---- 2 files changed, 11 insertions(+), 17 deletions(-)