diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-13 21:12:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-13 21:12:32 +0200 |
commit | 0f3e58ffe0b4a36393d7cc702e5b467dae6605af (patch) | |
tree | 314271257b5a099b921f6efe485b76357389b384 /Applications | |
parent | 14aa7f2d44e5d99f398c7bb0478fb9f62803f2f2 (diff) | |
download | serenity-0f3e58ffe0b4a36393d7cc702e5b467dae6605af.zip |
PaintBrush: Clip layer contents outside the image rect when compositing
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/PaintBrush/Image.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Applications/PaintBrush/Image.cpp b/Applications/PaintBrush/Image.cpp index 015262b8ae..4110a5612e 100644 --- a/Applications/PaintBrush/Image.cpp +++ b/Applications/PaintBrush/Image.cpp @@ -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()); } } |