1 /* 2 Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann (at) kde.org> 3 2004, 2005 Rob Buis <buis (at) kde.org> 4 2005 Eric Seidel <eric (at) 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 "SVGLightSource.h" 26 #include "SVGFEDiffuseLighting.h" 27 #include "SVGRenderTreeAsText.h" 28 #include "Filter.h" 29 30 namespace WebCore { 31 32 FEDiffuseLighting::FEDiffuseLighting(FilterEffect* in , const Color& lightingColor, const float& surfaceScale, 33 const float& diffuseConstant, const float& kernelUnitLengthX, const float& kernelUnitLengthY, PassRefPtr<LightSource> lightSource) 34 : FilterEffect() 35 , m_in(in) 36 , m_lightingColor(lightingColor) 37 , m_surfaceScale(surfaceScale) 38 , m_diffuseConstant(diffuseConstant) 39 , m_kernelUnitLengthX(kernelUnitLengthX) 40 , m_kernelUnitLengthY(kernelUnitLengthY) 41 , m_lightSource(lightSource) 42 { 43 } 44 45 PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(FilterEffect* in , const Color& lightingColor, 46 const float& surfaceScale, const float& diffuseConstant, const float& kernelUnitLengthX, 47 const float& kernelUnitLengthY, PassRefPtr<LightSource> lightSource) 48 { 49 return adoptRef(new FEDiffuseLighting(in, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource)); 50 } 51 52 FEDiffuseLighting::~FEDiffuseLighting() 53 { 54 } 55 56 Color FEDiffuseLighting::lightingColor() const 57 { 58 return m_lightingColor; 59 } 60 61 void FEDiffuseLighting::setLightingColor(const Color& lightingColor) 62 { 63 m_lightingColor = lightingColor; 64 } 65 66 float FEDiffuseLighting::surfaceScale() const 67 { 68 return m_surfaceScale; 69 } 70 71 void FEDiffuseLighting::setSurfaceScale(float surfaceScale) 72 { 73 m_surfaceScale = surfaceScale; 74 } 75 76 float FEDiffuseLighting::diffuseConstant() const 77 { 78 return m_diffuseConstant; 79 } 80 81 void FEDiffuseLighting::setDiffuseConstant(float diffuseConstant) 82 { 83 m_diffuseConstant = diffuseConstant; 84 } 85 86 float FEDiffuseLighting::kernelUnitLengthX() const 87 { 88 return m_kernelUnitLengthX; 89 } 90 91 void FEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX) 92 { 93 m_kernelUnitLengthX = kernelUnitLengthX; 94 } 95 96 float FEDiffuseLighting::kernelUnitLengthY() const 97 { 98 return m_kernelUnitLengthY; 99 } 100 101 void FEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY) 102 { 103 m_kernelUnitLengthY = kernelUnitLengthY; 104 } 105 106 const LightSource* FEDiffuseLighting::lightSource() const 107 { 108 return m_lightSource.get(); 109 } 110 111 void FEDiffuseLighting::setLightSource(PassRefPtr<LightSource> lightSource) 112 { 113 m_lightSource = lightSource; 114 } 115 116 void FEDiffuseLighting::apply(Filter*) 117 { 118 } 119 120 void FEDiffuseLighting::dump() 121 { 122 } 123 124 TextStream& FEDiffuseLighting::externalRepresentation(TextStream& ts) const 125 { 126 ts << "[type=DIFFUSE-LIGHTING] "; 127 FilterEffect::externalRepresentation(ts); 128 ts << " [surface scale=" << m_surfaceScale << "]" 129 << " [diffuse constant=" << m_diffuseConstant << "]" 130 << " [kernel unit length " << m_kernelUnitLengthX << ", " << m_kernelUnitLengthY << "]"; 131 return ts; 132 } 133 134 } // namespace WebCore 135 136 #endif // ENABLE(SVG) && ENABLE(FILTERS) 137