PixelPaint: Allow partial invalidation of Layer and Image

Let's give ourselves the tools needed to update less than the entire
image every time we paint.

This patch adds plumbing so that Layer invalidations have a modified
rect that gets passed on to Image, and then on to ImageEditor.
This commit is contained in:
Andreas Kling 2021-07-06 20:35:19 +02:00
commit f7053059c9
Notes: sideshowbarker 2024-07-18 10:15:00 +09:00
6 changed files with 14 additions and 13 deletions

View file

@ -384,13 +384,13 @@ void Image::remove_client(ImageClient& client)
m_clients.remove(&client);
}
void Image::layer_did_modify_bitmap(Badge<Layer>, Layer const& layer)
void Image::layer_did_modify_bitmap(Badge<Layer>, Layer const& layer, Gfx::IntRect const& modified_layer_rect)
{
auto layer_index = index_of(layer);
for (auto* client : m_clients)
client->image_did_modify_layer(layer_index);
did_change();
did_change(modified_layer_rect.translated(layer.location()));
}
void Image::layer_did_modify_properties(Badge<Layer>, Layer const& layer)
@ -402,10 +402,11 @@ void Image::layer_did_modify_properties(Badge<Layer>, Layer const& layer)
did_change();
}
void Image::did_change()
void Image::did_change(Gfx::IntRect const& a_modified_rect)
{
auto modified_rect = a_modified_rect.is_empty() ? this->rect() : a_modified_rect;
for (auto* client : m_clients)
client->image_did_change();
client->image_did_change(modified_rect);
}
ImageUndoCommand::ImageUndoCommand(Image& image)