2008-07-03 Alex Mathews <possessedpenguinbob@gmail.com>
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jul 2008 01:10:08 +0000 (01:10 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Jul 2008 01:10:08 +0000 (01:10 +0000)
        Reviewed by Oliver Hunt.

        Bug 19835: WebKit needs cross-platform filter system
        <https://bugs.webkit.org/show_bug.cgi?id=19835>

        More class refactoring in preparation for cross-platform filter
        implementation.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@34992 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/svg/FilterEffect.h
WebCore/svg/SVGComponentTransferFunctionElement.cpp
WebCore/svg/SVGComponentTransferFunctionElement.h
WebCore/svg/SVGFEColorMatrixElement.cpp
WebCore/svg/SVGFEColorMatrixElement.h
WebCore/svg/SVGFEComponentTransferElement.cpp
WebCore/svg/SVGFEComponentTransferElement.h
WebCore/svg/SVGFECompositeElement.cpp
WebCore/svg/SVGFECompositeElement.h
WebCore/svg/graphics/filters/SVGFEBlend.cpp
WebCore/svg/graphics/filters/SVGFEBlend.h
WebCore/svg/graphics/filters/SVGFEColorMatrix.cpp
WebCore/svg/graphics/filters/SVGFEColorMatrix.h
WebCore/svg/graphics/filters/SVGFEComponentTransfer.cpp
WebCore/svg/graphics/filters/SVGFEComponentTransfer.h
WebCore/svg/graphics/filters/SVGFEComposite.cpp
WebCore/svg/graphics/filters/SVGFEComposite.h
WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm [deleted file]
WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm [deleted file]
WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm [deleted file]

index 1891038..16c26d1 100644 (file)
@@ -1,3 +1,86 @@
+2008-07-03  Alex Mathews  <possessedpenguinbob@gmail.com>
+
+        Reviewed by Oliver Hunt.
+
+        Bug 19835: WebKit needs cross-platform filter system
+        <https://bugs.webkit.org/show_bug.cgi?id=19835>
+
+        More class refactoring in preparation for cross-platform filter
+        implementation.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * svg/FilterEffect.h:
+        * svg/SVGComponentTransferFunctionElement.cpp:
+        (WebCore::SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement):
+        (WebCore::SVGComponentTransferFunctionElement::parseMappedAttribute):
+        (WebCore::SVGComponentTransferFunctionElement::transferFunction):
+        * svg/SVGComponentTransferFunctionElement.h:
+        * svg/SVGFEColorMatrixElement.cpp:
+        (WebCore::SVGFEColorMatrixElement::SVGFEColorMatrixElement):
+        (WebCore::SVGFEColorMatrixElement::parseMappedAttribute):
+        (WebCore::SVGFEColorMatrixElement::filterEffect):
+        (WebCore::SVGFEColorMatrixElement::build):
+        * svg/SVGFEColorMatrixElement.h:
+        * svg/SVGFEComponentTransferElement.cpp:
+        (WebCore::SVGFEComponentTransferElement::filterEffect):
+        (WebCore::SVGFEComponentTransferElement::build):
+        * svg/SVGFEComponentTransferElement.h:
+        * svg/SVGFECompositeElement.cpp:
+        (WebCore::SVGFECompositeElement::SVGFECompositeElement):
+        (WebCore::SVGFECompositeElement::parseMappedAttribute):
+        (WebCore::SVGFECompositeElement::filterEffect):
+        (WebCore::SVGFECompositeElement::build):
+        * svg/SVGFECompositeElement.h:
+        * svg/graphics/filters/SVGFEBlend.cpp:
+        * svg/graphics/filters/SVGFEBlend.h:
+        * svg/graphics/filters/SVGFEColorMatrix.cpp:
+        (WebCore::FEColorMatrix::FEColorMatrix):
+        (WebCore::FEColorMatrix::create):
+        (WebCore::FEColorMatrix::type):
+        (WebCore::FEColorMatrix::setType):
+        (WebCore::FEColorMatrix::values):
+        (WebCore::FEColorMatrix::setValues):
+        (WebCore::FEColorMatrix::apply):
+        (WebCore::FEColorMatrix::dump):
+        * svg/graphics/filters/SVGFEColorMatrix.h:
+        (WebCore::):
+        * svg/graphics/filters/SVGFEComponentTransfer.cpp:
+        (WebCore::FEComponentTransfer::FEComponentTransfer):
+        (WebCore::FEComponentTransfer::create):
+        (WebCore::FEComponentTransfer::redFunction):
+        (WebCore::FEComponentTransfer::setRedFunction):
+        (WebCore::FEComponentTransfer::greenFunction):
+        (WebCore::FEComponentTransfer::setGreenFunction):
+        (WebCore::FEComponentTransfer::blueFunction):
+        (WebCore::FEComponentTransfer::setBlueFunction):
+        (WebCore::FEComponentTransfer::alphaFunction):
+        (WebCore::FEComponentTransfer::setAlphaFunction):
+        (WebCore::FEComponentTransfer::apply):
+        (WebCore::FEComponentTransfer::dump):
+        * svg/graphics/filters/SVGFEComponentTransfer.h:
+        (WebCore::):
+        (WebCore::ComponentTransferFunction::ComponentTransferFunction):
+        * svg/graphics/filters/SVGFEComposite.cpp:
+        (WebCore::FEComposite::FEComposite):
+        (WebCore::FEComposite::create):
+        (WebCore::FEComposite::operation):
+        (WebCore::FEComposite::setOperation):
+        (WebCore::FEComposite::k1):
+        (WebCore::FEComposite::setK1):
+        (WebCore::FEComposite::k2):
+        (WebCore::FEComposite::setK2):
+        (WebCore::FEComposite::k3):
+        (WebCore::FEComposite::setK3):
+        (WebCore::FEComposite::k4):
+        (WebCore::FEComposite::setK4):
+        (WebCore::FEComposite::apply):
+        (WebCore::FEComposite::dump):
+        * svg/graphics/filters/SVGFEComposite.h:
+        (WebCore::):
+        * svg/graphics/filters/cg/SVGFEColorMatrixCg.mm: Removed.
+        * svg/graphics/filters/cg/SVGFEComponentTransferCg.mm: Removed.
+        * svg/graphics/filters/cg/SVGFECompositeCg.mm: Removed.
+
 2008-07-03  Dan Bernstein  <mitz@apple.com>
 
         Reviewed by John Sullivan.
index 4d8a708..cd06f81 100644 (file)
                B25599330D00D8BA00BB825C /* SVGResourceClipperCg.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B25598970D00D8B800BB825C /* SVGResourceClipperCg.cpp */; };
                B25599350D00D8BA00BB825C /* SVGResourceFilterCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598990D00D8B800BB825C /* SVGResourceFilterCg.mm */; };
                B25599370D00D8BA00BB825C /* SVGResourceMaskerCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B255989B0D00D8B800BB825C /* SVGResourceMaskerCg.mm */; };
