[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:25:05 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 27a747457c14c338770810d0824a7cd0c64716fd
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Nov 6 21:08:10 2009 +0000

    2009-11-06  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            feMorphology filter is not implemented
            [https://bugs.webkit.org/show_bug.cgi?id=5863]
    
            The Implementation of feMorphology.
    
            Test: We have allready a test for feMorphology
                  svg/W3C-SVG-1.1/filters-morph-01-f.svg
    
            * svg/graphics/filters/SVGFEMorphology.cpp:
            (WebCore::FEMorphology::apply):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50604 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index fee6db1..904da0f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-11-06  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        feMorphology filter is not implemented
+        [https://bugs.webkit.org/show_bug.cgi?id=5863]
+
+        The Implementation of feMorphology.
+        
+        Test: We have allready a test for feMorphology
+              svg/W3C-SVG-1.1/filters-morph-01-f.svg
+
+        * svg/graphics/filters/SVGFEMorphology.cpp:
+        (WebCore::FEMorphology::apply):
+
 2009-11-06  Steve Block  <steveblock at google.com>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp b/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
index f7fc5d8..290cc7c 100644
--- a/WebCore/svg/graphics/filters/SVGFEMorphology.cpp
+++ b/WebCore/svg/graphics/filters/SVGFEMorphology.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,16 @@
 
 #if ENABLE(SVG) && ENABLE(FILTERS)
 #include "SVGFEMorphology.h"
-#include "SVGRenderTreeAsText.h"
+
+#include "CanvasPixelArray.h"
 #include "Filter.h"
+#include "ImageData.h"
+#include "SVGRenderTreeAsText.h"
+
+#include <wtf/Vector.h>
+
+using std::min;
+using std::max;
 
 namespace WebCore {
 
@@ -72,8 +81,73 @@ void FEMorphology::setRadiusY(float radiusY)
     m_radiusY = radiusY;
 }
 
-void FEMorphology::apply(Filter*)
+void FEMorphology::apply(Filter* filter)
 {
+    m_in->apply(filter);
+    if (!m_in->resultImage())
+        return;
+    
+    if (!getEffectContext())
+        return;
+
+    if (!m_radiusX || !m_radiusY)
+        return;
+
+    IntRect imageRect(IntPoint(), resultImage()->size());
+    IntRect effectDrawingRect = calculateDrawingIntRect(m_in->subRegion());
+    RefPtr<CanvasPixelArray> srcPixelArray(m_in->resultImage()->getPremultipliedImageData(effectDrawingRect)->data());
+    RefPtr<ImageData> imageData = ImageData::create(imageRect.width(), imageRect.height());
+
+    int radiusX = static_cast<int>(m_radiusX);
+    int radiusY = static_cast<int>(m_radiusY);
+    int effectWidth = effectDrawingRect.width() * 4;
+    
+    // Limit the radius size to effect width
+    radiusX = min(effectDrawingRect.width() - 1, radiusX);
+    
+    Vector<unsigned char> extrema;
+    for (int y = 0; y < effectDrawingRect.height(); ++y) {
+        int startY = max(0, y - radiusY);
+        int endY = min(effectDrawingRect.height() - 1, y + radiusY);
+        for (unsigned channel = 0; channel < 4; ++channel) {
+            // Fill the kernel
+            extrema.clear();
+            for (int j = 0; j <= radiusX; ++j) {
+                unsigned char columnExtrema = srcPixelArray->get(startY * effectWidth + 4 * j + channel);
+                for (int i = startY; i <= endY; ++i) {
+                    unsigned char pixel = srcPixelArray->get(i * effectWidth + 4 * j + channel);
+                    if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) ||
+                        (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema))
+                        columnExtrema = pixel;
+                }
+                extrema.append(columnExtrema);
+            }
+            
+            // Kernel is filled, get extrema of next column 
+            for (int x = 0; x < effectDrawingRect.width(); ++x) {
+                unsigned endX = min(x + radiusX, effectDrawingRect.width() - 1);
+                unsigned char columnExtrema = srcPixelArray->get(startY * effectWidth + endX * 4 + channel);
+                for (int i = startY; i <= endY; ++i) {
+                    unsigned char pixel = srcPixelArray->get(i * effectWidth + endX * 4 + channel);
+                    if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && pixel <= columnExtrema) ||
+                        (m_type == FEMORPHOLOGY_OPERATOR_DILATE && pixel >= columnExtrema))
+                        columnExtrema = pixel;
+                }
+                if (x - radiusX >= 0)
+                    extrema.remove(0);
+                if (x + radiusX <= effectDrawingRect.width())
+                    extrema.append(columnExtrema);
+                unsigned char entireExtrema = extrema[0];
+                for (unsigned kernelIndex = 0; kernelIndex < extrema.size(); ++kernelIndex) {
+                    if ((m_type == FEMORPHOLOGY_OPERATOR_ERODE && extrema[kernelIndex] <= entireExtrema) ||
+                        (m_type == FEMORPHOLOGY_OPERATOR_DILATE && extrema[kernelIndex] >= entireExtrema))
+                        entireExtrema = extrema[kernelIndex];
+                }
+                imageData->data()->set(y * effectWidth + 4 * x + channel, entireExtrema);
+            }
+        }
+    }
+    resultImage()->putPremultipliedImageData(imageData.get(), imageRect, IntPoint());
 }
 
 void FEMorphology::dump()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list