diff options
author | Andreas Kling <kling@serenityos.org> | 2021-07-06 20:38:24 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-07 13:01:20 +0200 |
commit | 7cbcf5a5fa199ff21f6223de6057b385dca5a88e (patch) | |
tree | 380fbdc112194aaf8b87a09d0972e7973cbb9953 | |
parent | f7053059c96d4a84c237b4395fe0a0ba4f3dbafc (diff) | |
download | serenity-7cbcf5a5fa199ff21f6223de6057b385dca5a88e.zip |
PixelPaint: Make PenTool only invalidate the modified area :^)
-rw-r--r-- | Userland/Applications/PixelPaint/PenTool.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Userland/Applications/PixelPaint/PenTool.cpp b/Userland/Applications/PixelPaint/PenTool.cpp index d26e24acef..26b48e5851 100644 --- a/Userland/Applications/PixelPaint/PenTool.cpp +++ b/Userland/Applications/PixelPaint/PenTool.cpp @@ -31,7 +31,7 @@ void PenTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent GUI::Painter painter(layer.bitmap()); painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); - layer.did_modify_bitmap(); + layer.did_modify_bitmap(Gfx::IntRect::centered_on(event.position(), Gfx::IntSize { m_thickness, m_thickness })); m_last_drawing_event_position = event.position(); } @@ -49,11 +49,16 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent return; GUI::Painter painter(layer.bitmap()); - if (m_last_drawing_event_position != Gfx::IntPoint(-1, -1)) + Gfx::IntRect changed_rect; + if (m_last_drawing_event_position != Gfx::IntPoint(-1, -1)) { painter.draw_line(m_last_drawing_event_position, event.position(), m_editor->color_for(event), m_thickness); - else + changed_rect = Gfx::IntRect::from_two_points(m_last_drawing_event_position, event.position()); + } else { painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); - layer.did_modify_bitmap(); + changed_rect = Gfx::IntRect::from_two_points(event.position(), event.position()); + } + changed_rect.inflate(m_thickness * 4, m_thickness * 4); + layer.did_modify_bitmap(changed_rect); m_last_drawing_event_position = event.position(); } |