2008-07-01 Alex Mathews <possessedpenguinbob@gmail.com>
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Jul 2008 05:55:50 +0000 (05:55 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Jul 2008 05:55:50 +0000 (05:55 +0000)
        Reviewed by Oliver Hunt.

        Renaming of class SVGFEBlend to FEBlend as well as removing
        a little bit of antiquated code. This includes the removal of
        SVGFEBlendCg.mm; the feBlend element will now no longer
        render.

        * WebCore.xcodeproj/project.pbxproj:
        * svg/FilterBuilder.h:
        (WebCore::FilterBuilder::add):
        (WebCore::FilterBuilder::getEffectById):
        * svg/SVGFEBlendElement.cpp:
        (WebCore::SVGFEBlendElement::SVGFEBlendElement):
        (WebCore::SVGFEBlendElement::parseMappedAttribute):
        (WebCore::SVGFEBlendElement::filterEffect):
        (WebCore::SVGFEBlendElement::build):
        * svg/SVGFEBlendElement.h:
        * svg/SVGFilterPrimitiveStandardAttributes.h:
        * svg/graphics/filters/SVGFEBlend.cpp:
        (WebCore::FEBlend::FEBlend):
        (WebCore::FEBlend::create):
        (WebCore::FEBlend::in2):
        (WebCore::FEBlend::setIn2):
        (WebCore::FEBlend::blendMode):
        (WebCore::FEBlend::setBlendMode):
        (WebCore::FEBlend::apply):
        (WebCore::FEBlend::dump):
        * svg/graphics/filters/SVGFEBlend.h:
        (WebCore::):
        * svg/graphics/filters/cg/SVGFEBlendCg.mm: Removed.

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

WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/svg/FilterBuilder.h
WebCore/svg/SVGFEBlendElement.cpp
WebCore/svg/SVGFEBlendElement.h
WebCore/svg/graphics/filters/SVGFEBlend.cpp
WebCore/svg/graphics/filters/SVGFEBlend.h
WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm [deleted file]

index 8da4208..b442fe5 100644 (file)
@@ -1,3 +1,36 @@
+2008-07-01  Alex Mathews  <possessedpenguinbob@gmail.com>
+
+        Reviewed by Oliver Hunt.
+
+        Renaming of class SVGFEBlend to FEBlend as well as removing
+        a little bit of antiquated code. This includes the removal of
+        SVGFEBlendCg.mm; the feBlend element will now no longer
+        render. 
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * svg/FilterBuilder.h:
+        (WebCore::FilterBuilder::add):
+        (WebCore::FilterBuilder::getEffectById):
+        * svg/SVGFEBlendElement.cpp:
+        (WebCore::SVGFEBlendElement::SVGFEBlendElement):
+        (WebCore::SVGFEBlendElement::parseMappedAttribute):
+        (WebCore::SVGFEBlendElement::filterEffect):
+        (WebCore::SVGFEBlendElement::build):
+        * svg/SVGFEBlendElement.h:
+        * svg/SVGFilterPrimitiveStandardAttributes.h:
+        * svg/graphics/filters/SVGFEBlend.cpp:
+        (WebCore::FEBlend::FEBlend):
+        (WebCore::FEBlend::create):
+        (WebCore::FEBlend::in2):
+        (WebCore::FEBlend::setIn2):
+        (WebCore::FEBlend::blendMode):
+        (WebCore::FEBlend::setBlendMode):
+        (WebCore::FEBlend::apply):
+        (WebCore::FEBlend::dump):
+        * svg/graphics/filters/SVGFEBlend.h:
+        (WebCore::):
+        * svg/graphics/filters/cg/SVGFEBlendCg.mm: Removed.
+
 2008-07-02  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Darin.
index 5f45f77..4d8a708 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 */; };
-               B25599380D00D8BA00BB825C /* SVGFEBlendCg.mm in Sources */ = {isa = PBXBuildFile; fileRef = B255989E0D00D8B800BB825C /* SVGFEBlendCg.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 */; };
                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>"; };
