mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-13 01:40:36 +00:00
LibWeb: Support SVG gradient spread method in Skia painter
Progress on Tests/LibWeb/Ref/svg-gradient-spreadMethod.html
This commit is contained in:
parent
2c396b5378
commit
5c4ca5ac12
Notes:
sideshowbarker
2024-07-16 23:17:55 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/5c4ca5ac12 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/598
1 changed files with 15 additions and 1 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue