- Revision
- 150370
- Author
- mrobin...@webkit.org
- Date
- 2013-05-20 09:39:30 -0700 (Mon, 20 May 2013)
Log Message
[Cairo] Canvas-shadow behavior is not being as expected
https://bugs.webkit.org/show_bug.cgi?id=108897
Patch by Rashmi Shyamasundar <rashmi...@samsung.com> on 2013-05-18
Reviewed by Martin Robinson.
Source/WebCore:
ShadowBlur::endShadowLayer copies the image from shadowContext to cairoContext.
CairoContext-path should be empty for doing this copy. Otherwise, the
original-image area will also get filled with the shadow.
Test: fast/canvas/canvas-image-shadow.html
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::drawPathShadow):
LayoutTests:
Test to verify the shadow of an image drawn on canvas.
This test uses an image whose size is smaller than,
the size of the rectangle which should be filled with the image.
* fast/canvas/canvas-image-shadow-expected.txt: Added.
* fast/canvas/canvas-image-shadow.html: Added.
* fast/canvas/script-tests/canvas-image-shadow.js: Added.
(draw):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (150369 => 150370)
--- trunk/LayoutTests/ChangeLog 2013-05-20 16:21:47 UTC (rev 150369)
+++ trunk/LayoutTests/ChangeLog 2013-05-20 16:39:30 UTC (rev 150370)
@@ -1,3 +1,19 @@
+2013-05-18 Rashmi Shyamasundar <rashmi...@samsung.com>
+
+ [Cairo] Canvas-shadow behavior is not being as expected
+ https://bugs.webkit.org/show_bug.cgi?id=108897
+
+ Reviewed by Martin Robinson.
+
+ Test to verify the shadow of an image drawn on canvas.
+ This test uses an image whose size is smaller than,
+ the size of the rectangle which should be filled with the image.
+
+ * fast/canvas/canvas-image-shadow-expected.txt: Added.
+ * fast/canvas/canvas-image-shadow.html: Added.
+ * fast/canvas/script-tests/canvas-image-shadow.js: Added.
+ (draw):
+
2013-05-20 Christophe Dumez <ch.du...@sisa.samsung.com>
[EFL] Reenabled INDEXED_DATABASE after r150344
Added: trunk/LayoutTests/fast/canvas/canvas-image-shadow-expected.txt (0 => 150370)
--- trunk/LayoutTests/fast/canvas/canvas-image-shadow-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-image-shadow-expected.txt 2013-05-20 16:39:30 UTC (rev 150370)
@@ -0,0 +1,18 @@
+Test to verify the shadow of an image drawn on canvas
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS imgdata[0] is 0
+PASS imgdata[1] is 255
+PASS imgdata[2] is 0
+PASS imgdata[0] is 255
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+PASS imgdata[0] is 0
+PASS imgdata[1] is 0
+PASS imgdata[2] is 0
+
Property changes on: trunk/LayoutTests/fast/canvas/canvas-image-shadow-expected.txt
___________________________________________________________________
Added: svn:executable
Added: svn:eol-style
Added: trunk/LayoutTests/fast/canvas/canvas-image-shadow.html (0 => 150370)
--- trunk/LayoutTests/fast/canvas/canvas-image-shadow.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-image-shadow.html 2013-05-20 16:39:30 UTC (rev 150370)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="myCanvas" width="400" height="400"></canvas>
+<script src=""
+<script src=""
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/canvas/canvas-image-shadow.html
___________________________________________________________________
Added: svn:executable
Added: svn:eol-style
Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-image-shadow.js (0 => 150370)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-image-shadow.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-image-shadow.js 2013-05-20 16:39:30 UTC (rev 150370)
@@ -0,0 +1,48 @@
+description("Test to verify the shadow of an image drawn on canvas");
+
+// Create an auxiliary canvas to draw to and create an image from.
+// This is done instead of simply loading an image from the file system
+// because that would throw a SECURITY_ERR DOM Exception.
+var aCanvas = document.createElement('canvas');
+aCanvas.setAttribute('width', '200');
+aCanvas.setAttribute('height', '200');
+var aCtx = aCanvas.getContext('2d');
+
+// Draw a rectangle on the same canvas.
+aCtx.fillStyle = 'rgb(0, 255, 0)';
+aCtx.rect(0, 0, 100, 50);
+aCtx.fill();
+
+// Create the image object to be drawn on the master canvas.
+var img = new Image();
+img._onload_ = draw;
+img.src = ""
+
+function draw()
+{
+ var canvas = document.getElementById('myCanvas');
+ var ctx = canvas.getContext('2d');
+ ctx.shadowOffsetX = 200;
+ ctx.shadowOffsetY = 50;
+ ctx.fillStyle = ctx.createPattern(img, 'repeat-x');
+ ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ ctx.fillRect(0, 0, 200, 200);
+
+ var imageData = ctx.getImageData(10, 10, 1, 1);
+ imgdata = imageData.data;
+ shouldBe("imgdata[0]", "0");
+ shouldBe("imgdata[1]", "255");
+ shouldBe("imgdata[2]", "0");
+
+ imageData = ctx.getImageData(290, 60, 1, 1);
+ imgdata = imageData.data;
+ shouldBe("imgdata[0]", "255");
+ shouldBe("imgdata[1]", "0");
+ shouldBe("imgdata[2]", "0");
+
+ imageData = ctx.getImageData(90, 60, 1, 1);
+ imgdata = imageData.data;
+ shouldBe("imgdata[0]", "0");
+ shouldBe("imgdata[1]", "0");
+ shouldBe("imgdata[2]", "0");
+}
Property changes on: trunk/LayoutTests/fast/canvas/script-tests/canvas-image-shadow.js
___________________________________________________________________
Added: svn:executable
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (150369 => 150370)
--- trunk/Source/WebCore/ChangeLog 2013-05-20 16:21:47 UTC (rev 150369)
+++ trunk/Source/WebCore/ChangeLog 2013-05-20 16:39:30 UTC (rev 150370)
@@ -1,3 +1,19 @@
+2013-05-18 Rashmi Shyamasundar <rashmi...@samsung.com>
+
+ [Cairo] Canvas-shadow behavior is not being as expected
+ https://bugs.webkit.org/show_bug.cgi?id=108897
+
+ Reviewed by Martin Robinson.
+
+ ShadowBlur::endShadowLayer copies the image from shadowContext to cairoContext.
+ CairoContext-path should be empty for doing this copy. Otherwise, the
+ original-image area will also get filled with the shadow.
+
+ Test: fast/canvas/canvas-image-shadow.html
+
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::drawPathShadow):
+
2013-05-20 Lamarque V. Souza <lamarque.so...@basyskom.com>
-webkit-text-underline-position should not be inherited
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (150369 => 150370)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2013-05-20 16:21:47 UTC (rev 150369)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2013-05-20 16:39:30 UTC (rev 150370)
@@ -141,10 +141,12 @@
cairo_stroke(cairoShadowContext);
}
+ // The original path may still be hanging around on the context and endShadowLayer
+ // will take care of properly creating a path to draw the result shadow. We remove the path
+ // temporarily and then restore it.
+ // See: https://bugs.webkit.org/show_bug.cgi?id=108897
+ cairo_new_path(cairoContext);
shadow.endShadowLayer(context);
-
- // ShadowBlur::endShadowLayer destroys the current path on the Cairo context. We restore it here.
- cairo_new_path(cairoContext);
cairo_append_path(cairoContext, path.get());
}