diff --git a/SharedGraphics/Painter.cpp b/SharedGraphics/Painter.cpp index 84bb6f7e3b..ce8f74562d 100644 --- a/SharedGraphics/Painter.cpp +++ b/SharedGraphics/Painter.cpp @@ -56,8 +56,32 @@ Painter::~Painter() #endif } +void Painter::fill_rect_with_draw_op(const Rect& a_rect, Color color) +{ + auto rect = a_rect; + rect.move_by(m_translation); + rect.intersect(m_clip_rect); + + if (rect.is_empty()) + return; + + 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) { + for (int j = 0; j < rect.width(); ++j) + set_pixel_with_draw_op(dst[j], color.value()); + dst += dst_skip; + } +} + void Painter::fill_rect(const Rect& a_rect, Color color) { + if (m_draw_op != DrawOp::Copy) { + fill_rect_with_draw_op(a_rect, color); + return; + } + auto rect = a_rect; rect.move_by(m_translation); rect.intersect(m_clip_rect); diff --git a/SharedGraphics/Painter.h b/SharedGraphics/Painter.h index f28db3ac5c..22acc64313 100644 --- a/SharedGraphics/Painter.h +++ b/SharedGraphics/Painter.h @@ -47,6 +47,7 @@ public: private: void set_pixel_with_draw_op(dword& pixel, const Color&); + void fill_rect_with_draw_op(const Rect&, Color); const Font* m_font; Point m_translation;