Added: trunk/LayoutTests/fast/canvas/canvas-gradient-on-compositing-expected.txt (0 => 166785)
--- trunk/LayoutTests/fast/canvas/canvas-gradient-on-compositing-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-gradient-on-compositing-expected.txt 2014-04-04 16:41:09 UTC (rev 166785)
@@ -0,0 +1,11 @@
+Test that compositing does not influence the gradient space to context space mapping.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS getPixel(125,50) is [0,0,0,0]
+PASS getPixel(175,50) is [0,128,0,255]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-gradient-on-compositing.js (0 => 166785)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-gradient-on-compositing.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-gradient-on-compositing.js 2014-04-04 16:41:09 UTC (rev 166785)
@@ -0,0 +1,45 @@
+description("Test that compositing does not influence the gradient space to context space mapping.");
+var ctx = document.createElement('canvas').getContext('2d');
+
+function dataToArray(data) {
+ var result = new Array(data.length)
+ for (var i = 0; i < data.length; i++)
+ result[i] = data[i];
+ return result;
+}
+
+function getPixel(x, y) {
+ var data = ""
+ if (!data) // getImageData failed, which should never happen
+ return [-1,-1,-1,-1];
+ return dataToArray(data.data);
+}
+
+function pixelShouldBe(x, y, colour) {
+ shouldBe("getPixel(" + [x, y] +")", "["+colour+"]");
+}
+
+var grad = ctx.createLinearGradient(100,0,200,0);
+grad.addColorStop(0, 'rgba(0,0,0,0)');
+grad.addColorStop(0.5, 'rgba(0,0,0,0)');
+grad.addColorStop(0.5, 'rgba(0,128,0,1)');
+grad.addColorStop(1, 'rgba(0,128,0,1)');
+
+ctx.fillStyle = "rgba(0,0,0,0)";
+ctx.beginPath();
+ctx.moveTo(100,0);
+ctx.rect(100,0,100,100);
+ctx.closePath();
+ctx.fill();
+
+ctx.globalCompositeOperation = 'destination-atop';
+
+ctx.fillStyle = grad;
+ctx.beginPath();
+ctx.moveTo(100,0);
+ctx.rect(100,0,100,100);
+ctx.closePath();
+ctx.fill();
+
+pixelShouldBe(125,50,[0,0,0,0]);
+pixelShouldBe(175,50,[0,128,0,255]);
Modified: trunk/Source/WebCore/ChangeLog (166784 => 166785)
--- trunk/Source/WebCore/ChangeLog 2014-04-04 16:30:18 UTC (rev 166784)
+++ trunk/Source/WebCore/ChangeLog 2014-04-04 16:41:09 UTC (rev 166785)
@@ -1,3 +1,19 @@
+2014-04-04 Dirk Schulze <k...@webkit.org>
+
+ Gradient offsets are off if compositing operator != source-over
+ https://bugs.webkit.org/show_bug.cgi?id=129791
+
+ Reviewed by Andreas Kling.
+
+ Instead of transforming the path before drawing it on the context,
+ the whole context should be transformed. This will make the gradient
+ map correctly to the context space.
+
+ Test: fast/canvas/canvas-gradient-on-compositing.html
+
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::fullCanvasCompositedFill):
+
2014-04-04 Zalan Bujtas <za...@apple.com>
Subpixel rendering: Move background images to device pixel boundaries.
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (166784 => 166785)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2014-04-04 16:30:18 UTC (rev 166784)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2014-04-04 16:41:09 UTC (rev 166785)
@@ -1679,10 +1679,10 @@
return;
Path path = transformAreaToDevice(area);
- path.translate(FloatSize(-bufferRect.x(), -bufferRect.y()));
-
buffer->context()->setCompositeOperation(CompositeSourceOver);
+ buffer->context()->translate(FloatSize(-bufferRect.x(), -bufferRect.y()));
modifiableState().m_fillStyle.applyFillColor(buffer->context());
+
buffer->context()->fillPath(path);
compositeBuffer(buffer.get(), bufferRect, state().m_globalComposite);