1 /* 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann (at) kde.org> 3 * Copyright (C) 2004, 2005 Rob Buis <buis (at) kde.org> 4 * Copyright (C) 2005 Eric Seidel <eric (at) webkit.org> 5 * Copyright (C) 2013 Google Inc. All rights reserved. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 */ 22 23 #include "config.h" 24 25 #include "core/platform/graphics/filters/FESpecularLighting.h" 26 27 #include "core/platform/graphics/filters/LightSource.h" 28 #include "core/platform/text/TextStream.h" 29 #include "core/rendering/RenderTreeAsText.h" 30 31 namespace WebCore { 32 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 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 48 FESpecularLighting::~FESpecularLighting() 49 { 50 } 51 52 Color FESpecularLighting::lightingColor() const 53 { 54 return m_lightingColor; 55 } 56 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 65 float FESpecularLighting::surfaceScale() const 66 { 67 return m_surfaceScale; 68 } 69 70 bool FESpecularLighting::setSurfaceScale(float surfaceScale) 71 { 72 if (m_surfaceScale == surfaceScale) 73 return false; 74 m_surfaceScale = surfaceScale; 75 return true; 76 } 77 78 float FESpecularLighting::specularConstant() const 79 { 80 return m_specularConstant; 81 } 82 83 bool FESpecularLighting::setSpecularConstant(float specularConstant) 84 { 85 if (m_specularConstant == specularConstant) 86 return false; 87 m_specularConstant = specularConstant; 88 return true; 89 } 90 91 float FESpecularLighting::specularExponent() const 92 { 93 return m_specularExponent; 94 } 95 96 bool FESpecularLighting::setSpecularExponent(float specularExponent) 97 { 98 if (m_specularExponent == specularExponent) 99 return false; 100 m_specularExponent = specularExponent; 101 return true; 102 } 103 104 float FESpecularLighting::kernelUnitLengthX() const 105 { 106 return m_kernelUnitLengthX; 107 } 108 109 bool FESpecularLighting::setKernelUnitLengthX(float kernelUnitLengthX) 110 { 111 if (m_kernelUnitLengthX == kernelUnitLengthX) 112 return false; 113 m_kernelUnitLengthX = kernelUnitLengthX; 114 return true; 115 } 116 117 float FESpecularLighting::kernelUnitLengthY() const 118 { 119 return m_kernelUnitLengthY; 120 } 121 122 bool FESpecularLighting::setKernelUnitLengthY(float kernelUnitLengthY) 123 { 124 if (m_kernelUnitLengthY == kernelUnitLengthY) 125 return false; 126 m_kernelUnitLengthY = kernelUnitLengthY; 127 return true; 128 } 129 130 const LightSource* FESpecularLighting::lightSource() const 131 { 132 return m_lightSource.get(); 133 } 134 135 void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource) 136 { 137 m_lightSource = lightSource; 138 } 139 140 TextStream& FESpecularLighting::externalRepresentation(TextStream& ts, int indent) const 141 { 142 writeIndent(ts, indent); 143 ts << "[feSpecularLighting"; 144 FilterEffect::externalRepresentation(ts); 145 ts << " surfaceScale=\"" << m_surfaceScale << "\" " 146 << "specualConstant=\"" << m_specularConstant << "\" " 147 << "specularExponent=\"" << m_specularExponent << "\"]\n"; 148 inputEffect(0)->externalRepresentation(ts, indent + 1); 149 return ts; 150 } 151 152 } // namespace WebCore 153