[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

krit at webkit.org krit at webkit.org
Wed Apr 7 23:28:25 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit cdad416bf41a800396e74728cfc0698d6362114f
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 10 07:23:39 2009 +0000

    2009-11-09  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Oliver Hunt.
    
            SVG feDisplacementMap is not implemented
            [https://bugs.webkit.org/show_bug.cgi?id=31255]
    
            This is the implementation of the SVG filter effect
            feDisplacementMap.
    
            Test: svg/filters/feDisplacementMap.svg
    
            * svg/graphics/filters/SVGFEDisplacementMap.cpp:
            (WebCore::FEDisplacementMap::apply):
    
            Test for SVG filter effect feDisplacementMap.
    
            * platform/mac/svg/filters/feDisplacementMap-expected.checksum: Added.
            * platform/mac/svg/filters/feDisplacementMap-expected.png: Added.
            * platform/mac/svg/filters/feDisplacementMap-expected.txt: Added.
            * svg/filters/feDisplacementMap.svg: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50718 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 99b1699..d7245f9 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
+2009-11-09  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Oliver Hunt.
+
+        Test for SVG filter effect feDisplacementMap.
+
+        * platform/mac/svg/filters/feDisplacementMap-expected.checksum: Added.
+        * platform/mac/svg/filters/feDisplacementMap-expected.png: Added.
+        * platform/mac/svg/filters/feDisplacementMap-expected.txt: Added.
+        * svg/filters/feDisplacementMap.svg: Added.
+
 2009-11-03  Shinichiro Hamaji  <hamaji at chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.checksum b/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.checksum
new file mode 100644
index 0000000..49ccafd
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.checksum
@@ -0,0 +1 @@
+9e20468ff7a8395c8cf735e054ca4772
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.png b/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.png
new file mode 100644
index 0000000..f9774bf
Binary files /dev/null and b/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.txt b/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.txt
new file mode 100644
index 0000000..7ad8c2b
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/filters/feDisplacementMap-expected.txt
@@ -0,0 +1,15 @@
+KRenderingPaintServer {id="linGrad" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#00FF00)]] [start=(0,0)] [end=(1,1)]}
+KRenderingPaintServer {id="radGrad" [type=RADIAL-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#00FF00)]] [center=(0.50,0.50)] [focal=(0.50,0.50)] [radius=0.50]}
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (10,10) size 220x100
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGHiddenContainer {linearGradient} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+      RenderSVGHiddenContainer {radialGradient} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+        RenderSVGGradientStop {stop} at (0,0) size 0x0
+    RenderSVGImage {image} at (10,10) size 100x100 [filter=f1]
+    RenderSVGImage {image} at (130,10) size 100x100 [filter=f1]
diff --git a/LayoutTests/svg/filters/feDisplacementMap.svg b/LayoutTests/svg/filters/feDisplacementMap.svg
new file mode 100644
index 0000000..4d2c322
--- /dev/null
+++ b/LayoutTests/svg/filters/feDisplacementMap.svg
@@ -0,0 +1,22 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+<linearGradient id="linGrad" x1="0%" y1="0%" x2="100%" y2="100%">
+<stop offset="0%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
+<stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
+</linearGradient>
+<radialGradient id="radGrad" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
+<stop offset="0%" style="stop-color:rgb(255,0,0);stop-opacity:1"/>
+<stop offset="100%" style="stop-color:rgb(0,255,0);stop-opacity:1"/>
+</radialGradient>
+<filter id="f1" filterUnits="objectBoundingBox" x="0" y="0" width="1" height="1" primitiveUnits="objectBoundingBox">
+<feFlood flood-color="#000" x="5%" y="5%" width="5%" height="5%" result="flood1"/>
+<feFlood flood-color="#000" x="0%" y="0%" width="5%" height="5%" result="flood2"/>
+<feComposite in="flood1" in2="flood2" result="pair"/>
+<feTile in="pair" result="tile"/>
+<feDisplacementMap in="tile" in2="SourceGraphic" scale="64" xChannelSelector="R" yChannelSelector="G"/>
+</filter>
+</defs>
+<image x="10" y="10" width="100" height="100" xlink:href="../W3C-SVG-1.1/resources/rotate20.png" filter="url(#f1)"/>
+<image x="130" y="10" width="100" height="100" xlink:href="../W3C-SVG-1.1/resources/sphere.png" filter="url(#f1)"/>
+</svg>
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 30e8fc6..f440e80 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-09  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Oliver Hunt.
+
+        SVG feDisplacementMap is not implemented
+        [https://bugs.webkit.org/show_bug.cgi?id=31255]
+
+        This is the implementation of the SVG filter effect
+        feDisplacementMap. 
+
+        Test: svg/filters/feDisplacementMap.svg
+
+        * svg/graphics/filters/SVGFEDisplacementMap.cpp:
+        (WebCore::FEDisplacementMap::apply):
+
 2009-11-09  Kent Tamura  <tkent at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
index abb57ee..cc5a4b3 100644
--- a/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEDisplacementMap.cpp
@@ -2,6 +2,7 @@
     Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann at kde.org>
                   2004, 2005 Rob Buis <buis at kde.org>
                   2005 Eric Seidel <eric at webkit.org>
+                  2009 Dirk Schulze <krit at webkit.org>
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
@@ -23,8 +24,12 @@
 
 #if ENABLE(SVG) && ENABLE(FILTERS)
 #include "SVGFEDisplacementMap.h"
-#include "SVGRenderTreeAsText.h"
+
+#include "CanvasPixelArray.h"
 #include "Filter.h"
+#include "GraphicsContext.h"
+#include "ImageData.h"
+#include "SVGRenderTreeAsText.h"
 
 namespace WebCore {
 
@@ -75,8 +80,51 @@ void FEDisplacementMap::setScale(float scale)
     m_scale = scale;
 }
 
-void FEDisplacementMap::apply(Filter*)
+void FEDisplacementMap::apply(Filter* filter)
 {
+    m_in->apply(filter);
+    m_in2->apply(filter);
+    if (!m_in->resultImage() || !m_in2->resultImage())
+        return;
+
+    if (m_xChannelSelector == CHANNEL_UNKNOWN || m_yChannelSelector == CHANNEL_UNKNOWN)
+        return;
+
+    if (!getEffectContext())
+        return;
+
+    IntRect effectADrawingRect = calculateDrawingIntRect(m_in->subRegion());
+    RefPtr<CanvasPixelArray> srcPixelArrayA(m_in->resultImage()->getPremultipliedImageData(effectADrawingRect)->data());
+
+    IntRect effectBDrawingRect = calculateDrawingIntRect(m_in2->subRegion());
+    RefPtr<CanvasPixelArray> srcPixelArrayB(m_in2->resultImage()->getUnmultipliedImageData(effectBDrawingRect)->data());
+
+    IntRect imageRect(IntPoint(), resultImage()->size());
+    RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height());
+
+    ASSERT(srcPixelArrayA->length() == srcPixelArrayB->length());
+
+    float scale = m_scale / 255.f;
+    float scaleAdjustment = 0.5f - 0.5f * m_scale;
+    int stride = imageRect.width() * 4;
+    for (int y = 0; y < imageRect.height(); ++y) {
+        int line = y * stride;
+        for (int x = 0; x < imageRect.width(); ++x) {
+            int dstIndex = line + x * 4;
+            int srcX = x + static_cast<int>(scale * srcPixelArrayB->get(dstIndex + m_xChannelSelector - 1) + scaleAdjustment);
+            int srcY = y + static_cast<int>(scale * srcPixelArrayB->get(dstIndex + m_yChannelSelector - 1) + scaleAdjustment);
+            for (unsigned channel = 0; channel < 4; ++channel) {
+                if (srcX < 0 || srcX >= imageRect.width() || srcY < 0 || srcY >= imageRect.height())
+                    imageData->data()->set(dstIndex + channel, static_cast<unsigned char>(0));
+                else {
+                    unsigned char pixelValue = srcPixelArrayA->get(srcY * stride + srcX * 4 + channel);
+                    imageData->data()->set(dstIndex + channel, pixelValue);
+                }
+            }
+
+        }
+    }
+    resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint());
 }
 
 void FEDisplacementMap::dump()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list