From 0f3e58ffe0b4a36393d7cc702e5b467dae6605af Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 13 May 2020 21:12:32 +0200 Subject: PaintBrush: Clip layer contents outside the image rect when compositing --- Applications/PaintBrush/Image.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Applications') 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()); } } -- cgit v1.2.3