diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-01-12 21:45:45 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-01-12 21:45:45 +0100 |
commit | edc827077ecf7984f23d8273cd1b3456d470e621 (patch) | |
tree | 655895e7c3749b18c9bd52cf48f8532e5f8d94ab /Widgets | |
parent | 6b4e88b51587153dceb8855e4f573694bf6a15c2 (diff) | |
download | serenity-edc827077ecf7984f23d8273cd1b3456d470e621.zip |
Optimize WindowManager::flush() with fast_dword_copy().
Diffstat (limited to 'Widgets')
-rw-r--r-- | Widgets/GraphicsBitmap.h | 1 | ||||
-rw-r--r-- | Widgets/Painter.cpp | 30 | ||||
-rw-r--r-- | Widgets/WindowManager.cpp | 12 |
3 files changed, 9 insertions, 34 deletions
diff --git a/Widgets/GraphicsBitmap.h b/Widgets/GraphicsBitmap.h index 64d68d2134..2ab8f92bdc 100644 --- a/Widgets/GraphicsBitmap.h +++ b/Widgets/GraphicsBitmap.h @@ -17,6 +17,7 @@ public: Size size() const { return m_size; } int width() const { return m_size.width(); } int height() const { return m_size.height(); } + size_t pitch() const { return m_pitch; } private: explicit GraphicsBitmap(const Size&); diff --git a/Widgets/Painter.cpp b/Widgets/Painter.cpp index 5ae921bd6f..fbd09f65e4 100644 --- a/Widgets/Painter.cpp +++ b/Widgets/Painter.cpp @@ -7,36 +7,6 @@ #define DEBUG_WIDGET_UNDERDRAW -ALWAYS_INLINE void fast_dword_copy(dword* dest, const dword* src, size_t count) -{ -#ifdef SERENITY - asm volatile( - "rep movsl\n" - : "=S"(src), "=D"(dest) - : "S"(src), "D"(dest), "c"(count) - : "memory" - ); -#else - memcpy(dest, src, count * sizeof(dword)); -#endif -} - -ALWAYS_INLINE void fast_dword_fill(dword* dest, dword value, size_t count) -{ -#ifdef SERENITY - asm volatile( - "rep stosl\n" - : "=D"(dest) - : "D"(dest), "c"(count), "a"(value) - : "memory" - ); -#else - for (size_t i = 0; x <= count; ++x) { - dest[i] = value; - } -#endif -} - Painter::Painter(GraphicsBitmap& bitmap) { m_font = &Font::defaultFont(); diff --git a/Widgets/WindowManager.cpp b/Widgets/WindowManager.cpp index 41785387fa..3f6ec1ef5a 100644 --- a/Widgets/WindowManager.cpp +++ b/Widgets/WindowManager.cpp @@ -346,10 +346,14 @@ void WindowManager::flush(const Rect& a_rect) { auto rect = Rect::intersection(a_rect, m_screen_rect); - for (int y = rect.top(); y <= rect.bottom(); ++y) { - auto* front_scanline = m_front_bitmap->scanline(y); - auto* back_scanline = m_back_bitmap->scanline(y); - memcpy(front_scanline + rect.x(), back_scanline + rect.x(), rect.width() * sizeof(RGBA32)); + RGBA32* front_ptr = m_front_bitmap->scanline(rect.y()) + rect.x(); + const RGBA32* back_ptr = m_back_bitmap->scanline(rect.y()) + rect.x(); + size_t pitch = m_back_bitmap->pitch(); + + for (int y = 0; y < rect.height(); ++y) { + fast_dword_copy(front_ptr, back_ptr, rect.width()); + front_ptr = (RGBA32*)((byte*)front_ptr + pitch); + back_ptr = (const RGBA32*)((const byte*)back_ptr + pitch); } m_framebuffer.flush(); |