Title: [172119] trunk
Revision
172119
Author
commit-qu...@webkit.org
Date
2014-08-05 19:19:40 -0700 (Tue, 05 Aug 2014)

Log Message

[CG] strokeRect does not honor lineJoin
https://bugs.webkit.org/show_bug.cgi?id=132948

Patch by Nikos Andronikos <nikos.andronikos-web...@cisra.canon.com.au> on 2014-08-05
Reviewed by Darin Adler.

Source/WebCore:

Replaced use of CGContextStrokeRectWithWidth convenience function with explicit
call to CGContextAddRect and CGContextStrokePath.  The convenience functions
CGContextStrokeRect and CGContextStrokeRectWithWidth fail to apply some attributes
(e.g. stroke join) of the graphics state in certain cases.

Test: fast/canvas/canvas-strokeRect-lineJoin.html

* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::strokeRect):

LayoutTests:

Test behavior of canvas with stroke rect with line join

* fast/canvas/canvas-strokeRect-lineJoin-expected.txt: Added.
* fast/canvas/canvas-strokeRect-lineJoin.html: Added.
* fast/canvas/script-tests/canvas-strokeRect-lineJoin.js: Added.
* platform/mac-mountainlion/canvas/philip/tests/2d.strokeRect.zero.5-expected.txt: Added.
* platform/mac/fast/canvas/canvas-strokeRect-alpha-shadow-expected.txt: Removed.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (172118 => 172119)


--- trunk/LayoutTests/ChangeLog	2014-08-06 01:39:58 UTC (rev 172118)
+++ trunk/LayoutTests/ChangeLog	2014-08-06 02:19:40 UTC (rev 172119)
@@ -1,3 +1,18 @@
+2014-08-05  Nikos Andronikos  <nikos.andronikos-web...@cisra.canon.com.au>
+
+        [CG] strokeRect does not honor lineJoin
+        https://bugs.webkit.org/show_bug.cgi?id=132948
+
+        Reviewed by Darin Adler.
+
+        Test behavior of canvas with stroke rect with line join
+
+        * fast/canvas/canvas-strokeRect-lineJoin-expected.txt: Added.
+        * fast/canvas/canvas-strokeRect-lineJoin.html: Added.
+        * fast/canvas/script-tests/canvas-strokeRect-lineJoin.js: Added.
+        * platform/mac-mountainlion/canvas/philip/tests/2d.strokeRect.zero.5-expected.txt: Added.
+        * platform/mac/fast/canvas/canvas-strokeRect-alpha-shadow-expected.txt: Removed.
+
 2014-08-05  Bem Jones-Bey  <bjone...@adobe.com>
 
         [GTK] [CSS Shapes] Layout test fast/shapes/shape-outside-floats/shape-outside-image-shape-margin.html fails

Added: trunk/LayoutTests/fast/canvas/canvas-strokeRect-lineJoin-expected.txt (0 => 172119)


--- trunk/LayoutTests/fast/canvas/canvas-strokeRect-lineJoin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-strokeRect-lineJoin-expected.txt	2014-08-06 02:19:40 UTC (rev 172119)
@@ -0,0 +1,51 @@
+Ensure correct behavior of canvas with stroke rect with line join
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 255
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 255
+PASS data[0] is not 255
+PASS data[0] is not 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 255
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 255
+PASS data[0] is not 255
+PASS data[0] is not 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS data[0] is 0
+PASS data[0] is 255
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-strokeRect-lineJoin.html (0 => 172119)


--- trunk/LayoutTests/fast/canvas/canvas-strokeRect-lineJoin.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-strokeRect-lineJoin.html	2014-08-06 02:19:40 UTC (rev 172119)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-strokeRect-lineJoin.js (0 => 172119)