-               B25599390D00D8BA00BB825C /* SVGFEColorMatrixCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B255989F0D00D8B800BB825C /* SVGFEColorMatrixCg.mm */; };
-               B255993A0D00D8BA00BB825C /* SVGFEComponentTransferCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598A00D00D8B800BB825C /* SVGFEComponentTransferCg.mm */; };
-               B255993B0D00D8BA00BB825C /* SVGFECompositeCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598A10D00D8B800BB825C /* SVGFECompositeCg.mm */; };
                B255993C0D00D8BA00BB825C /* SVGFEDiffuseLightingCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598A20D00D8B800BB825C /* SVGFEDiffuseLightingCg.mm */; };
                B255993D0D00D8BA00BB825C /* SVGFEDisplacementMapCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598A30D00D8B800BB825C /* SVGFEDisplacementMapCg.mm */; };
                B255993E0D00D8BA00BB825C /* SVGFEFloodCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B25598A40D00D8B800BB825C /* SVGFEFloodCg.mm */; };
                B25598970D00D8B800BB825C /* SVGResourceClipperCg.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGResourceClipperCg.cpp; sourceTree = "<group>"; };
                B25598990D00D8B800BB825C /* SVGResourceFilterCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGResourceFilterCg.mm; sourceTree = "<group>"; };
                B255989B0D00D8B800BB825C /* SVGResourceMaskerCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGResourceMaskerCg.mm; sourceTree = "<group>"; };
-               B255989F0D00D8B800BB825C /* SVGFEColorMatrixCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFEColorMatrixCg.mm; sourceTree = "<group>"; };
-               B25598A00D00D8B800BB825C /* SVGFEComponentTransferCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFEComponentTransferCg.mm; sourceTree = "<group>"; };
-               B25598A10D00D8B800BB825C /* SVGFECompositeCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFECompositeCg.mm; sourceTree = "<group>"; };
                B25598A20D00D8B800BB825C /* SVGFEDiffuseLightingCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFEDiffuseLightingCg.mm; sourceTree = "<group>"; };
                B25598A30D00D8B800BB825C /* SVGFEDisplacementMapCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFEDisplacementMapCg.mm; sourceTree = "<group>"; };
                B25598A40D00D8B800BB825C /* SVGFEFloodCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFEFloodCg.mm; sourceTree = "<group>"; };
                B255989D0D00D8B800BB825C /* cg */ = {
                        isa = PBXGroup;
                        children = (
-                               B255989F0D00D8B800BB825C /* SVGFEColorMatrixCg.mm */,
-                               B25598A00D00D8B800BB825C /* SVGFEComponentTransferCg.mm */,
-                               B25598A10D00D8B800BB825C /* SVGFECompositeCg.mm */,
                                B25598A20D00D8B800BB825C /* SVGFEDiffuseLightingCg.mm */,
                                B25598A30D00D8B800BB825C /* SVGFEDisplacementMapCg.mm */,
                                B25598A40D00D8B800BB825C /* SVGFEFloodCg.mm */,
                                B25599720D00D8BA00BB825C /* SVGFEBlend.cpp in Sources */,
                                B22279C70D00BF220071B782 /* SVGFEBlendElement.cpp in Sources */,
                                B25599740D00D8BA00BB825C /* SVGFEColorMatrix.cpp in Sources */,
-                               B25599390D00D8BA00BB825C /* SVGFEColorMatrixCg.mm in Sources */,
                                B22279CA0D00BF220071B782 /* SVGFEColorMatrixElement.cpp in Sources */,
                                B25599760D00D8BA00BB825C /* SVGFEComponentTransfer.cpp in Sources */,
-                               B255993A0D00D8BA00BB825C /* SVGFEComponentTransferCg.mm in Sources */,
                                B22279CD0D00BF220071B782 /* SVGFEComponentTransferElement.cpp in Sources */,
                                B25599780D00D8BA00BB825C /* SVGFEComposite.cpp in Sources */,
-                               B255993B0D00D8BA00BB825C /* SVGFECompositeCg.mm in Sources */,
                                B22279D00D00BF220071B782 /* SVGFECompositeElement.cpp in Sources */,
                                B255997A0D00D8BA00BB825C /* SVGFEConvolveMatrix.cpp in Sources */,
                                B255997C0D00D8BA00BB825C /* SVGFEDiffuseLighting.cpp in Sources */,
index 5f8d400..b014409 100644 (file)
@@ -21,7 +21,9 @@
 #define FilterEffect_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
index e0872a7..d8257be 100644 (file)
@@ -33,7 +33,7 @@ namespace WebCore {
 
 SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement(const QualifiedName& tagName, Document* doc)
     : SVGElement(tagName, doc)
-    , m_type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN)
+    , m_type(FECOMPONENTTRANSFER_TYPE_UNKNOWN)
     , m_tableValues(SVGNumberList::create(SVGNames::tableValuesAttr))
     , m_slope(1.0f)
     , m_intercept(0.0f)
@@ -61,15 +61,15 @@ void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute*
     if (attr->name() == SVGNames::typeAttr)
     {
         if (value == "identity")
-            setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY);
+            setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_IDENTITY);
         else if (value == "table")
-            setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_TABLE);
+            setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_TABLE);
         else if (value == "discrete")
-            setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE);
+            setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_DISCRETE);
         else if (value == "linear")
-            setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_LINEAR);
+            setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_LINEAR);
         else if (value == "gamma")
-            setTypeBaseValue(SVG_FECOMPONENTTRANSFER_TYPE_GAMMA);
+            setTypeBaseValue(FECOMPONENTTRANSFER_TYPE_GAMMA);
     }
     else if (attr->name() == SVGNames::tableValuesAttr)
         tableValuesBaseValue()->parse(value);
@@ -87,10 +87,10 @@ void SVGComponentTransferFunctionElement::parseMappedAttribute(MappedAttribute*
         SVGElement::parseMappedAttribute(attr);
 }
 
-SVGComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const
+ComponentTransferFunction SVGComponentTransferFunctionElement::transferFunction() const
 {
-    SVGComponentTransferFunction func;
-    func.type = (SVGComponentTransferType) type();
+    ComponentTransferFunction func;
+    func.type = (ComponentTransferType) type();
     func.slope = slope();
     func.intercept = intercept();
     func.amplitude = amplitude();
index eadff18..aaf746c 100644 (file)
@@ -41,7 +41,7 @@ namespace WebCore
         // Derived from: 'Element'
         virtual void parseMappedAttribute(MappedAttribute* attr);
         
-        SVGComponentTransferFunction transferFunction() const;
+        ComponentTransferFunction transferFunction() const;
 
     private:
         ANIMATED_PROPERTY_DECLARATIONS(SVGComponentTransferFunctionElement, int, int, Type, type)
index 6d4db8a..be6ed0f 100644 (file)
@@ -33,7 +33,7 @@ namespace WebCore {
 
 SVGFEColorMatrixElement::SVGFEColorMatrixElement(const QualifiedName& tagName, Document* doc)
     : SVGFilterPrimitiveStandardAttributes(tagName, doc)
-    , m_type(SVG_FECOLORMATRIX_TYPE_UNKNOWN)
+    , m_type(FECOLORMATRIX_TYPE_UNKNOWN)
     , m_values(SVGNumberList::create(SVGNames::valuesAttr))
     , m_filterEffect(0)
 {
@@ -52,13 +52,13 @@ void SVGFEColorMatrixElement::parseMappedAttribute(MappedAttribute* attr)
     const String& value = attr->value();
     if (attr->name() == SVGNames::typeAttr) {
         if (value == "matrix")
-            setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_MATRIX);
+            setTypeBaseValue(FECOLORMATRIX_TYPE_MATRIX);
         else if (value == "saturate")
-            setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_SATURATE);
+            setTypeBaseValue(FECOLORMATRIX_TYPE_SATURATE);
         else if (value == "hueRotate")
-            setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_HUEROTATE);
+            setTypeBaseValue(FECOLORMATRIX_TYPE_HUEROTATE);
         else if (value == "luminanceToAlpha")
-            setTypeBaseValue(SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA);
+            setTypeBaseValue(FECOLORMATRIX_TYPE_LUMINANCETOALPHA);
     }
     else if (attr->name() == SVGNames::inAttr)
         setIn1BaseValue(value);
