Skip to content

Commit

Permalink
LibWeb: Support radial gradient with asymmetrical size in Skia painter
Browse files Browse the repository at this point in the history
Progress on Tests/Ref/css-gradients.html
  • Loading branch information
kalenikaliaksandr committed Jul 15, 2024
1 parent af9b91e commit be1075e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Userland/Libraries/LibWeb/Painting/DisplayListPlayerSkia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1143,8 +1143,14 @@ CommandResult DisplayListPlayerSkia::paint_radial_gradient(PaintRadialGradient c

auto const& rect = command.rect;
auto center = to_skia_point(command.center.translated(command.rect.location()));
auto radius = command.size.height();
auto shader = SkGradientShader::MakeRadial(center, radius, colors.data(), positions.data(), positions.size(), SkTileMode::kClamp, 0);

auto const size = command.size.to_type<float>();
SkMatrix matrix;
// Skia does not support specifying of horizontal and vertical radius's separately,
// so instead we apply scale matrix
matrix.setScale(size.width() / size.height(), 1.0f, center.x(), center.y());

auto shader = SkGradientShader::MakeRadial(center, size.height(), colors.data(), positions.data(), positions.size(), SkTileMode::kClamp, 0, &matrix);

SkPaint paint;
paint.setShader(shader);
Expand Down

0 comments on commit be1075e

Please sign in to comment.