summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-20 22:02:56 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-21 01:46:25 +0200
commita6e1b9eed2bc3ff938c9072ee621ac77d227b3fc (patch)
treef3fc09a9cdfd72e0f794ccca2a9a9ad755ee5320 /Userland/Libraries/LibWeb/Painting
parente095b9c6f987570b0bba097a02e367ebf409c6d9 (diff)
downloadserenity-a6e1b9eed2bc3ff938c9072ee621ac77d227b3fc.zip
LibWeb: Snap transformed stacking contexts to pixel grid
Make sure that we're painting them at an integer pixel position, to avoid smearing.
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting')
-rw-r--r--Userland/Libraries/LibWeb/Painting/StackingContext.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
index ab7adf366a..dbdb091b4b 100644
--- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
+++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp
@@ -295,7 +295,12 @@ void StackingContext::paint(PaintContext& context) const
auto transformed_destination_rect = affine_transform.map(source_rect).translated(transform_origin);
source_rect.translate_by(transform_origin);
- context.painter().draw_scaled_bitmap(transformed_destination_rect.to_rounded<int>(), *bitmap, source_rect, opacity, Gfx::Painter::ScalingMode::BilinearBlend);
+
+ // NOTE: If the destination and source rects are the same size, we round the source rect to ensure that it's pixel-aligned.
+ if (transformed_destination_rect.size() == source_rect.size())
+ context.painter().draw_scaled_bitmap(transformed_destination_rect.to_rounded<int>(), *bitmap, source_rect.to_rounded<int>(), opacity);
+ else
+ context.painter().draw_scaled_bitmap(transformed_destination_rect.to_rounded<int>(), *bitmap, source_rect, opacity, Gfx::Painter::ScalingMode::BilinearBlend);
} else {
paint_internal(context);
}