mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
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:
parent
ac2238ee70
commit
2c5a062c8f
|
@ -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>());
|
||||
|
|
Loading…
Reference in a new issue