diff options
author | Tom <tomut@yahoo.com> | 2021-02-09 22:07:56 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-10 09:12:49 +0100 |
commit | 5d4c4bd37291b5b5fa8aee179bfeae99a5afd07c (patch) | |
tree | 13aa43d5fb7632c104f4fbe4f390f033ebdaed1a /Userland/Services | |
parent | 338bb732898dbf68db9554e6a32b4a89ccabb891 (diff) | |
download | serenity-5d4c4bd37291b5b5fa8aee179bfeae99a5afd07c.zip |
WindowServer: Occlusion calculation fixes
We didn't properly determine whether a window was fully covered, which
caused some artifacts in certain cases.
Fixes #5283
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/WindowServer/Compositor.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 5564f25ef4..f5b338061b 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -948,8 +948,14 @@ void Compositor::recompute_occlusions() if (covering_rect.is_empty()) return IterationDecision::Continue; - auto add_opaque = [&](const Gfx::IntRect& covering) { + auto add_opaque = [&](const Gfx::IntRect& covering) -> bool { opaque_covering.add(covering); + if (opaque_covering.contains(window_frame_rect)) { + // This window (including frame) is entirely covered by another opaque window + visible_opaque.clear(); + transparency_rects.clear(); + return false; + } if (!visible_opaque.is_empty()) { auto uncovered_opaque = visible_opaque.shatter(covering); visible_opaque = move(uncovered_opaque); @@ -959,6 +965,7 @@ void Compositor::recompute_occlusions() auto uncovered_transparency = transparency_rects.shatter(covering); transparency_rects = move(uncovered_transparency); } + return true; }; auto add_transparent = [&](const Gfx::IntRect& covering) { visible_rects.for_each_intersected(covering, [&](const Gfx::IntRect& intersected) { @@ -972,25 +979,23 @@ void Compositor::recompute_occlusions() }; if (w2.is_opaque()) { if (w2.frame().is_opaque()) { - if (opaque_covering.contains(covering_rect)) { - // This window (including frame) is entirely covered by another opaque window - visible_opaque.clear(); - transparency_rects.clear(); + if (!add_opaque(covering_rect)) return IterationDecision::Break; - } - add_opaque(covering_rect); } else { auto covering_window_rect = covering_rect.intersected(w2.rect()); - add_opaque(covering_window_rect); + if (!add_opaque(covering_window_rect)) + return IterationDecision::Break; for (auto& covering_frame_rect : covering_rect.shatter(covering_window_rect)) add_transparent(covering_frame_rect); } } else { if (w2.frame().is_opaque()) { auto covering_window_rect = covering_rect.intersected(w2.rect()); + for (auto& covering_frame_rect : covering_rect.shatter(covering_window_rect)) { + if (!add_opaque(covering_frame_rect)) + return IterationDecision::Break; + } add_transparent(covering_window_rect); - for (auto& covering_frame_rect : covering_rect.shatter(covering_window_rect)) - add_opaque(covering_frame_rect); } else { add_transparent(covering_rect); } @@ -1013,6 +1018,11 @@ void Compositor::recompute_occlusions() auto visible_rects_below_window = visible_rects.shatter(w.rect().intersected(screen_rect)); visible_rects = move(visible_rects_below_window); } + } else if (w.frame().is_opaque()) { + for (auto& rect : window_frame_rect.shatter(w.rect())) { + auto visible_rects_below_window = visible_rects.shatter(rect); + visible_rects = move(visible_rects_below_window); + } } return IterationDecision::Continue; }); |