Home | History | Annotate | Download | only in filters
      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  *
      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 "FEDiffuseLighting.h"
     26 
     27 #include "LightSource.h"
     28 #include "RenderTreeAsText.h"
     29 #include "TextStream.h"
     30 
     31 namespace WebCore {
     32 
     33 FEDiffuseLighting::FEDiffuseLighting(Filter* filter, const Color& lightingColor, float surfaceScale,
     34     float diffuseConstant, float kernelUnitLengthX, float kernelUnitLengthY, PassRefPtr<LightSource> lightSource)
     35     : FELighting(filter, DiffuseLighting, lightingColor, surfaceScale, diffuseConstant, 0, 0, kernelUnitLengthX, kernelUnitLengthY, lightSource)
     36 {
     37 }
     38 
     39 PassRefPtr<FEDiffuseLighting> FEDiffuseLighting::create(Filter* filter, const Color& lightingColor,
     40     float surfaceScale, float diffuseConstant, float kernelUnitLengthX,
     41     float kernelUnitLengthY, PassRefPtr<LightSource> lightSource)
     42 {
     43     return adoptRef(new FEDiffuseLighting(filter, lightingColor, surfaceScale, diffuseConstant, kernelUnitLengthX, kernelUnitLengthY, lightSource));
     44 }
     45 
     46 FEDiffuseLighting::~FEDiffuseLighting()
     47 {
     48 }
     49 
     50 Color FEDiffuseLighting::lightingColor() const
     51 {
     52     return m_lightingColor;
     53 }
     54 
     55 bool FEDiffuseLighting::setLightingColor(const Color& lightingColor)
     56 {
     57     if (m_lightingColor == lightingColor)
     58         return false;
     59     m_lightingColor = lightingColor;
     60     return true;
     61 }
     62 
     63 float FEDiffuseLighting::surfaceScale() const
     64 {
     65     return m_surfaceScale;
     66 }
     67 
     68 bool FEDiffuseLighting::setSurfaceScale(float surfaceScale)
     69 {
     70     if (m_surfaceScale == surfaceScale)
     71         return false;
     72     m_surfaceScale = surfaceScale;
     73     return true;
     74 }
     75 
     76 float FEDiffuseLighting::diffuseConstant() const
     77 {
     78     return m_diffuseConstant;
     79 }
     80 
     81 bool FEDiffuseLighting::setDiffuseConstant(float diffuseConstant)
     82 {
     83     if (m_diffuseConstant == diffuseConstant)
     84         return false;
     85     m_diffuseConstant = diffuseConstant;
     86     return true;
     87 }
     88 
     89 float FEDiffuseLighting::kernelUnitLengthX() const
     90 {
     91     return m_kernelUnitLengthX;
     92 }
     93 
     94 bool FEDiffuseLighting::setKernelUnitLengthX(float kernelUnitLengthX)
     95 {
     96     if (m_kernelUnitLengthX == kernelUnitLengthX)
     97         return false;
     98     m_kernelUnitLengthX = kernelUnitLengthX;
     99     return true;
    100 }
    101 
    102 float FEDiffuseLighting::kernelUnitLengthY() const
    103 {
    104     return m_kernelUnitLengthY;
    105 }
    106 
    107 bool FEDiffuseLighting::setKernelUnitLengthY(float kernelUnitLengthY)
    108 {
    109     if (m_kernelUnitLengthY == kernelUnitLengthY)
    110         return false;
    111     m_kernelUnitLengthY = kernelUnitLengthY;
    112     return true;
    113 }
    114 
    115 const LightSource* FEDiffuseLighting::lightSource() const
    116 {
    117     return m_lightSource.get();
    118 }
    119 
    120 void FEDiffuseLighting::setLightSource(PassRefPtr<LightSource> lightSource)
    121 {
    122     m_lightSource = lightSource;
    123 }
    124 
    125 void FEDiffuseLighting::dump()
    126 {
    127 }
    128 
    129 TextStream& FEDiffuseLighting::externalRepresentation(TextStream& ts, int indent) const
    130 {
    131     writeIndent(ts, indent);
    132     ts << "[feDiffuseLighting";
    133     FilterEffect::externalRepresentation(ts);
    134     ts << " surfaceScale=\"" << m_surfaceScale << "\" "
    135        << "diffuseConstant=\"" << m_diffuseConstant << "\" "
    136        << "kernelUnitLength=\"" << m_kernelUnitLengthX << ", " << m_kernelUnitLengthY << "\"]\n";
    137     inputEffect(0)->externalRepresentation(ts, indent + 1);
    138     return ts;
    139 }
    140 
    141 } // namespace WebCore
    142 
    143 #endif // ENABLE(FILTERS)
    144