LibGfx+LibWeb: Use mipmaps for downscaling images

This changes Gfx::ScalingMode to reflect the three modes of scaling we
support using Skia, which makes it a bit easier to reason about the mode
to select. New is ::BilinearMipmap, which uses linear interpolation
between mipmap levels to produce higher quality downscaled images.

The cubic resampling options Mitchell and its sibling CatmullRom both
produced weird artifacts or resulted in a worse quality than
BilinearMipmap when downscaling. We might not have been using these
correctly, but the new ::BilinearMipmap method seems to mirror what
Chrome uses for downscaled images.
This commit is contained in:
Jelle Raaijmakers 2025-11-11 16:43:41 +01:00 committed by Alexander Kalenik
parent 7544066c0c
commit 3f6cbeb87e
Notes: github-actions[bot] 2025-11-12 15:00:21 +00:00
23 changed files with 66 additions and 29 deletions

View file

@ -188,7 +188,7 @@ WebIDL::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasIm
auto scaling_mode = Gfx::ScalingMode::NearestNeighbor;
if (drawing_state().image_smoothing_enabled) {
// FIXME: Honor drawing_state().image_smoothing_quality
scaling_mode = Gfx::ScalingMode::BilinearBlend;
scaling_mode = Gfx::ScalingMode::BilinearMipmap;
}
if (auto* painter = this->painter()) {