webengine/osswebengine/WebCore/platform/graphics/svg/SVGResourceFilter.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2     Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <wildfox@kde.org>
       
     3                   2004, 2005 Rob Buis <buis@kde.org>
       
     4                   2005 Eric Seidel <eric.seidel@kdemail.net>
       
     5 
       
     6     This file is part of the KDE project
       
     7 
       
     8     This library is free software; you can redistribute it and/or
       
     9     modify it under the terms of the GNU Library General Public
       
    10     License as published by the Free Software Foundation; either
       
    11     version 2 of the License, or (at your option) any later version.
       
    12 
       
    13     This library is distributed in the hope that it will be useful,
       
    14     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    16     Library General Public License for more details.
       
    17 
       
    18     You should have received a copy of the GNU Library General Public License
       
    19     aint with this library; see the file COPYING.LIB.  If not, write to
       
    20     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    21     Boston, MA 02110-1301, USA.
       
    22 */
       
    23 
       
    24 #ifndef SVGResourceFilter_h
       
    25 #define SVGResourceFilter_h
       
    26 
       
    27 #if ENABLE(SVG) && ENABLE(SVG_EXPERIMENTAL_FEATURES)
       
    28 #include "SVGResource.h"
       
    29 #include "SVGFilterEffect.h"
       
    30 
       
    31 #include "FloatRect.h"
       
    32 
       
    33 #if PLATFORM(CI)
       
    34 #include <ApplicationServices/ApplicationServices.h>
       
    35 
       
    36 #ifdef __OBJC__
       
    37 @class CIImage;
       
    38 @class CIFilter;
       
    39 @class CIContext;
       
    40 @class NSArray;
       
    41 @class NSMutableDictionary;
       
    42 #else
       
    43 class CIImage;
       
    44 class CIFilter;
       
    45 class CIContext;
       
    46 class NSArray;
       
    47 class NSMutableDictionary;
       
    48 #endif
       
    49 #endif
       
    50 
       
    51 namespace WebCore {
       
    52 
       
    53 class GraphicsContext;
       
    54 class SVGFilterEffect;
       
    55 
       
    56 class SVGResourceFilter : public SVGResource {
       
    57 public:
       
    58     // To be implemented in platform specific code.
       
    59     SVGResourceFilter();
       
    60     virtual ~SVGResourceFilter();
       
    61 
       
    62     static SVGFilterEffect* createFilterEffect(const SVGFilterEffectType&);
       
    63 
       
    64     virtual bool isFilter() const { return true; }
       
    65 
       
    66     bool filterBoundingBoxMode() const { return m_filterBBoxMode; }
       
    67     void setFilterBoundingBoxMode(bool bboxMode) { m_filterBBoxMode = bboxMode; }
       
    68 
       
    69     bool effectBoundingBoxMode() const { return m_effectBBoxMode; }
       
    70     void setEffectBoundingBoxMode(bool bboxMode) { m_effectBBoxMode = bboxMode; }
       
    71 
       
    72     FloatRect filterRect() const { return m_filterRect; }
       
    73     void setFilterRect(const FloatRect& rect) { m_filterRect = rect; }
       
    74 
       
    75     FloatRect filterBBoxForItemBBox(FloatRect itemBBox) const;
       
    76 
       
    77     void clearEffects();
       
    78     void addFilterEffect(SVGFilterEffect*);
       
    79 
       
    80     virtual TextStream& externalRepresentation(TextStream&) const;
       
    81 
       
    82     // To be implemented in platform specific code.
       
    83     void prepareFilter(GraphicsContext*&, const FloatRect& bbox);
       
    84     void applyFilter(GraphicsContext*&, const FloatRect& bbox);
       
    85 
       
    86 #if PLATFORM(CI)
       
    87     CIImage* imageForName(const String&) const;
       
    88     void setImageForName(CIImage*, const String&);
       
    89 
       
    90     void setOutputImage(const SVGFilterEffect*, CIImage*);
       
    91     CIImage* inputImage(const SVGFilterEffect*);
       
    92 #endif
       
    93 
       
    94 private:
       
    95 #if PLATFORM(CI)
       
    96     NSArray* getCIFilterStack(CIImage* inputImage);
       
    97 
       
    98     CIContext* m_filterCIContext;
       
    99     CGLayerRef m_filterCGLayer;
       
   100     GraphicsContext* m_savedContext;
       
   101     NSMutableDictionary* m_imagesByName;
       
   102 #endif
       
   103 
       
   104     FloatRect m_filterRect;
       
   105     Vector<SVGFilterEffect*> m_effects;
       
   106 
       
   107     bool m_filterBBoxMode;
       
   108     bool m_effectBBoxMode;
       
   109 };
       
   110 
       
   111 SVGResourceFilter* getFilterById(Document*, const AtomicString&);
       
   112 
       
   113 } // namespace WebCore
       
   114 
       
   115 #endif // ENABLE(SVG)
       
   116 
       
   117 #endif // SVGResourceFilter_h