[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

commit-queue at webkit.org commit-queue at webkit.org
Sun Feb 20 22:59:21 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 7240bdccea585c45428b51aa9387c7fbfb55d229
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 14 23:46:58 2011 +0000

    2011-01-14  Helder Correia  <helder at sencha.com>
    
            Reviewed by Simon Fraser.
    
            Shadow is not drawn when filling a path with a gradient
            https://bugs.webkit.org/show_bug.cgi?id=51982
    
            This happens in CG and is related to bug 51869, this time to be fixed
            in GraphicsContext::fillPath(const Path& path). We need to draw the
            gradient clipped to the path on a CGLayer first, and then draw the
            layer on the GraphicsContext.
    
            * fast/canvas/canvas-fillPath-gradient-shadow-expected.txt: Added.
            * fast/canvas/canvas-fillPath-gradient-shadow.html: Added.
            * fast/canvas/script-tests/canvas-fillPath-gradient-shadow.js: Added.
            * platform/chromium/test_expectations.txt: Skipping new test since it fails.
            * platform/qt/Skipped: Ditto.
    2011-01-14  Helder Correia  <helder at sencha.com>
    
            Reviewed by Simon Fraser.
    
            Shadow is not drawn when filling a path with a gradient
            https://bugs.webkit.org/show_bug.cgi?id=51982
    
            This happens in CG and is related to bug 51869, this time to be fixed
            in GraphicsContext::fillPath(const Path& path). We need to draw the
            gradient clipped to the path on a CGLayer first, and then draw the
            layer on the GraphicsContext.
    
            Test: fast/canvas/canvas-fillPath-gradient-shadow.html
    
            * platform/graphics/cg/GraphicsContextCG.cpp:
            (WebCore::GraphicsContext::fillPath):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75833 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 204d94b..59c8c4e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2011-01-14  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Simon Fraser.
+
+        Shadow is not drawn when filling a path with a gradient
+        https://bugs.webkit.org/show_bug.cgi?id=51982
+
+        This happens in CG and is related to bug 51869, this time to be fixed
+        in GraphicsContext::fillPath(const Path& path). We need to draw the
+        gradient clipped to the path on a CGLayer first, and then draw the
+        layer on the GraphicsContext.
+
+        * fast/canvas/canvas-fillPath-gradient-shadow-expected.txt: Added.
+        * fast/canvas/canvas-fillPath-gradient-shadow.html: Added.
+        * fast/canvas/script-tests/canvas-fillPath-gradient-shadow.js: Added.
+        * platform/chromium/test_expectations.txt: Skipping new test since it fails.
+        * platform/qt/Skipped: Ditto.
+
 2011-01-14  Mihai Parparita  <mihaip at chromium.org>
 
         Update the pixel expectations for the chromium-mac port.
diff --git a/LayoutTests/fast/canvas/canvas-fillPath-gradient-shadow-expected.txt b/LayoutTests/fast/canvas/canvas-fillPath-gradient-shadow-expected.txt
new file mode 100644
index 0000000..a2ebbdb
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-fillPath-gradient-shadow-expected.txt
@@ -0,0 +1,97 @@
+Ensure correct behavior of canvas with fillPath using a gradient fillStyle 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 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
+ 
+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 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+PASS data[0] is 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+PASS data[0] is 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+PASS data[0] is 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+ 
+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 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
+ 
+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 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+PASS data[0] is 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+PASS data[0] is 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+PASS data[0] is 255
+PASS data[1] is 0
+PASS data[2] is 0
+PASS data[3] is around 31
+ 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/canvas-fillPath-gradient-shadow.html b/LayoutTests/fast/canvas/canvas-fillPath-gradient-shadow.html
new file mode 100644
index 0000000..3d2320d
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-fillPath-gradient-shadow.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/canvas-fillPath-gradient-shadow.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-fillPath-gradient-shadow.js b/LayoutTests/fast/canvas/script-tests/canvas-fillPath-gradient-shadow.js
new file mode 100644
index 0000000..dd0ac60
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-fillPath-gradient-shadow.js
@@ -0,0 +1,118 @@
+description("Ensure correct behavior of canvas with fillPath using a gradient fillStyle and a shadow");
+
+function print(message, color)
+{
+    var paragraph = document.createElement("div");
+    paragraph.appendChild(document.createTextNode(message));
+    paragraph.style.fontFamily = "monospace";
+    if (color)
+        paragraph.style.color = color;
+    document.getElementById("console").appendChild(paragraph);
+}
+
+function shouldBeAround(a, b)
+{
+    var evalA;
+    try {
+        evalA = eval(a);
+    } catch(e) {
+        evalA = e;
+    }
+
+    if (Math.abs(evalA - b) < 15)
+        print("PASS " + a + " is around " + b , "green")
+    else
+        print("FAIL " + a + " is not around " + b + " (actual: " + evalA + ")", "red");
+}
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+canvas.setAttribute('width', '600');
+canvas.setAttribute('height', '1100');
+var ctx = canvas.getContext('2d');
+
+var gradient = ctx.createLinearGradient(0, 0, 300, 0);
+gradient.addColorStop(0, 'rgba(0, 0, 255, 0.5)');
+gradient.addColorStop(1, 'rgba(0, 0, 255, 0.5)');
+
+ctx.save();
+ctx.fillStyle = gradient;
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.shadowOffsetX = 250;
+
+function fillShape(x, y) {
+    ctx.beginPath();
+    ctx.arc(x, y, 100, 0, Math.PI*2, true);
+    ctx.arc(x, y, 50,  0, Math.PI*2, false);
+    ctx.fill();
+}
+
+// Alpha shadow.
+ctx.shadowBlur = 0;
+fillShape(150, 150);
+
+// Blurry shadow.
+ctx.shadowBlur = 10;
+fillShape(150, 400);
+
+ctx.rotate(Math.PI/2);
+
+// Rotated alpha shadow.
+ctx.shadowBlur = 0;
+fillShape(650, -150);
+
+// Rotated blurry shadow.
+ctx.shadowBlur = 10;
+fillShape(900, -150);
+
+ctx.restore();
+
+var imageData, data;
+ctx.fillStyle = 'black';
+
+function test(alphaTestFunction, x, y, r, g, b, a) {
+    // Get pixel.
+    imageData = ctx.getImageData(x, y, 1, 1);
+    data = imageData.data;
+    // Test pixel color components.
+    shouldBe('data[0]', r+'');
+    shouldBe('data[1]', g+'');
+    shouldBe('data[2]', b+'');
+    alphaTestFunction('data[3]', a+'');
+    // Plot test point.
+    ctx.fillRect(x, y, 3, 3);
+}
+
+print('Verifying alpha shadow...');
+test(shouldBe, 400, 150, 0, 0, 0, 0);
+test(shouldBeAround, 400, 75, 255,  0, 0, 64);
+test(shouldBeAround, 400, 225, 255, 0, 0, 64);
+test(shouldBeAround, 325, 150, 255, 0, 0, 64);
+test(shouldBeAround, 475, 150, 255, 0, 0, 64);
+
+print(' ');
+print('Verifying blurry shadow...');
+test(shouldBe, 400, 400, 0, 0, 0, 0);
+test(shouldBeAround, 400, 300, 255, 0, 0, 31);
+test(shouldBeAround, 400, 500, 255, 0, 0, 31);
+test(shouldBeAround, 300, 400, 255, 0, 0, 31);
+test(shouldBeAround, 500, 400, 255, 0, 0, 31);
+
+print(' ');
+print('Verifying rotated alpha shadow...');
+test(shouldBe, 400, 650, 0, 0, 0, 0);
+test(shouldBeAround, 400, 575, 255, 0, 0, 64);
+test(shouldBeAround, 400, 725, 255, 0, 0, 64);
+test(shouldBeAround, 325, 650, 255, 0, 0, 64);
+test(shouldBeAround, 475, 650, 255, 0, 0, 64);
+
+print(' ');
+print('Verifying rotated blurry shadow...');
+test(shouldBe, 400, 900, 0, 0, 0, 0);
+test(shouldBeAround, 400, 800, 255, 0, 0, 31);
+test(shouldBeAround, 400, 1000, 255, 0, 0, 31);
+test(shouldBeAround, 300, 900, 255, 0, 0, 31);
+test(shouldBeAround, 500, 900, 255, 0, 0, 31);
+
+print(' ');
+var successfullyParsed = true;
diff --git a/LayoutTests/platform/chromium/test_expectations.txt b/LayoutTests/platform/chromium/test_expectations.txt
index 0e83e11..8e21f80 100644
--- a/LayoutTests/platform/chromium/test_expectations.txt
+++ b/LayoutTests/platform/chromium/test_expectations.txt
@@ -1297,6 +1297,7 @@ BUGCR23477 MAC : fast/canvas/canvas-as-image-incremental-repaint.html = IMAGE
 BUGCR23477 MAC : fast/canvas/canvas-incremental-repaint.html = IMAGE
 BUGCR23477 MAC : fast/canvas/fill-stroke-clip-reset-path.html = IMAGE
 BUGCR23477 MAC : fast/dynamic/containing-block-change.html = IMAGE
+BUGWK51982 LINUX WIN : fast/canvas/canvas-fillPath-gradient-shadow.html = FAIL
 
 // Unexpected gray
 BUGCR23476 MAC : fast/forms/listbox-clip.html = IMAGE
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index ff8a8fc..583beae 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -2367,6 +2367,7 @@ fast/text/large-text-composed-char-dos.html
 fast/text/international/002.html
 fast/block/positioning/absolute-in-inline-rtl-4.html
 fast/canvas/canvas-gradient-addStop-error.html
+fast/canvas/canvas-fillPath-gradient-shadow.html
 fast/css/zoom-body-scroll.html
 fast/dom/Element/getBoundingClientRect.html
 fast/dom/Element/getClientRects.html
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index cad8d21..11ba9af 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2011-01-14  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Simon Fraser.
+
+        Shadow is not drawn when filling a path with a gradient
+        https://bugs.webkit.org/show_bug.cgi?id=51982
+
+        This happens in CG and is related to bug 51869, this time to be fixed
+        in GraphicsContext::fillPath(const Path& path). We need to draw the
+        gradient clipped to the path on a CGLayer first, and then draw the
+        layer on the GraphicsContext.
+
+        Test: fast/canvas/canvas-fillPath-gradient-shadow.html
+
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::fillPath):
+
 2011-01-14  Simon Fraser  <simon.fraser at apple.com>
 
         Reviewed by Adam Roben.
diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
index acd912f..eddf735 100644
--- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
@@ -546,21 +546,46 @@ void GraphicsContext::fillPath(const Path& path)
 
     CGContextRef context = platformContext();
 
-    CGContextBeginPath(context);
-    CGContextAddPath(context, path.platformPath());
-
     if (m_state.fillGradient) {
-        CGContextSaveGState(context);
-        if (fillRule() == RULE_EVENODD)
-            CGContextEOClip(context);
-        else
-            CGContextClip(context);
-        CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
-        m_state.fillGradient->paint(this);
-        CGContextRestoreGState(context);
+        if (hasShadow()) {
+            FloatRect rect = path.boundingRect();
+            CGLayerRef layer = CGLayerCreateWithContext(context, CGSizeMake(rect.width(), rect.height()), 0);
+            CGContextRef layerContext = CGLayerGetContext(layer);
+
+            CGContextTranslateCTM(layerContext, -rect.x(), -rect.y());
+            CGContextBeginPath(layerContext);
+            CGContextAddPath(layerContext, path.platformPath());
+            CGContextConcatCTM(layerContext, m_state.fillGradient->gradientSpaceTransform());
+
+            if (fillRule() == RULE_EVENODD)
+                CGContextEOClip(layerContext);
+            else
+                CGContextClip(layerContext);
+
+            m_state.fillGradient->paint(layerContext);
+            CGContextDrawLayerAtPoint(context, CGPointMake(rect.left(), rect.top()), layer);
+            CGLayerRelease(layer);
+        } else {
+            CGContextBeginPath(context);
+            CGContextAddPath(context, path.platformPath());
+            CGContextSaveGState(context);
+            CGContextConcatCTM(context, m_state.fillGradient->gradientSpaceTransform());
+
+            if (fillRule() == RULE_EVENODD)
+                CGContextEOClip(context);
+            else
+                CGContextClip(context);
+
+            m_state.fillGradient->paint(this);
+            CGContextRestoreGState(context);
+        }
+
         return;
     }
 
+    CGContextBeginPath(context);
+    CGContextAddPath(context, path.platformPath());
+
     if (m_state.fillPattern)
         applyFillPattern();
     fillPathWithFillRule(context, fillRule());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list