From 048c732a4e619fd41635cedb310a70edb49369b9 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 26 May 2021 21:32:52 +0300 Subject: [PATCH] scenes/opengl: Remove half-pixel correction workaround It was needed to work around visual glitches in the wobbly windows effect. Since the wobbly windows effect renders the animated window into an offscreen texture, we don't need this workaround anymore. Furthermore, rather than using half-pixel correction, it is more desirable to use an offscreen texture as it results in simpler design. Performance-wise, it's not that bad that we need to start looking for other ways to get rid of the seams between window contents and deco. --- src/libkwineffects/kwinglutils.cpp | 10 --------- src/libkwineffects/kwinglutils.h | 2 -- src/plugins/scenes/opengl/scene_opengl.cpp | 25 ---------------------- 3 files changed, 37 deletions(-) diff --git a/src/libkwineffects/kwinglutils.cpp b/src/libkwineffects/kwinglutils.cpp index 8a93cdc413..6a002e9a67 100644 --- a/src/libkwineffects/kwinglutils.cpp +++ b/src/libkwineffects/kwinglutils.cpp @@ -333,7 +333,6 @@ void GLShader::resolveLocations() mFloatLocation[Saturation] = uniformLocation("saturation"); mColorLocation[Color] = uniformLocation("geometryColor"); - mVec4Location[TextureClamp] = uniformLocation("textureClamp"); mLocationsResolved = true; } @@ -856,10 +855,6 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const } else if (traits & ShaderTrait::UniformColor) stream << "uniform vec4 geometryColor;\n"; - if (traits & ShaderTrait::ClampTexture) { - stream << "uniform vec4 textureClamp;\n"; - } - if (output != QByteArrayLiteral("gl_FragColor")) stream << "\nout vec4 " << output << ";\n"; @@ -867,11 +862,6 @@ QByteArray ShaderManager::generateFragmentSource(ShaderTraits traits) const if (traits & ShaderTrait::MapTexture) { stream << "vec2 texcoordC = texcoord0;\n"; - if (traits & ShaderTrait::ClampTexture) { - stream << "texcoordC.x = clamp(texcoordC.x, textureClamp.x, textureClamp.z);\n"; - stream << "texcoordC.y = clamp(texcoordC.y, textureClamp.y, textureClamp.w);\n"; - } - if (traits & (ShaderTrait::Modulate | ShaderTrait::AdjustSaturation)) { stream << " vec4 texel = " << textureLookup << "(sampler, texcoordC);\n"; if (traits & ShaderTrait::Modulate) diff --git a/src/libkwineffects/kwinglutils.h b/src/libkwineffects/kwinglutils.h index 498337228d..25136954ab 100644 --- a/src/libkwineffects/kwinglutils.h +++ b/src/libkwineffects/kwinglutils.h @@ -118,7 +118,6 @@ public: enum Vec4Uniform { ModulationConstant, - TextureClamp, Vec4UniformCount }; @@ -176,7 +175,6 @@ enum class ShaderTrait { UniformColor = (1 << 1), Modulate = (1 << 2), AdjustSaturation = (1 << 3), - ClampTexture = (1 << 4), }; Q_DECLARE_FLAGS(ShaderTraits, ShaderTrait) diff --git a/src/plugins/scenes/opengl/scene_opengl.cpp b/src/plugins/scenes/opengl/scene_opengl.cpp index 71e7da81d0..84eeb25856 100644 --- a/src/plugins/scenes/opengl/scene_opengl.cpp +++ b/src/plugins/scenes/opengl/scene_opengl.cpp @@ -1464,8 +1464,6 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai const QMatrix4x4 modelViewProjection = modelViewProjectionMatrix(mask, data); const QMatrix4x4 mvpMatrix = modelViewProjection * windowMatrix; - bool useX11TextureClamp = false; - GLShader *shader = data.shader; GLenum filter; @@ -1474,7 +1472,6 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai } else { const bool isTransformed = mask & (Effect::PAINT_WINDOW_TRANSFORMED | Effect::PAINT_SCREEN_TRANSFORMED); - useX11TextureClamp = isTransformed; if (isTransformed && options->glSmoothScale() != 0) { filter = GL_LINEAR; } else { @@ -1484,9 +1481,6 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai if (!shader) { ShaderTraits traits = ShaderTrait::MapTexture; - if (useX11TextureClamp) { - traits |= ShaderTrait::ClampTexture; - } if (data.opacity() != 1.0 || data.brightness() != 1.0 || data.crossFadeProgress() != 1.0) traits |= ShaderTrait::Modulate; @@ -1551,25 +1545,6 @@ void OpenGLWindow::performPaint(int mask, const QRegion ®ion, const WindowPai renderNode.texture->setWrapMode(GL_CLAMP_TO_EDGE); renderNode.texture->bind(); - if (renderNode.leafType == ContentLeaf && useX11TextureClamp) { - // X11 windows are reparented to have their buffer in the middle of a larger texture - // holding the frame window. - // This code passes the texture geometry to the fragment shader - // any samples near the edge of the texture will be constrained to be - // at least half a pixel in bounds, meaning we don't bleed the transparent border - QRectF bufferContentRect = surfaceItem()->shape().boundingRect(); - bufferContentRect.adjust(0.5, 0.5, -0.5, -0.5); - const QRect bufferGeometry = toplevel->bufferGeometry(); - - float leftClamp = bufferContentRect.left() / bufferGeometry.width(); - float topClamp = bufferContentRect.top() / bufferGeometry.height(); - float rightClamp = bufferContentRect.right() / bufferGeometry.width(); - float bottomClamp = bufferContentRect.bottom() / bufferGeometry.height(); - shader->setUniform(GLShader::TextureClamp, QVector4D({leftClamp, topClamp, rightClamp, bottomClamp})); - } else { - shader->setUniform(GLShader::TextureClamp, QVector4D({0, 0, 1, 1})); - } - vbo->draw(region, primitiveType, renderNode.firstVertex, renderNode.vertexCount, m_hardwareClipping); }