Title: [226443] trunk
Revision
226443
Author
[email protected]
Date
2018-01-05 03:41:18 -0800 (Fri, 05 Jan 2018)

Log Message

[Cairo] Canvas: Path::clear should clear its transform
https://bugs.webkit.org/show_bug.cgi?id=181320

Patch by Fujii Hironori <[email protected]> on 2018-01-05
Reviewed by Carlos Garcia Campos.

Source/WebCore:

Path of Cairo port has its cairo context. Path::clear() didn't
clear the transform matrix of the context.

Test: fast/canvas/reset-scaling-by-height-change.html

* platform/graphics/cairo/PathCairo.cpp:
(WebCore::Path::clear): Reset the transform matrix of Path.

LayoutTests:

* fast/canvas/reset-scaling-by-height-change-expected.txt: Added.
* fast/canvas/reset-scaling-by-height-change.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226442 => 226443)


--- trunk/LayoutTests/ChangeLog	2018-01-05 11:11:44 UTC (rev 226442)
+++ trunk/LayoutTests/ChangeLog	2018-01-05 11:41:18 UTC (rev 226443)
@@ -1,3 +1,13 @@
+2018-01-05  Fujii Hironori  <[email protected]>
+
+        [Cairo] Canvas: Path::clear should clear its transform
+        https://bugs.webkit.org/show_bug.cgi?id=181320
+
+        Reviewed by Carlos Garcia Campos.
+
+        * fast/canvas/reset-scaling-by-height-change-expected.txt: Added.
+        * fast/canvas/reset-scaling-by-height-change.html: Added.
+
 2018-01-04  Joseph Pecoraro  <[email protected]>
 
         REGRESSION (r225709): Web Inspector: CSS Source maps not loading

Added: trunk/LayoutTests/fast/canvas/reset-scaling-by-height-change-expected.txt (0 => 226443)


--- trunk/LayoutTests/fast/canvas/reset-scaling-by-height-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/reset-scaling-by-height-change-expected.txt	2018-01-05 11:41:18 UTC (rev 226443)
@@ -0,0 +1,11 @@
+The test to ensure resetting scaling by height change
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS false is false
+PASS false is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/reset-scaling-by-height-change.html (0 => 226443)


--- trunk/LayoutTests/fast/canvas/reset-scaling-by-height-change.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/reset-scaling-by-height-change.html	2018-01-05 11:41:18 UTC (rev 226443)
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas></canvas>
+<script>
+
+description("The test to ensure resetting scaling by height change");
+
+function assertPixelApprox(ctx, x,y, r,g,b,a, tolerance)
+{
+    var imgdata = ctx.getImageData(x, y, 1, 1);
+    var diff = Math.max(Math.abs(r-imgdata.data[0]), Math.abs(g-imgdata.data[1]), Math.abs(b-imgdata.data[2]), Math.abs(a-imgdata.data[3]));
+    shouldBeFalse((diff > tolerance).toString());
+}
+
+function quadToPath(quad)
+{
+    ctx.beginPath();
+    ctx.moveTo(quad[0].x, quad[0].y);
+    ctx.lineTo(quad[1].x, quad[1].y);
+    ctx.lineTo(quad[2].x, quad[2].y);
+    ctx.lineTo(quad[3].x, quad[3].y);
+    ctx.closePath();
+}
+
+window.canvas = document.querySelector("canvas");
+window.ctx = canvas.getContext("2d");
+
+for (var i=0; i<100; i++) {
+    ctx.scale(10, 10);
+}
+// Setting width or height resets the transform of the canvas context
+canvas.width = 200;
+canvas.height = 100;
+
+quadToPath([{x:0,y:0},{x:0,y:100},{x:100,y:100},{x:100,y:0}]);
+ctx.fillStyle = 'rgb(0, 255, 0)';
+ctx.fill();
+
+assertPixelApprox(ctx, 50, 50, 0, 255, 0, 255, 0);
+assertPixelApprox(ctx, 150, 50, 0, 0, 0, 0, 0);
+
+</script>
+<script src=""
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (226442 => 226443)


--- trunk/Source/WebCore/ChangeLog	2018-01-05 11:11:44 UTC (rev 226442)
+++ trunk/Source/WebCore/ChangeLog	2018-01-05 11:41:18 UTC (rev 226443)
@@ -1,3 +1,18 @@
+2018-01-05  Fujii Hironori  <[email protected]>
+
+        [Cairo] Canvas: Path::clear should clear its transform
+        https://bugs.webkit.org/show_bug.cgi?id=181320
+
+        Reviewed by Carlos Garcia Campos.
+
+        Path of Cairo port has its cairo context. Path::clear() didn't
+        clear the transform matrix of the context.
+
+        Test: fast/canvas/reset-scaling-by-height-change.html
+
+        * platform/graphics/cairo/PathCairo.cpp:
+        (WebCore::Path::clear): Reset the transform matrix of Path.
+
 2018-01-04  Devin Rousso  <[email protected]>
 
         Web Inspector: replace HTMLCanvasElement with CanvasRenderingContext for instrumentation logic

Modified: trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp (226442 => 226443)


--- trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp	2018-01-05 11:11:44 UTC (rev 226442)
+++ trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp	2018-01-05 11:41:18 UTC (rev 226443)
@@ -113,6 +113,7 @@
         return;
 
     cairo_t* cr = platformPath()->context();
+    cairo_identity_matrix(cr);
     cairo_new_path(cr);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to