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 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
23 #include "SVGFEMorphology.h"
24 #include "TextStream.h"
25
26 namespace WebCore
27 {
28
SVGFEMorphology(SVGResourceFilter * filter)29 SVGFEMorphology::SVGFEMorphology(SVGResourceFilter *filter)
30 : SVGFilterEffect(filter)
31 , m_operator(SVG_MORPHOLOGY_OPERATOR_UNKNOWN)
32 , m_radiusX(0.0f)
33 , m_radiusY(0.0f)
34 {
35 }
36
morphologyOperator() const37 SVGMorphologyOperatorType SVGFEMorphology::morphologyOperator() const
38 {
39 return m_operator;
40 }
41
setMorphologyOperator(SVGMorphologyOperatorType _operator)42 void SVGFEMorphology::setMorphologyOperator(SVGMorphologyOperatorType _operator)
43 {
44 m_operator = _operator;
45 }
46
radiusX() const47 float SVGFEMorphology::radiusX() const
48 {
49 return m_radiusX;
50 }
51
setRadiusX(float radiusX)52 void SVGFEMorphology::setRadiusX(float radiusX)
53 {
54 m_radiusX = radiusX;
55 }
56
radiusY() const57 float SVGFEMorphology::radiusY() const
58 {
59 return m_radiusY;
60 }
61
setRadiusY(float radiusY)62 void SVGFEMorphology::setRadiusY(float radiusY)
63 {
64 m_radiusY = radiusY;
65 }
66
operator <<(TextStream & ts,SVGMorphologyOperatorType t)67 static TextStream &operator<<(TextStream &ts, SVGMorphologyOperatorType t)
68 {
69 switch (t) {
70 case SVG_MORPHOLOGY_OPERATOR_UNKNOWN:
71 ts << "UNKNOWN"; break;
72 case SVG_MORPHOLOGY_OPERATOR_ERODE:
73 ts << "ERODE"; break;
74 case SVG_MORPHOLOGY_OPERATOR_DIALATE:
75 ts << "DIALATE"; break;
76 }
77 return ts;
78 }
79
externalRepresentation(TextStream & ts) const80 TextStream &SVGFEMorphology::externalRepresentation(TextStream &ts) const
81 {
82 ts << "[type=MORPHOLOGY-OPERATOR] ";
83 SVGFilterEffect::externalRepresentation(ts);
84 ts << " [operator type=" << morphologyOperator() << "]"
85 << " [radius x=" << radiusX() << " y=" << radiusY() << "]";
86 return ts;
87 }
88
89 } // namespace WebCore
90
91 #endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
92