From 2c5a062c8fbdb2e114336e499d90dbccfc9f45c8 Mon Sep 17 00:00:00 2001 From: Valtteri Koskivuori Date: Thu, 8 Jun 2023 23:57:53 +0300 Subject: [PATCH] LibWeb: Teach CSS transformed StackingContexts about image-rendering Previously, all StackingContexts which were scaled using CSS transforms were hard-coded to use BilinearBlend. This fix maps specified image-rendering properties to reasonable ScalingModes for painting. --- Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 3a5497c8b1..52832e6284 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -413,10 +414,12 @@ void StackingContext::paint(PaintContext& context) const auto paint_context = context.clone(painter); paint_internal(paint_context); - if (destination_rect.size() == bitmap->size()) + if (destination_rect.size() == bitmap->size()) { context.painter().blit(destination_rect.location(), *bitmap, bitmap->rect(), opacity); - else - context.painter().draw_scaled_bitmap(destination_rect, *bitmap, bitmap->rect(), opacity, Gfx::Painter::ScalingMode::BilinearBlend); + } else { + auto scaling_mode = CSS::to_gfx_scaling_mode(m_box->computed_values().image_rendering(), bitmap->rect(), destination_rect); + context.painter().draw_scaled_bitmap(destination_rect, *bitmap, bitmap->rect(), opacity, scaling_mode); + } } else { Gfx::PainterStateSaver saver(context.painter()); context.painter().translate(affine_transform.translation().to_rounded());