mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
PixelPaint: Make PenTool only invalidate the modified area :^)
This commit is contained in:
parent
f7053059c9
commit
7cbcf5a5fa
1 changed files with 9 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue