From 86a9796a5acde8004a5c357dad70f99442a5b351 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sun, 2 Apr 2023 12:32:04 +0200 Subject: [PATCH] kwinglutils: bind texture in GLTexture::render ... instead of doing it everywhere that the method is used --- src/cursordelegate_opengl.cpp | 2 -- src/effects.cpp | 2 -- src/effects/magnifier/magnifier.cpp | 2 -- src/effects/screenedge/screenedgeeffect.cpp | 2 -- src/effects/startupfeedback/startupfeedback.cpp | 2 -- src/effects/trackmouse/trackmouse.cpp | 2 -- src/effects/zoom/zoom.cpp | 4 ---- src/libkwineffects/kwingltexture.cpp | 2 ++ src/libkwineffects/kwinglutils.cpp | 2 -- src/plugins/screencast/outputscreencastsource.cpp | 2 -- src/plugins/screencast/regionscreencastsource.cpp | 4 ---- src/plugins/screencast/screencaststream.cpp | 2 -- src/plugins/screencast/screencastutils.h | 2 -- 13 files changed, 2 insertions(+), 28 deletions(-) diff --git a/src/cursordelegate_opengl.cpp b/src/cursordelegate_opengl.cpp index 29ac142630..c828104520 100644 --- a/src/cursordelegate_opengl.cpp +++ b/src/cursordelegate_opengl.cpp @@ -66,11 +66,9 @@ void CursorDelegateOpenGL::paint(const RenderTarget &renderTarget, const QRegion glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_texture->bind(); ShaderBinder binder(ShaderTrait::MapTexture); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); m_texture->render(region, cursorRect.size(), scale); - m_texture->unbind(); glDisable(GL_BLEND); GLFramebuffer::popFramebuffer(); diff --git a/src/effects.cpp b/src/effects.cpp index 035d27ecab..02471892b3 100644 --- a/src/effects.cpp +++ b/src/effects.cpp @@ -1646,9 +1646,7 @@ void EffectsHandlerImpl::renderOffscreenQuickView(const RenderTarget &renderTarg glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - t->bind(); t->render(w->size(), viewport.scale()); - t->unbind(); glDisable(GL_BLEND); ShaderManager::instance()->popShader(); diff --git a/src/effects/magnifier/magnifier.cpp b/src/effects/magnifier/magnifier.cpp index a36f0b674a..75508c01f2 100644 --- a/src/effects/magnifier/magnifier.cpp +++ b/src/effects/magnifier/magnifier.cpp @@ -125,14 +125,12 @@ void MagnifierEffect::paintScreen(const RenderTarget &renderTarget, const Render if (effects->isOpenGLCompositing()) { m_fbo->blitFromRenderTarget(renderTarget, viewport, srcArea.toRect(), QRect(QPoint(), m_fbo->size())); // paint magnifier - m_texture->bind(); auto s = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture); QMatrix4x4 mvp = viewport.projectionMatrix(); mvp.translate(area.x() * scale, area.y() * scale); s->setUniform(GLShader::ModelViewProjectionMatrix, mvp); m_texture->render(area.size(), scale); ShaderManager::instance()->popShader(); - m_texture->unbind(); GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer(); vbo->reset(); diff --git a/src/effects/screenedge/screenedgeeffect.cpp b/src/effects/screenedge/screenedgeeffect.cpp index f1b53c85ac..6d097b0d23 100644 --- a/src/effects/screenedge/screenedgeeffect.cpp +++ b/src/effects/screenedge/screenedgeeffect.cpp @@ -80,7 +80,6 @@ void ScreenEdgeEffect::paintScreen(const RenderTarget &renderTarget, const Rende GLTexture *texture = glow->texture.get(); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - texture->bind(); ShaderBinder binder(ShaderTrait::MapTexture | ShaderTrait::Modulate); const QVector4D constant(opacity, opacity, opacity, opacity); binder.shader()->setUniform(GLShader::ModulationConstant, constant); @@ -89,7 +88,6 @@ void ScreenEdgeEffect::paintScreen(const RenderTarget &renderTarget, const Rende mvp.translate(glow->geometry.x() * scale, glow->geometry.y() * scale); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); texture->render(glow->geometry.size(), scale); - texture->unbind(); glDisable(GL_BLEND); } else if (effects->compositingType() == QPainterCompositing) { QImage tmp(glow->image->size(), QImage::Format_ARGB32_Premultiplied); diff --git a/src/effects/startupfeedback/startupfeedback.cpp b/src/effects/startupfeedback/startupfeedback.cpp index c7dedfe98b..0d567ab758 100644 --- a/src/effects/startupfeedback/startupfeedback.cpp +++ b/src/effects/startupfeedback/startupfeedback.cpp @@ -213,7 +213,6 @@ void StartupFeedbackEffect::paintScreen(const RenderTarget &renderTarget, const } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - texture->bind(); if (m_type == BlinkingFeedback && m_blinkingShader && m_blinkingShader->isValid()) { const QColor &blinkingColor = BLINKING_COLORS[FRAME_TO_BLINKING_COLOR[m_frame]]; ShaderManager::instance()->pushShader(m_blinkingShader.get()); @@ -227,7 +226,6 @@ void StartupFeedbackEffect::paintScreen(const RenderTarget &renderTarget, const ShaderManager::instance()->getBoundShader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); texture->render(m_currentGeometry.size(), scale); ShaderManager::instance()->popShader(); - texture->unbind(); glDisable(GL_BLEND); } } diff --git a/src/effects/trackmouse/trackmouse.cpp b/src/effects/trackmouse/trackmouse.cpp index 522200a378..c78eb4650d 100644 --- a/src/effects/trackmouse/trackmouse.cpp +++ b/src/effects/trackmouse/trackmouse.cpp @@ -122,9 +122,7 @@ void TrackMouseEffect::paintScreen(const RenderTarget &renderTarget, const Rende QMatrix4x4 mvp(matrix); mvp.translate(m_lastRect[i].x() * scale, m_lastRect[i].y() * scale); shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_texture[i]->bind(); m_texture[i]->render(m_lastRect[i].size(), scale); - m_texture[i]->unbind(); } glDisable(GL_BLEND); } else if (effects->compositingType() == QPainterCompositing && !m_image[0].isNull() && !m_image[1].isNull()) { diff --git a/src/effects/zoom/zoom.cpp b/src/effects/zoom/zoom.cpp index 6969ae6901..d732ef8f16 100644 --- a/src/effects/zoom/zoom.cpp +++ b/src/effects/zoom/zoom.cpp @@ -361,9 +361,7 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp shader->setUniform(GLShader::ModelViewProjectionMatrix, viewport.projectionMatrix() * matrix); - offscreen.texture->bind(); offscreen.texture->render(offscreen.viewport.size(), scale); - offscreen.texture->unbind(); } ShaderManager::instance()->popShader(); @@ -382,7 +380,6 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp const QPointF p = (effects->cursorPos() - cursor.hotSpot()) * zoom + QPoint(xTranslation, yTranslation); - cursorTexture->bind(); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); auto s = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture); @@ -391,7 +388,6 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp s->setUniform(GLShader::ModelViewProjectionMatrix, mvp); cursorTexture->render(cursorSize, scale); ShaderManager::instance()->popShader(); - cursorTexture->unbind(); glDisable(GL_BLEND); } } diff --git a/src/libkwineffects/kwingltexture.cpp b/src/libkwineffects/kwingltexture.cpp index eb7abbb6d6..03b6e8f855 100644 --- a/src/libkwineffects/kwingltexture.cpp +++ b/src/libkwineffects/kwingltexture.cpp @@ -564,7 +564,9 @@ void GLTexture::render(const QRectF &source, const QRegion ®ion, const QSizeF d->m_vbo->setData(4, 2, verts, texcoords); } + bind(); d->m_vbo->render(region, GL_TRIANGLE_STRIP, hardwareClipping); + unbind(); } GLuint GLTexture::texture() const diff --git a/src/libkwineffects/kwinglutils.cpp b/src/libkwineffects/kwinglutils.cpp index cf92a604ff..6da397b663 100644 --- a/src/libkwineffects/kwinglutils.cpp +++ b/src/libkwineffects/kwinglutils.cpp @@ -1193,9 +1193,7 @@ bool GLFramebuffer::blitFromRenderTarget(const RenderTarget &sourceRenderTarget, ShaderBinder binder(ShaderTrait::MapTexture); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mat); - texture->bind(); texture->render(sourceViewport.mapToRenderTargetTexture(source), infiniteRegion(), destination.size(), 1); - texture->unbind(); GLFramebuffer::popFramebuffer(); return true; diff --git a/src/plugins/screencast/outputscreencastsource.cpp b/src/plugins/screencast/outputscreencastsource.cpp index c25dbf8a0f..cee132268e 100644 --- a/src/plugins/screencast/outputscreencastsource.cpp +++ b/src/plugins/screencast/outputscreencastsource.cpp @@ -66,9 +66,7 @@ void OutputScreenCastSource::render(GLFramebuffer *target) shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix); GLFramebuffer::pushFramebuffer(target); - outputTexture->bind(); outputTexture->render(textureSize(), m_output->scale()); - outputTexture->unbind(); GLFramebuffer::popFramebuffer(); } diff --git a/src/plugins/screencast/regionscreencastsource.cpp b/src/plugins/screencast/regionscreencastsource.cpp index 8307a755cc..9c0a4c45ba 100644 --- a/src/plugins/screencast/regionscreencastsource.cpp +++ b/src/plugins/screencast/regionscreencastsource.cpp @@ -64,9 +64,7 @@ void RegionScreenCastSource::updateOutput(Output *output) shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix); - outputTexture->bind(); outputTexture->render(output->geometry().size(), 1 / m_scale); - outputTexture->unbind(); GLFramebuffer::popFramebuffer(); } } @@ -102,9 +100,7 @@ void RegionScreenCastSource::render(GLFramebuffer *target) projectionMatrix.ortho(QRect(QPoint(), target->size())); shader->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix); - m_renderedTexture->bind(); m_renderedTexture->render(target->size(), m_scale); - m_renderedTexture->unbind(); ShaderManager::instance()->popShader(); GLFramebuffer::popFramebuffer(); diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index 5143afe10f..84c93a4800 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -527,7 +527,6 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion) } m_cursor.texture->setContentTransform(TextureTransforms()); - m_cursor.texture->bind(); const auto cursorRect = cursorGeometry(cursor); mvp.translate(cursorRect.left(), r.height() - cursorRect.top() - cursor->image().height()); shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); @@ -536,7 +535,6 @@ void ScreenCastStream::recordFrame(const QRegion &_damagedRegion) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); m_cursor.texture->render(cursorRect.size(), m_cursor.scale); glDisable(GL_BLEND); - m_cursor.texture->unbind(); ShaderManager::instance()->popShader(); GLFramebuffer::popFramebuffer(); diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h index 997b5c205b..f9d54e39dc 100644 --- a/src/plugins/screencast/screencastutils.h +++ b/src/plugins/screencast/screencastutils.h @@ -92,9 +92,7 @@ static void grabTexture(GLTexture *texture, spa_data *spa, spa_video_format form shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix); GLFramebuffer::pushFramebuffer(&fbo); - texture->bind(); texture->render(size, 1); - texture->unbind(); GLFramebuffer::popFramebuffer(); doGrabTexture(&backingTexture, spa, format); } else {