mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
PaintBrush: Clip layer contents outside the image rect when compositing
This commit is contained in:
parent
14aa7f2d44
commit
0f3e58ffe0
Notes:
sideshowbarker
2024-07-19 06:40:06 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/0f3e58ffe0b
1 changed files with 6 additions and 2 deletions
|
@ -51,12 +51,16 @@ Image::Image(const Gfx::Size& size)
|
|||
|
||||
void Image::paint_into(GUI::Painter& painter, const Gfx::Rect& dest_rect, const Gfx::Rect& src_rect)
|
||||
{
|
||||
(void) src_rect;
|
||||
Gfx::PainterStateSaver saver(painter);
|
||||
painter.add_clip_rect(dest_rect);
|
||||
for (auto& layer : m_layers) {
|
||||
auto target = dest_rect.translated(layer.location());
|
||||
target.set_size(layer.size());
|
||||
#ifdef IMAGE_DEBUG
|
||||
dbg() << "Composite layer " << layer.name() << " target: " << target << ", src_rect: " << src_rect;
|
||||
dbg() << "Composite layer " << layer.name() << " target: " << target << ", layer.rect: " << layer.rect();
|
||||
#endif
|
||||
painter.draw_scaled_bitmap(target, layer.bitmap(), src_rect);
|
||||
painter.draw_scaled_bitmap(target, layer.bitmap(), layer.rect());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue