From c65523382d640536237ff0512a3b32ffb7ea586f Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sun, 20 Feb 2022 20:31:22 +0200 Subject: [PATCH] scene: Simplify the management of opaque regions Window painting is no longer split in two phases - PAINT_WINDOW_OPAQUE and PAINT_WINDOW_TRANSLUCENT. PAINT_WINDOW_TRANSLUCENT is used as a hint to the occlusion culling logic to ignore the opaque region. Given that, the handling of the opaque region can be simplified. If no effect sets the PAINT_WINDOW_TRANSLUCENT flag, then the opaque region can be used as is. --- src/scene.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/scene.cpp b/src/scene.cpp index e1f73c8acb..fddc286200 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -337,7 +337,7 @@ void Scene::preparePaintGenericScreen() resetRepaintsHelper(sceneWindow->windowItem(), painted_screen); WindowPrePaintData data; - data.mask = m_paintContext.mask | (sceneWindow->isOpaque() ? PAINT_WINDOW_OPAQUE : PAINT_WINDOW_TRANSLUCENT); + data.mask = m_paintContext.mask; data.paint = infiniteRegion(); // no clipping, so doesn't really matter sceneWindow->resetPaintingEnabled(); @@ -360,14 +360,14 @@ void Scene::preparePaintSimpleScreen() for (Window *sceneWindow : std::as_const(stacking_order)) { const Toplevel *toplevel = sceneWindow->window(); WindowPrePaintData data; - data.mask = m_paintContext.mask | (sceneWindow->isOpaque() ? PAINT_WINDOW_OPAQUE : PAINT_WINDOW_TRANSLUCENT); + data.mask = m_paintContext.mask; accumulateRepaints(sceneWindow->windowItem(), painted_screen, &data.paint); // Clip out the decoration for opaque windows; the decoration is drawn in the second pass. if (sceneWindow->isOpaque()) { const SurfaceItem *surfaceItem = sceneWindow->surfaceItem(); if (surfaceItem) { - data.clip |= surfaceItem->mapToGlobal(surfaceItem->shape()); + data.clip = surfaceItem->mapToGlobal(surfaceItem->shape()); } } else if (toplevel->hasAlpha() && toplevel->opacity() == 1.0) { const SurfaceItem *surfaceItem = sceneWindow->surfaceItem(); @@ -375,9 +375,6 @@ void Scene::preparePaintSimpleScreen() const QRegion shape = surfaceItem->shape(); const QRegion opaque = surfaceItem->opaque(); data.clip = surfaceItem->mapToGlobal(shape & opaque); - if (opaque == shape) { - data.mask = m_paintContext.mask | PAINT_WINDOW_OPAQUE; - } } }