LibWeb: Support SVG gradient spread method in Skia painter

Progress on Tests/LibWeb/Ref/svg-gradient-spreadMethod.html
This commit is contained in:
Aliaksandr Kalenik 2024-07-12 13:58:37 +03:00 committed by Alexander Kalenik
parent 2c396b5378
commit 5c4ca5ac12
Notes: sideshowbarker 2024-07-16 23:17:55 +09:00

View file

@ -786,6 +786,20 @@ CommandResult DisplayListPlayerSkia::fill_path_using_color(FillPathUsingColor co
return CommandResult::Continue;
}
SkTileMode to_skia_tile_mode(SVGLinearGradientPaintStyle::SpreadMethod spread_method)
{
switch (spread_method) {
case SVGLinearGradientPaintStyle::SpreadMethod::Pad:
return SkTileMode::kClamp;
case SVGLinearGradientPaintStyle::SpreadMethod::Reflect:
return SkTileMode::kMirror;
case SVGLinearGradientPaintStyle::SpreadMethod::Repeat:
return SkTileMode::kRepeat;
default:
VERIFY_NOT_REACHED();
}
}
SkPaint paint_style_to_skia_paint(Painting::SVGGradientPaintStyle const& paint_style, Gfx::FloatRect bounding_rect)
{
SkPaint paint;
@ -816,7 +830,7 @@ SkPaint paint_style_to_skia_paint(Painting::SVGGradientPaintStyle const& paint_s
positions.append(color_stop.position);
}
auto shader = SkGradientShader::MakeLinear(points.data(), colors.data(), positions.data(), color_stops.size(), SkTileMode::kClamp, 0, &matrix);
auto shader = SkGradientShader::MakeLinear(points.data(), colors.data(), positions.data(), color_stops.size(), to_skia_tile_mode(paint_style.spread_method()), 0, &matrix);
paint.setShader(shader);
} else if (is<SVGRadialGradientPaintStyle>(paint_style)) {
// TODO: