From e22d9d957b12fa84d552c8787df4426b22d4d0fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Tue, 23 Jan 2018 20:27:16 +0100 Subject: [PATCH 1/2] Enable blending if a subsurface has an alpha channel Summary: While investigating BUG 387313 I noticed that blending might be disabled for subsurfaces. Blending was disabled before rendering the subsurfaces and it is not checked whether the surfaces have an alpha channel or not. This change addresses this problem by disabling blending after all subsurfaces have been rendered and enabling blending if a subsurface has an alpha channel. Unfortunately this does not fix the investigated bug. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D10060 --- plugins/scenes/opengl/scene_opengl.cpp | 8 +++++--- plugins/scenes/opengl/scene_opengl.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp index 9a02c26ee0..d225b8e660 100644 --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -47,6 +47,7 @@ along with this program. If not, see . #include "decorations/decoratedclient.h" #include +#include #include #include @@ -1358,7 +1359,7 @@ QMatrix4x4 SceneOpenGL2Window::modelViewProjectionMatrix(int mask, const WindowP return scene->projectionMatrix() * mvMatrix; } -static void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping) +void SceneOpenGL2Window::renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping) { QMatrix4x4 newWindowMatrix = windowMatrix; newWindowMatrix.translate(pixmap->subSurface()->position().x(), pixmap->subSurface()->position().y()); @@ -1369,6 +1370,7 @@ static void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMat } if (!pixmap->texture()->isNull()) { + setBlendEnabled(pixmap->buffer() && pixmap->buffer()->hasAlphaChannel()); // render this texture shader->setUniform(GLShader::ModelViewProjectionMatrix, mvp * newWindowMatrix); auto texture = pixmap->texture(); @@ -1515,8 +1517,6 @@ void SceneOpenGL2Window::performPaint(int mask, QRegion region, WindowPaintData vbo->unbindArrays(); - setBlendEnabled(false); - // render sub-surfaces auto wp = windowPixmap(); const auto &children = wp ? wp->children() : QVector(); @@ -1528,6 +1528,8 @@ void SceneOpenGL2Window::performPaint(int mask, QRegion region, WindowPaintData renderSubSurface(shader, modelViewProjection, windowMatrix, static_cast(pixmap), region, m_hardwareClipping); } + setBlendEnabled(false); + if (!data.shader) ShaderManager::instance()->popShader(); diff --git a/plugins/scenes/opengl/scene_opengl.h b/plugins/scenes/opengl/scene_opengl.h index 6643dc3537..6453d3b57c 100644 --- a/plugins/scenes/opengl/scene_opengl.h +++ b/plugins/scenes/opengl/scene_opengl.h @@ -173,6 +173,8 @@ protected: bool m_hardwareClipping; }; +class OpenGLWindowPixmap; + class SceneOpenGL2Window : public SceneOpenGL::Window { public: @@ -209,6 +211,7 @@ protected: virtual void performPaint(int mask, QRegion region, WindowPaintData data); private: + void renderSubSurface(GLShader *shader, const QMatrix4x4 &mvp, const QMatrix4x4 &windowMatrix, OpenGLWindowPixmap *pixmap, const QRegion ®ion, bool hardwareClipping); /** * Whether prepareStates enabled blending and restore states should disable again. **/ From aefa11f11a251d1270da08a73b367088baec0d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 28 Jan 2018 10:33:26 +0100 Subject: [PATCH 2/2] Block geometry updates on move resize finish and don't configure xdg shell surfaces while blocked Summary: We send out too many configure requests when finishing move resize which also triggers quick tiling. This change addresses the problem of the too many configure requests by making the configure method check whether geometry updates are blocked. And to make this work properly for the end of finish move resize the complete method is wrapped in a geometry update blocker. BUG: 388072 FIXED-IN: 5.12.1 Test Plan: Quick tiling test passes, both Wayland and X11 windows are quick tiled correctly. Reviewers: #kwin, #plasma, jgrulich Subscribers: plasma-devel, kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D10156 --- autotests/integration/quick_tiling_test.cpp | 4 +--- geometry.cpp | 1 + shell_client.cpp | 3 +++ shell_client.h | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/autotests/integration/quick_tiling_test.cpp b/autotests/integration/quick_tiling_test.cpp index 7fb844c086..7958612d64 100644 --- a/autotests/integration/quick_tiling_test.cpp +++ b/autotests/integration/quick_tiling_test.cpp @@ -470,7 +470,7 @@ void QuickTilingTest::testQuickTilingPointerMoveXdgShell() QCOMPARE(c->quickTileMode(), QuickTileMode(QuickTileFlag::None)); QCOMPARE(c->maximizeMode(), MaximizeRestore); QVERIFY(configureRequestedSpy.wait()); - QCOMPARE(configureRequestedSpy.count(), 2); + QTRY_COMPARE(configureRequestedSpy.count(), 2); QSignalSpy quickTileChangedSpy(c, &AbstractClient::quickTileModeChanged); QVERIFY(quickTileChangedSpy.isValid()); @@ -492,9 +492,7 @@ void QuickTilingTest::testQuickTilingPointerMoveXdgShell() QCOMPARE(quickTileChangedSpy.count(), 1); QTEST(c->quickTileMode(), "expectedMode"); QVERIFY(configureRequestedSpy.wait()); - QEXPECT_FAIL("", "BUG 388072", Continue); QCOMPARE(configureRequestedSpy.count(), 4); - QEXPECT_FAIL("", "BUG 388072", Continue); QCOMPARE(false, configureRequestedSpy.last().first().toSize().isEmpty()); } diff --git a/geometry.cpp b/geometry.cpp index 7885b6b365..d732ee6da4 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -2745,6 +2745,7 @@ bool Client::doStartMoveResize() void AbstractClient::finishMoveResize(bool cancel) { + GeometryUpdatesBlocker blocker(this); const bool wasResize = isResize(); // store across leaveMoveResize leaveMoveResize(); diff --git a/shell_client.cpp b/shell_client.cpp index 113092001e..6df6814bb9 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -293,6 +293,9 @@ void ShellClient::init() if (m_closing) { return; } + if (m_requestGeometryBlockCounter != 0 || areGeometryUpdatesBlocked()) { + return; + } m_xdgShellSurface->configure(xdgSurfaceStates()); }; configure(); diff --git a/shell_client.h b/shell_client.h index 3a22acbcf3..205e9caec3 100644 --- a/shell_client.h +++ b/shell_client.h @@ -245,6 +245,8 @@ private: if (m_client->m_requestGeometryBlockCounter == 0) { if (m_client->m_blockedRequestGeometry.isValid()) { m_client->requestGeometry(m_client->m_blockedRequestGeometry); + } else if (m_client->m_xdgShellSurface) { + m_client->m_xdgShellSurface->configure(m_client->xdgSurfaceStates()); } } }