-               B255989E0D00D8B800BB825C /* SVGFEBlendCg.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SVGFEBlendCg.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>"; };
                                B22277CC0D00BF1F0071B782 /* ColorDistance.h */,
                                E415F1830D9A1A830033CE97 /* ElementTimeControl.h */,
                                E415F10C0D9A05870033CE97 /* ElementTimeControl.idl */,
+                               50A5E4710E1AEF3A000A03AE /* Filter.cpp */,
                                50A5DF730E1A13C9000A03AE /* Filter.h */,
                                50A5DF740E1A13C9000A03AE /* FilterBuilder.h */,
+                               50A5E4730E1AEF84000A03AE /* FilterEffect.cpp */,
                                50A5E20F0E1ABAF2000A03AE /* FilterEffect.h */,
                                B22277CD0D00BF1F0071B782 /* GradientAttributes.h */,
                                B22277CE0D00BF1F0071B782 /* LinearGradientAttributes.h */,
                                B22278150D00BF1F0071B782 /* SVGDefinitionSrcElement.h */,
                                B22278160D00BF1F0071B782 /* SVGDefinitionSrcElement.idl */,
                                B22278170D00BF1F0071B782 /* SVGDefsElement.cpp */,
-                               50A5E4710E1AEF3A000A03AE /* Filter.cpp */,
                                B22278180D00BF1F0071B782 /* SVGDefsElement.h */,
