[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 23:10:32 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 6f93041c59ef2e9cb381c1a0bf49c02e3f3dc0f6
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 18 18:10:37 2011 +0000

    2011-01-18  Helder Correia  <helder at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Incorrect shadow alpha with semi-transparent solid fillStyle
            https://bugs.webkit.org/show_bug.cgi?id=52611
    
            This is related to bug 52559. The shadow color alpha must be multiplied
            by the context brush alpha.
    
            New test to ensure correct behavior of canvas with fillPath using a
            semi-transparent fillStyle color and a shadow.
    
            * fast/canvas/canvas-fillPath-alpha-shadow-expected.txt: Added.
            * fast/canvas/canvas-fillPath-alpha-shadow.html: Added.
            * fast/canvas/script-tests/canvas-fillPath-alpha-shadow.js: Added.
    2011-01-18  Helder Correia  <helder at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Incorrect shadow alpha with semi-transparent solid fillStyle
            https://bugs.webkit.org/show_bug.cgi?id=52611
    
            This is related to bug 52559. The shadow color alpha must be multiplied
            by the context brush alpha.
    
            Test: fast/canvas/canvas-fillPath-alpha-shadow.html
    
            * platform/graphics/qt/GraphicsContextQt.cpp:
            (WebCore::GraphicsContext::fillPath):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76033 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 5444c5e..a7dc6cc 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,20 @@
+2011-01-18  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Incorrect shadow alpha with semi-transparent solid fillStyle
+        https://bugs.webkit.org/show_bug.cgi?id=52611
+
+        This is related to bug 52559. The shadow color alpha must be multiplied
+        by the context brush alpha.
+
+        New test to ensure correct behavior of canvas with fillPath using a
+        semi-transparent fillStyle color and a shadow.
+
+        * fast/canvas/canvas-fillPath-alpha-shadow-expected.txt: Added.
+        * fast/canvas/canvas-fillPath-alpha-shadow.html: Added.
+        * fast/canvas/script-tests/canvas-fillPath-alpha-shadow.js: Added.
+
 2011-01-18  John Knottenbelt  <jknotten at chromium.org>
 
         Unreviewed; updated chromium test expectations.
diff --git a/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow-expected.txt b/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow-expected.txt
new file mode 100644
index 0000000..ef7d6cd
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow-expected.txt
@@ -0,0 +1,97 @@
+Ensure correct behavior of canvas with fillPath using a fillStyle color with alpha 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-alpha-shadow.html b/LayoutTests/fast/canvas/canvas-fillPath-alpha-shadow.html
new file mode 100644
index 0000000..e3feb39
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-fillPath-alpha-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-alpha-shadow.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-fillPath-alpha-shadow.js b/LayoutTests/fast/canvas/script-tests/canvas-fillPath-alpha-shadow.js
new file mode 100644
index 0000000..2aadc3e
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-fillPath-alpha-shadow.js
@@ -0,0 +1,114 @@
+description("Ensure correct behavior of canvas with fillPath using a fillStyle color with alpha 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');
+
+ctx.save();
+ctx.fillStyle = 'rgba(0, 0, 255, 0.5)';
+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/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index c16b9dc..a15a746 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-18  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Incorrect shadow alpha with semi-transparent solid fillStyle
+        https://bugs.webkit.org/show_bug.cgi?id=52611
+
+        This is related to bug 52559. The shadow color alpha must be multiplied
+        by the context brush alpha.
+
+        Test: fast/canvas/canvas-fillPath-alpha-shadow.html
+
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::fillPath):
+
 2011-01-18  Andrey Kosyakov  <caseq at chromium.org>
 
         Reviewed by Yury Semikhatsky.
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index 253cd84..33731dd 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -8,7 +8,7 @@
  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
  * Copyright (C) 2008 Dirk Schulze <vbs85 at gmx.de>
- * Copyright (C) 2010 Sencha, Inc.
+ * Copyright (C) 2010, 2011 Sencha, Inc.
  *
  * All rights reserved.
  *
@@ -505,14 +505,19 @@ void GraphicsContext::fillPath(const Path& path)
                     brush.setTransform(m_state.fillGradient->gradientSpaceTransform());
                     shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
                     shadowPainter->fillPath(platformPath, brush);
-                } else
-                    shadowPainter->fillPath(platformPath, QColor(shadow->m_color));
+                } else {
+                    QColor shadowColor = shadow->m_color;
+                    shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF());
+                    shadowPainter->fillPath(platformPath, shadowColor);
+                }
                 shadow->endShadowLayer(this);
             }
         } else {
             QPointF offset = shadow->offset();
             p->translate(offset);
-            p->fillPath(platformPath, QColor(shadow->m_color));
+            QColor shadowColor = shadow->m_color;
+            shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF());
+            p->fillPath(platformPath, shadowColor);
             p->translate(-offset);
         }
     }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list