summaryrefslogtreecommitdiff
path: root/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-21 21:05:10 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-21 21:05:10 +0200
commit08228f34b9b4f0e8d6b6115363d9123949663dda (patch)
tree9dd800f8d042f122142adf67f29510868c52fe8a /LibGUI
parent9aa9454c6b641dc3483ad177aafdb53f11701fdf (diff)
downloadserenity-08228f34b9b4f0e8d6b6115363d9123949663dda.zip
GWindow: Only flip the window backing stores once per paint event.
Diffstat (limited to 'LibGUI')
-rw-r--r--LibGUI/GWindow.cpp14
-rw-r--r--LibGUI/GWindow.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp
index d72f266fc3..f221bf220b 100644
--- a/LibGUI/GWindow.cpp
+++ b/LibGUI/GWindow.cpp
@@ -226,13 +226,12 @@ void GWindow::event(CEvent& event)
rects.append({ { }, paint_event.window_size() });
}
- for (auto& rect : rects) {
+ for (auto& rect : rects)
m_main_widget->event(*make<GPaintEvent>(rect));
- if (m_double_buffering_enabled)
- flip(rect);
- }
- if (!m_double_buffering_enabled && created_new_backing_store)
+ if (m_double_buffering_enabled)
+ flip(rects);
+ else if (created_new_backing_store)
set_current_backing_bitmap(*m_back_bitmap, true);
if (m_window_id) {
@@ -451,7 +450,7 @@ void GWindow::set_current_backing_bitmap(GraphicsBitmap& bitmap, bool flush_imme
GEventLoop::current().sync_request(message, WSAPI_ServerMessage::Type::DidSetWindowBackingStore);
}
-void GWindow::flip(const Rect& dirty_rect)
+void GWindow::flip(const Vector<Rect, 32>& dirty_rects)
{
swap(m_front_bitmap, m_back_bitmap);
@@ -465,7 +464,8 @@ void GWindow::flip(const Rect& dirty_rect)
// Copy whatever was painted from the front to the back.
Painter painter(*m_back_bitmap);
- painter.blit(dirty_rect.location(), *m_front_bitmap, dirty_rect);
+ for (auto& dirty_rect : dirty_rects)
+ painter.blit(dirty_rect.location(), *m_front_bitmap, dirty_rect);
}
Retained<GraphicsBitmap> GWindow::create_backing_bitmap(const Size& size)
diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h
index 2e6c4ac7a2..b3f113d0df 100644
--- a/LibGUI/GWindow.h
+++ b/LibGUI/GWindow.h
@@ -128,7 +128,7 @@ private:
Retained<GraphicsBitmap> create_backing_bitmap(const Size&);
void set_current_backing_bitmap(GraphicsBitmap&, bool flush_immediately = false);
- void flip(const Rect& dirty_rect);
+ void flip(const Vector<Rect, 32>& dirty_rects);
RetainPtr<GraphicsBitmap> m_front_bitmap;
RetainPtr<GraphicsBitmap> m_back_bitmap;