PixelPaint: Inflate update rect for PenTool

Previously using PenTool while zoomed in could cause rendering glitches
since the update rect was misaligned with the image, most likely because
of rounding errors.
Loosening the rect with 1 pixel on either side takes care of this.
This commit is contained in:
Marcus Nilsson 2021-08-07 23:16:52 +02:00 committed by Andreas Kling
parent 99dfab08c9
commit 8c81d195c7
Notes: sideshowbarker 2024-07-18 07:14:57 +09:00

View file

@ -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(Gfx::IntRect::centered_on(event.position(), Gfx::IntSize { m_thickness, m_thickness }));
layer.did_modify_bitmap(Gfx::IntRect::centered_on(event.position(), Gfx::IntSize { m_thickness + 2, m_thickness + 2 }));
m_last_drawing_event_position = event.position();
}
@ -57,7 +57,7 @@ void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent
painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness);
changed_rect = Gfx::IntRect::from_two_points(event.position(), event.position());
}
changed_rect.inflate(m_thickness, m_thickness);
changed_rect.inflate(m_thickness + 2, m_thickness + 2);
layer.did_modify_bitmap(changed_rect);
m_last_drawing_event_position = event.position();