@@ -68,14 +68,19 @@ void SVGFEColorMatrixElement::parseMappedAttribute(MappedAttribute* attr)
         SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
 }
 
-SVGFEColorMatrix* SVGFEColorMatrixElement::filterEffect(SVGResourceFilter* filter) const
+SVGFilterEffect* SVGFEColorMatrixElement::filterEffect(SVGResourceFilter* filter) const
 {
-    if (!m_filterEffect)
-        m_filterEffect = SVGFEColorMatrix::create(filter);
-        
-    m_filterEffect->setIn(in1());
-    setStandardAttributes(m_filterEffect.get());
+    ASSERT_NOT_REACHED();
+    return 0;
+}
 
+bool SVGFEColorMatrixElement::build(FilterBuilder* builder)
+{
+    FilterEffect* input1 = builder->getEffectById(in1());
+    
+    if(!input1)
+        return false;
+    
     Vector<float> _values;
     SVGNumberList* numbers = values();
 
@@ -84,13 +89,13 @@ SVGFEColorMatrix* SVGFEColorMatrixElement::filterEffect(SVGResourceFilter* filte
     for (unsigned int i = 0;i < nr;i++)
         _values.append(numbers->getItem(i, ec));
 
-    m_filterEffect->setValues(_values);
-    m_filterEffect->setType((SVGColorMatrixType) type());
+    RefPtr<FilterEffect> addedEffect = FEColorMatrix::create(input1, static_cast<ColorMatrixType> (type()), _values);
+    builder->add(result(), addedEffect.release());
     
-    return m_filterEffect.get();
+    return true;
 }
 
-}
+} //namespace WebCore
 
 #endif // ENABLE(SVG)
 
index bda0553..a03013c 100644 (file)
@@ -24,6 +24,7 @@
 #define SVGFEColorMatrixElement_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterBuilder.h"
 #include "SVGFEColorMatrix.h"
 #include "SVGFilterPrimitiveStandardAttributes.h"
 
@@ -38,7 +39,8 @@ namespace WebCore
         virtual ~SVGFEColorMatrixElement();
 
         virtual void parseMappedAttribute(MappedAttribute*);
-        virtual SVGFEColorMatrix* filterEffect(SVGResourceFilter*) const;
+        virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+        bool build(FilterBuilder*);
 
     protected:
         virtual const SVGElement* contextElement() const { return this; }
@@ -48,7 +50,7 @@ namespace WebCore
         ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, int, int, Type, type)
         ANIMATED_PROPERTY_DECLARATIONS(SVGFEColorMatrixElement, SVGNumberList*, RefPtr<SVGNumberList>, Values, values)
 
-        mutable RefPtr<SVGFEColorMatrix> m_filterEffect;
+        mutable RefPtr<FEColorMatrix> m_filterEffect;
     };
 
 } // namespace WebCore
index ed65f14..f6cbbbf 100644 (file)
@@ -57,26 +57,39 @@ void SVGFEComponentTransferElement::parseMappedAttribute(MappedAttribute* attr)
         SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
 }
 
-SVGFEComponentTransfer* SVGFEComponentTransferElement::filterEffect(SVGResourceFilter* filter) const
+SVGFilterEffect* SVGFEComponentTransferElement::filterEffect(SVGResourceFilter* filter) const
 {
-    if (!m_filterEffect)
-        m_filterEffect = SVGFEComponentTransfer::create(filter);
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+bool SVGFEComponentTransferElement::build(FilterBuilder* builder)
+{
+    FilterEffect* input1 = builder->getEffectById(in1());
     
-    m_filterEffect->setIn(in1());
-    setStandardAttributes(m_filterEffect.get());
+    if(!input1)
+        return false;
+
+    ComponentTransferFunction red;
+    ComponentTransferFunction green;
+    ComponentTransferFunction blue;
+    ComponentTransferFunction alpha;
     
     for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
         if (n->hasTagName(SVGNames::feFuncRTag))
-            m_filterEffect->setRedFunction(static_cast<SVGFEFuncRElement*>(n)->transferFunction());
+            red = static_cast<SVGFEFuncRElement*>(n)->transferFunction();
         else if (n->hasTagName(SVGNames::feFuncGTag))
-            m_filterEffect->setGreenFunction(static_cast<SVGFEFuncGElement*>(n)->transferFunction());
+            green = static_cast<SVGFEFuncGElement*>(n)->transferFunction();
         else if (n->hasTagName(SVGNames::feFuncBTag))
-            m_filterEffect->setBlueFunction(static_cast<SVGFEFuncBElement*>(n)->transferFunction());
+           blue = static_cast<SVGFEFuncBElement*>(n)->transferFunction();
         else if (n->hasTagName(SVGNames::feFuncATag))
-            m_filterEffect->setAlphaFunction(static_cast<SVGFEFuncAElement*>(n)->transferFunction());
+            alpha = static_cast<SVGFEFuncAElement*>(n)->transferFunction();
     }
-
-    return m_filterEffect.get();
+    
+    RefPtr<FilterEffect> addedEffect = FEComponentTransfer::create(input1, red, green, blue, alpha);
+    builder->add(result(), addedEffect.release());
+    
+    return true;
 }
 
 }
index 02958b1..e391ec2 100644 (file)
@@ -24,6 +24,7 @@
 #define SVGFEComponentTransferElement_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterBuilder.h"
 #include "SVGFilterPrimitiveStandardAttributes.h"
 #include "SVGFEComponentTransfer.h"
 
@@ -37,7 +38,8 @@ namespace WebCore
         virtual ~SVGFEComponentTransferElement();
 
         virtual void parseMappedAttribute(MappedAttribute*);
-        virtual SVGFEComponentTransfer* filterEffect(SVGResourceFilter*) const;
+        virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+        bool build(FilterBuilder*);
 
     protected:
         virtual const SVGElement* contextElement() const { return this; }
@@ -45,7 +47,7 @@ namespace WebCore
     private:
         ANIMATED_PROPERTY_DECLARATIONS(SVGFEComponentTransferElement, String, String, In1, in1)
 
-        mutable RefPtr<SVGFEComponentTransfer> m_filterEffect;
+        mutable RefPtr<FEComponentTransfer> m_filterEffect;
     };
 
 } // namespace WebCore
index a135e3d..229117a 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 
 SVGFECompositeElement::SVGFECompositeElement(const QualifiedName& tagName, Document* doc)
     : SVGFilterPrimitiveStandardAttributes(tagName, doc)
-    , m__operator(SVG_FECOMPOSITE_OPERATOR_OVER)
+    , m__operator(FECOMPOSITE_OPERATOR_OVER)
     , m_k1(0.0f)
     , m_k2(0.0f)
     , m_k3(0.0f)
@@ -58,17 +58,17 @@ void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr)
     const String& value = attr->value();
     if (attr->name() == SVGNames::operatorAttr) {
         if (value == "over")
-            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OVER);
+            set_operatorBaseValue(FECOMPOSITE_OPERATOR_OVER);
         else if (value == "in")
-            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_IN);
+            set_operatorBaseValue(FECOMPOSITE_OPERATOR_IN);
         else if (value == "out")
-            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_OUT);
+            set_operatorBaseValue(FECOMPOSITE_OPERATOR_OUT);
         else if (value == "atop")
-            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ATOP);
+            set_operatorBaseValue(FECOMPOSITE_OPERATOR_ATOP);
         else if (value == "xor")
