1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:58:12 +00:00

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. :^)
This commit is contained in:
Andreas Kling 2022-09-29 01:20:13 +02:00
parent e8a5233b94
commit b7f9387f69

View file

@ -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<int>());
paint_internal(context);
}
}