1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:27:35 +00:00

Have WindowManager::invalidate() unite dirty rects that intersect each other.

This is kinda primitive but it avoids double-draw when slowly dragging stuff.
This commit is contained in:
Andreas Kling 2019-01-13 00:04:23 +01:00
parent c43903eebd
commit e4cb9b2985
3 changed files with 27 additions and 2 deletions

View file

@ -8,6 +8,8 @@
#include "Process.h"
#include "MemoryManager.h"
//#define DEBUG_FLUSH_YELLOW
static const int windowTitleBarHeight = 16;
static inline Rect titleBarRectForWindow(const Rect& window)
@ -327,6 +329,12 @@ void WindowManager::invalidate(const Rect& a_rect)
for (auto& r : m_invalidated_rects) {
if (r.contains(rect))
return;
if (r.intersects(rect)) {
// Unite with the existing dirty rect.
// FIXME: It would be much nicer to compute the exact rects needing repaint.
r = r.united(rect);
return;
}
}
m_invalidated_rects.append(rect);
@ -350,6 +358,11 @@ void WindowManager::flush(const Rect& a_rect)
const RGBA32* back_ptr = m_back_bitmap->scanline(rect.y()) + rect.x();
size_t pitch = m_back_bitmap->pitch();
#ifdef DEBUG_FLUSH_YELLOW
Painter p(*m_front_bitmap);
p.fill_rect(rect, Color::Yellow);
#endif
for (int y = 0; y < rect.height(); ++y) {
fast_dword_copy(front_ptr, back_ptr, rect.width());
front_ptr = (RGBA32*)((byte*)front_ptr + pitch);