LibGfx: Move Gfx::Painter::ScalingMode => Gfx::ScalingMode

This will allow users to avoid including Painter.h
This commit is contained in:
Andreas Kling 2024-06-05 10:10:38 +02:00 committed by Andreas Kling
commit 254d040ff4
Notes: sideshowbarker 2024-07-17 05:23:40 +09:00
14 changed files with 67 additions and 51 deletions

View file

@ -8,7 +8,7 @@
#include <AK/Optional.h>
#include <LibGfx/FontCascadeList.h>
#include <LibGfx/Painter.h>
#include <LibGfx/ScalingMode.h>
#include <LibWeb/CSS/BackdropFilter.h>
#include <LibWeb/CSS/CalculatedOr.h>
#include <LibWeb/CSS/Clip.h>
@ -319,19 +319,19 @@ struct BorderRadiusData {
};
// FIXME: Find a better place for this helper.
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value, Gfx::IntRect source, Gfx::IntRect target)
inline Gfx::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;
return Gfx::ScalingMode::BoxSampling;
return Gfx::ScalingMode::BilinearBlend;
case CSS::ImageRendering::CrispEdges:
return Gfx::Painter::ScalingMode::NearestNeighbor;
return Gfx::ScalingMode::NearestNeighbor;
case CSS::ImageRendering::Pixelated:
return Gfx::Painter::ScalingMode::SmoothPixels;
return Gfx::ScalingMode::SmoothPixels;
}
VERIFY_NOT_REACHED();
}