From f92e721ae8b71fac9a07ff7d2cf56fcb0ae87d81 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 17 Jan 2019 01:25:26 +0100 Subject: [PATCH] Tidy up Painter::fill_rect() a bit. --- Widgets/Painter.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Widgets/Painter.cpp b/Widgets/Painter.cpp index a32471cee1..8943d84411 100644 --- a/Widgets/Painter.cpp +++ b/Widgets/Painter.cpp @@ -35,18 +35,18 @@ Painter::~Painter() { } -void Painter::fill_rect(const Rect& rect, Color color) +void Painter::fill_rect(const Rect& a_rect, Color color) { - Rect r = rect; - r.move_by(m_translation); + auto rect = a_rect; + rect.move_by(m_translation); + rect.intersect(m_clip_rect); - int min_y = max(r.top(), m_clip_rect.top()); - int max_y = min(r.bottom(), m_clip_rect.bottom()); - int min_x = max(r.left(), m_clip_rect.left()); - int max_x = min(r.right(), m_clip_rect.right()); - for (int y = min_y; y <= max_y; ++y) { - RGBA32* bits = m_target->scanline(y); - fast_dword_fill(bits + min_x, color.value(), max_x - min_x + 1); + RGBA32* dst = m_target->scanline(rect.top()) + rect.left(); + const unsigned dst_skip = m_target->width(); + + for (int i = rect.height() - 1; i >= 0; --i) { + fast_dword_fill(dst, color.value(), rect.width()); + dst += dst_skip; } }