[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:29:59 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 240961aec9ab73c43ea35959465286ca196a7131
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 13 08:56:31 2010 +0000

    2010-12-13  Helder Correia  <helder at sencha.com>
    
            Reviewed by Eric Seidel.
    
            [Qt] StillImage::draw() should use ContextShadow
            https://bugs.webkit.org/show_bug.cgi?id=50849
    
            The branch that checks for a shadow requirement in StillImage::draw()
            is executed when drawing a canvas onto a canvas with
            ctx1.drawImage(canvas2, x, y). The current implementation supports
            solid shadows only. And if transformations are present, the offset gets
            transformed as well. Thus, ContextShadow must be used instead in order
            to support blur and correct offset transformations.
    
            * fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt: Added.
            * fast/canvas/canvas-draw-canvas-on-canvas-shadow.html: Added.
            * fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js: Added.
    2010-12-13  Helder Correia  <helder at sencha.com>
    
            Reviewed by Eric Seidel.
    
            [Qt] StillImage::draw() should use ContextShadow
            https://bugs.webkit.org/show_bug.cgi?id=50849
    
            The branch that checks for a shadow requirement in StillImage::draw()
            is executed when drawing a canvas onto a canvas with
            ctx1.drawImage(canvas2, x, y). The current implementation supports
            solid shadows only. And if transformations are present, the offset gets
            transformed as well. Thus, ContextShadow must be used instead in order
            to support blur and correct offset transformations.
    
            Test: fast/canvas/canvas-draw-canvas-on-canvas-shadow.html
    
            * platform/graphics/qt/StillImageQt.cpp:
            (WebCore::StillImage::draw):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73889 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index b098c84..475c27e 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,21 @@
+2010-12-13  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Eric Seidel.
+
+        [Qt] StillImage::draw() should use ContextShadow
+        https://bugs.webkit.org/show_bug.cgi?id=50849
+
+        The branch that checks for a shadow requirement in StillImage::draw()
+        is executed when drawing a canvas onto a canvas with
+        ctx1.drawImage(canvas2, x, y). The current implementation supports
+        solid shadows only. And if transformations are present, the offset gets
+        transformed as well. Thus, ContextShadow must be used instead in order
+        to support blur and correct offset transformations.
+
+        * fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt: Added.
+        * fast/canvas/canvas-draw-canvas-on-canvas-shadow.html: Added.
+        * fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js: Added.
+
 2010-10-28  MORITA Hajime  <morrita at google.com>
 
         Reviewed by Ojan Vafai.
diff --git a/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt b/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt
new file mode 100644
index 0000000..5b3196b
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-shadow-expected.txt
@@ -0,0 +1,57 @@
+Ensure correct behavior when drawing a canvas on a canvas with shadows. 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 127
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 127
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 127
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 100
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 100
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 100
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 50
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 50
+PASS d[0] is 255
+PASS d[1] is 0
+PASS d[2] is 0
+PASS d[3] is around 50
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-shadow.html b/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-shadow.html
new file mode 100644
index 0000000..ae71a6b
--- /dev/null
+++ b/LayoutTests/fast/canvas/canvas-draw-canvas-on-canvas-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-draw-canvas-on-canvas-shadow.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js b/LayoutTests/fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js
new file mode 100644
index 0000000..83ab990
--- /dev/null
+++ b/LayoutTests/fast/canvas/script-tests/canvas-draw-canvas-on-canvas-shadow.js
@@ -0,0 +1,135 @@
+description("Ensure correct behavior when drawing a canvas on a canvas with shadows. 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) < 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', '600');
+var ctx = canvas.getContext('2d');
+ctx.shadowOffsetX = 100;
+ctx.shadowOffsetY = 100;
+
+var aCanvas = document.createElement('canvas');
+aCanvas.width = 300;
+aCanvas.height = 300;
+
+var aCtx = aCanvas.getContext('2d');
+aCtx.fillStyle = 'rgba(0, 0, 255, 1.0)';
+aCtx.fillRect(100, 100, 100, 100);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.drawImage(aCanvas, 0, 0);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.drawImage(aCanvas, 0, 200);
+
+ctx.shadowBlur = 5;
+ctx.shadowColor = 'rgba(255, 0, 0, 1.0)';
+ctx.drawImage(aCanvas, 200, 0);
+
+ctx.shadowColor = 'rgba(255, 0, 0, 0.5)';
+ctx.drawImage(aCanvas, 200, 200);
+
+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]', '127');
+
+d = ctx.getImageData(299, 405, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '127');
+
+d = ctx.getImageData(205, 499, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '127');
+
+// Verify blurry shadow.
+d = ctx.getImageData(500, 211, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '100');
+
+d = ctx.getImageData(399, 205, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '100');
+
+d = ctx.getImageData(450, 300, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '100');
+
+// Verify blurry alpha shadow.
+d = ctx.getImageData(500, 411, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '50');
+
+d = ctx.getImageData(399, 405, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '50');
+
+d = ctx.getImageData(450, 500, 1, 1).data;
+shouldBe('d[0]', '255');
+shouldBe('d[1]', '0');
+shouldBe('d[2]', '0');
+shouldBeAround('d[3]', '50');
+
+var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c115ead..0fc895d 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2010-12-13  Helder Correia  <helder at sencha.com>
+
+        Reviewed by Eric Seidel.
+
+        [Qt] StillImage::draw() should use ContextShadow
+        https://bugs.webkit.org/show_bug.cgi?id=50849
+
+        The branch that checks for a shadow requirement in StillImage::draw()
+        is executed when drawing a canvas onto a canvas with
+        ctx1.drawImage(canvas2, x, y). The current implementation supports
+        solid shadows only. And if transformations are present, the offset gets
+        transformed as well. Thus, ContextShadow must be used instead in order
+        to support blur and correct offset transformations.
+
+        Test: fast/canvas/canvas-draw-canvas-on-canvas-shadow.html
+
+        * platform/graphics/qt/StillImageQt.cpp:
+        (WebCore::StillImage::draw):
+
 2010-12-12  Jon Honeycutt  <jhoneycutt at apple.com>
 
         Unreviewed build fix.
diff --git a/WebCore/platform/graphics/qt/StillImageQt.cpp b/WebCore/platform/graphics/qt/StillImageQt.cpp
index 3038356..f1e5dcd 100644
--- a/WebCore/platform/graphics/qt/StillImageQt.cpp
+++ b/WebCore/platform/graphics/qt/StillImageQt.cpp
@@ -28,6 +28,7 @@
 #include "config.h"
 #include "StillImageQt.h"
 
+#include "ContextShadow.h"
 #include "GraphicsContext.h"
 #include "IntSize.h"
 
@@ -67,7 +68,6 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
     if (m_pixmap->isNull())
         return;
 
-
     FloatRect normalizedSrc = src.normalized();
     FloatRect normalizedDst = dst.normalized();
 
@@ -76,21 +76,14 @@ void StillImage::draw(GraphicsContext* ctxt, const FloatRect& dst,
 
     ctxt->setCompositeOperation(op);
 
-    FloatSize shadowOffset;
-    float shadowBlur;
-    Color shadowColor;
-    if (ctxt->getShadow(shadowOffset, shadowBlur, shadowColor)) {
-        FloatRect shadowImageRect(normalizedDst);
-        shadowImageRect.move(shadowOffset.width(), shadowOffset.height());
-
-        QImage shadowImage(QSize(static_cast<int>(normalizedSrc.width()), static_cast<int>(normalizedSrc.height())), QImage::Format_ARGB32_Premultiplied);
-        QPainter p(&shadowImage);
-        p.setCompositionMode(QPainter::CompositionMode_Source);
-        p.fillRect(shadowImage.rect(), shadowColor);
-        p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
-        p.drawPixmap(QRect(0, 0, normalizedDst.width(), normalizedDst.height()), *m_pixmap, normalizedSrc);
-        p.end();
-        painter->drawImage(shadowImageRect, shadowImage, normalizedSrc);
+    ContextShadow* shadow = ctxt->contextShadow();
+    if (shadow->m_type != ContextShadow::NoShadow) {
+        QPainter* shadowPainter = shadow->beginShadowLayer(painter, normalizedDst);
+        if (shadowPainter) {
+            shadowPainter->setOpacity(static_cast<qreal>(shadow->m_color.alpha()) / 255);
+            shadowPainter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);
+            shadow->endShadowLayer(painter);
+        }
     }
 
     painter->drawPixmap(normalizedDst, *m_pixmap, normalizedSrc);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list