From patchwork Wed Sep 16 14:52:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9638 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 52F58C3B5B for ; Wed, 16 Sep 2020 14:53:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2081262E75; Wed, 16 Sep 2020 16:53:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="SFhthe73"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D63B760533 for ; Wed, 16 Sep 2020 16:53:55 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE58F57F; Wed, 16 Sep 2020 16:53:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1600268023; bh=0AK0kfDsGCE8d8n04+QvYEIYL1/BcMeFDFNlR429Cu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFhthe73P25sAk7mFj5tVGBZCJLOduonzgH5AcAuX6plAd6kG4oxXIUbho+JBPqzn i9oGNz1f3KFNDMTQSA25lLLYqGaPuzMG9/Numb00WX+bfYID8GwDWiPocarCCgdMhL iRIVcmpW0qoodK3obz5jo9Vp0pfUE3KJVMp8fpA8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 16 Sep 2020 17:52:49 +0300 Message-Id: <20200916145254.1644-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200916145254.1644-1-laurent.pinchart@ideasonboard.com> References: <20200916145254.1644-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/7] qcam: viewfinder_gl: Don't store texture IDs in class members X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Niklas Söderlund --- 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_;