From b7f9387f69a17eb209d97a2783ca32e3bee16d7d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 29 Sep 2022 01:20:13 +0200 Subject: [PATCH] LibWeb: Don't draw only-translated stacking contexts via bitmap If the 2D transform in effect is just a simple translation, we don't need to draw into a temporary bitmap and then transform it. We can just translate the painter. :^) --- Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 8d525f2fe1c..d08d3e6f477 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -292,7 +292,7 @@ void StackingContext::paint(PaintContext& context) const auto affine_transform = affine_transform_matrix(); - if (opacity < 1.0f || !affine_transform.is_identity()) { + if (opacity < 1.0f || !affine_transform.is_identity_or_translation()) { auto transform_origin = this->transform_origin(); auto source_rect = paintable().absolute_paint_rect().translated(-transform_origin); auto transformed_destination_rect = affine_transform.map(source_rect).translated(transform_origin); @@ -333,6 +333,8 @@ void StackingContext::paint(PaintContext& context) const else context.painter().draw_scaled_bitmap(destination_rect, *bitmap, bitmap->rect(), opacity, Gfx::Painter::ScalingMode::BilinearBlend); } else { + Gfx::PainterStateSaver saver(context.painter()); + context.painter().translate(affine_transform.translation().to_rounded()); paint_internal(context); } }