mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:27:34 +00:00
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. :^)
This commit is contained in:
parent
9fc419395e
commit
7d5d5b387e
1 changed files with 4 additions and 2 deletions
|
@ -36,8 +36,10 @@ void CanvasBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect())))
|
if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dom_node().bitmap())
|
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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue