Explorar o código

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. :^)
Andreas Kling %!s(int64=2) %!d(string=hai) anos
pai
achega
b7f9387f69
Modificáronse 1 ficheiros con 3 adicións e 1 borrados
  1. 3 1
      Userland/Libraries/LibWeb/Painting/StackingContext.cpp

+ 3 - 1
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<int>());
         paint_internal(context);
     }
 }