From 08322ab8e166b00671a5f1c608e756a5690ab5cb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 10 Feb 2019 14:46:43 +0100 Subject: [PATCH] LibGUI: Coalesce update rects at the GWindow level. --- LibGUI/GWidget.cpp | 6 ------ LibGUI/GWidget.h | 2 -- LibGUI/GWindow.cpp | 9 +++++++++ LibGUI/GWindow.h | 1 + 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/LibGUI/GWidget.cpp b/LibGUI/GWidget.cpp index 75f394188a..9d05141f3d 100644 --- a/LibGUI/GWidget.cpp +++ b/LibGUI/GWidget.cpp @@ -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(event)); case GEvent::Resize: return handle_resize_event(static_cast(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())); } diff --git a/LibGUI/GWidget.h b/LibGUI/GWidget.h index ad45fa92d4..5b5cb957d5 100644 --- a/LibGUI/GWidget.h +++ b/LibGUI/GWidget.h @@ -136,7 +136,5 @@ private: SizePolicy m_vertical_size_policy { SizePolicy::Fill }; Size m_preferred_size; - Vector m_pending_paint_event_rects; - bool m_fill_with_background_color { true }; }; diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index f9a76295ce..9fb21d61b5 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -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(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); diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index e7c406d8fe..f7d82e1bfd 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -69,6 +69,7 @@ private: WeakPtr m_global_cursor_tracking_widget; Rect m_rect_when_windowless; String m_title_when_windowless; + Vector m_pending_paint_event_rects; bool m_should_exit_app_on_close { false }; };