File indexing completed on 2024-05-12 11:51:56

0001 /*
0002     Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
0003                   2004, 2005 Rob Buis <buis@kde.org>
0004                   2005 Eric Seidel <eric@webkit.org>
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Library General Public
0008     License as published by the Free Software Foundation; either
0009     version 2 of the License, or (at your option) any later version.
0010 
0011     This library is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014     Library General Public License for more details.
0015 
0016     You should have received a copy of the GNU Library General Public License
0017     aint with this library; see the file COPYING.LIB.  If not, write to
0018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019     Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef SVGResourceFilter_h
0023 #define SVGResourceFilter_h
0024 
0025 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
0026 #include "SVGResource.h"
0027 #include "SVGFilterEffect.h"
0028 
0029 #include "FloatRect.h"
0030 
0031 #include <wtf/OwnPtr.h>
0032 
0033 namespace WebCore
0034 {
0035 
0036 class GraphicsContext;
0037 class SVGFilterEffect;
0038 
0039 class SVGResourceFilterPlatformData
0040 {
0041 public:
0042     virtual ~SVGResourceFilterPlatformData() {}
0043 };
0044 
0045 class SVGResourceFilter : public SVGResource
0046 {
0047 public:
0048     SVGResourceFilter();
0049 
0050     virtual SVGResourceType resourceType() const
0051     {
0052         return FilterResourceType;
0053     }
0054 
0055     bool filterBoundingBoxMode() const
0056     {
0057         return m_filterBBoxMode;
0058     }
0059     void setFilterBoundingBoxMode(bool bboxMode)
0060     {
0061         m_filterBBoxMode = bboxMode;
0062     }
0063 
0064     bool effectBoundingBoxMode() const
0065     {
0066         return m_effectBBoxMode;
0067     }
0068     void setEffectBoundingBoxMode(bool bboxMode)
0069     {
0070         m_effectBBoxMode = bboxMode;
0071     }
0072 
0073     bool xBoundingBoxMode() const
0074     {
0075         return m_xBBoxMode;
0076     }
0077     void setXBoundingBoxMode(bool bboxMode)
0078     {
0079         m_xBBoxMode = bboxMode;
0080     }
0081 
0082     bool yBoundingBoxMode() const
0083     {
0084         return m_yBBoxMode;
0085     }
0086     void setYBoundingBoxMode(bool bboxMode)
0087     {
0088         m_yBBoxMode = bboxMode;
0089     }
0090 
0091     FloatRect filterRect() const
0092     {
0093         return m_filterRect;
0094     }
0095     void setFilterRect(const FloatRect &rect)
0096     {
0097         m_filterRect = rect;
0098     }
0099 
0100     FloatRect filterBBoxForItemBBox(const FloatRect &itemBBox) const;
0101 
0102     void clearEffects();
0103     void addFilterEffect(SVGFilterEffect *);
0104 
0105     virtual TextStream &externalRepresentation(TextStream &) const;
0106 
0107     // To be implemented in platform specific code.
0108     void prepareFilter(GraphicsContext *&, const FloatRect &bbox);
0109     void applyFilter(GraphicsContext *&, const FloatRect &bbox);
0110 
0111     SVGResourceFilterPlatformData *platformData()
0112     {
0113         return m_platformData.get();
0114     }
0115     const Vector<SVGFilterEffect *> &effects()
0116     {
0117         return m_effects;
0118     }
0119 
0120 private:
0121     SVGResourceFilterPlatformData *createPlatformData();
0122 
0123     OwnPtr<SVGResourceFilterPlatformData> m_platformData;
0124 
0125     bool m_filterBBoxMode : 1;
0126     bool m_effectBBoxMode : 1;
0127 
0128     bool m_xBBoxMode : 1;
0129     bool m_yBBoxMode : 1;
0130 
0131     FloatRect m_filterRect;
0132     Vector<SVGFilterEffect *> m_effects;
0133 };
0134 
0135 SVGResourceFilter *getFilterById(Document *, const AtomicString &);
0136 
0137 } // namespace WebCore
0138 
0139 #endif // ENABLE(SVG)
0140 
0141 #endif // SVGResourceFilter_h