mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 20:45:08 +00:00
LibGUI+WindowServer: Coalesce paints and resizes on the client side.
Only process paint and resize events on the GUI client side if those events have the latest up-to-date window size. This drastically reduces async overdraw during interactive resize.
This commit is contained in:
parent
0ac55f2c38
commit
55811f233f
5 changed files with 50 additions and 13 deletions
|
@ -211,11 +211,17 @@ void GWindow::event(GEvent& event)
|
|||
return;
|
||||
auto& paint_event = static_cast<GPaintEvent&>(event);
|
||||
auto rect = paint_event.rect();
|
||||
if (m_back_bitmap && m_back_bitmap->size() != paint_event.window_size()) {
|
||||
// Eagerly discard the backing store if we learn from this paint event that it needs to be bigger.
|
||||
// Otherwise we would have to wait for a resize event to tell us. This way we don't waste the
|
||||
// effort on painting into an undersized bitmap that will be thrown away anyway.
|
||||
m_back_bitmap = nullptr;
|
||||
}
|
||||
bool created_new_backing_store = !m_back_bitmap;
|
||||
if (!m_back_bitmap)
|
||||
m_back_bitmap = create_backing_bitmap(paint_event.window_size());
|
||||
if (rect.is_empty() || created_new_backing_store)
|
||||
rect = m_main_widget->rect();
|
||||
rect = { { }, paint_event.window_size() };
|
||||
|
||||
m_main_widget->event(*make<GPaintEvent>(rect));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue