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
Notes: sideshowbarker 2024-07-19 15:48:01 +09:00
4 changed files with 10 additions and 8 deletions

View file

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

View file

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

View file

@ -147,6 +147,7 @@ void GWindow::event(GEvent& event)
}
if (event.is_paint_event()) {
m_pending_paint_event_rects.clear();
if (!m_main_widget)
return;
auto& paint_event = static_cast<GPaintEvent&>(event);
@ -196,6 +197,14 @@ void GWindow::update(const Rect& a_rect)
{
if (!m_window_id)
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;
int rc = gui_invalidate_window(m_window_id, a_rect.is_null() ? nullptr : &rect);
ASSERT(rc == 0);

View file

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