• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 class GraphicsContext;
36 class SVGFilterEffect;
37 
38 class SVGResourceFilterPlatformData {
39 public:
~SVGResourceFilterPlatformData()40     virtual ~SVGResourceFilterPlatformData() {}
41 };
42 
43 class SVGResourceFilter : public SVGResource {
44 public:
45     SVGResourceFilter();
46 
resourceType()47     virtual SVGResourceType resourceType() const { return FilterResourceType; }
48 
filterBoundingBoxMode()49     bool filterBoundingBoxMode() const { return m_filterBBoxMode; }
setFilterBoundingBoxMode(bool bboxMode)50     void setFilterBoundingBoxMode(bool bboxMode) { m_filterBBoxMode = bboxMode; }
51 
effectBoundingBoxMode()52     bool effectBoundingBoxMode() const { return m_effectBBoxMode; }
setEffectBoundingBoxMode(bool bboxMode)53     void setEffectBoundingBoxMode(bool bboxMode) { m_effectBBoxMode = bboxMode; }
54 
xBoundingBoxMode()55     bool xBoundingBoxMode() const { return m_xBBoxMode; }
setXBoundingBoxMode(bool bboxMode)56     void setXBoundingBoxMode(bool bboxMode) { m_xBBoxMode = bboxMode; }
57 
yBoundingBoxMode()58     bool yBoundingBoxMode() const { return m_yBBoxMode; }
setYBoundingBoxMode(bool bboxMode)59     void setYBoundingBoxMode(bool bboxMode) { m_yBBoxMode = bboxMode; }
60 
filterRect()61     FloatRect filterRect() const { return m_filterRect; }
setFilterRect(const FloatRect & rect)62     void setFilterRect(const FloatRect& rect) { m_filterRect = rect; }
63 
64     FloatRect filterBBoxForItemBBox(const FloatRect& itemBBox) const;
65 
66     void clearEffects();
67     void addFilterEffect(SVGFilterEffect*);
68 
69     virtual TextStream& externalRepresentation(TextStream&) const;
70 
71     // To be implemented in platform specific code.
72     void prepareFilter(GraphicsContext*&, const FloatRect& bbox);
73     void applyFilter(GraphicsContext*&, const FloatRect& bbox);
74 
platformData()75     SVGResourceFilterPlatformData* platformData() { return m_platformData.get(); }
effects()76     const Vector<SVGFilterEffect*>& effects() { return m_effects; }
77 
78 private:
79     SVGResourceFilterPlatformData* createPlatformData();
80 
81     OwnPtr<SVGResourceFilterPlatformData> m_platformData;
82 
83     bool m_filterBBoxMode : 1;
84     bool m_effectBBoxMode : 1;
85 
86     bool m_xBBoxMode : 1;
87     bool m_yBBoxMode : 1;
88 
89     FloatRect m_filterRect;
90     Vector<SVGFilterEffect*> m_effects;
91 };
92 
93 SVGResourceFilter* getFilterById(Document*, const AtomicString&);
94 
95 } // namespace WebCore
96 
97 #endif // ENABLE(SVG)
98 
99 #endif // SVGResourceFilter_h
100