• 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 #include "config.h"
23 
24 #if ENABLE(SVG) && ENABLE(FILTERS)
25 #include "SVGFETurbulence.h"
26 #include "SVGRenderTreeAsText.h"
27 #include "Filter.h"
28 
29 namespace WebCore {
30 
FETurbulence(TurbulanceType type,const float & baseFrequencyX,const float & baseFrequencyY,const int & numOctaves,const float & seed,bool stitchTiles)31 FETurbulence::FETurbulence(TurbulanceType type, const float& baseFrequencyX, const float& baseFrequencyY,
32     const int& numOctaves, const float& seed, bool stitchTiles)
33     : FilterEffect()
34     , m_type(type)
35     , m_baseFrequencyX(baseFrequencyX)
36     , m_baseFrequencyY(baseFrequencyY)
37     , m_numOctaves(numOctaves)
38     , m_seed(seed)
39     , m_stitchTiles(stitchTiles)
40 {
41 }
42 
create(TurbulanceType type,const float & baseFrequencyX,const float & baseFrequencyY,const int & numOctaves,const float & seed,bool stitchTiles)43 PassRefPtr<FETurbulence> FETurbulence::create(TurbulanceType type, const float& baseFrequencyX, const float& baseFrequencyY,
44     const int& numOctaves, const float& seed, bool stitchTiles)
45 {
46     return adoptRef(new FETurbulence(type, baseFrequencyX, baseFrequencyY, numOctaves, seed, stitchTiles));
47 }
48 
type() const49 TurbulanceType FETurbulence::type() const
50 {
51     return m_type;
52 }
53 
setType(TurbulanceType type)54 void FETurbulence::setType(TurbulanceType type)
55 {
56     m_type = type;
57 }
58 
baseFrequencyY() const59 float FETurbulence::baseFrequencyY() const
60 {
61     return m_baseFrequencyY;
62 }
63 
setBaseFrequencyY(float baseFrequencyY)64 void FETurbulence::setBaseFrequencyY(float baseFrequencyY)
65 {
66     m_baseFrequencyY = baseFrequencyY;
67 }
68 
baseFrequencyX() const69 float FETurbulence::baseFrequencyX() const
70 {
71     return m_baseFrequencyX;
72 }
73 
setBaseFrequencyX(float baseFrequencyX)74 void FETurbulence::setBaseFrequencyX(float baseFrequencyX)
75 {
76        m_baseFrequencyX = baseFrequencyX;
77 }
78 
seed() const79 float FETurbulence::seed() const
80 {
81     return m_seed;
82 }
83 
setSeed(float seed)84 void FETurbulence::setSeed(float seed)
85 {
86     m_seed = seed;
87 }
88 
numOctaves() const89 int FETurbulence::numOctaves() const
90 {
91     return m_numOctaves;
92 }
93 
setNumOctaves(bool numOctaves)94 void FETurbulence::setNumOctaves(bool numOctaves)
95 {
96     m_numOctaves = numOctaves;
97 }
98 
stitchTiles() const99 bool FETurbulence::stitchTiles() const
100 {
101     return m_stitchTiles;
102 }
103 
setStitchTiles(bool stitch)104 void FETurbulence::setStitchTiles(bool stitch)
105 {
106     m_stitchTiles = stitch;
107 }
108 
apply(Filter *)109 void FETurbulence::apply(Filter*)
110 {
111 }
112 
dump()113 void FETurbulence::dump()
114 {
115 }
116 
operator <<(TextStream & ts,TurbulanceType t)117 static TextStream& operator<<(TextStream& ts, TurbulanceType t)
118 {
119     switch (t)
120     {
121         case FETURBULENCE_TYPE_UNKNOWN:
122             ts << "UNKNOWN"; break;
123         case FETURBULENCE_TYPE_TURBULENCE:
124             ts << "TURBULANCE"; break;
125         case FETURBULENCE_TYPE_FRACTALNOISE:
126             ts << "NOISE"; break;
127     }
128     return ts;
129 }
130 
externalRepresentation(TextStream & ts) const131 TextStream& FETurbulence::externalRepresentation(TextStream& ts) const
132 {
133     ts << "[type=TURBULENCE] ";
134     FilterEffect::externalRepresentation(ts);
135     ts << " [turbulence type=" << type() << "]"
136         << " [base frequency x=" << baseFrequencyX() << " y=" << baseFrequencyY() << "]"
137         << " [seed=" << seed() << "]"
138         << " [num octaves=" << numOctaves() << "]"
139         << " [stitch tiles=" << stitchTiles() << "]";
140 
141     return ts;
142 }
143 
144 } // namespace WebCore
145 
146 #endif // ENABLE(SVG) && ENABLE(FILTERS)
147