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 "SVGRenderTreeAsText.h"
24 #include "SVGFEDisplacementMap.h"
25
26 namespace WebCore
27 {
28
SVGFEDisplacementMap(SVGResourceFilter * filter)29 SVGFEDisplacementMap::SVGFEDisplacementMap(SVGResourceFilter *filter)
30 : SVGFilterEffect(filter)
31 , m_xChannelSelector(SVG_CHANNEL_UNKNOWN)
32 , m_yChannelSelector(SVG_CHANNEL_UNKNOWN)
33 , m_scale(0)
34 {
35 }
36
in2() const37 String SVGFEDisplacementMap::in2() const
38 {
39 return m_in2;
40 }
41
setIn2(const String & in2)42 void SVGFEDisplacementMap::setIn2(const String &in2)
43 {
44 m_in2 = in2;
45 }
46
xChannelSelector() const47 SVGChannelSelectorType SVGFEDisplacementMap::xChannelSelector() const
48 {
49 return m_xChannelSelector;
50 }
51
setXChannelSelector(const SVGChannelSelectorType xChannelSelector)52 void SVGFEDisplacementMap::setXChannelSelector(const SVGChannelSelectorType xChannelSelector)
53 {
54 m_xChannelSelector = xChannelSelector;
55 }
56
yChannelSelector() const57 SVGChannelSelectorType SVGFEDisplacementMap::yChannelSelector() const
58 {
59 return m_yChannelSelector;
60 }
61
setYChannelSelector(const SVGChannelSelectorType yChannelSelector)62 void SVGFEDisplacementMap::setYChannelSelector(const SVGChannelSelectorType yChannelSelector)
63 {
64 m_yChannelSelector = yChannelSelector;
65 }
66
scale() const67 float SVGFEDisplacementMap::scale() const
68 {
69 return m_scale;
70 }
71
setScale(float scale)72 void SVGFEDisplacementMap::setScale(float scale)
73 {
74 m_scale = scale;
75 }
76
operator <<(TextStream & ts,SVGChannelSelectorType t)77 static TextStream &operator<<(TextStream &ts, SVGChannelSelectorType t)
78 {
79 switch (t) {
80 case SVG_CHANNEL_UNKNOWN:
81 ts << "UNKNOWN"; break;
82 case SVG_CHANNEL_R:
83 ts << "RED"; break;
84 case SVG_CHANNEL_G:
85 ts << "GREEN"; break;
86 case SVG_CHANNEL_B:
87 ts << "BLUE"; break;
88 case SVG_CHANNEL_A:
89 ts << "ALPHA"; break;
90 }
91 return ts;
92 }
93
externalRepresentation(TextStream & ts) const94 TextStream &SVGFEDisplacementMap::externalRepresentation(TextStream &ts) const
95 {
96 ts << "[type=DISPLACEMENT-MAP] ";
97 SVGFilterEffect::externalRepresentation(ts);
98 if (!in2().isEmpty()) {
99 ts << " [in2=" << in2() << "]";
100 }
101 ts << " [scale=" << m_scale << "]"
102 << " [x channel selector=" << m_xChannelSelector << "]"
103 << " [y channel selector=" << m_yChannelSelector << "]";
104 return ts;
105 }
106
107 } // namespace WebCore
108
109 #endif // ENABLE(SVG) && ENABLE(SVG_FILTERS)
110