mirror of
https://github.com/RGBCube/serenity
synced 2025-06-16 14:32:09 +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
1 changed files with 6 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
||||||
#include <LibGfx/Matrix4x4.h>
|
#include <LibGfx/Matrix4x4.h>
|
||||||
#include <LibGfx/Painter.h>
|
#include <LibGfx/Painter.h>
|
||||||
#include <LibGfx/Rect.h>
|
#include <LibGfx/Rect.h>
|
||||||
|
#include <LibWeb/CSS/ComputedValues.h>
|
||||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||||
#include <LibWeb/Layout/Box.h>
|
#include <LibWeb/Layout/Box.h>
|
||||||
#include <LibWeb/Layout/ReplacedBox.h>
|
#include <LibWeb/Layout/ReplacedBox.h>
|
||||||
|
@ -413,10 +414,12 @@ void StackingContext::paint(PaintContext& context) const
|
||||||
auto paint_context = context.clone(painter);
|
auto paint_context = context.clone(painter);
|
||||||
paint_internal(paint_context);
|
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);
|
context.painter().blit(destination_rect.location(), *bitmap, bitmap->rect(), opacity);
|
||||||
else
|
} else {
|
||||||
context.painter().draw_scaled_bitmap(destination_rect, *bitmap, bitmap->rect(), opacity, Gfx::Painter::ScalingMode::BilinearBlend);
|
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 {
|
} else {
|
||||||
Gfx::PainterStateSaver saver(context.painter());
|
Gfx::PainterStateSaver saver(context.painter());
|
||||||
context.painter().translate(affine_transform.translation().to_rounded<int>());
|
context.painter().translate(affine_transform.translation().to_rounded<int>());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue