WindowServer: Skip composing windows where entire dirty rect is covered.

If another window is currently in front of us and is fully opaque,
we can just skip to the next window. This avoids a whole lot of painting
with overlapping windows. :^)
This commit is contained in:
Andreas Kling 2019-03-09 21:38:28 +01:00
parent 963e95cb1a
commit 272a41d02d
Notes: sideshowbarker 2024-07-19 15:06:10 +09:00

View file

@ -871,6 +871,20 @@ void WSWindowManager::compose()
return false;
};
auto any_opaque_window_above_this_one_contains_rect = [this] (const WSWindow& a_window, const Rect& r) {
for (auto* window = a_window.next(); window; window = window->next()) {
if (!window->is_visible())
continue;
if (window->opacity() < 1.0f)
continue;
if (window->has_alpha_channel())
continue;
if (outer_window_rect(*window).contains(r))
return true;
}
return false;
};
auto any_dirty_rect_intersects_window = [&dirty_rects] (const WSWindow& window) {
auto window_rect = outer_window_rect(window);
for (auto& dirty_rect : dirty_rects.rects()) {
@ -898,6 +912,8 @@ void WSWindowManager::compose()
PainterStateSaver saver(*m_back_painter);
m_back_painter->set_clip_rect(outer_window_rect(window));
for (auto& dirty_rect : dirty_rects.rects()) {
if (any_opaque_window_above_this_one_contains_rect(window, dirty_rect))
continue;
PainterStateSaver saver(*m_back_painter);
m_back_painter->set_clip_rect(dirty_rect);
paint_window_frame(window);