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.
This commit is contained in:
Valtteri Koskivuori 2023-06-08 23:57:53 +03:00 committed by Andreas Kling
parent ac2238ee70
commit 2c5a062c8f

View file

@ -13,6 +13,7 @@
#include <LibGfx/Matrix4x4.h>
#include <LibGfx/Painter.h>
#include <LibGfx/Rect.h>
#include <LibWeb/CSS/ComputedValues.h>
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/ReplacedBox.h>
@ -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<int>());