mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibWeb: Use box sampling instead of bilinear scaling when downscaling
As a heuristic, either the width or height of the scaled image should decrease for box sampling to be used. Otherwise, we use bilinear scaling.
This commit is contained in:
parent
fae9a05039
commit
7652dbd983
5 changed files with 13 additions and 6 deletions
|
@ -185,12 +185,14 @@ struct BorderRadiusData {
|
|||
};
|
||||
|
||||
// FIXME: Find a better place for this helper.
|
||||
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value)
|
||||
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value, Gfx::IntRect source, Gfx::IntRect target)
|
||||
{
|
||||
switch (css_value) {
|
||||
case CSS::ImageRendering::Auto:
|
||||
case CSS::ImageRendering::HighQuality:
|
||||
case CSS::ImageRendering::Smooth:
|
||||
if (target.width() < source.width() || target.height() < source.height())
|
||||
return Gfx::Painter::ScalingMode::BoxSampling;
|
||||
return Gfx::Painter::ScalingMode::BilinearBlend;
|
||||
case CSS::ImageRendering::CrispEdges:
|
||||
return Gfx::Painter::ScalingMode::NearestNeighbor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue