[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 17:47:23 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit a5ff9136aeedf3f209f79e3e1edd49619e87e225
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 30 10:20:10 2010 +0000

    2010-11-30  Helder Correia  <helder at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Path stroke shadow has incorrect behavior when using ctx.scale(x,y)
            https://bugs.webkit.org/show_bug.cgi?id=50198
    
            New fast canvas test to ensure correct behavior of path stroke shadow
            when using scaling.
    
            * fast/canvas/canvas-scale-strokePath-shadow-expected.txt: Added.
            * fast/canvas/canvas-scale-strokePath-shadow.html: Added.
            * fast/canvas/script-tests/canvas-scale-strokePath-shadow.js: Added.
    2010-11-30  Helder Correia  <helder at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] Path stroke shadow has incorrect behavior when using ctx.scale(x,y)
            https://bugs.webkit.org/show_bug.cgi?id=50198
    
            Handle the special case when scaling is used and translate the shadow
            offset accordingly. The correct behavior is ensured in ContextShadow
            already, the issue only happens when using a non-blur shadow.
    
            Test: fast/canvas/canvas-scale-strokePath-shadow.html
    
            * platform/graphics/qt/GraphicsContextQt.cpp:
            (WebCore::GraphicsContext::strokePath):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72900 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 7d247a5..5ed6719 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-11-30  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Path stroke shadow has incorrect behavior when using ctx.scale(x,y)
+        https://bugs.webkit.org/show_bug.cgi?id=50198
+
+        New fast canvas test to ensure correct behavior of path stroke shadow
+        when using scaling.
+
+        * fast/canvas/canvas-scale-strokePath-shadow-expected.txt: Added.
+        * fast/canvas/canvas-scale-strokePath-shadow.html: Added.
+        * fast/canvas/script-tests/canvas-scale-strokePath-shadow.js: Added.
+
 2010-11-30  Nikolas Zimmermann  <nzimmermann at rim.com>
 
         Not reviewed.
diff --git a/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt b/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
new file mode 100644
index 0000000..e56201f
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
@@ -0,0 +1,57 @@
+Ensure correct behavior of canvas with path stroke + shadow after scaling. A blue and red checkered pattern should be displayed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 255
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 255
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 255
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 76
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 76
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 76
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 20
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 22
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 28
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 22
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 15
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 17
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html b/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow.html
new file mode 100644
index 0000000..e32403e
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-scale-strokePath-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-scale-strokePath-shadow.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js b/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
new file mode 100644
index 0000000..5198d94
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
@@ -0,0 +1,154 @@
+description("Ensure correct behavior of canvas with path stroke + shadow after scaling. A blue and red checkered pattern should be displayed.");
+
+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) < 10)
+        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', '1000');
+canvas.setAttribute('height', '1000');
+var ctx = canvas.getContext('2d');
+
+ctx.scale(2, 2);
+ctx.shadowOffsetX = 100;
+ctx.shadowOffsetY = 100;
+ctx.strokeStyle = 'rgba(0, 0, 255, 1)';
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.beginPath();
+ctx.moveTo(50, 50);
+ctx.lineTo(100, 50);
+ctx.lineTo(100, 100);
+ctx.lineTo(50, 100);
+ctx.lineTo(50, 50);
+ctx.stroke();
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
+ctx.beginPath();
+ctx.moveTo(50, 150);
+ctx.lineTo(100, 150);
+ctx.lineTo(100, 200);
+ctx.lineTo(50, 200);
+ctx.lineTo(50, 150);
+ctx.stroke();
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.shadowBlur = 10;
+ctx.beginPath();
+ctx.moveTo(150, 50);
+ctx.lineTo(200, 50);
+ctx.lineTo(200, 100);
+ctx.lineTo(150, 100);
+ctx.lineTo(150, 50);
+ctx.stroke();
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.6)';
+ctx.beginPath();
+ctx.moveTo(150, 150);
+ctx.lineTo(200, 150);
+ctx.lineTo(200, 200);
+ctx.lineTo(150, 200);
+ctx.lineTo(150, 150);
+ctx.stroke();
+
+var d; // imageData.data
+
+// Verify solid shadow.
+d = ctx.getImageData(200, 205, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '255');
+
+d = ctx.getImageData(299, 295, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '255');
+
+d = ctx.getImageData(201, 299, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '255');
+
+// Verify solid alpha shadow.
+d = ctx.getImageData(200, 405, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '76');
+
+d = ctx.getImageData(299, 405, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '76');
+
+d = ctx.getImageData(205, 499, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '76');
+
+// Verify blurry shadow.
+d = ctx.getImageData(394, 208, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '20');
+
+d = ctx.getImageData(503, 301, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '22');
+
+d = ctx.getImageData(504, 250, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '28');
+
+// Verify blurry alpha shadow.
+d = ctx.getImageData(405, 405, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '22');
+
+d = ctx.getImageData(415, 495, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '15');
+
+d = ctx.getImageData(450, 504, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '17');
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 34f0783..0362f29 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -2,6 +2,22 @@
 
         Reviewed by Kenneth Rohde Christiansen.
 
+        [Qt] Path stroke shadow has incorrect behavior when using ctx.scale(x,y)
+        https://bugs.webkit.org/show_bug.cgi?id=50198
+
+        Handle the special case when scaling is used and translate the shadow
+        offset accordingly. The correct behavior is ensured in ContextShadow
+        already, the issue only happens when using a non-blur shadow.
+
+        Test: fast/canvas/canvas-scale-strokePath-shadow.html
+
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::strokePath):
+
+2010-11-30  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
         [Qt] Path filling should keep shadow offset after context scaling
         https://bugs.webkit.org/show_bug.cgi?id=50194
 
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index de6892e..eafbc15 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -584,9 +584,21 @@ void GraphicsContext::strokePath()
         {
             QPen shadowPen(pen);
             shadowPen.setColor(m_data->shadow.m_color);
-            p->translate(m_data->shadow.offset());
-            p->strokePath(path, shadowPen);
-            p->translate(-m_data->shadow.offset());
+            QPointF offset = shadow->offset();
+            const QTransform transform = p->transform();
+            if (transform.isScaling()) {
+                // If scaling is required, find the new coord for shadow origin,
+                // so that the relative offset to its shape is kept.
+                QPointF translatedOffset(offset.x() / transform.m11(),
+                                         offset.y() / transform.m22());
+                path.translate(translatedOffset);
+                p->strokePath(path, shadowPen);
+                path.translate(-translatedOffset);
+            } else {
+                p->translate(offset);
+                p->strokePath(path, shadowPen);
+                p->translate(-offset);
+            }
         } else {
             FloatRect boundingRect = path.controlPointRect();
             boundingRect.inflate(pen.miterLimit() + pen.widthF());

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list