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

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 16:36:40 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 99061237fa582a90731e42c74f5dca11e0bc207d
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 29 10:12:08 2010 +0000

    2010-11-29  Helder Correia  <helder at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] fillRect shadow has incorrect behavior when using ctx.scale(x,y)
            https://bugs.webkit.org/show_bug.cgi?id=50141
    
            New fast canvas test to ensure correct fillRect shadow when using
            ctx.scale(x,y).
    
            * fast/canvas/canvas-scale-fillRect-shadow-expected.txt: Added.
            * fast/canvas/canvas-scale-fillRect-shadow.html: Added.
            * fast/canvas/script-tests/canvas-scale-fillRect-shadow.js: Added.
    2010-11-29  Helder Correia  <helder at sencha.com>
    
            Reviewed by Kenneth Rohde Christiansen.
    
            [Qt] fillRect shadow has incorrect behavior when using ctx.scale(x,y)
            https://bugs.webkit.org/show_bug.cgi?id=50141
    
            Don't apply scaling transformation to shadow offsets.
    
            Test: fast/canvas/canvas-scale-fillRect-shadow.html
    
            * platform/graphics/ContextShadow.h:
            * platform/graphics/qt/ContextShadowQt.cpp:
            (WebCore::ContextShadow::beginShadowLayer):
            (WebCore::ContextShadow::endShadowLayer):
            * platform/graphics/qt/GraphicsContextQt.cpp:
            (WebCore::GraphicsContext::fillRect):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72784 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4b2e033..ae7a444 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
+2010-11-29  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] fillRect shadow has incorrect behavior when using ctx.scale(x,y)
+        https://bugs.webkit.org/show_bug.cgi?id=50141
+
+        New fast canvas test to ensure correct fillRect shadow when using
+        ctx.scale(x,y).
+
+        * fast/canvas/canvas-scale-fillRect-shadow-expected.txt: Added.
+        * fast/canvas/canvas-scale-fillRect-shadow.html: Added.
+        * fast/canvas/script-tests/canvas-scale-fillRect-shadow.js: Added.
+
 2010-11-28  Dimitri Glazkov  <dglazkov at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/canvas/canvas-scale-fillRect-shadow-expected.txt b/LayoutTests/fast/canvas/canvas-scale-fillRect-shadow-expected.txt
new file mode 100644
index 0000000..94f0a8e
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-scale-fillRect-shadow-expected.txt
@@ -0,0 +1,57 @@
+Ensure correct behavior of canvas with fillRect+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 83
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 83
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 53
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 24
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 24
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 24
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/canvas-scale-fillRect-shadow.html b/LayoutTests/fast/canvas/canvas-scale-fillRect-shadow.html
new file mode 100644
index 0000000..9eae434
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-scale-fillRect-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-fillRect-shadow.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-scale-fillRect-shadow.js b/LayoutTests/fast/canvas/script-tests/canvas-scale-fillRect-shadow.js
new file mode 100644
index 0000000..99a1e59
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-scale-fillRect-shadow.js
@@ -0,0 +1,130 @@
+description("Ensure correct behavior of canvas with fillRect+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.fillStyle = 'rgba(0, 0, 255, 1)';
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.fillRect(50, 50, 50, 50);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
+ctx.fillRect(50, 150, 50, 50);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.shadowBlur = 10;
+ctx.fillRect(150, 50, 50, 50);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.3)';
+ctx.fillRect(150, 150, 50, 50);
+
+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(200, 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(398, 205, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '83');
+
+d = ctx.getImageData(501, 205, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '83');
+
+d = ctx.getImageData(500, 300, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '53');
+
+// Verify blurry alpha shadow.
+d = ctx.getImageData(398, 405, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '24');
+
+d = ctx.getImageData(405, 501, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '24');
+
+d = ctx.getImageData(405, 501, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '24');
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9db015b..487277b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-11-29  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] fillRect shadow has incorrect behavior when using ctx.scale(x,y)
+        https://bugs.webkit.org/show_bug.cgi?id=50141
+
+        Don't apply scaling transformation to shadow offsets.
+
+        Test: fast/canvas/canvas-scale-fillRect-shadow.html
+
+        * platform/graphics/ContextShadow.h:
+        * platform/graphics/qt/ContextShadowQt.cpp:
+        (WebCore::ContextShadow::beginShadowLayer):
+        (WebCore::ContextShadow::endShadowLayer):
+        * platform/graphics/qt/GraphicsContextQt.cpp:
+        (WebCore::GraphicsContext::fillRect):
+
 2010-11-28  Dimitri Glazkov  <dglazkov at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/platform/graphics/ContextShadow.h b/WebCore/platform/graphics/ContextShadow.h
