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

WindowServer: Coalesce flushing buffers into one ioctl() call

We regularily need to flush many rectangles, so instead of making many
expensive ioctl() calls to the framebuffer driver, collect the
rectangles and only make one call. And if we have too many rectangles
then it may be cheaper to just update the entire region, in which case
we simply convert them all into a union and just flush that one
rectangle instead.
This commit is contained in:
Tom 2021-06-26 11:04:01 -06:00 committed by Andreas Kling
parent 56cd0f929e
commit 38af4c29e6
7 changed files with 123 additions and 31 deletions

View file

@ -8,6 +8,7 @@
#include "ScreenLayout.h"
#include <AK/NonnullOwnPtrVector.h>
#include <AK/OwnPtr.h>
#include <Kernel/API/KeyCode.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Color.h>
@ -57,6 +58,8 @@ private:
unsigned m_scroll_step_size { 1 };
};
struct ScreenFBData;
class Screen {
public:
template<typename... Args>
@ -160,7 +163,9 @@ public:
Gfx::IntSize size() const { return { m_virtual_rect.width(), m_virtual_rect.height() }; }
Gfx::IntRect rect() const { return m_virtual_rect; }
void flush_display(const Gfx::IntRect& rect);
bool can_device_flush_buffers() const { return m_can_device_flush_buffers; }
void queue_flush_display_rect(Gfx::IntRect const& rect);
void flush_display();
private:
Screen(ScreenLayout::Screen&);
@ -189,10 +194,12 @@ private:
Gfx::RGBA32* m_framebuffer { nullptr };
bool m_can_set_buffer { false };
bool m_can_device_flush_buffers { true }; // If the device can't do it we revert to false
int m_pitch { 0 };
Gfx::IntRect m_virtual_rect;
int m_framebuffer_fd { -1 };
NonnullOwnPtr<ScreenFBData> m_framebuffer_data;
ScreenLayout::Screen& m_info;
};