mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +00:00
WindowServer: Fix flickering
Rather than blitting and rendering each window every time, only render what actually changed. And while doing so, only render the portions that are visible on the screen. This avoids flickering because flipping framebuffers isn't always perfectly in sync with the code, so it's possible that the flip happens slightly delayed and we can briefly see the next iteration having partially completed. Also, avoid touching the mouse cursor unless it is in an area that needs updating. This reduces flickering unless it is over an area that is updated often. And because we no longer render the entire screen, we'll save the contents below the cursor so that we can hide it before touching that area. Fixes #2981
This commit is contained in:
@@ -234,17 +234,31 @@ Gfx::IntRect WindowFrame::rect() const
|
||||
|
||||
void WindowFrame::invalidate_title_bar()
|
||||
{
|
||||
Compositor::the().invalidate(title_bar_rect().translated(rect().location()));
|
||||
invalidate(title_bar_rect());
|
||||
}
|
||||
|
||||
void WindowFrame::invalidate(Gfx::IntRect relative_rect)
|
||||
{
|
||||
auto frame_rect = rect();
|
||||
auto window_rect = m_window.rect();
|
||||
relative_rect.move_by(frame_rect.x() - window_rect.x(), frame_rect.y() - window_rect.y());
|
||||
m_window.invalidate(relative_rect);
|
||||
}
|
||||
|
||||
void WindowFrame::notify_window_rect_changed(const Gfx::IntRect& old_rect, const Gfx::IntRect& new_rect)
|
||||
{
|
||||
layout_buttons();
|
||||
|
||||
auto& wm = WindowManager::the();
|
||||
wm.invalidate(frame_rect_for_window(m_window, old_rect));
|
||||
wm.invalidate(frame_rect_for_window(m_window, new_rect));
|
||||
wm.notify_rect_changed(m_window, old_rect, new_rect);
|
||||
auto old_frame_rect = frame_rect_for_window(m_window, old_rect);
|
||||
auto& compositor = Compositor::the();
|
||||
for (auto& dirty : old_frame_rect.shatter(rect()))
|
||||
compositor.invalidate_screen(dirty);
|
||||
if (!m_window.is_opaque())
|
||||
compositor.invalidate_screen(rect());
|
||||
|
||||
compositor.invalidate_occlusions();
|
||||
|
||||
WindowManager::the().notify_rect_changed(m_window, old_rect, new_rect);
|
||||
}
|
||||
|
||||
void WindowFrame::layout_buttons()
|
||||
|
||||
Reference in New Issue
Block a user