From e9af67af3ef6fb5ab68d3db74ac7285871286cba Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sun, 6 Feb 2022 17:42:55 +0200 Subject: [PATCH] kwineffects: Add GLTexture::render() overload that takes no scissor region In many cases, we don't care about the scissor region. This change adds a relevant overload to make code easier to read. --- src/effects/magnifier/magnifier.cpp | 2 +- src/effects/screenedge/screenedgeeffect.cpp | 2 +- .../screentransform/screentransform.cpp | 2 +- src/effects/showfps/showfps.cpp | 2 +- .../startupfeedback/startupfeedback.cpp | 2 +- src/effects/trackmouse/trackmouse.cpp | 2 +- src/effects/zoom/zoom.cpp | 2 +- src/libkwineffects/kwingltexture.cpp | 7 ++++++- src/libkwineffects/kwingltexture.h | 1 + .../screencast/outputscreencastsource.cpp | 2 +- src/plugins/screencast/screencaststream.cpp | 2 +- src/scenes/opengl/scene_opengl.cpp | 21 +++++++++---------- 12 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/effects/magnifier/magnifier.cpp b/src/effects/magnifier/magnifier.cpp index f9f954e120..6541b7da1a 100644 --- a/src/effects/magnifier/magnifier.cpp +++ b/src/effects/magnifier/magnifier.cpp @@ -135,7 +135,7 @@ void MagnifierEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintDa mvp.ortho(0, size.width(), size.height(), 0, 0, 65535); mvp.translate(area.x(), area.y()); s->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_texture->render(infiniteRegion(), area); + m_texture->render(area); ShaderManager::instance()->popShader(); m_texture->unbind(); QVector verts; diff --git a/src/effects/screenedge/screenedgeeffect.cpp b/src/effects/screenedge/screenedgeeffect.cpp index 3e5e14ee8b..d6500ac63e 100644 --- a/src/effects/screenedge/screenedgeeffect.cpp +++ b/src/effects/screenedge/screenedgeeffect.cpp @@ -94,7 +94,7 @@ void ScreenEdgeEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD QMatrix4x4 mvp = data.projectionMatrix(); mvp.translate((*it)->geometry.x(), (*it)->geometry.y()); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - texture->render(infiniteRegion(), (*it)->geometry); + texture->render((*it)->geometry); texture->unbind(); glDisable(GL_BLEND); } else if (effects->compositingType() == QPainterCompositing) { diff --git a/src/effects/screentransform/screentransform.cpp b/src/effects/screentransform/screentransform.cpp index 4fac726e21..411e8c0b2d 100644 --- a/src/effects/screentransform/screentransform.cpp +++ b/src/effects/screentransform/screentransform.cpp @@ -141,7 +141,7 @@ void ScreenTransformEffect::paintScreen(int mask, const QRegion ®ion, KWin::S shader->setUniform(GLShader::ModelViewProjectionMatrix, matrix); state.m_texture->bind(); - state.m_texture->render(infiniteRegion(), textureRect); + state.m_texture->render(textureRect); state.m_texture->unbind(); } effects->addRepaintFull(); diff --git a/src/effects/showfps/showfps.cpp b/src/effects/showfps/showfps.cpp index e4c5d4fc42..86babb0b41 100644 --- a/src/effects/showfps/showfps.cpp +++ b/src/effects/showfps/showfps.cpp @@ -229,7 +229,7 @@ void ShowFpsEffect::paintGL(int fps, const QMatrix4x4 &projectionMatrix) QMatrix4x4 mvp = projectionMatrix; mvp.translate(fpsTextRect.x(), fpsTextRect.y()); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - fpsText->render(infiniteRegion(), fpsTextRect); + fpsText->render(fpsTextRect); fpsText->unbind(); effects->addRepaint(fpsTextRect); } diff --git a/src/effects/startupfeedback/startupfeedback.cpp b/src/effects/startupfeedback/startupfeedback.cpp index 29e501067a..f7aa9610f6 100644 --- a/src/effects/startupfeedback/startupfeedback.cpp +++ b/src/effects/startupfeedback/startupfeedback.cpp @@ -229,7 +229,7 @@ void StartupFeedbackEffect::paintScreen(int mask, const QRegion ®ion, ScreenP QMatrix4x4 mvp = data.projectionMatrix(); mvp.translate(m_currentGeometry.x(), m_currentGeometry.y()); ShaderManager::instance()->getBoundShader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - texture->render(infiniteRegion(), m_currentGeometry); + texture->render(m_currentGeometry); ShaderManager::instance()->popShader(); texture->unbind(); glDisable(GL_BLEND); diff --git a/src/effects/trackmouse/trackmouse.cpp b/src/effects/trackmouse/trackmouse.cpp index 0fc473fa6b..97fb816e60 100644 --- a/src/effects/trackmouse/trackmouse.cpp +++ b/src/effects/trackmouse/trackmouse.cpp @@ -119,7 +119,7 @@ void TrackMouseEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintD mvp.translate(m_lastRect[i].x(), m_lastRect[i].y()); shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); m_texture[i]->bind(); - m_texture[i]->render(infiniteRegion(), m_lastRect[i]); + m_texture[i]->render(m_lastRect[i]); m_texture[i]->unbind(); } glDisable(GL_BLEND); diff --git a/src/effects/zoom/zoom.cpp b/src/effects/zoom/zoom.cpp index 97276a8b06..fb70345bfa 100644 --- a/src/effects/zoom/zoom.cpp +++ b/src/effects/zoom/zoom.cpp @@ -344,7 +344,7 @@ void ZoomEffect::paintScreen(int mask, const QRegion ®ion, ScreenPaintData& d QMatrix4x4 mvp = data.projectionMatrix(); mvp.translate(rect.x(), rect.y()); s->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - cursorTexture->render(infiniteRegion(), rect); + cursorTexture->render(rect); ShaderManager::instance()->popShader(); cursorTexture->unbind(); glDisable(GL_BLEND); diff --git a/src/libkwineffects/kwingltexture.cpp b/src/libkwineffects/kwingltexture.cpp index 8f57be244b..dcb4e8bbbf 100644 --- a/src/libkwineffects/kwingltexture.cpp +++ b/src/libkwineffects/kwingltexture.cpp @@ -10,7 +10,7 @@ */ #include "kwinconfig.h" // KWIN_HAVE_OPENGL - +#include "kwineffects.h" #include "kwinglplatform.h" #include "kwinglutils_funcs.h" #include "kwinglutils.h" @@ -496,6 +496,11 @@ void GLTexture::unbind() glBindTexture(d->m_target, 0); } +void GLTexture::render(const QRect &rect) +{ + render(infiniteRegion(), rect, false); +} + void GLTexture::render(const QRegion ®ion, const QRect& rect, bool hardwareClipping) { Q_D(GLTexture); diff --git a/src/libkwineffects/kwingltexture.h b/src/libkwineffects/kwingltexture.h index 61ff4b99f4..c184cb4b60 100644 --- a/src/libkwineffects/kwingltexture.h +++ b/src/libkwineffects/kwingltexture.h @@ -103,6 +103,7 @@ public: virtual void discard(); void bind(); void unbind(); + void render(const QRect &rect); void render(const QRegion ®ion, const QRect& rect, bool hardwareClipping = false); GLuint texture() const; diff --git a/src/plugins/screencast/outputscreencastsource.cpp b/src/plugins/screencast/outputscreencastsource.cpp index 30e9edd454..49fc58058f 100644 --- a/src/plugins/screencast/outputscreencastsource.cpp +++ b/src/plugins/screencast/outputscreencastsource.cpp @@ -58,7 +58,7 @@ void OutputScreenCastSource::render(GLRenderTarget *target) GLRenderTarget::pushRenderTarget(target); outputTexture->bind(); - outputTexture->render(infiniteRegion(), geometry); + outputTexture->render(geometry); outputTexture->unbind(); GLRenderTarget::popRenderTarget(); } diff --git a/src/plugins/screencast/screencaststream.cpp b/src/plugins/screencast/screencaststream.cpp index e9b1a1e1df..2860fb89fa 100644 --- a/src/plugins/screencast/screencaststream.cpp +++ b/src/plugins/screencast/screencaststream.cpp @@ -427,7 +427,7 @@ void ScreenCastStream::recordFrame(const QRegion &damagedRegion) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - m_cursor.texture->render(infiniteRegion(), cursorRect); + m_cursor.texture->render(cursorRect); glDisable(GL_BLEND); m_cursor.texture->unbind(); m_cursor.lastRect = cursorRect; diff --git a/src/scenes/opengl/scene_opengl.cpp b/src/scenes/opengl/scene_opengl.cpp index f1acc6b0aa..f56bea7537 100644 --- a/src/scenes/opengl/scene_opengl.cpp +++ b/src/scenes/opengl/scene_opengl.cpp @@ -164,7 +164,7 @@ void SceneOpenGL::paintCursor(AbstractOutput *output, const QRegion &rendered) m_cursorTexture->bind(); ShaderBinder binder(ShaderTrait::MapTexture); binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_cursorTexture->render(region, cursorRect); + m_cursorTexture->render(cursorRect); m_cursorTexture->unbind(); glDisable(GL_BLEND); } @@ -363,7 +363,7 @@ void SceneOpenGL::paintOffscreenQuickView(OffscreenQuickView *w) glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); t->bind(); - t->render(QRegion(infiniteRegion()), w->geometry()); + t->render(w->geometry()); t->unbind(); glDisable(GL_BLEND); @@ -944,8 +944,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do if (m_effectFrame->geometry().isEmpty()) return; // Nothing to display - Q_UNUSED(_region); - const QRegion region = infiniteRegion(); // TODO: Old region doesn't seem to work with OpenGL + Q_UNUSED(_region); // TODO: Old region doesn't seem to work with OpenGL GLShader* shader = m_effectFrame->shader(); if (!shader) { @@ -1087,7 +1086,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do mvp.translate(pt.x(), pt.y()); shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_unstyledVBO->render(region, GL_TRIANGLES); + m_unstyledVBO->render(GL_TRIANGLES); m_unstyledTexture->unbind(); } else if (m_effectFrame->style() == EffectFrameStyled) { if (!m_texture) // Lazy creation @@ -1106,7 +1105,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do mvp.translate(rect.x(), rect.y()); shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); - m_texture->render(region, rect); + m_texture->render(rect); m_texture->unbind(); } @@ -1126,7 +1125,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); m_selectionTexture->bind(); - m_selectionTexture->render(region, m_effectFrame->selection()); + m_selectionTexture->render(m_effectFrame->selection()); m_selectionTexture->unbind(); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } @@ -1148,7 +1147,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do } m_oldIconTexture->bind(); - m_oldIconTexture->render(region, QRect(topLeft, m_effectFrame->iconSize())); + m_oldIconTexture->render(QRect(topLeft, m_effectFrame->iconSize())); m_oldIconTexture->unbind(); if (shader) { const float a = opacity * m_effectFrame->crossFadeProgress(); @@ -1165,7 +1164,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do m_iconTexture = new GLTexture(m_effectFrame->icon().pixmap(m_effectFrame->iconSize())); } m_iconTexture->bind(); - m_iconTexture->render(region, QRect(topLeft, m_effectFrame->iconSize())); + m_iconTexture->render(QRect(topLeft, m_effectFrame->iconSize())); m_iconTexture->unbind(); } @@ -1181,7 +1180,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do } m_oldTextTexture->bind(); - m_oldTextTexture->render(region, m_effectFrame->geometry()); + m_oldTextTexture->render(m_effectFrame->geometry()); m_oldTextTexture->unbind(); if (shader) { const float a = opacity * m_effectFrame->crossFadeProgress(); @@ -1198,7 +1197,7 @@ void SceneOpenGL::EffectFrame::render(const QRegion &_region, double opacity, do if (m_textTexture) { m_textTexture->bind(); - m_textTexture->render(region, m_effectFrame->geometry()); + m_textTexture->render(m_effectFrame->geometry()); m_textTexture->unbind(); } }