1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibWeb: Support more CSS image-rendering values

This patch adds support for "crisp-edges", "high-quality" and "smooth"
for the CSS image-rendering property.

"crisp-edges" maps to nearest-neighbor scaling for <canvas> and <img>
elements, while "high-quality" and "smooth" both use bilinear blending.
This commit is contained in:
Andreas Kling 2022-03-06 18:17:50 +01:00
parent fe52ee2f8e
commit 6d1a9672a4
7 changed files with 42 additions and 9 deletions

View file

@ -22,6 +22,7 @@
#include <AK/WeakPtr.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Color.h>
#include <LibGfx/Painter.h>
#include <LibWeb/CSS/Angle.h>
#include <LibWeb/CSS/Display.h>
#include <LibWeb/CSS/Frequency.h>
@ -146,9 +147,27 @@ enum class Float {
enum class ImageRendering {
Auto,
Pixelated
CrispEdges,
HighQuality,
Pixelated,
Smooth,
};
// FIXME: Find a better place for this helper.
inline Gfx::Painter::ScalingMode to_gfx_scaling_mode(CSS::ImageRendering css_value)
{
switch (css_value) {
case CSS::ImageRendering::Auto:
case CSS::ImageRendering::HighQuality:
case CSS::ImageRendering::Smooth:
return Gfx::Painter::ScalingMode::BilinearBlend;
case CSS::ImageRendering::CrispEdges:
case CSS::ImageRendering::Pixelated:
return Gfx::Painter::ScalingMode::NearestNeighbor;
}
VERIFY_NOT_REACHED();
}
enum class JustifyContent {
FlexStart,
FlexEnd,