diff --git a/gfx/2d/PathD2D.cpp b/gfx/2d/PathD2D.cpp index c11f3566f8a7..de01b410a9bf 100644 --- a/gfx/2d/PathD2D.cpp +++ b/gfx/2d/PathD2D.cpp @@ -188,10 +188,10 @@ void PathBuilderD2D::Arc(const Point& aOrigin, Float aRadius, Float aStartAngle, // XXX - Workaround for now, D2D does not appear to do the desired thing when // the angle sweeps a complete circle. bool fullCircle = false; - if (aEndAngle - aStartAngle >= 2 * M_PI) { + if (aEndAngle - aStartAngle >= 1.9999 * M_PI) { fullCircle = true; aEndAngle = Float(aStartAngle + M_PI * 1.9999); - } else if (aStartAngle - aEndAngle >= 2 * M_PI) { + } else if (aStartAngle - aEndAngle >= 1.9999 * M_PI) { fullCircle = true; aStartAngle = Float(aEndAngle + M_PI * 1.9999); } diff --git a/testing/web-platform/tests/html/canvas/element/path-objects/2d.path.arc.twopie.5.html b/testing/web-platform/tests/html/canvas/element/path-objects/2d.path.arc.twopie.5.html new file mode 100644 index 000000000000..955a6c87436a --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/path-objects/2d.path.arc.twopie.5.html @@ -0,0 +1,34 @@ + + +Canvas test: 2d.path.arc.twopie.5 + + + + + + +

2d.path.arc.twopie.5

+

arc() draws correctly when start = 2 and end = start + 2pi+e and clockwise

+ + +

Actual output:

+

FAIL (fallback content)

+ + + + diff --git a/testing/web-platform/tests/html/canvas/element/path-objects/2d.path.arc.twopie.6.html b/testing/web-platform/tests/html/canvas/element/path-objects/2d.path.arc.twopie.6.html new file mode 100644 index 000000000000..9420ecdc935b --- /dev/null +++ b/testing/web-platform/tests/html/canvas/element/path-objects/2d.path.arc.twopie.6.html @@ -0,0 +1,34 @@ + + +Canvas test: 2d.path.arc.twopie.6 + + + + + + +

2d.path.arc.twopie.6

+

arc() draws correctly when start = 5 and end = start + 2pi+e and clockwise

+ + +

Actual output:

+

FAIL (fallback content)

+ + + + diff --git a/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.5.html b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.5.html new file mode 100644 index 000000000000..17c66c527c40 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.5.html @@ -0,0 +1,35 @@ + + +OffscreenCanvas test: 2d.path.arc.twopie.5 + + + + +

2d.path.arc.twopie.5

+

arc() draws correctly when start = 2 and end = start + 2pi+e and clockwise

+ + + diff --git a/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.5.worker.js b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.5.worker.js new file mode 100644 index 000000000000..8fa29d5a9727 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.5.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.path.arc.twopie.5 +// Description:arc() draws correctly when start = 2 and end = start + 2pi+e and clockwise +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("arc() draws correctly when start = 2 and end = start + 2pi+e and clockwise"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + ctx.fillStyle = '#fff'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#000'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 50, 2, 2 + 2*Math.PI, false); + ctx.closePath(); + ctx.fill(); + _assertPixel(canvas, 95,25, 0,0,0,255); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.6.html b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.6.html new file mode 100644 index 000000000000..befec827044c --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.6.html @@ -0,0 +1,35 @@ + + +OffscreenCanvas test: 2d.path.arc.twopie.6 + + + + +

2d.path.arc.twopie.6

+

arc() draws correctly when start = 5 and end = start + 2pi+e and clockwise

+ + + diff --git a/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.6.worker.js b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.6.worker.js new file mode 100644 index 000000000000..546cbce33c02 --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/path-objects/2d.path.arc.twopie.6.worker.js @@ -0,0 +1,30 @@ +// DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. +// OffscreenCanvas test in a worker:2d.path.arc.twopie.6 +// Description:arc() draws correctly when start = 5 and end = start + 2pi+e and clockwise +// Note: + +importScripts("/resources/testharness.js"); +importScripts("/html/canvas/resources/canvas-tests.js"); + +var t = async_test("arc() draws correctly when start = 5 and end = start + 2pi+e and clockwise"); +var t_pass = t.done.bind(t); +var t_fail = t.step_func(function(reason) { + throw reason; +}); +t.step(function() { + + var canvas = new OffscreenCanvas(100, 50); + var ctx = canvas.getContext('2d'); + + ctx.fillStyle = '#fff'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#000'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 50, 5, 5 + 2*Math.PI, false); + ctx.closePath(); + ctx.fill(); + _assertPixel(canvas, 5,25, 0,0,0,255); + t.done(); +}); +done(); diff --git a/testing/web-platform/tests/html/canvas/tools/gentest.py b/testing/web-platform/tests/html/canvas/tools/gentest.py index 6574ff532383..36cb7fe0f6cd 100644 --- a/testing/web-platform/tests/html/canvas/tools/gentest.py +++ b/testing/web-platform/tests/html/canvas/tools/gentest.py @@ -1,3 +1,13 @@ +# To use this script: +# -make a python virtual environment somewhere (it doesn't matter where) +# python3 -m venv venv +# -enter the virtual environment +# source venv/bin/activate +# -install required packages in the venv +# pip3 install cairocffi jinja2 pyyaml +# -change to the directory with this script and run it +# python3 gentest.py + from gentestutils import genTestUtils from gentestutilsunion import genTestUtils_union diff --git a/testing/web-platform/tests/html/canvas/tools/yaml-new/path-objects.yaml b/testing/web-platform/tests/html/canvas/tools/yaml-new/path-objects.yaml index eec142c7692b..673c90857442 100644 --- a/testing/web-platform/tests/html/canvas/tools/yaml-new/path-objects.yaml +++ b/testing/web-platform/tests/html/canvas/tools/yaml-new/path-objects.yaml @@ -966,6 +966,32 @@ @assert pixel 50,20 == 0,255,0,255; expected: green +- name: 2d.path.arc.twopie.5 + desc: arc() draws correctly when start = 2 and end = start + 2pi+e and clockwise + code: | + ctx.fillStyle = '#fff'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#000'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 50, 2, 2 + 2*Math.PI, false); + ctx.closePath(); + ctx.fill(); + @assert pixel 95,25 == 0,0,0,255; + +- name: 2d.path.arc.twopie.6 + desc: arc() draws correctly when start = 5 and end = start + 2pi+e and clockwise + code: | + ctx.fillStyle = '#fff'; + ctx.fillRect(0, 0, 100, 50); + ctx.fillStyle = '#000'; + ctx.beginPath(); + ctx.moveTo(50, 25); + ctx.arc(50, 25, 50, 5, 5 + 2*Math.PI, false); + ctx.closePath(); + ctx.fill(); + @assert pixel 5,25 == 0,0,0,255; + - name: 2d.path.arc.shape.1 desc: arc() from 0 to pi does not draw anything in the wrong half code: |