1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:07:36 +00:00

WindowServer: Cache the last two backing stores to make flipping faster.

Instead of reattaching to the shared buffer on every flip, keep a reference
to the last seen backing store GraphicsBitmap. This way we can simply
swap the two last buffers when a flip happens.

This does increase memory consumption in apps that disable double-buffering
but I'll address that issue separately.
This commit is contained in:
Andreas Kling 2019-03-18 20:52:23 +01:00
parent 214b67defd
commit 794c81626e
2 changed files with 24 additions and 9 deletions

View file

@ -58,7 +58,17 @@ public:
virtual void on_message(WSMessage&) override;
GraphicsBitmap* backing_store() { return m_backing_store.ptr(); }
void set_backing_store(RetainPtr<GraphicsBitmap>&& backing_store) { m_backing_store = move(backing_store); }
void set_backing_store(RetainPtr<GraphicsBitmap>&& backing_store)
{
m_last_backing_store = move(m_backing_store);
m_backing_store = move(backing_store);
}
void swap_backing_stores()
{
swap(m_backing_store, m_last_backing_store);
}
GraphicsBitmap* last_backing_store() { return m_last_backing_store.ptr(); }
void set_global_cursor_tracking_enabled(bool);
bool global_cursor_tracking() const { return m_global_cursor_tracking_enabled; }
@ -97,6 +107,7 @@ private:
bool m_has_alpha_channel { false };
bool m_has_painted_since_last_resize { false };
RetainPtr<GraphicsBitmap> m_backing_store;
RetainPtr<GraphicsBitmap> m_last_backing_store;
int m_window_id { -1 };
float m_opacity { 1 };
Rect m_last_lazy_resize_rect;