--- trunk/LayoutTests/fast/canvas/script-tests/canvas-strokeRect-lineJoin.js	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-strokeRect-lineJoin.js	2014-08-06 02:19:40 UTC (rev 172119)
@@ -0,0 +1,224 @@
+description("Ensure correct behavior of canvas with stroke rect with line join");
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '600');
+canvas.setAttribute('height', '400');
+var ctx = canvas.getContext('2d');
+
+ctx.fillStyle="rgba(255, 255, 255, 1.0)";
+ctx.fillRect(0, 0, canvas.width, canvas.height);
+
+ctx.strokeStyle="rgba(0, 0, 0, 1.0)";
+
+ctx.lineWidth = 20;
+
+ctx.save();
+
+ctx.lineJoin = "miter";
+ctx.translate(20, 20);
+ctx.strokeRect(0, 0, 100, 100);
+
+ctx.lineJoin = "bevel";
+ctx.translate(200, 0);
+ctx.strokeRect(0, 0, 100, 100);
+
+ctx.lineJoin = "round";
+ctx.translate(200, 0);
+ctx.strokeRect(0, 0, 100, 100);
+
+ctx.restore();
+
+ctx.translate(0, 200);
+
+ctx.scale(20, 20);
+
+ctx.lineWidth = 1.0;
+
+ctx.lineJoin = "miter";
+ctx.translate(1, 1);
+ctx.strokeRect(0, 0, 5, 5);
+
+ctx.lineJoin = "bevel";
+ctx.translate(10, 0);
+ctx.strokeRect(0, 0, 5, 5);
+
+ctx.lineJoin = "round";
+ctx.translate(10, 0);
+ctx.strokeRect(0, 0, 5, 5);
+
+var imageData, data;
+
+// Verify Join : miter.
+imageData = ctx.getImageData(10, 10, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(10, 17, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(17, 10, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(20, 20, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(30, 30, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(110, 110, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(129, 129, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+// Verify Join : bevel.
+imageData = ctx.getImageData(210, 10, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(210, 17, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(217, 10, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(220, 20, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(230, 30, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(310, 110, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(329, 129, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+// Verify Join : round.
+imageData = ctx.getImageData(410, 10, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(410, 17, 1, 1);
+data = ""
+shouldNotBe('data[0]', '255');
+
+imageData = ctx.getImageData(417, 10, 1, 1);
+data = ""
+shouldNotBe('data[0]', '255');
+
+imageData = ctx.getImageData(420, 20, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(430, 30, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(510, 110, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(529, 129, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+// Verify Join : miter using scaling.
+imageData = ctx.getImageData(10, 210, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(10, 217, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(17, 210, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(20, 220, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(30, 230, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(110, 310, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(129, 329, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+// Verify Join : bevel using scaling.
+imageData = ctx.getImageData(210, 210, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(210, 217, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(217, 210, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(220, 220, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(230, 230, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(310, 310, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(329, 329, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+// Verify Join : round using scaling.
+imageData = ctx.getImageData(410, 210, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(410, 217, 1, 1);
+data = ""
+shouldNotBe('data[0]', '255');
+
+imageData = ctx.getImageData(417, 210, 1, 1);
+data = ""
+shouldNotBe('data[0]', '255');
+
+imageData = ctx.getImageData(420, 220, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(430, 230, 1, 1);
+data = ""
+shouldBe('data[0]', '255');
+
+imageData = ctx.getImageData(510, 310, 1, 1);
+data = ""
+shouldBe('data[0]', '0');
+
+imageData = ctx.getImageData(529, 329, 1, 1);
+data = ""
+shouldBe('data[0]', '255');

Deleted: trunk/LayoutTests/platform/mac/fast/canvas/canvas-strokeRect-alpha-shadow-expected.txt (172118 => 172119)


--- trunk/LayoutTests/platform/mac/fast/canvas/canvas-strokeRect-alpha-shadow-expected.txt	2014-08-06 01:39:58 UTC (rev 172118)
+++ trunk/LayoutTests/platform/mac/fast/canvas/canvas-strokeRect-alpha-shadow-expected.txt	2014-08-06 02:19:40 UTC (rev 172119)
@@ -1,213 +0,0 @@
-Ensure correct behavior of canvas with strokeRect using a semi-transparent solid strokeStyle and a shadow
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-Verifying alpha shadow...
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
- 
-Verifying blurry shadow...
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
- 
-Verifying rotated alpha shadow...
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
- 
-Verifying rotated blurry shadow...
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 255
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is around 64
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
-FAIL data[0] should be 0. Was 255.
-PASS data[1] is 0
-PASS data[2] is 0
-FAIL data[3] should be 0. Was 1.
-PASS data[0] is 0
-PASS data[1] is 0
-PASS data[2] is 0
-PASS data[3] is 0
- 
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Added: trunk/LayoutTests/platform/mac-mountainlion/canvas/philip/tests/2d.strokeRect.zero.5-expected.txt (0 => 172119)


--- trunk/LayoutTests/platform/mac-mountainlion/canvas/philip/tests/2d.strokeRect.zero.5-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mountainlion/canvas/philip/tests/2d.strokeRect.zero.5-expected.txt	2014-08-06 02:19:40 UTC (rev 172119)
@@ -0,0 +1 @@
+Failed assertion: got pixel [0,0,0,0] at (50,25), expected [0,255,0,255]

Modified: trunk/Source/WebCore/ChangeLog (172118 => 172119)


--- trunk/Source/WebCore/ChangeLog	2014-08-06 01:39:58 UTC (rev 172118)
+++ trunk/Source/WebCore/ChangeLog	2014-08-06 02:19:40 UTC (rev 172119)
@@ -1,3 +1,20 @@
+2014-08-05  Nikos Andronikos  <nikos.andronikos-web...@cisra.canon.com.au>
+
+        [CG] strokeRect does not honor lineJoin
+        https://bugs.webkit.org/show_bug.cgi?id=132948
+
+        Reviewed by Darin Adler.
+
+        Replaced use of CGContextStrokeRectWithWidth convenience function with explicit 
+        call to CGContextAddRect and CGContextStrokePath.  The convenience functions
+        CGContextStrokeRect and CGContextStrokeRectWithWidth fail to apply some attributes
+        (e.g. stroke join) of the graphics state in certain cases.
+
+        Test: fast/canvas/canvas-strokeRect-lineJoin.html
+
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::strokeRect):
+
 2014-08-05  Brent Fulgham  <bfulg...@apple.com>
 
         [Win] Build attempts to use ANGLE when not building WebGL.

Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (172118 => 172119)


--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp	2014-08-06 01:39:58 UTC (rev 172118)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp	2014-08-06 02:19:40 UTC (rev 172119)
@@ -1161,7 +1161,19 @@
 
     if (m_state.strokePattern)
         applyStrokePattern();
-    CGContextStrokeRectWithWidth(context, rect, lineWidth);
+
+    // Using CGContextAddRect and CGContextStrokePath to stroke rect rather than
+    // convenience functions (CGContextStrokeRect/CGContextStrokeRectWithWidth).
+    // The convenience functions currently (in at least OSX 10.9.4) fail to
+    // apply some attributes of the graphics state in certain cases
+    // (as identified in https://bugs.webkit.org/show_bug.cgi?id=132948)
+    CGContextSaveGState(context);
+    setStrokeThickness(lineWidth);
+
+    CGContextAddRect(context, rect);
+    CGContextStrokePath(context);
+
+    CGContextRestoreGState(context);
 }
 
 void GraphicsContext::setLineCap(LineCap cap)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to