mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
WindowServer: Occlusion calculation fixes
We didn't properly determine whether a window was fully covered, which caused some artifacts in certain cases. Fixes #5283
This commit is contained in:
parent
338bb73289
commit
5d4c4bd372
1 changed files with 20 additions and 10 deletions
|
@ -948,8 +948,14 @@ void Compositor::recompute_occlusions()
|
||||||
if (covering_rect.is_empty())
|
if (covering_rect.is_empty())
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
|
|
||||||
auto add_opaque = [&](const Gfx::IntRect& covering) {
|
auto add_opaque = [&](const Gfx::IntRect& covering) -> bool {
|
||||||
opaque_covering.add(covering);
|
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()) {
|
if (!visible_opaque.is_empty()) {
|
||||||
auto uncovered_opaque = visible_opaque.shatter(covering);
|
auto uncovered_opaque = visible_opaque.shatter(covering);
|
||||||
visible_opaque = move(uncovered_opaque);
|
visible_opaque = move(uncovered_opaque);
|
||||||
|
@ -959,6 +965,7 @@ void Compositor::recompute_occlusions()
|
||||||
auto uncovered_transparency = transparency_rects.shatter(covering);
|
auto uncovered_transparency = transparency_rects.shatter(covering);
|
||||||
transparency_rects = move(uncovered_transparency);
|
transparency_rects = move(uncovered_transparency);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
auto add_transparent = [&](const Gfx::IntRect& covering) {
|
auto add_transparent = [&](const Gfx::IntRect& covering) {
|
||||||
visible_rects.for_each_intersected(covering, [&](const Gfx::IntRect& intersected) {
|
visible_rects.for_each_intersected(covering, [&](const Gfx::IntRect& intersected) {
|
||||||
|
@ -972,25 +979,23 @@ void Compositor::recompute_occlusions()
|
||||||
};
|
};
|
||||||
if (w2.is_opaque()) {
|
if (w2.is_opaque()) {
|
||||||
if (w2.frame().is_opaque()) {
|
if (w2.frame().is_opaque()) {
|
||||||
if (opaque_covering.contains(covering_rect)) {
|
if (!add_opaque(covering_rect))
|
||||||
// This window (including frame) is entirely covered by another opaque window
|
|
||||||
visible_opaque.clear();
|
|
||||||
transparency_rects.clear();
|
|
||||||
return IterationDecision::Break;
|
return IterationDecision::Break;
|
||||||
}
|
|
||||||
add_opaque(covering_rect);
|
|
||||||
} else {
|
} else {
|
||||||
auto covering_window_rect = covering_rect.intersected(w2.rect());
|
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))
|
for (auto& covering_frame_rect : covering_rect.shatter(covering_window_rect))
|
||||||
add_transparent(covering_frame_rect);
|
add_transparent(covering_frame_rect);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (w2.frame().is_opaque()) {
|
if (w2.frame().is_opaque()) {
|
||||||
auto covering_window_rect = covering_rect.intersected(w2.rect());
|
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);
|
add_transparent(covering_window_rect);
|
||||||
for (auto& covering_frame_rect : covering_rect.shatter(covering_window_rect))
|
|
||||||
add_opaque(covering_frame_rect);
|
|
||||||
} else {
|
} else {
|
||||||
add_transparent(covering_rect);
|
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));
|
auto visible_rects_below_window = visible_rects.shatter(w.rect().intersected(screen_rect));
|
||||||
visible_rects = move(visible_rects_below_window);
|
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;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue