• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4  * Copyright (C) 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  * along 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(FILTERS)
25 #include "FESpecularLighting.h"
26 
27 #include "LightSource.h"
28 #include "RenderTreeAsText.h"
29 #include "TextStream.h"
30 
31 namespace WebCore {
32 
FESpecularLighting(Filter * filter,const Color & lightingColor,float surfaceScale,float specularConstant,float specularExponent,float kernelUnitLengthX,float kernelUnitLengthY,PassRefPtr<LightSource> lightSource)33 FESpecularLighting::FESpecularLighting(Filter* filter, const Color& lightingColor, float surfaceScale,
34     float specularConstant, float specularExponent, float kernelUnitLengthX,
35     float kernelUnitLengthY, PassRefPtr<LightSource> lightSource)
36     : FELighting(filter, SpecularLighting, lightingColor, surfaceScale, 0, specularConstant, specularExponent, kernelUnitLengthX, kernelUnitLengthY, lightSource)
37 {
38 }
39 
create(Filter * filter,const Color & lightingColor,float surfaceScale,float specularConstant,float specularExponent,float kernelUnitLengthX,float kernelUnitLengthY,PassRefPtr<LightSource> lightSource)40 PassRefPtr<FESpecularLighting> FESpecularLighting::create(Filter* filter, const Color& lightingColor,
41     float surfaceScale, float specularConstant, float specularExponent,
42     float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource)
43 {
44     return adoptRef(new FESpecularLighting(filter, lightingColor, surfaceScale, specularConstant, specularExponent,
45         kernelUnitLengthX, kernelUnitLengthY, lightSource));
46 }
47 
~FESpecularLighting()48 FESpecularLighting::~FESpecularLighting()
49 {
50 }
51 
lightingColor() const52 Color FESpecularLighting::lightingColor() const
53 {
54     return m_lightingColor;
55 }
56 
setLightingColor(const Color & lightingColor)57 bool FESpecularLighting::setLightingColor(const Color& lightingColor)
58 {
59     if (m_lightingColor == lightingColor)
60         return false;
61     m_lightingColor = lightingColor;
62     return true;
63 }
64 
surfaceScale() const65 float FESpecularLighting::surfaceScale() const
66 {
67     return m_surfaceScale;
68 }
69 
setSurfaceScale(float surfaceScale)70 bool FESpecularLighting::setSurfaceScale(float surfaceScale)
71 {
72     if (m_surfaceScale == surfaceScale)
73         return false;
74     m_surfaceScale = surfaceScale;
75     return true;
76 }
77 
specularConstant() const78 float FESpecularLighting::specularConstant() const
79 {
80     return m_specularConstant;
81 }
82 
setSpecularConstant(float specularConstant)83 bool FESpecularLighting::setSpecularConstant(float specularConstant)
84 {
85     if (m_specularConstant == specularConstant)
86         return false;
87     m_specularConstant = specularConstant;
88     return true;
89 }
90 
specularExponent() const91 float FESpecularLighting::specularExponent() const
92 {
93     return m_specularExponent;
94 }
95 
setSpecularExponent(float specularExponent)96 bool FESpecularLighting::setSpecularExponent(float specularExponent)
97 {
98     if (m_specularExponent == specularExponent)
99         return false;
100     m_specularExponent = specularExponent;
101     return true;
102 }
103 
kernelUnitLengthX() const104 float FESpecularLighting::kernelUnitLengthX() const
105 {
106     return m_kernelUnitLengthX;
107 }
108 
setKernelUnitLengthX(float kernelUnitLengthX)109 bool FESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX)
110 {
111     if (m_kernelUnitLengthX == kernelUnitLengthX)
112         return false;
113     m_kernelUnitLengthX = kernelUnitLengthX;
114     return true;
115 }
116 
kernelUnitLengthY() const117 float FESpecularLighting::kernelUnitLengthY() const
118 {
119     return m_kernelUnitLengthY;
120 }
121 
setKernelUnitLengthY(float kernelUnitLengthY)122 bool FESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY)
123 {
124     if (m_kernelUnitLengthY == kernelUnitLengthY)
125         return false;
126     m_kernelUnitLengthY = kernelUnitLengthY;
127     return true;
128 }
129 
lightSource() const130 const LightSource* FESpecularLighting::lightSource() const
131 {
132     return m_lightSource.get();
133 }
134 
setLightSource(PassRefPtr<LightSource> lightSource)135 void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource)
136 {
137     m_lightSource = lightSource;
138 }
139 
dump()140 void FESpecularLighting::dump()
141 {
142 }
143 
externalRepresentation(TextStream & ts,int indent) const144 TextStream& FESpecularLighting::externalRepresentation(TextStream& ts, int indent) const
145 {
146     writeIndent(ts, indent);
147     ts << "[feSpecularLighting";
148     FilterEffect::externalRepresentation(ts);
149     ts << " surfaceScale=\"" << m_surfaceScale << "\" "
150        << "specualConstant=\"" << m_specularConstant << "\" "
151        << "specularExponent=\"" << m_specularExponent << "\"]\n";
152     inputEffect(0)->externalRepresentation(ts, indent + 1);
153     return ts;
154 }
155 
156 } // namespace WebCore
157 
158 #endif // ENABLE(FILTERS)
159