-                               50A5E4730E1AEF84000A03AE /* FilterEffect.cpp */,
                                B22278190D00BF1F0071B782 /* SVGDefsElement.idl */,
                                B222781A0D00BF1F0071B782 /* SVGDescElement.cpp */,
                                B222781B0D00BF1F0071B782 /* SVGDescElement.h */,
                B255989D0D00D8B800BB825C /* cg */ = {
                        isa = PBXGroup;
                        children = (
-                               B255989E0D00D8B800BB825C /* SVGFEBlendCg.mm */,
                                B255989F0D00D8B800BB825C /* SVGFEColorMatrixCg.mm */,
                                B25598A00D00D8B800BB825C /* SVGFEComponentTransferCg.mm */,
                                B25598A10D00D8B800BB825C /* SVGFECompositeCg.mm */,
                                B22279BF0D00BF220071B782 /* SVGEllipseElement.cpp in Sources */,
                                B22279C40D00BF220071B782 /* SVGExternalResourcesRequired.cpp in Sources */,
                                B25599720D00D8BA00BB825C /* SVGFEBlend.cpp in Sources */,
-                               B25599380D00D8BA00BB825C /* SVGFEBlendCg.mm in Sources */,
                                B22279C70D00BF220071B782 /* SVGFEBlendElement.cpp in Sources */,
                                B25599740D00D8BA00BB825C /* SVGFEColorMatrix.cpp in Sources */,
                                B25599390D00D8BA00BB825C /* SVGFEColorMatrixCg.mm in Sources */,
index 319615d..630537c 100644 (file)
@@ -34,13 +34,13 @@ namespace WebCore {
     
     class FilterBuilder : public RefCounted<FilterBuilder> {
     public:
-        void add(const String& id, PassRefPtr<FilterEffect> effect) { m_namedEffects.set(id, effect); }
-        FilterEffect* getEffectById(const String& id) const { return m_namedEffects.get(id).get(); }
+        void add(const String& id, PassRefPtr<FilterEffect> effect) { m_namedEffects.set(id.impl(), effect); }
+        FilterEffect* getEffectById(const String& id) const { return m_namedEffects.get(id.impl()).get(); }
         
         PassRefPtr<Filter> filter() const { return m_filter; }
         
     private:
-        HashMap<String, RefPtr<FilterEffect> > m_namedEffects;
+        HashMap<StringImpl*, RefPtr<FilterEffect> > m_namedEffects;
         
         RefPtr<Filter> m_filter;
     };
index 694ac97..9848ebb 100644 (file)
@@ -31,7 +31,7 @@ namespace WebCore {
 
 SVGFEBlendElement::SVGFEBlendElement(const QualifiedName& tagName, Document* doc)
     : SVGFilterPrimitiveStandardAttributes(tagName, doc)
-    , m_mode(SVG_FEBLEND_MODE_NORMAL)
+    , m_mode(FEBLEND_MODE_NORMAL)
     , m_filterEffect(0)
 {
 }
@@ -49,15 +49,15 @@ void SVGFEBlendElement::parseMappedAttribute(MappedAttribute* attr)
     const String& value = attr->value();
     if (attr->name() == SVGNames::modeAttr) {
         if (value == "normal")
-            setModeBaseValue(SVG_FEBLEND_MODE_NORMAL);
+            setModeBaseValue(FEBLEND_MODE_NORMAL);
         else if (value == "multiply")
-            setModeBaseValue(SVG_FEBLEND_MODE_MULTIPLY);
+            setModeBaseValue(FEBLEND_MODE_MULTIPLY);
         else if (value == "screen")
-            setModeBaseValue(SVG_FEBLEND_MODE_SCREEN);
+            setModeBaseValue(FEBLEND_MODE_SCREEN);
         else if (value == "darken")
-            setModeBaseValue(SVG_FEBLEND_MODE_DARKEN);
+            setModeBaseValue(FEBLEND_MODE_DARKEN);
         else if (value == "lighten")
-            setModeBaseValue(SVG_FEBLEND_MODE_LIGHTEN);
+            setModeBaseValue(FEBLEND_MODE_LIGHTEN);
     } else if (attr->name() == SVGNames::inAttr)
         setIn1BaseValue(value);
     else if (attr->name() == SVGNames::in2Attr)
@@ -66,16 +66,24 @@ void SVGFEBlendElement::parseMappedAttribute(MappedAttribute* attr)
         SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
 }
 
-SVGFEBlend* SVGFEBlendElement::filterEffect(SVGResourceFilter* filter) const
+SVGFilterEffect* SVGFEBlendElement::filterEffect(SVGResourceFilter* filter) const
 {
-    if (!m_filterEffect)
-        m_filterEffect = SVGFEBlend::create(filter);
+    ASSERT_NOT_REACHED(); 
+    return 0;
+}
+
+bool SVGFEBlendElement::build(FilterBuilder* builder)
+{
+    FilterEffect* input1 = builder->getEffectById(in1());
+    FilterEffect* input2 = builder->getEffectById(in2());
+    
+    if(!input1 || !input2)
+        return false;
+
+    RefPtr<FilterEffect> addedEffect = FEBlend::create(input1, input2, static_cast<BlendModeType> (mode()));
+    builder->add(result(), addedEffect.release());
     
-    m_filterEffect->setBlendMode((SVGBlendModeType) mode());
-    m_filterEffect->setIn(in1());
-    m_filterEffect->setIn2(in2());
-    setStandardAttributes(m_filterEffect.get());
-    return m_filterEffect.get();
+    return true;
 }
 
 }
index 72185e4..2ac7b55 100644 (file)
@@ -24,6 +24,7 @@
 #define SVGFEBlendElement_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterBuilder.h"
 #include "SVGFEBlend.h"
 #include "SVGFilterPrimitiveStandardAttributes.h"
 
@@ -36,7 +37,8 @@ namespace WebCore
         virtual ~SVGFEBlendElement();
 
         virtual void parseMappedAttribute(MappedAttribute*);
-        virtual SVGFEBlend* filterEffect(SVGResourceFilter*) const;
+        virtual SVGFilterEffect* filterEffect(SVGResourceFilter*) const;
+        bool build(FilterBuilder*);
 
     protected:
         virtual const SVGElement* contextElement() const { return this; }
@@ -46,7 +48,7 @@ namespace WebCore
         ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, String, String, In2, in2)
         ANIMATED_PROPERTY_DECLARATIONS(SVGFEBlendElement, int, int, Mode, mode)
 
-        mutable RefPtr<SVGFEBlend> m_filterEffect;
+        mutable RefPtr<FEBlend> m_filterEffect;
     };
 
 } // namespace WebCore
