mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
PixelPaint: Split bitmap() of Layer into {content, display}_bitmap
This is in preparation to support masking of Layers. We now distinguish between the "display_bitmap" which will be the whole Layer with every effect applied and the "content_bitmap" which contains the actual unmodified pixels in the Layer.
This commit is contained in:
parent
b6510f8e76
commit
31a9196bfe
14 changed files with 73 additions and 42 deletions
|
@ -29,7 +29,7 @@ void BrushTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|||
|
||||
// Shift+Click draws a line from the last position to current one.
|
||||
if (layer_event.shift() && m_has_clicked) {
|
||||
draw_line(layer->bitmap(), color_for(layer_event), m_last_position, layer_event.position());
|
||||
draw_line(layer->content_bitmap(), color_for(layer_event), m_last_position, layer_event.position());
|
||||
auto modified_rect = Gfx::IntRect::from_two_points(m_last_position, layer_event.position()).inflated(m_size * 2, m_size * 2);
|
||||
layer->did_modify_bitmap(modified_rect);
|
||||
m_last_position = layer_event.position();
|
||||
|
@ -39,7 +39,7 @@ void BrushTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|||
const int first_draw_opacity = 10;
|
||||
|
||||
for (int i = 0; i < first_draw_opacity; ++i)
|
||||
draw_point(layer->bitmap(), color_for(layer_event), layer_event.position());
|
||||
draw_point(layer->content_bitmap(), color_for(layer_event), layer_event.position());
|
||||
|
||||
layer->did_modify_bitmap(Gfx::IntRect::centered_on(layer_event.position(), Gfx::IntSize { m_size * 2, m_size * 2 }));
|
||||
m_last_position = layer_event.position();
|
||||
|
@ -55,7 +55,7 @@ void BrushTool::on_mousemove(Layer* layer, MouseEvent& event)
|
|||
if (!(layer_event.buttons() & GUI::MouseButton::Primary || layer_event.buttons() & GUI::MouseButton::Secondary))
|
||||
return;
|
||||
|
||||
draw_line(layer->bitmap(), color_for(layer_event), m_last_position, layer_event.position());
|
||||
draw_line(layer->content_bitmap(), color_for(layer_event), m_last_position, layer_event.position());
|
||||
|
||||
auto modified_rect = Gfx::IntRect::from_two_points(m_last_position, layer_event.position()).inflated(m_size * 2, m_size * 2);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue