/src/3rdparty/webkit/Source/WebCore/platform/graphics/filters/FESpecularLighting.cpp

https://bitbucket.org/ultra_iter/qt-vtl · C++ · 158 lines · 113 code · 25 blank · 20 comment · 12 complexity · ebaabbe2d1bc037e1262cdabb15c73e6 MD5 · raw file

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