-            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_XOR);
+            set_operatorBaseValue(FECOMPOSITE_OPERATOR_XOR);
         else if (value == "arithmetic")
-            set_operatorBaseValue(SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
+            set_operatorBaseValue(FECOMPOSITE_OPERATOR_ARITHMETIC);
     }
     else if (attr->name() == SVGNames::inAttr)
         setIn1BaseValue(value);
@@ -86,21 +86,25 @@ void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr)
         SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
 }
 
-SVGFEComposite* SVGFECompositeElement::filterEffect(SVGResourceFilter* filter) const
+SVGFilterEffect* SVGFECompositeElement::filterEffect(SVGResourceFilter* filter) const
 {
-    if (!m_filterEffect)
-        m_filterEffect = SVGFEComposite::create(filter);
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+bool SVGFECompositeElement::build(FilterBuilder* builder)
+{
+    FilterEffect* input1 = builder->getEffectById(in1());
+    FilterEffect* input2 = builder->getEffectById(in2());
     
-    m_filterEffect->setOperation((SVGCompositeOperationType) _operator());
-    m_filterEffect->setIn(in1());
-    m_filterEffect->setIn2(in2());
-    m_filterEffect->setK1(k1());
-    m_filterEffect->setK2(k2());
-    m_filterEffect->setK3(k3());
-    m_filterEffect->setK4(k4());
-
-    setStandardAttributes(m_filterEffect.get());
-    return m_filterEffect.get();
+    if(!input1 || !input2)
+        return false;
+    
+    RefPtr<FilterEffect> addedEffect = FEComposite::create(input1, input2, static_cast<CompositeOperationType> (_operator()),
+        k1(), k2(), k3(), k4());
+    builder->add(result(), addedEffect.release());
+
+    return true;
 }
 
 }
index 841a677..73310ce 100644 (file)
@@ -24,6 +24,7 @@
 #define SVGFECompositeElement_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterBuilder.h"
 #include "SVGFEComposite.h"
 #include "SVGFilterPrimitiveStandardAttributes.h"
 
@@ -37,7 +38,8 @@ namespace WebCore
         virtual ~SVGFECompositeElement();
 
         virtual void parseMappedAttribute(MappedAttribute*);
-        virtual SVGFEComposite* filterEffect(SVGResourceFilter*) const;
+        virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+        bool build(FilterBuilder*);
 
     protected:
         virtual const SVGElement* contextElement() const { return this; }
@@ -51,7 +53,7 @@ namespace WebCore
         ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, float, float, K3, k3)
         ANIMATED_PROPERTY_DECLARATIONS(SVGFECompositeElement, float, float, K4, k4)
 
-        mutable RefPtr<SVGFEComposite> m_filterEffect;
+        mutable RefPtr<FEComposite> m_filterEffect;
     };
 
 } // namespace WebCore
index f6d328d..826f209 100644 (file)
@@ -23,7 +23,6 @@
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
 #include "SVGFEBlend.h"
