Truly independent web browser
Compositor: Rotate canvas conic gradients to their start angle
Andreas Klingf3789b470b35
diff --git a/Services/Compositor/PainterSkia.cpp b/Services/Compositor/PainterSkia.cppindex 46343c0834b..37a93c1b655 100644--- a/Services/Compositor/PainterSkia.cpp+++ b/Services/Compositor/PainterSkia.cpp@@ -116,9 +116,12 @@ static void apply_paint_style(SkPaint& paint, PaintStyle const& style, SkColorSpauto center = conic_gradient->center();auto start_angle_degrees = AK::to_degrees(conic_gradient->start_angle());+ // NB: The angles of a Skia sweep gradient pick where its colors start and end, and every angle outside of them+ // takes the color of the nearest end. So the gradient is rotated to its start angle instead.SkMatrix matrix;+ matrix.setRotate(start_angle_degrees, center.x(), center.y());SkGradient gradient { SkGradient::Colors { { colors.data(), colors.size() }, { positions.data(), positions.size() }, SkTileMode::kClamp, sk_ref_sp(color_space) }, {} };- auto shader = SkShaders::SweepGradient(to_skia_point(center), start_angle_degrees, start_angle_degrees + 360, gradient, &matrix);+ auto shader = SkShaders::SweepGradient(to_skia_point(center), 0, 360, gradient, &matrix);paint.setShader(shader);} else if (auto const* canvas_pattern = as_if<CanvasPatternPaintStyle>(style)) {auto frame = canvas_pattern->image();diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txtindex 5896efd5f67..79724f4efe9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/element/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Conic gradient with positive rotation\ No newline at end of file+1 Pass+Pass Conic gradient with positive rotation\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txtindex 5896efd5f67..79724f4efe9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Conic gradient with positive rotation\ No newline at end of file+1 Pass+Pass Conic gradient with positive rotation\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.worker.txt b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.worker.txtindex 5896efd5f67..79724f4efe9 100644--- a/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.worker.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/html/canvas/offscreen/fill-and-stroke-styles/2d.gradient.conic.positive.rotation.worker.txt@@ -2,5 +2,5 @@ Harness status: OKFound 1 tests-1 Fail-Fail Conic gradient with positive rotation\ No newline at end of file+1 Pass+Pass Conic gradient with positive rotation\ No newline at end of file