index 2b779f7..26f0a36 100644
--- a/WebCore/platform/graphics/ContextShadow.h
+++ b/WebCore/platform/graphics/ContextShadow.h
@@ -120,6 +120,11 @@ private:
     PlatformImage m_layerImage;
     PlatformContext m_layerContext;
 
+#if PLATFORM(QT)
+    // Used for reference when canvas scale(x,y) was called.
+    FloatRect m_unscaledLayerRect;
+#endif
+
     void blurLayerImage(unsigned char*, const IntSize& imageSize, int stride);
     void calculateLayerBoundingRect(const FloatRect& layerArea, const IntRect& clipRect);
 #if PLATFORM(CAIRO)
diff --git a/WebCore/platform/graphics/qt/ContextShadowQt.cpp b/WebCore/platform/graphics/qt/ContextShadowQt.cpp
index 5ba0b6f..f7c70f6 100644
--- a/WebCore/platform/graphics/qt/ContextShadowQt.cpp
+++ b/WebCore/platform/graphics/qt/ContextShadowQt.cpp
@@ -114,6 +114,7 @@ PlatformContext ContextShadow::beginShadowLayer(PlatformContext p, const FloatRe
     else
         clipRect = p->transform().inverted().mapRect(p->window());
 
+    m_unscaledLayerRect = layerArea;
     calculateLayerBoundingRect(layerArea, IntRect(clipRect.x(), clipRect.y(), clipRect.width(), clipRect.height()));
 
     // Don't paint if we are totally outside the clip region.
@@ -154,7 +155,14 @@ void ContextShadow::endShadowLayer(PlatformContext p)
         p.end();
     }
 
-    p->drawImage(m_layerRect.topLeft(), m_layerImage);
+    const QTransform transform = p->transform();
+    if (transform.isScaling()) {
+        qreal x = m_unscaledLayerRect.x() + m_offset.width()  / transform.m11() - m_blurDistance;
+        qreal y = m_unscaledLayerRect.y() + m_offset.height() / transform.m22() - m_blurDistance;
+        p->drawImage(QPointF(x, y), m_layerImage);
+    } else
+        p->drawImage(m_layerRect.topLeft(), m_layerImage);
+
     scratchShadowBuffer()->schedulePurge();
 }
 
diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
index a7fcb0b..b399f4e 100644
--- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
+++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
@@ -716,9 +716,16 @@ void GraphicsContext::fillRect(const FloatRect& rect)
                 // without using the shadow layer at all.
                 QColor shadowColor = shadow->m_color;
                 shadowColor.setAlphaF(shadowColor.alphaF() * p->brush().color().alphaF());
-                p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor);
+                const QTransform transform = p->transform();
+                if (transform.isScaling()) {
+                    p->fillRect(normalizedRect.translated(static_cast<qreal>(shadow->offset().x()) / transform.m11(),
+                                                          static_cast<qreal>(shadow->offset().y()  / transform.m22())),
+                                shadowColor);
+                } else
+                    p->fillRect(normalizedRect.translated(shadow->offset()), shadowColor);
             }
         }
+
         p->fillRect(normalizedRect, p->brush());
     }
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list