1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 11:48:13 +00:00

LibGUI: Coalesce update rects at the GWindow level.

This commit is contained in:
Andreas Kling 2019-02-10 14:46:43 +01:00
parent 53d34a0885
commit 08322ab8e1
4 changed files with 10 additions and 8 deletions

View file

@ -38,7 +38,6 @@ void GWidget::event(GEvent& event)
{ {
switch (event.type()) { switch (event.type()) {
case GEvent::Paint: case GEvent::Paint:
m_pending_paint_event_rects.clear();
return handle_paint_event(static_cast<GPaintEvent&>(event)); return handle_paint_event(static_cast<GPaintEvent&>(event));
case GEvent::Resize: case GEvent::Resize:
return handle_resize_event(static_cast<GResizeEvent&>(event)); return handle_resize_event(static_cast<GResizeEvent&>(event));
@ -175,11 +174,6 @@ void GWidget::update(const Rect& rect)
auto* w = window(); auto* w = window();
if (!w) if (!w)
return; return;
for (auto& pending_rect : m_pending_paint_event_rects) {
if (pending_rect.contains(rect))
return;
}
m_pending_paint_event_rects.append(rect);
w->update(rect.translated(window_relative_rect().location())); w->update(rect.translated(window_relative_rect().location()));
} }

View file

@ -136,7 +136,5 @@ private:
SizePolicy m_vertical_size_policy { SizePolicy::Fill }; SizePolicy m_vertical_size_policy { SizePolicy::Fill };
Size m_preferred_size; Size m_preferred_size;
Vector<Rect> m_pending_paint_event_rects;
bool m_fill_with_background_color { true }; bool m_fill_with_background_color { true };
}; };

View file

@ -147,6 +147,7 @@ void GWindow::event(GEvent& event)
} }
if (event.is_paint_event()) { if (event.is_paint_event()) {
m_pending_paint_event_rects.clear();
if (!m_main_widget) if (!m_main_widget)
return; return;
auto& paint_event = static_cast<GPaintEvent&>(event); auto& paint_event = static_cast<GPaintEvent&>(event);
@ -196,6 +197,14 @@ void GWindow::update(const Rect& a_rect)
{ {
if (!m_window_id) if (!m_window_id)
return; return;
for (auto& pending_rect : m_pending_paint_event_rects) {
if (pending_rect.contains(a_rect)) {
dbgprintf("Ignoring %s since it's contained by pending rect %s\n", a_rect.to_string().characters(), pending_rect.to_string().characters());
return;
}
}
m_pending_paint_event_rects.append(a_rect);
GUI_Rect rect = a_rect; GUI_Rect rect = a_rect;
int rc = gui_invalidate_window(m_window_id, a_rect.is_null() ? nullptr : &rect); int rc = gui_invalidate_window(m_window_id, a_rect.is_null() ? nullptr : &rect);
ASSERT(rc == 0); ASSERT(rc == 0);

View file

@ -69,6 +69,7 @@ private:
WeakPtr<GWidget> m_global_cursor_tracking_widget; WeakPtr<GWidget> m_global_cursor_tracking_widget;
Rect m_rect_when_windowless; Rect m_rect_when_windowless;
String m_title_when_windowless; String m_title_when_windowless;
Vector<Rect> m_pending_paint_event_rects;
bool m_should_exit_app_on_close { false }; bool m_should_exit_app_on_close { false };
}; };