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>
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.
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.
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.
25 #include "FESpecularLighting.h"
27 #include "LightSource.h"
28 #include "RenderTreeAsText.h"
29 #include "TextStream.h"
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)
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)
44 return adoptRef(new FESpecularLighting(filter, lightingColor, surfaceScale, specularConstant, specularExponent,
45 kernelUnitLengthX, kernelUnitLengthY, lightSource));
48 FESpecularLighting::~FESpecularLighting()
52 Color FESpecularLighting::lightingColor() const
54 return m_lightingColor;
57 bool FESpecularLighting::setLightingColor(const Color& lightingColor)
59 if (m_lightingColor == lightingColor)
61 m_lightingColor = lightingColor;
65 float FESpecularLighting::surfaceScale() const
67 return m_surfaceScale;
70 bool FESpecularLighting::setSurfaceScale(float surfaceScale)
72 if (m_surfaceScale == surfaceScale)
74 m_surfaceScale = surfaceScale;
78 float FESpecularLighting::specularConstant() const
80 return m_specularConstant;
83 bool FESpecularLighting::setSpecularConstant(float specularConstant)
85 if (m_specularConstant == specularConstant)
87 m_specularConstant = specularConstant;
91 float FESpecularLighting::specularExponent() const
93 return m_specularExponent;
96 bool FESpecularLighting::setSpecularExponent(float specularExponent)
98 if (m_specularExponent == specularExponent)
100 m_specularExponent = specularExponent;
104 float FESpecularLighting::kernelUnitLengthX() const
106 return m_kernelUnitLengthX;
109 bool FESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX)
111 if (m_kernelUnitLengthX == kernelUnitLengthX)
113 m_kernelUnitLengthX = kernelUnitLengthX;
117 float FESpecularLighting::kernelUnitLengthY() const
119 return m_kernelUnitLengthY;
122 bool FESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY)
124 if (m_kernelUnitLengthY == kernelUnitLengthY)
126 m_kernelUnitLengthY = kernelUnitLengthY;
130 const LightSource* FESpecularLighting::lightSource() const
132 return m_lightSource.get();
135 void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource)
137 m_lightSource = lightSource;
140 void FESpecularLighting::dump()
144 TextStream& FESpecularLighting::externalRepresentation(TextStream& ts, int indent) const
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);
156 } // namespace WebCore
158 #endif // ENABLE(FILTERS)