1 /* 2 Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 2004, 2005 Rob Buis <buis@kde.org> 4 2005 Eric Seidel <eric@webkit.org> 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Library General Public 8 License as published by the Free Software Foundation; either 9 version 2 of the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Library General Public License for more details. 15 16 You should have received a copy of the GNU Library General Public License 17 aint with this library; see the file COPYING.LIB. If not, write to 18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef SVGResourceFilter_h 23 #define SVGResourceFilter_h 24 25 #if ENABLE(SVG) && ENABLE(SVG_FILTERS) 26 #include "SVGResource.h" 27 #include "SVGFilterEffect.h" 28 29 #include "FloatRect.h" 30 31 #include <wtf/OwnPtr.h> 32 33 namespace WebCore 34 { 35 36 class GraphicsContext; 37 class SVGFilterEffect; 38 39 class SVGResourceFilterPlatformData 40 { 41 public: ~SVGResourceFilterPlatformData()42 virtual ~SVGResourceFilterPlatformData() {} 43 }; 44 45 class SVGResourceFilter : public SVGResource 46 { 47 public: 48 SVGResourceFilter(); 49 resourceType()50 virtual SVGResourceType resourceType() const 51 { 52 return FilterResourceType; 53 } 54 filterBoundingBoxMode()55 bool filterBoundingBoxMode() const 56 { 57 return m_filterBBoxMode; 58 } setFilterBoundingBoxMode(bool bboxMode)59 void setFilterBoundingBoxMode(bool bboxMode) 60 { 61 m_filterBBoxMode = bboxMode; 62 } 63 effectBoundingBoxMode()64 bool effectBoundingBoxMode() const 65 { 66 return m_effectBBoxMode; 67 } setEffectBoundingBoxMode(bool bboxMode)68 void setEffectBoundingBoxMode(bool bboxMode) 69 { 70 m_effectBBoxMode = bboxMode; 71 } 72 xBoundingBoxMode()73 bool xBoundingBoxMode() const 74 { 75 return m_xBBoxMode; 76 } setXBoundingBoxMode(bool bboxMode)77 void setXBoundingBoxMode(bool bboxMode) 78 { 79 m_xBBoxMode = bboxMode; 80 } 81 yBoundingBoxMode()82 bool yBoundingBoxMode() const 83 { 84 return m_yBBoxMode; 85 } setYBoundingBoxMode(bool bboxMode)86 void setYBoundingBoxMode(bool bboxMode) 87 { 88 m_yBBoxMode = bboxMode; 89 } 90 filterRect()91 FloatRect filterRect() const 92 { 93 return m_filterRect; 94 } setFilterRect(const FloatRect & rect)95 void setFilterRect(const FloatRect &rect) 96 { 97 m_filterRect = rect; 98 } 99 100 FloatRect filterBBoxForItemBBox(const FloatRect &itemBBox) const; 101 102 void clearEffects(); 103 void addFilterEffect(SVGFilterEffect *); 104 105 virtual TextStream &externalRepresentation(TextStream &) const; 106 107 // To be implemented in platform specific code. 108 void prepareFilter(GraphicsContext *&, const FloatRect &bbox); 109 void applyFilter(GraphicsContext *&, const FloatRect &bbox); 110 platformData()111 SVGResourceFilterPlatformData *platformData() 112 { 113 return m_platformData.get(); 114 } effects()115 const Vector<SVGFilterEffect *> &effects() 116 { 117 return m_effects; 118 } 119 120 private: 121 SVGResourceFilterPlatformData *createPlatformData(); 122 123 OwnPtr<SVGResourceFilterPlatformData> m_platformData; 124 125 bool m_filterBBoxMode : 1; 126 bool m_effectBBoxMode : 1; 127 128 bool m_xBBoxMode : 1; 129 bool m_yBBoxMode : 1; 130 131 FloatRect m_filterRect; 132 Vector<SVGFilterEffect *> m_effects; 133 }; 134 135 SVGResourceFilter *getFilterById(Document *, const AtomicString &); 136 137 } // namespace WebCore 138 139 #endif // ENABLE(SVG) 140 141 #endif // SVGResourceFilter_h 142