index b7e2afa..f6d328d 100644 (file)
 
 namespace WebCore {
 
-SVGFEBlend::SVGFEBlend(SVGResourceFilter* filter)
-    : SVGFilterEffect(filter)
-    , m_mode(SVG_FEBLEND_MODE_UNKNOWN)
+FEBlend::FEBlend(FilterEffect* in, FilterEffect* in2, BlendModeType mode)
+    : FilterEffect()
+    , m_in(in)
+    , m_in2(in2)
+    , m_mode(mode)
 {
 }
 
-PassRefPtr<SVGFEBlend> SVGFEBlend::create(SVGResourceFilter* filter)
+PassRefPtr<FEBlend> FEBlend::create(FilterEffect* in, FilterEffect* in2, BlendModeType mode)
 {
-    return adoptRef(new SVGFEBlend(filter));
+    return adoptRef(new FEBlend(in, in2, mode));
 }
 
-String SVGFEBlend::in2() const
+FilterEffect* FEBlend::in2() const
 {
-    return m_in2;
+    return m_in2.get();
 }
 
-void SVGFEBlend::setIn2(const String& in2)
+void FEBlend::setIn2(FilterEffect* in2)
 {
     m_in2 = in2;
 }
 
-SVGBlendModeType SVGFEBlend::blendMode() const
+BlendModeType FEBlend::blendMode() const
 {
     return m_mode;
 }
 
-void SVGFEBlend::setBlendMode(SVGBlendModeType mode)
+void FEBlend::setBlendMode(BlendModeType mode)
 {
     m_mode = mode;
 }
 
-static TextStream& operator<<(TextStream& ts, SVGBlendModeType t)
+void FEBlend::apply()
 {
-    switch (t)
-    {
-        case SVG_FEBLEND_MODE_UNKNOWN:
-            ts << "UNKNOWN"; break;
-        case SVG_FEBLEND_MODE_NORMAL:
-            ts << "NORMAL"; break;
-        case SVG_FEBLEND_MODE_MULTIPLY:
-            ts << "MULTIPLY"; break;
-        case SVG_FEBLEND_MODE_SCREEN:
-            ts << "SCREEN"; break;
-        case SVG_FEBLEND_MODE_DARKEN:
-            ts << "DARKEN"; break;
-        case SVG_FEBLEND_MODE_LIGHTEN:
-            ts << "LIGHTEN"; break;
-    }
-    return ts;
 }
 
-TextStream& SVGFEBlend::externalRepresentation(TextStream& ts) const
+void FEBlend::dump()
 {
-    ts << "[type=BLEND] ";
-    SVGFilterEffect::externalRepresentation(ts);
-    if (!m_in2.isEmpty())
-        ts << " [in2=\"" << m_in2 << "\"]";
-    ts << " [blend mode=" << m_mode << "]";
-    return ts;
 }
 
 } // namespace WebCore
index 1b6b28b..e31879e 100644 (file)
 #define SVGFEBlend_h
 
 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