-#include "TextStream.h"
 
 namespace WebCore {
 
index e31879e..b2835e8 100644 (file)
@@ -24,7 +24,6 @@
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
 #include "FilterEffect.h"
-#include "SVGFilterEffect.h"
 
 namespace WebCore {
 
index 61c7fb4..3831a08 100644 (file)
 
 namespace WebCore {
 
-SVGFEColorMatrix::SVGFEColorMatrix(SVGResourceFilter* filter)
-    : SVGFilterEffect(filter)
-    , m_type(SVG_FECOLORMATRIX_TYPE_UNKNOWN)
+FEColorMatrix::FEColorMatrix(FilterEffect* in, ColorMatrixType type, const Vector<float>& values)
+    : FilterEffect()
+    , m_in(in)
+    , m_type(type)
+    , m_values(values)
 {
 }
 
-PassRefPtr<SVGFEColorMatrix> SVGFEColorMatrix::create(SVGResourceFilter* filter)
+PassRefPtr<FEColorMatrix> FEColorMatrix::create(FilterEffect* in, ColorMatrixType type, const Vector<float>& values)
 {
-    return adoptRef(new SVGFEColorMatrix(filter));
+    return adoptRef(new FEColorMatrix(in, type, values));
 }
 
-SVGColorMatrixType SVGFEColorMatrix::type() const
+ColorMatrixType FEColorMatrix::type() const
 {
     return m_type;
 }
 
-void SVGFEColorMatrix::setType(SVGColorMatrixType type)
+void FEColorMatrix::setType(ColorMatrixType type)
 {
     m_type = type;
 }
 
-const Vector<float>& SVGFEColorMatrix::values() const
+const Vector<float>& FEColorMatrix::values() const
 {
     return m_values;
 }
 
-void SVGFEColorMatrix::setValues(const Vector<float> &values)
+void FEColorMatrix::setValues(const Vector<float> &values)
 {
     m_values = values;
 }
 
-static TextStream& operator<<(TextStream& ts, SVGColorMatrixType t)
+void FEColorMatrix::apply()
 {
-    switch (t)
-    {
-        case SVG_FECOLORMATRIX_TYPE_UNKNOWN:
-            ts << "UNKNOWN"; break;
-        case SVG_FECOLORMATRIX_TYPE_MATRIX:
-            ts << "CMT_MATRIX"; break;
-        case SVG_FECOLORMATRIX_TYPE_SATURATE:
-            ts << "CMT_SATURATE"; break;
-        case SVG_FECOLORMATRIX_TYPE_HUEROTATE:
-            ts << "HUE-ROTATE"; break;
-        case SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
-            ts << "LUMINANCE-TO-ALPHA"; break;
-    }
-    return ts;
 }
 
-TextStream& SVGFEColorMatrix::externalRepresentation(TextStream& ts) const
+void FEColorMatrix::dump()
 {
-    ts << "[type=COLOR-MATRIX] ";
-    SVGFilterEffect::externalRepresentation(ts);
-    ts << " [color matrix type=" << type() << "]"
-        << " [values=" << values() << "]";
-    return ts;
 }
 
 } // namespace WebCore
index aeb24f6..d8193ed 100644 (file)
 #define SVGFEColorMatrix_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
-#include "SVGRenderTreeAsText.h"
+#include "FilterEffect.h"
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
-enum SVGColorMatrixType {
-    SVG_FECOLORMATRIX_TYPE_UNKNOWN          = 0,
-    SVG_FECOLORMATRIX_TYPE_MATRIX           = 1,
-    SVG_FECOLORMATRIX_TYPE_SATURATE         = 2,
-    SVG_FECOLORMATRIX_TYPE_HUEROTATE        = 3,
-    SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4
-};
-
-class SVGFEColorMatrix : public SVGFilterEffect {
-public:
-    static PassRefPtr<SVGFEColorMatrix> create(SVGResourceFilter*);
-
-    SVGColorMatrixType type() const;
-    void setType(SVGColorMatrixType);
-
-    const Vector<float>& values() const;
-    void setValues(const Vector<float>&);
-
-    virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
-    virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
-    SVGFEColorMatrix(SVGResourceFilter*);
-
-    SVGColorMatrixType m_type;
-    Vector<float> m_values;
-};
+    enum ColorMatrixType {
+        FECOLORMATRIX_TYPE_UNKNOWN          = 0,
+        FECOLORMATRIX_TYPE_MATRIX           = 1,
+        FECOLORMATRIX_TYPE_SATURATE         = 2,
+        FECOLORMATRIX_TYPE_HUEROTATE        = 3,
+        FECOLORMATRIX_TYPE_LUMINANCETOALPHA = 4
+    };
+
+    class FEColorMatrix : public FilterEffect {
+    public:
+        static PassRefPtr<FEColorMatrix> create(FilterEffect*, ColorMatrixType, const Vector<float>&);
+
+        ColorMatrixType type() const;
+        void setType(ColorMatrixType);
+
+        const Vector<float>& values() const;
+        void setValues(const Vector<float>&);
+        
+        virtual void apply();
+        virtual void dump();
+
+    private:
+        FEColorMatrix(FilterEffect*, ColorMatrixType, const Vector<float>&);
+
+        RefPtr<FilterEffect> m_in;
+        ColorMatrixType m_type;
+        Vector<float> m_values;
+    };
 
 } // namespace WebCore
 
index 4fe4d3d..050ce75 100644 (file)
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
 #include "SVGFEComponentTransfer.h"
-#include "TextStream.h"
 
 namespace WebCore {
 
-SVGFEComponentTransfer::SVGFEComponentTransfer(SVGResourceFilter* filter)
-    : SVGFilterEffect(filter)
+FEComponentTransfer::FEComponentTransfer(FilterEffect* in, const ComponentTransferFunction& redFunc, 
+    const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc)
+    : FilterEffect()
+    , m_in(in)
+    , m_redFunc(redFunc)
+    , m_greenFunc(greenFunc)
+    , m_blueFunc(blueFunc)
+    , m_alphaFunc(alphaFunc)
 {
 }
 
-PassRefPtr<SVGFEComponentTransfer> SVGFEComponentTransfer::create(SVGResourceFilter* filter)
+PassRefPtr<FEComponentTransfer> FEComponentTransfer::create(FilterEffect* in, const ComponentTransferFunction& redFunc, 
+    const ComponentTransferFunction& greenFunc, const ComponentTransferFunction& blueFunc, const ComponentTransferFunction& alphaFunc)
 {
-    return adoptRef(new SVGFEComponentTransfer(filter));
+    return adoptRef(new FEComponentTransfer(in, redFunc, greenFunc, blueFunc, alphaFunc));
 }
 
-SVGComponentTransferFunction SVGFEComponentTransfer::redFunction() const
+ComponentTransferFunction FEComponentTransfer::redFunction() const
 {
     return m_redFunc;
 }
 
-void SVGFEComponentTransfer::setRedFunction(const SVGComponentTransferFunction& func)
+void FEComponentTransfer::setRedFunction(const ComponentTransferFunction& func)
 {
     m_redFunc = func;
 }
 
-SVGComponentTransferFunction SVGFEComponentTransfer::greenFunction() const
+ComponentTransferFunction FEComponentTransfer::greenFunction() const
 {
     return m_greenFunc;
 }
 
-void SVGFEComponentTransfer::setGreenFunction(const SVGComponentTransferFunction& func)
+void FEComponentTransfer::setGreenFunction(const ComponentTransferFunction& func)
 {
     m_greenFunc = func;
 }
 
-SVGComponentTransferFunction SVGFEComponentTransfer::blueFunction() const
+ComponentTransferFunction FEComponentTransfer::blueFunction() const
 {
     return m_blueFunc;
 }
 
-void SVGFEComponentTransfer::setBlueFunction(const SVGComponentTransferFunction& func)
+void FEComponentTransfer::setBlueFunction(const ComponentTransferFunction& func)
 {
     m_blueFunc = func;
 }
 
-SVGComponentTransferFunction SVGFEComponentTransfer::alphaFunction() const
+ComponentTransferFunction FEComponentTransfer::alphaFunction() const
 {
     return m_alphaFunc;
 }
 
-void SVGFEComponentTransfer::setAlphaFunction(const SVGComponentTransferFunction& func)
+void FEComponentTransfer::setAlphaFunction(const ComponentTransferFunction& func)
 {
     m_alphaFunc = func;
 }
 
-static TextStream& operator<<(TextStream& ts, SVGComponentTransferType t)
+void FEComponentTransfer::apply()
 {
-    switch (t)
-    {
-        case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
-            ts << "UNKNOWN"; break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
-            ts << "IDENTITY"; break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
-            ts << "TABLE"; break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
-            ts << "DISCRETE"; break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
-            ts << "LINEAR"; break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
-            ts << "GAMMA"; break;
-    }
-    return ts;
 }
 
-static TextStream& operator<<(TextStream& ts, const SVGComponentTransferFunction &func)
+void FEComponentTransfer::dump()
 {
-    ts << "[type=" << func.type << "]";
-    switch (func.type) {
-        case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
-        case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
-            break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
-        case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
-        {
-            ts << " [table values=";
-            Vector<float>::const_iterator itr=func.tableValues.begin();
-            if (itr != func.tableValues.end()) {
-                ts << *itr++;
-                for (; itr!=func.tableValues.end(); itr++) {
-                    ts << " " << *itr;
-                }
-            }
-            ts << "]";
-            break;
-        }
-        case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
-            ts << " [slope=" << func.slope << "]"
-               << " [intercept=" << func.intercept << "]";
-            break;
-        case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
-            ts << " [amplitude=" << func.amplitude << "]"
-               << " [exponent=" << func.exponent << "]"
-               << " [offset=" << func.offset << "]";
-            break;
-    }
-    return ts;
-}
-
-TextStream& SVGFEComponentTransfer::externalRepresentation(TextStream& ts) const
-{
-    ts << "[type=COMPONENT-TRANSFER] ";
-    SVGFilterEffect::externalRepresentation(ts);
-    ts << " [red func=" << redFunction() << "]"
-        << " [green func=" << greenFunction() << "]"
-        << " [blue func=" << blueFunction() << "]"
-        << " [alpha func=" << alphaFunction() << "]";
-    return ts;
 }
 
 } // namespace WebCore
index 29d22ba..20d70c0 100644 (file)
 #define SVGFEComponentTransfer_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include <wtf/Vector.h>
-
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
 #include "SVGFEDisplacementMap.h"
 
-#if PLATFORM(CI)
-#ifdef __OBJC__
-@class CIImage;
-@class CIFilter;
-#else
-class CIImage;
-class CIFilter;
-#endif
-#endif
+#include <wtf/Vector.h>
 
 namespace WebCore {
 
-enum SVGComponentTransferType {
-    SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN  = 0,
-    SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
-    SVG_FECOMPONENTTRANSFER_TYPE_TABLE    = 2,
-    SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
-    SVG_FECOMPONENTTRANSFER_TYPE_LINEAR   = 4,
-    SVG_FECOMPONENTTRANSFER_TYPE_GAMMA    = 5
-};
-
-struct SVGComponentTransferFunction {
-    SVGComponentTransferFunction()
-        : type(SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN)
-        , slope(0.0f)
-        , intercept(0.0f)
-        , amplitude(0.0f)
-        , exponent(0.0f)
-        , offset(0.0f)
-    {
-    }
-
-    SVGComponentTransferType type;
-
-    float slope;
-    float intercept;
-    float amplitude;
-    float exponent;
-    float offset;
-
-    Vector<float> tableValues;
-};
-
-class SVGFEComponentTransfer : public SVGFilterEffect {
-public:
-    static PassRefPtr<SVGFEComponentTransfer> create(SVGResourceFilter*);
-
-    SVGComponentTransferFunction redFunction() const;
-    void setRedFunction(const SVGComponentTransferFunction&);
-
-    SVGComponentTransferFunction greenFunction() const;
-    void setGreenFunction(const SVGComponentTransferFunction&);
-
-    SVGComponentTransferFunction blueFunction() const;
-    void setBlueFunction(const SVGComponentTransferFunction&);
-
-    SVGComponentTransferFunction alphaFunction() const;
-    void setAlphaFunction(const SVGComponentTransferFunction&);
-
-    virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
-    virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-
-private:
-    CIFilter* getFunctionFilter(SVGChannelSelectorType, CIImage* inputImage) const;
-#endif
-
-private:
-    SVGFEComponentTransfer(SVGResourceFilter*);
-
-    SVGComponentTransferFunction m_redFunc;
-    SVGComponentTransferFunction m_greenFunc;
-    SVGComponentTransferFunction m_blueFunc;
-    SVGComponentTransferFunction m_alphaFunc;
-};
+    enum ComponentTransferType {
+        FECOMPONENTTRANSFER_TYPE_UNKNOWN  = 0,
+        FECOMPONENTTRANSFER_TYPE_IDENTITY = 1,
+        FECOMPONENTTRANSFER_TYPE_TABLE    = 2,
+        FECOMPONENTTRANSFER_TYPE_DISCRETE = 3,
+        FECOMPONENTTRANSFER_TYPE_LINEAR   = 4,
+        FECOMPONENTTRANSFER_TYPE_GAMMA    = 5
+    };
+
+    struct ComponentTransferFunction {
+        ComponentTransferFunction()
+            : type(FECOMPONENTTRANSFER_TYPE_UNKNOWN)
+            , slope(0.0f)
+            , intercept(0.0f)
+            , amplitude(0.0f)
+            , exponent(0.0f)
+            , offset(0.0f)
+        {
+        }
+
+        ComponentTransferType type;
+
+        float slope;
+        float intercept;
+        float amplitude;
+        float exponent;
+        float offset;
+
+        Vector<float> tableValues;
+    };
+
+    class FEComponentTransfer : public FilterEffect {
+    public:
+        static PassRefPtr<FEComponentTransfer> create(FilterEffect*, const ComponentTransferFunction&, 
+                const ComponentTransferFunction&, const ComponentTransferFunction&, const ComponentTransferFunction&);
+
+        ComponentTransferFunction redFunction() const;
+        void setRedFunction(const ComponentTransferFunction&);
+
+        ComponentTransferFunction greenFunction() const;
+        void setGreenFunction(const ComponentTransferFunction&);
+
+        ComponentTransferFunction blueFunction() const;
+        void setBlueFunction(const ComponentTransferFunction&);
+
+        ComponentTransferFunction alphaFunction() const;
+        void setAlphaFunction(const ComponentTransferFunction&);
+        
+        virtual void apply();
+        virtual void dump();
+
+    private:
+        FEComponentTransfer(FilterEffect*,const ComponentTransferFunction&, const ComponentTransferFunction&,
+                const ComponentTransferFunction&, const ComponentTransferFunction&);
+
+        RefPtr<FilterEffect> m_in;
+        ComponentTransferFunction m_redFunc;
+        ComponentTransferFunction m_greenFunc;
+        ComponentTransferFunction m_blueFunc;
+        ComponentTransferFunction m_alphaFunc;
+    };
 
 } // namespace WebCore
 
index 0d59138..4085eca 100644 (file)
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
 #include "SVGFEComposite.h"
-#include "TextStream.h"
 
 namespace WebCore {
 
-SVGFEComposite::SVGFEComposite(SVGResourceFilter* filter)
-    : SVGFilterEffect(filter)
-    , m_operation(SVG_FECOMPOSITE_OPERATOR_UNKNOWN)
-    , m_k1(0.0f)
-    , m_k2(0.0f)
-    , m_k3(0.0f)
-    , m_k4(0.0f)
+FEComposite::FEComposite(FilterEffect* in, FilterEffect* in2, const CompositeOperationType& type,
+    const float& k1, const float& k2, const float& k3, const float& k4)
+    : FilterEffect()
+    , m_in(in)
+    , m_in2(in2)
+    , m_type(type)
+    , m_k1(k1)
+    , m_k2(k2)
+    , m_k3(k3)
+    , m_k4(k4)
 {
 }
 
-PassRefPtr<SVGFEComposite> SVGFEComposite::create(SVGResourceFilter* filter)
+PassRefPtr<FEComposite> FEComposite::create(FilterEffect* in, FilterEffect* in2, const CompositeOperationType& type,
+    const float& k1, const float& k2, const float& k3, const float& k4)
 {
-    return adoptRef(new SVGFEComposite(filter));
+    return adoptRef(new FEComposite(in, in2, type, k1, k2, k3, k4));
 }
 
-String SVGFEComposite::in2() const
+CompositeOperationType FEComposite::operation() const
 {
-    return m_in2;
+    return m_type;
 }
 
-void SVGFEComposite::setIn2(const String& in2)
+void FEComposite::setOperation(CompositeOperationType type)
 {
-    m_in2 = in2;
+    m_type = type;
 }
 
-SVGCompositeOperationType SVGFEComposite::operation() const
-{
-    return m_operation;
-}
-
-void SVGFEComposite::setOperation(SVGCompositeOperationType oper)
-{
-    m_operation = oper;
-}
-
-float SVGFEComposite::k1() const
+float FEComposite::k1() const
 {
     return m_k1;
 }
 
-void SVGFEComposite::setK1(float k1)
+void FEComposite::setK1(float k1)
 {
     m_k1 = k1;
 }
 
-float SVGFEComposite::k2() const
+float FEComposite::k2() const
 {
     return m_k2;
 }
 
-void SVGFEComposite::setK2(float k2)
+void FEComposite::setK2(float k2)
 {
     m_k2 = k2;
 }
 
-float SVGFEComposite::k3() const
+float FEComposite::k3() const
 {
     return m_k3;
 }
 
-void SVGFEComposite::setK3(float k3)
+void FEComposite::setK3(float k3)
 {
     m_k3 = k3;
 }
 
-float SVGFEComposite::k4() const
+float FEComposite::k4() const
 {
     return m_k4;
 }
 
-void SVGFEComposite::setK4(float k4)
+void FEComposite::setK4(float k4)
 {
     m_k4 = k4;
 }
 
-TextStream& SVGFEComposite::externalRepresentation(TextStream& ts) const
+void FEComposite::apply()
+{
+}
+
+void FEComposite::dump()
 {
-    ts << "[type=COMPOSITE] ";
-    SVGFilterEffect::externalRepresentation(ts);
-    if (!in2().isEmpty())
-        ts << " [in2=\"" << in2() << "\"]";
-    ts << " [k1=" << k1() << " k2=" << k2() << " k3=" << k3() << " k4=" << k4() << "]";
-    return ts;
 }
 
 } // namespace WebCore
index 5dbb7d6..d205395 100644 (file)
 #define SVGFEComposite_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFilterEffect.h"
+#include "FilterEffect.h"
+#include "PlatformString.h"
 
 namespace WebCore {
 
-enum SVGCompositeOperationType {
-    SVG_FECOMPOSITE_OPERATOR_UNKNOWN    = 0, 
-    SVG_FECOMPOSITE_OPERATOR_OVER       = 1,
-    SVG_FECOMPOSITE_OPERATOR_IN         = 2,
-    SVG_FECOMPOSITE_OPERATOR_OUT        = 3,
-    SVG_FECOMPOSITE_OPERATOR_ATOP       = 4,
-    SVG_FECOMPOSITE_OPERATOR_XOR        = 5,
-    SVG_FECOMPOSITE_OPERATOR_ARITHMETIC = 6
-};
-
-class SVGFEComposite : public SVGFilterEffect {
-public:
-    static PassRefPtr<SVGFEComposite> create(SVGResourceFilter*);
-
-    String in2() const;
-    void setIn2(const String&);
-
-    SVGCompositeOperationType operation() const;
-    void setOperation(SVGCompositeOperationType);
-
-    float k1() const;
-    void setK1(float);
-
-    float k2() const;
-    void setK2(float);
-
-    float k3() const;
-    void setK3(float);
-
-    float k4() const;
-    void setK4(float);
-
-    virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
-    virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
-    SVGFEComposite(SVGResourceFilter*);
-
-    SVGCompositeOperationType m_operation;
-    float m_k1;
-    float m_k2;
-    float m_k3;
-    float m_k4;
-    String m_in2;
-};
+    enum CompositeOperationType {
+        FECOMPOSITE_OPERATOR_UNKNOWN    = 0, 
+        FECOMPOSITE_OPERATOR_OVER       = 1,
+        FECOMPOSITE_OPERATOR_IN         = 2,
+        FECOMPOSITE_OPERATOR_OUT        = 3,
+        FECOMPOSITE_OPERATOR_ATOP       = 4,
+        FECOMPOSITE_OPERATOR_XOR        = 5,
+        FECOMPOSITE_OPERATOR_ARITHMETIC = 6
+    };
+
+    class FEComposite : public FilterEffect {
+    public:
+        static PassRefPtr<FEComposite> create(FilterEffect*, FilterEffect*, const CompositeOperationType&,
+                const float&, const float&, const float&, const float&);
+
+        CompositeOperationType operation() const;
+        void setOperation(CompositeOperationType);
+
+        float k1() const;
+        void setK1(float);
+
+        float k2() const;
+        void setK2(float);
+
+        float k3() const;
+        void setK3(float);
+
+        float k4() const;
+        void setK4(float);
+        
+        virtual void apply();
+        virtual void dump();
+
+    private:
+        FEComposite(FilterEffect*, FilterEffect*, const CompositeOperationType&,
+                const float&, const float&, const float&, const float&);
+
+        RefPtr<FilterEffect> m_in;
+        RefPtr<FilterEffect> m_in2;
+        CompositeOperationType m_type;
+        float m_k1;
+        float m_k2;
+        float m_k3;
+        float m_k4;
+    };
 
 } // namespace WebCore
 
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEColorMatrixCg.mm
deleted file mode 100644 (file)
index ae6e4aa..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-    Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
-
-    This file is part of the KDE project
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    aint with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFEColorMatrix.h"
-#include "SVGFEHelpersCg.h"
-
-#include <wtf/MathExtras.h>
-
-namespace WebCore {
-
-#define CMValuesCheck(expected, type) \
-    if (values().size() != expected) { \
-        NSLog(@"Error, incorrect number of values in ColorMatrix for type \"%s\", expected: %i actual: %i, ignoring filter.  Values:", type, expected, values().size()); \
-        for (unsigned x=0; x < values().size(); x++) fprintf(stderr, " %f", values()[x]); \
-        fprintf(stderr, "\n"); \
-        return nil; \
-    }
-
-CIFilter* SVGFEColorMatrix::getCIFilter(const FloatRect& bbox) const
-{
-    SVGResourceFilter* svgFilter = filter();
-    SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-    CIFilter* filter = nil;
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    switch (type()) {
-    case SVG_FECOLORMATRIX_TYPE_UNKNOWN:
-        return nil;     
-    case SVG_FECOLORMATRIX_TYPE_MATRIX:
-    {
-        CMValuesCheck(20, "matrix");
-        filter = [CIFilter filterWithName:@"CIColorMatrix"];
-        [filter setDefaults];
-        const Vector<float>& v = values();
-        [filter setValue:[CIVector vectorWithX:v[0] Y:v[1] Z:v[2] W:v[3]] forKey:@"inputRVector"];
-        [filter setValue:[CIVector vectorWithX:v[5] Y:v[6] Z:v[7] W:v[8]] forKey:@"inputGVector"];
-        [filter setValue:[CIVector vectorWithX:v[10] Y:v[11] Z:v[12] W:v[13]] forKey:@"inputBVector"];
-        [filter setValue:[CIVector vectorWithX:v[15] Y:v[16] Z:v[17] W:v[18]] forKey:@"inputAVector"];
-        [filter setValue:[CIVector vectorWithX:v[4] Y:v[9] Z:v[14] W:v[19]] forKey:@"inputBiasVector"];
-        break;
-    }
-    case SVG_FECOLORMATRIX_TYPE_SATURATE:
-    {
-        CMValuesCheck(1, "saturate");
-        filter = [CIFilter filterWithName:@"CIColorControls"];
-        [filter setDefaults];
-        float saturation = values()[0];
-        if ((saturation < 0.0) || (saturation > 3.0))
-            NSLog(@"WARNING: Saturation adjustment: %f outside supported range.");
-        [filter setValue:[NSNumber numberWithFloat:saturation] forKey:@"inputSaturation"];
-        break;
-    }
-    case SVG_FECOLORMATRIX_TYPE_HUEROTATE:
-    {
-        CMValuesCheck(1, "hueRotate");
-        filter = [CIFilter filterWithName:@"CIHueAdjust"];
-        [filter setDefaults];
-        float radians = deg2rad(values()[0]);
-        [filter setValue:[NSNumber numberWithFloat:radians] forKey:@"inputAngle"];
-        break;
-    }
-    case SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA:
-    {
-        CMValuesCheck(0, "luminanceToAlpha");
-        // FIXME: I bet there is an easy filter to do this.
-        filter = [CIFilter filterWithName:@"CIColorMatrix"];
-        [filter setDefaults];
-        CGFloat zero[4] = {0, 0, 0, 0};
-        CGFloat alpha[4] = {0.2125f, 0.7154f, 0.0721f, 0};
-        [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputRVector"];
-        [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputGVector"];
-        [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBVector"];
-        [filter setValue:[CIVector vectorWithValues:alpha count:4] forKey:@"inputAVector"];
-        [filter setValue:[CIVector vectorWithValues:zero count:4] forKey:@"inputBiasVector"];
-        break;
-    }
-    default:
-    LOG_ERROR("Unhandled ColorMatrix type: %i", type());
-    return nil;
-    }
-    CIImage *inputImage = filterPlatformData->inputImage(this);
-    FE_QUARTZ_CHECK_INPUT(inputImage);
-    [filter setValue:inputImage forKey:@"inputImage"];
-
-    FE_QUARTZ_MAP_TO_SUBREGION(bbox);
-    FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEComponentTransferCg.mm
deleted file mode 100644 (file)
index 61515db..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-    Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
-
-    This file is part of the KDE project
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    aint with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFEComponentTransfer.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKComponentMergeFilter.h"
-#import "WKIdentityTransferFilter.h"
-#import "WKTableTransferFilter.h"
-#import "WKDiscreteTransferFilter.h"
-#import "WKLinearTransferFilter.h"
-#import "WKGammaTransferFilter.h"
-
-namespace WebCore {
-
-static CIImage* genImageFromTable(const Vector<float>& table)
-{
-    int length = table.size();
-    int nBytes = length * 4 * sizeof(float);
-    float* tableStore = (float *) malloc(nBytes);
-    NSData* bitmapData = [NSData dataWithBytesNoCopy:tableStore length:nBytes];
-    for (Vector<float>::const_iterator it = table.begin(); it != table.end(); it++) {
-        const float value = *it;
-        *tableStore++ = value;
-        *tableStore++ = value;
-        *tableStore++ = value;
-        *tableStore++ = value;
-    }
-    return [CIImage imageWithBitmapData:bitmapData bytesPerRow:nBytes size:CGSizeMake(length, 1) format:kCIFormatRGBAf colorSpace:nil];
-}
-
-static void setParametersForComponentFunc(CIFilter* filter, const SVGComponentTransferFunction& func, CIVector* channelSelector)
-{
-    switch (func.type) {
-    case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
-        return;
-    case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
-        [filter setValue:genImageFromTable(func.tableValues) forKey:@"inputTable"];
-        [filter setValue:channelSelector forKey:@"inputSelector"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
-        [filter setValue:genImageFromTable(func.tableValues) forKey:@"inputTable"];
-        [filter setValue:channelSelector forKey:@"inputSelector"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
-        [filter setValue:[NSNumber numberWithFloat:func.slope] forKey:@"inputSlope"];
-        [filter setValue:[NSNumber numberWithFloat:func.intercept] forKey:@"inputIntercept"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
-        [filter setValue:[NSNumber numberWithFloat:func.amplitude] forKey:@"inputAmplitude"];
-        [filter setValue:[NSNumber numberWithFloat:func.exponent] forKey:@"inputExponent"];
-        [filter setValue:[NSNumber numberWithFloat:func.offset] forKey:@"inputOffset"];
-        break;
-    default:
-        // identity has no args
-        break;
-    }
-}
-
-static CIFilter* filterForComponentFunc(const SVGComponentTransferFunction& func)
-{
-    CIFilter *filter;
-    switch (func.type) {
-    case SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN:
-    case SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY:
-        filter = [CIFilter filterWithName:@"WKIdentityTransfer"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_TABLE:
-        filter = [CIFilter filterWithName:@"WKTableTransferFilter"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE:
-        filter = [CIFilter filterWithName:@"WKDiscreteTransferFilter"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_LINEAR:
-        filter = [CIFilter filterWithName:@"WKLinearTransfer"];
-        break;
-    case SVG_FECOMPONENTTRANSFER_TYPE_GAMMA:
-        filter = [CIFilter filterWithName:@"WKGammaTransfer"];
-        break;
-    default:
-        NSLog(@"WARNING: Unknown function type for feComponentTransfer");
-        //and to prevent the entire svg from failing as a result
-        filter = [CIFilter filterWithName:@"WKIdentityTransfer"];
-        break;
-    }
-    return filter;
-}
-
-static CIFilter* getFilterForFunc(const SVGComponentTransferFunction& func, CIImage* inputImage, CIVector* channelSelector)
-{
-    CIFilter* filter = filterForComponentFunc(func);
-    [filter setDefaults];
-
-    setParametersForComponentFunc(filter, func, channelSelector);
-    [filter setValue:inputImage forKey:@"inputImage"];
-    return filter;
-}
-
-CIFilter* SVGFEComponentTransfer::getFunctionFilter(SVGChannelSelectorType channel, CIImage* inputImage) const
-{
-    switch (channel) {
-        case SVG_CHANNEL_R:
-            return [getFilterForFunc(redFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
-        case SVG_CHANNEL_G:
-            return [getFilterForFunc(greenFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
-        case SVG_CHANNEL_B:
-            return [getFilterForFunc(blueFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
-        case SVG_CHANNEL_A:
-            return [getFilterForFunc(alphaFunction(), inputImage, getVectorForChannel(channel)) valueForKey:@"outputImage"];
-        default:
-            return nil;
-    }
-}
-
-CIFilter* SVGFEComponentTransfer::getCIFilter(const FloatRect& bbox) const
-{
-    [WKComponentMergeFilter class];
-    [WKIdentityTransferFilter class];
-    [WKTableTransferFilter class];
-    [WKDiscreteTransferFilter class];
-    [WKLinearTransferFilter class];
-    [WKGammaTransferFilter class];
-
-    SVGResourceFilter* svgFilter = filter();
-    SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-    CIFilter* filter = nil;
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    filter = [CIFilter filterWithName:@"WKComponentMerge"];
-    if (!filter)
-        return nil;
-    [filter setDefaults];
-    CIImage* inputImage = filterPlatformData->inputImage(this);
-    FE_QUARTZ_CHECK_INPUT(inputImage);
-
-    [filter setValue:getFunctionFilter(SVG_CHANNEL_R, inputImage) forKey:@"inputFuncR"];
-    [filter setValue:getFunctionFilter(SVG_CHANNEL_G, inputImage) forKey:@"inputFuncG"];
-    [filter setValue:getFunctionFilter(SVG_CHANNEL_B, inputImage) forKey:@"inputFuncB"];
-    [filter setValue:getFunctionFilter(SVG_CHANNEL_A, inputImage) forKey:@"inputFuncA"];
-
-    FE_QUARTZ_MAP_TO_SUBREGION(bbox);
-    FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
diff --git a/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm b/WebCore/svg/graphics/filters/cg/SVGFECompositeCg.mm
deleted file mode 100644 (file)
index 624612c..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-    Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
-
-    This file is part of the KDE project
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    aint with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-
-#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
-#include "SVGFEComposite.h"
-#include "SVGFEHelpersCg.h"
-
-#import "WKArithmeticFilter.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEComposite::getCIFilter(const FloatRect& bbox) const
-{
-    SVGResourceFilter* svgFilter = filter();
-    SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-    CIFilter* filter = nil;
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-    switch (operation()) {
-    case SVG_FECOMPOSITE_OPERATOR_UNKNOWN:
-        return nil;
-    case SVG_FECOMPOSITE_OPERATOR_OVER:
-        filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
-        break;
-    case SVG_FECOMPOSITE_OPERATOR_IN:
-        filter = [CIFilter filterWithName:@"CISourceInCompositing"];
-        break;
-    case SVG_FECOMPOSITE_OPERATOR_OUT:
-        filter = [CIFilter filterWithName:@"CISourceOutCompositing"];
-        break;
-    case SVG_FECOMPOSITE_OPERATOR_ATOP:
-        filter = [CIFilter filterWithName:@"CISourceAtopCompositing"];
-        break;
-    case SVG_FECOMPOSITE_OPERATOR_XOR:
-        //FIXME: I'm not sure this is right...
-        filter = [CIFilter filterWithName:@"CIExclusionBlendMode"];
-        break;
-    case SVG_FECOMPOSITE_OPERATOR_ARITHMETIC:
-        [WKArithmeticFilter class];
-        filter = [CIFilter filterWithName:@"WKArithmeticFilter"];
-        break;
-    }
-
-    [filter setDefaults];
-    CIImage* inputImage = filterPlatformData->inputImage(this);
-    CIImage* backgroundImage = filterPlatformData->imageForName(in2());
-    FE_QUARTZ_CHECK_INPUT(inputImage);
-    FE_QUARTZ_CHECK_INPUT(backgroundImage);
-    [filter setValue:inputImage forKey:@"inputImage"];
-    [filter setValue:backgroundImage forKey:@"inputBackgroundImage"];
-    //FIXME: this seems ugly
-    if (operation() == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) {
-        [filter setValue:[NSNumber numberWithFloat:k1()] forKey:@"inputK1"];
-        [filter setValue:[NSNumber numberWithFloat:k2()] forKey:@"inputK2"];
-        [filter setValue:[NSNumber numberWithFloat:k3()] forKey:@"inputK3"];
-        [filter setValue:[NSNumber numberWithFloat:k4()] forKey:@"inputK4"];
-    }
-
-    FE_QUARTZ_MAP_TO_SUBREGION(bbox);
-    FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)