diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 64892b041d..3de6598cb2 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -13,6 +13,36 @@ #include #endif +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 +} + namespace AK { template diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 76d36780c2..7b82fadd5a 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -22,7 +22,7 @@ #include "Scheduler.h" #include "PS2MouseDevice.h" -#define SPAWN_MULTIPLE_SHELLS +//#define SPAWN_MULTIPLE_SHELLS //#define STRESS_TEST_SPAWNING system_t system; 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();