[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 18:48:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit dc437f7c6ceedd1c1d5369d1cb18104abd6a8b54
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 20 01:02:20 2010 +0000

    2010-12-19  Helder Correia  <helder at sencha.com>
    
            Reviewed by Ariya Hidayat.
    
            [Qt] Blur distance should not be affected by transformations
            https://bugs.webkit.org/show_bug.cgi?id=51161
    
            From the spec at http://dev.w3.org/html5/2dcontext/#dom-context-2d-shadowblur:
            "The shadowBlur attribute specifies the level of the blurring effect.
            (The units do not map to coordinate space units, and are not affected
            by the current transformation matrix.)"
    
            Add test to ensure that the blur radius is not affected by the CTM.
    
            * fast/canvas/canvas-scale-shadowBlur-expected.txt: Added.
            * fast/canvas/canvas-scale-shadowBlur.html: Added.
            * fast/canvas/canvas-scale-strokePath-shadow-expected.txt: Increase
              shadowBlur and test tolerance to ease testing and support the
              different blurring algorithms.
            * fast/canvas/script-tests/canvas-scale-shadowBlur.js: Added.
            * fast/canvas/script-tests/canvas-scale-strokePath-shadow.js:
    2010-12-19  Helder Correia  <helder at sencha.com>
    
            Reviewed by Ariya Hidayat.
    
            [Qt] Blur distance should not be affected by transformations
            https://bugs.webkit.org/show_bug.cgi?id=51161
    
            From the spec at http://dev.w3.org/html5/2dcontext/#dom-context-2d-shadowblur:
            "The shadowBlur attribute specifies the level of the blurring effect.
            (The units do not map to coordinate space units, and are not affected
            by the current transformation matrix.)"
    
            Test: fast/canvas/canvas-scale-shadowBlur.html
    
            * platform/graphics/ContextShadow.cpp:
            (WebCore::ContextShadow::adjustBlurDistance):
            * platform/graphics/ContextShadow.h:
            * platform/graphics/cairo/ContextShadowCairo.cpp:
            (WebCore::ContextShadow::beginShadowLayer):
            * platform/graphics/qt/ContextShadowQt.cpp:
            (WebCore::ContextShadow::beginShadowLayer):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74328 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 043482e..3571367 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,25 @@
+2010-12-19  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Ariya Hidayat.
+
+        [Qt] Blur distance should not be affected by transformations
+        https://bugs.webkit.org/show_bug.cgi?id=51161
+
+        From the spec at http://dev.w3.org/html5/2dcontext/#dom-context-2d-shadowblur:
+        "The shadowBlur attribute specifies the level of the blurring effect.
+        (The units do not map to coordinate space units, and are not affected
+        by the current transformation matrix.)"
+
+        Add test to ensure that the blur radius is not affected by the CTM.
+
+        * fast/canvas/canvas-scale-shadowBlur-expected.txt: Added.
+        * fast/canvas/canvas-scale-shadowBlur.html: Added.
+        * fast/canvas/canvas-scale-strokePath-shadow-expected.txt: Increase
+          shadowBlur and test tolerance to ease testing and support the
+          different blurring algorithms.
+        * fast/canvas/script-tests/canvas-scale-shadowBlur.js: Added.
+        * fast/canvas/script-tests/canvas-scale-strokePath-shadow.js:
+
 2010-12-19  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Cameron Zwarich.
diff --git a/LayoutTests/fast/canvas/canvas-scale-shadowBlur-expected.txt b/LayoutTests/fast/canvas/canvas-scale-shadowBlur-expected.txt
new file mode 100644
index 0000000..a2bb3a9
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-scale-shadowBlur-expected.txt
@@ -0,0 +1,93 @@
+Ensure that canvas shadowBlur is not affected by transformations.
+
+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 around 255
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 126
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 255
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 255
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 126
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS d[0] is 0
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/canvas-scale-shadowBlur.html b/LayoutTests/fast/canvas/canvas-scale-shadowBlur.html
new file mode 100644
index 0000000..b51bd91
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-scale-shadowBlur.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-shadowBlur.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt b/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
index a337c4b..aeb8363 100644
--- a/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
+++ b/LayoutTests/fast/canvas/canvas-scale-strokePath-shadow-expected.txt
@@ -30,15 +30,15 @@ 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 149
+PASS d[3] is around 200
 PASS d[0] is 255
 PASS d[1] is 0
 PASS d[2] is 0
-PASS d[3] is around 116
+PASS d[3] is around 49
 PASS d[0] is 255
 PASS d[1] is 0
 PASS d[2] is 0
-PASS d[3] is around 115
+PASS d[3] is around 199
 PASS d[0] is 255
 PASS d[1] is 0
 PASS d[2] is 0
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-scale-shadowBlur.js b/LayoutTests/fast/canvas/script-tests/canvas-scale-shadowBlur.js
new file mode 100644
index 0000000..7c04cf8
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-scale-shadowBlur.js
@@ -0,0 +1,193 @@
+description("Ensure that canvas shadowBlur is not affected by transformations.");
+
+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', '600');
+canvas.setAttribute('height', '600');
+var ctx = canvas.getContext('2d');
+
+ctx.shadowBlur = 25;
+ctx.shadowOffsetX = 100;
+ctx.shadowOffsetY = 100;
+ctx.fillStyle = 'rgba(0, 0, 255, 1)';
+
+// top left
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.scale(4, 4);
+ctx.rotate(Math.PI/2);
+ctx.translate(25, -50);
+ctx.fillRect(0, 0, 25, 25);
+
+// bottom left
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.setTransform(1, 0, 0, 1, 0, 0);
+ctx.scale(0.5, 0.5);
+ctx.fillRect(200, 600, 200, 200);
+
+// top right
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.scale(2, 2);
+ctx.fillRect(300, 100, 100, 100);
+
+// bottom right
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.fillRect(300, 300, 100, 100);
+
+var d;
+
+// top left
+d = ctx.getImageData(250, 250, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '255');
+
+d = ctx.getImageData(250, 175, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(250, 325, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(175, 250, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(325, 250, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+// bottom left
+d = ctx.getImageData(250, 450, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '126');
+
+d = ctx.getImageData(250, 375, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(250, 525, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(175, 450, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(325, 450, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(250, 250, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '255');
+
+// top right
+d = ctx.getImageData(450, 250, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '255');
+
+d = ctx.getImageData(450, 175, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(450, 325, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(375, 250, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(525, 250, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+// top right
+d = ctx.getImageData(450, 450, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '126');
+
+d = ctx.getImageData(450, 375, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(450, 525, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(375, 450, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+d = ctx.getImageData(525, 450, 1, 1).data;
+shouldBe('d[0]', '0');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBe('d[3]', '0');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js b/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
index 6002175..5e5c8f3 100644
--- a/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
+++ b/LayoutTests/fast/canvas/script-tests/canvas-scale-strokePath-shadow.js
@@ -27,8 +27,8 @@ function shouldBeAround(a, b)
 
 var canvas = document.createElement('canvas');
 document.body.appendChild(canvas);
-canvas.setAttribute('width', '1000');
-canvas.setAttribute('height', '1000');
+canvas.setAttribute('width', '600');
+canvas.setAttribute('height', '600');
 var ctx = canvas.getContext('2d');
 
 ctx.scale(2, 2);
@@ -115,23 +115,23 @@ shouldBe('d[2]', '0');
 shouldBeAround('d[3]', '76');
 
 // Verify blurry shadow.
-d = ctx.getImageData(404, 210, 1, 1).data;
+d = ctx.getImageData(398, 210, 1, 1).data;
 shouldBe('d[0]', '255');
 shouldBe('d[1]', '0');
 shouldBe('d[2]', '0');
-shouldBeAround('d[3]', '149');
+shouldBeAround('d[3]', '200');
 
-d = ctx.getImageData(505, 250, 1, 1).data;
+d = ctx.getImageData(508, 250, 1, 1).data;
 shouldBe('d[0]', '255');
 shouldBe('d[1]', '0');
 shouldBe('d[2]', '0');
-shouldBeAround('d[3]', '116');
+shouldBeAround('d[3]', '49');
 
-d = ctx.getImageData(450, 205, 1, 1).data;
+d = ctx.getImageData(450, 198, 1, 1).data;
 shouldBe('d[0]', '255');
 shouldBe('d[1]', '0');
 shouldBe('d[2]', '0');
-shouldBeAround('d[3]', '115');
+shouldBeAround('d[3]', '199');
 
 // Verify blurry alpha shadow.
 d = ctx.getImageData(505, 450, 1, 1).data;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 3beaf96..621606f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-12-19  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Ariya Hidayat.
+
+        [Qt] Blur distance should not be affected by transformations
+        https://bugs.webkit.org/show_bug.cgi?id=51161
+
+        From the spec at http://dev.w3.org/html5/2dcontext/#dom-context-2d-shadowblur:
+        "The shadowBlur attribute specifies the level of the blurring effect.
+        (The units do not map to coordinate space units, and are not affected
+        by the current transformation matrix.)"
+
+        Test: fast/canvas/canvas-scale-shadowBlur.html
+
+        * platform/graphics/ContextShadow.cpp:
+        (WebCore::ContextShadow::adjustBlurDistance):
+        * platform/graphics/ContextShadow.h:
+        * platform/graphics/cairo/ContextShadowCairo.cpp:
+        (WebCore::ContextShadow::beginShadowLayer):
+        * platform/graphics/qt/ContextShadowQt.cpp:
+        (WebCore::ContextShadow::beginShadowLayer):
+
 2010-12-19  Dan Bernstein  <mitz at apple.com>
 
         Reviewed by Cameron Zwarich.
diff --git a/WebCore/platform/graphics/ContextShadow.cpp b/WebCore/platform/graphics/ContextShadow.cpp
index 5e7a7a0..b34e546 100644
--- a/WebCore/platform/graphics/ContextShadow.cpp
+++ b/WebCore/platform/graphics/ContextShadow.cpp
@@ -30,6 +30,7 @@
 #include "ContextShadow.h"
 
 #include "FloatQuad.h"
+#include <cmath>
 #include <wtf/MathExtras.h>
 #include <wtf/Noncopyable.h>
 
@@ -169,6 +170,34 @@ void ContextShadow::blurLayerImage(unsigned char* imageData, const IntSize& size
     }
 }
 
+void ContextShadow::adjustBlurDistance(const PlatformContext context)
+{
+    // Adjust blur if we're scaling, since the radius must not be affected by transformations.
+    const TransformationMatrix transform(getTransformationMatrixFromContext(context));
+
+    if (transform.isIdentity())
+        return;
+
+    // Calculale transformed unit vectors.
+    const FloatQuad unitQuad(FloatPoint(0, 0), FloatPoint(1, 0),
+                             FloatPoint(0, 1), FloatPoint(1, 1));
+    const FloatQuad transformedUnitQuad = transform.mapQuad(unitQuad);
+
+    // Calculate X axis scale factor.
+    const FloatSize xUnitChange = transformedUnitQuad.p2() - transformedUnitQuad.p1();
+    const float xAxisScale = sqrtf(xUnitChange.width() * xUnitChange.width()
+                                   + xUnitChange.height() * xUnitChange.height());
+
+    // Calculate Y axis scale factor.
+    const FloatSize yUnitChange = transformedUnitQuad.p3() - transformedUnitQuad.p1();
+    const float yAxisScale = sqrtf(yUnitChange.width() * yUnitChange.width()
+                                   + yUnitChange.height() * yUnitChange.height());
+
+    // blurLayerImage() does not support per-axis blurring, so calculate a balanced scaling.
+    const float scale = sqrtf(xAxisScale * yAxisScale);
+    m_blurDistance = roundf(static_cast<float>(m_blurDistance) / scale);
+}
+
 IntRect ContextShadow::calculateLayerBoundingRect(const PlatformContext context, const FloatRect& layerArea, const IntRect& clipRect)
 {
     // Calculate the destination of the blurred and/or transformed layer.
diff --git a/WebCore/platform/graphics/ContextShadow.h b/WebCore/platform/graphics/ContextShadow.h
index d13d321..8f14229 100644
--- a/WebCore/platform/graphics/ContextShadow.h
+++ b/WebCore/platform/graphics/ContextShadow.h
@@ -126,6 +126,7 @@ private:
     FloatPoint m_layerContextTranslation; // Translation to apply to m_layerContext for the shadow to be correctly clipped.
     bool m_shadowsIgnoreTransforms;
 
+    void adjustBlurDistance(const PlatformContext);
     void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride);
     IntRect calculateLayerBoundingRect(const PlatformContext, const FloatRect& layerArea, const IntRect& clipRect);
 
diff --git a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
index 6801269..ae91282 100644
--- a/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
+++ b/WebCore/platform/graphics/cairo/ContextShadowCairo.cpp
@@ -92,6 +92,8 @@ TransformationMatrix ContextShadow::getTransformationMatrixFromContext(PlatformC
 
 PlatformContext ContextShadow::beginShadowLayer(PlatformContext context, const FloatRect& layerArea)
 {
+    adjustBlurDistance(context);
+
     double x1, x2, y1, y2;
     cairo_clip_extents(context, &x1, &y1, &x2, &y2);
     IntRect layerRect = calculateLayerBoundingRect(context, layerArea, IntRect(x1, y1, x2 - x1, y2 - y1));
diff --git a/WebCore/platform/graphics/qt/ContextShadowQt.cpp b/WebCore/platform/graphics/qt/ContextShadowQt.cpp
index 48f7976..cb53b24 100644
--- a/WebCore/platform/graphics/qt/ContextShadowQt.cpp
+++ b/WebCore/platform/graphics/qt/ContextShadowQt.cpp
@@ -111,6 +111,9 @@ Q_GLOBAL_STATIC(ShadowBuffer, scratchShadowBuffer)
 
 PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRect& layerArea)
 {
+    // Set m_blurDistance.
+    adjustBlurDistance(p);
+
     QRect clipRect;
     if (p->hasClipping())
 #if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list