summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-06 01:40:43 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-06 01:51:18 +0100
commit7d5d5b387eaf253d1ee55a2edda82842c9713eb0 (patch)
treef66ed349097eccd1fee90d50e9d11749c73fdafa /Userland
parent9fc419395ee2bae343ee978ee5036f6eb2edbdfe (diff)
downloadserenity-7d5d5b387eaf253d1ee55a2edda82842c9713eb0.zip
LibWeb: Respect CSS image-rendering mode when painting canvas elements
If the content wants to be pixelated, we should honor that and paint with nearest-neighbor scaling. The fact that it's faster is a nice bonus as well. :^)
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/CanvasBox.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp b/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp
index adb0b9e396..7841d1c514 100644
--- a/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/CanvasBox.cpp
@@ -36,8 +36,10 @@ void CanvasBox::paint(PaintContext& context, PaintPhase phase)
if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect())))
return;
- if (dom_node().bitmap())
- context.painter().draw_scaled_bitmap(rounded_int_rect(absolute_rect()), *dom_node().bitmap(), dom_node().bitmap()->rect(), 1.0f, Gfx::Painter::ScalingMode::BilinearBlend);
+ if (dom_node().bitmap()) {
+ auto scaling_mode = computed_values().image_rendering() == CSS::ImageRendering::Pixelated ? Gfx::Painter::ScalingMode::NearestNeighbor : Gfx::Painter::ScalingMode::BilinearBlend;
+ context.painter().draw_scaled_bitmap(rounded_int_rect(absolute_rect()), *dom_node().bitmap(), dom_node().bitmap()->rect(), 1.0f, scaling_mode);
+ }
}
}