Title: [93982] trunk
Revision
93982
Author
[email protected]
Date
2011-08-29 10:14:57 -0700 (Mon, 29 Aug 2011)

Log Message

canvas arc() missing line to start of arc if swing is zero
https://bugs.webkit.org/show_bug.cgi?id=55696

Source/WebCore:

Patch by Tom Zakrajsek <[email protected]> on 2011-08-29
Reviewed by Andreas Kling.

Test: fast/canvas/canvas-arc-zero-lineto.html

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::arc):

LayoutTests:

LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html misinterprets pruning requirement
https://bugs.webkit.org/show_bug.cgi?id=66832

Patch by Tom Zakrajsek <[email protected]> on 2011-08-29
Reviewed by Andreas Kling.

Update to 2d.path.stroke.prune.arc.html was reviewed by Philip Taylor and will be part of the
next update to http://philip.html5.org/tests/canvas/suite/tests/2d.path.stroke.prune.arc.html

* canvas/philip/tests/2d.path.stroke.prune.arc.html:
* fast/canvas/canvas-arc-zero-lineto-expected.txt: Added.
* fast/canvas/canvas-arc-zero-lineto.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93981 => 93982)


--- trunk/LayoutTests/ChangeLog	2011-08-29 17:12:55 UTC (rev 93981)
+++ trunk/LayoutTests/ChangeLog	2011-08-29 17:14:57 UTC (rev 93982)
@@ -1,3 +1,20 @@
+2011-08-29  Tom Zakrajsek  <[email protected]>
+
+        canvas arc() missing line to start of arc if swing is zero
+        https://bugs.webkit.org/show_bug.cgi?id=55696
+
+        LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html misinterprets pruning requirement
+        https://bugs.webkit.org/show_bug.cgi?id=66832
+
+        Reviewed by Andreas Kling.
+
+        Update to 2d.path.stroke.prune.arc.html was reviewed by Philip Taylor and will be part of the
+        next update to http://philip.html5.org/tests/canvas/suite/tests/2d.path.stroke.prune.arc.html
+
+        * canvas/philip/tests/2d.path.stroke.prune.arc.html:
+        * fast/canvas/canvas-arc-zero-lineto-expected.txt: Added.
+        * fast/canvas/canvas-arc-zero-lineto.html: Added.
+
 2011-08-23  Chris Marrin  <[email protected]>
 
         [mac] requestAnimationFrame support for mac port

Modified: trunk/LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html (93981 => 93982)


--- trunk/LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html	2011-08-29 17:12:55 UTC (rev 93981)
+++ trunk/LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html	2011-08-29 17:14:57 UTC (rev 93982)
@@ -26,7 +26,7 @@
 ctx.stroke();
 
 ctx.beginPath();
-ctx.moveTo(50, 25);
+ctx.moveTo(60, 25);
 ctx.arc(50, 25, 10, 0, 0, false);
 ctx.stroke();
 

Added: trunk/LayoutTests/fast/canvas/canvas-arc-zero-lineto-expected.txt (0 => 93982)


--- trunk/LayoutTests/fast/canvas/canvas-arc-zero-lineto-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-arc-zero-lineto-expected.txt	2011-08-29 17:14:57 UTC (rev 93982)
@@ -0,0 +1,13 @@
+Bug 55696: Series of tests to ensure zero-length arc extends current subpath
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Pixel (50,20) is black.
+PASS Pixel (50,40) is black.
+PASS Pixel (50,60) is black.
+PASS Pixel (50,80) is black.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-arc-zero-lineto.html (0 => 93982)


--- trunk/LayoutTests/fast/canvas/canvas-arc-zero-lineto.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-arc-zero-lineto.html	2011-08-29 17:14:57 UTC (rev 93982)
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<canvas id="canvas" width="100" height="100"></canvas>
+<script>
+description("Bug 55696: Series of tests to ensure zero-length arc extends current subpath");
+var ctx = document.getElementById('canvas').getContext('2d');
+ctx.lineWidth = 4;
+
+function shouldBeBlackPixel(x,y)
+{
+    var data = "" y, 1, 1).data;
+    if (data[0] != 0 || data[1] != 0 || data[2] != 0 || data[3] != 255) {
+        testFailed("Pixel (" + x + "," + y + ") should be black; " +
+                   "was [" + data[0] + "," + data[1] + "," + data[2] + "," + data[3] + "]");
+    } else {
+        testPassed("Pixel (" + x + "," + y + ") is black.");
+    }
+}
+
+// moveTo + empty arc (swing == 0)
+ctx.beginPath();
+ctx.moveTo(20, 20);
+ctx.arc(80, 30, 10, -Math.PI/2, -Math.PI/2, true);
+ctx.stroke();
+shouldBeBlackPixel(50, 20);
+
+// moveTo + empty arc (radius == 0)
+ctx.beginPath();
+ctx.moveTo(20, 40);
+ctx.arc(80, 40, 0, 0, 6, false);
+ctx.stroke();
+shouldBeBlackPixel(50, 40)
+
+// empty arc (swing == 0) + lineTo
+ctx.beginPath();
+ctx.arc(20, 50, 10, Math.PI/2, Math.PI/2, false);
+ctx.lineTo(80, 60);
+ctx.stroke();
+shouldBeBlackPixel(50, 60);
+
+// empty arc (radius == 0) + lineTo
+ctx.beginPath();
+ctx.arc(20, 80, 0, 0, 6, false);
+ctx.lineTo(80, 80);
+ctx.stroke();
+shouldBeBlackPixel(50, 80);
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (93981 => 93982)


--- trunk/Source/WebCore/ChangeLog	2011-08-29 17:12:55 UTC (rev 93981)
+++ trunk/Source/WebCore/ChangeLog	2011-08-29 17:14:57 UTC (rev 93982)
@@ -1,3 +1,15 @@
+2011-08-29  Tom Zakrajsek  <[email protected]>
+
+        canvas arc() missing line to start of arc if swing is zero
+        https://bugs.webkit.org/show_bug.cgi?id=55696
+
+        Reviewed by Andreas Kling.
+
+        Test: fast/canvas/canvas-arc-zero-lineto.html
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::arc):
+
 2011-08-23  Chris Marrin  <[email protected]>
 
         [mac] requestAnimationFrame support for mac port

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (93981 => 93982)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2011-08-29 17:12:55 UTC (rev 93981)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2011-08-29 17:14:57 UTC (rev 93982)
@@ -833,8 +833,17 @@
         return;
     }
 
-    if (sa == ea)
+    if (!r || sa == ea) {
+        // A subpath consisting of a single empty arc should draw nothing.
+        // However, an empty arc may comprise one point in a non-empty
+        // subpath, so do not ignore empty arcs entirely.
+        FloatPoint pt(x + r * cosf(sa), y + r * sinf(sa));
+        if (!m_path.hasCurrentPoint())
+            m_path.moveTo(pt);
+        else
+            m_path.addLineTo(pt);
         return;
+    }
 
     if (!state().m_invertibleCTM)
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to