+#include "FilterEffect.h"
 #include "SVGFilterEffect.h"
 
 namespace WebCore {
 
-enum SVGBlendModeType {
-    SVG_FEBLEND_MODE_UNKNOWN  = 0,
-    SVG_FEBLEND_MODE_NORMAL   = 1,
-    SVG_FEBLEND_MODE_MULTIPLY = 2,
-    SVG_FEBLEND_MODE_SCREEN   = 3,
-    SVG_FEBLEND_MODE_DARKEN   = 4,
-    SVG_FEBLEND_MODE_LIGHTEN  = 5
-};
-
-class SVGFEBlend : public SVGFilterEffect {
-public:
-    static PassRefPtr<SVGFEBlend> create(SVGResourceFilter*);
-    
-    String in2() const;
-    void setIn2(const String&);
-
-    SVGBlendModeType blendMode() const;
-    void setBlendMode(SVGBlendModeType);
-
-    virtual TextStream& externalRepresentation(TextStream&) const;
-
-#if PLATFORM(CI)
-    virtual CIFilter* getCIFilter(const FloatRect& bbox) const;
-#endif
-
-private:
-    SVGFEBlend(SVGResourceFilter*);
-
-    SVGBlendModeType m_mode;
-    String m_in2;
-};
+    enum BlendModeType {
+        FEBLEND_MODE_UNKNOWN  = 0,
+        FEBLEND_MODE_NORMAL   = 1,
+        FEBLEND_MODE_MULTIPLY = 2,
+        FEBLEND_MODE_SCREEN   = 3,
+        FEBLEND_MODE_DARKEN   = 4,
+        FEBLEND_MODE_LIGHTEN  = 5
+    };
+
+    class FEBlend : public FilterEffect {
+    public:
+        static PassRefPtr<FEBlend> create(FilterEffect*, FilterEffect*, BlendModeType);
+        
+        FilterEffect* in2() const;
+        void setIn2(FilterEffect*);
+
+        BlendModeType blendMode() const;
+        void setBlendMode(BlendModeType);
+        
+        virtual void apply();
+        virtual void dump();
+
+    private:
+        FEBlend(FilterEffect*, FilterEffect*, BlendModeType);
+
+        RefPtr<FilterEffect> m_in;
+        RefPtr<FilterEffect> m_in2;
+        BlendModeType m_mode;
+    };
 
 } // namespace WebCore
 
diff --git a/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm b/WebCore/svg/graphics/filters/cg/SVGFEBlendCg.mm
deleted file mode 100644 (file)
index 29caaa0..0000000
+++ /dev/null
@@ -1,77 +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 "SVGFEBlend.h"
-#include "SVGFEHelpersCg.h"
-
-namespace WebCore {
-
-CIFilter* SVGFEBlend::getCIFilter(const FloatRect& bbox) const
-{
-    SVGResourceFilter* svgFilter = filter();
-    SVGResourceFilterPlatformDataMac* filterPlatformData = static_cast<SVGResourceFilterPlatformDataMac*>(svgFilter->platformData());
-    CIFilter* filter = nil;
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
-    switch (blendMode()) {
-    case SVG_FEBLEND_MODE_UNKNOWN:
-        return nil;
-    case SVG_FEBLEND_MODE_NORMAL:
-        // FIXME: I think this is correct....
-        filter = [CIFilter filterWithName:@"CISourceOverCompositing"];
-        break;
-    case SVG_FEBLEND_MODE_MULTIPLY:
-        filter = [CIFilter filterWithName:@"CIMultiplyBlendMode"];
-        break;
-    case SVG_FEBLEND_MODE_SCREEN:
-        filter = [CIFilter filterWithName:@"CIScreenBlendMode"];
-        break;
-    case SVG_FEBLEND_MODE_DARKEN:
-        filter = [CIFilter filterWithName:@"CIDarkenBlendMode"];
-        break;
-    case SVG_FEBLEND_MODE_LIGHTEN:
-        filter = [CIFilter filterWithName:@"CILightenBlendMode"];
-        break;
-    default:
-        LOG_ERROR("Unhandled blend mode: %i", blendMode());
-        return nil;
-    }
-
-    [filter setDefaults];
-
-    CIImage* inputImage = filterPlatformData->inputImage(this);
-    FE_QUARTZ_CHECK_INPUT(inputImage);
-    [filter setValue:inputImage forKey:@"inputImage"];
-
-    CIImage* backgroundImage = filterPlatformData->imageForName(in2());
-    FE_QUARTZ_CHECK_INPUT(backgroundImage);
-    [filter setValue:backgroundImage forKey:@"inputBackgroundImage"];
-
-    FE_QUARTZ_MAP_TO_SUBREGION(bbox);
-    FE_QUARTZ_OUTPUT_RETURN;
-}
-
-}
-
-#endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)