| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2013 Google Inc. All rights reserved. | 5 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| 11 * | 11 * |
| 12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
| 16 * | 16 * |
| 17 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "platform/graphics/filters/FESpecularLighting.h" | 23 #include "platform/graphics/filters/FESpecularLighting.h" |
| 24 | 24 |
| 25 #include "platform/graphics/filters/LightSource.h" | 25 #include "platform/graphics/filters/LightSource.h" |
| 26 #include "platform/text/TextStream.h" | 26 #include "platform/text/TextStream.h" |
| 27 #include "wtf/MathExtras.h" |
| 28 #include <algorithm> |
| 27 | 29 |
| 28 namespace blink { | 30 namespace blink { |
| 29 | 31 |
| 30 FESpecularLighting::FESpecularLighting(Filter* filter, const Color& lightingColo
r, float surfaceScale, | 32 FESpecularLighting::FESpecularLighting(Filter* filter, const Color& lightingColo
r, float surfaceScale, |
| 31 float specularConstant, float specularExponent, PassRefPtr<LightSource> ligh
tSource) | 33 float specularConstant, float specularExponent, PassRefPtr<LightSource> ligh
tSource) |
| 32 : FELighting(filter, SpecularLighting, lightingColor, surfaceScale, 0, specu
larConstant, specularExponent, lightSource) | 34 : FELighting(filter, SpecularLighting, lightingColor, surfaceScale, 0, specu
larConstant, specularExponent, lightSource) |
| 33 { | 35 { |
| 34 } | 36 } |
| 35 | 37 |
| 36 PassRefPtrWillBeRawPtr<FESpecularLighting> FESpecularLighting::create(Filter* fi
lter, const Color& lightingColor, | 38 PassRefPtrWillBeRawPtr<FESpecularLighting> FESpecularLighting::create(Filter* fi
lter, const Color& lightingColor, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return true; | 86 return true; |
| 85 } | 87 } |
| 86 | 88 |
| 87 float FESpecularLighting::specularExponent() const | 89 float FESpecularLighting::specularExponent() const |
| 88 { | 90 { |
| 89 return m_specularExponent; | 91 return m_specularExponent; |
| 90 } | 92 } |
| 91 | 93 |
| 92 bool FESpecularLighting::setSpecularExponent(float specularExponent) | 94 bool FESpecularLighting::setSpecularExponent(float specularExponent) |
| 93 { | 95 { |
| 94 specularExponent = std::min(std::max(specularExponent, 1.0f), 128.0f); | 96 specularExponent = clampTo(specularExponent, 1.0f, 128.0f); |
| 95 if (m_specularExponent == specularExponent) | 97 if (m_specularExponent == specularExponent) |
| 96 return false; | 98 return false; |
| 97 m_specularExponent = specularExponent; | 99 m_specularExponent = specularExponent; |
| 98 return true; | 100 return true; |
| 99 } | 101 } |
| 100 | 102 |
| 101 const LightSource* FESpecularLighting::lightSource() const | 103 const LightSource* FESpecularLighting::lightSource() const |
| 102 { | 104 { |
| 103 return m_lightSource.get(); | 105 return m_lightSource.get(); |
| 104 } | 106 } |
| 105 | 107 |
| 106 void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource) | 108 void FESpecularLighting::setLightSource(PassRefPtr<LightSource> lightSource) |
| 107 { | 109 { |
| 108 m_lightSource = lightSource; | 110 m_lightSource = lightSource; |
| 109 } | 111 } |
| 110 | 112 |
| 111 TextStream& FESpecularLighting::externalRepresentation(TextStream& ts, int inden
t) const | 113 TextStream& FESpecularLighting::externalRepresentation(TextStream& ts, int inden
t) const |
| 112 { | 114 { |
| 113 writeIndent(ts, indent); | 115 writeIndent(ts, indent); |
| 114 ts << "[feSpecularLighting"; | 116 ts << "[feSpecularLighting"; |
| 115 FilterEffect::externalRepresentation(ts); | 117 FilterEffect::externalRepresentation(ts); |
| 116 ts << " surfaceScale=\"" << m_surfaceScale << "\" " | 118 ts << " surfaceScale=\"" << m_surfaceScale << "\" " |
| 117 << "specualConstant=\"" << m_specularConstant << "\" " | 119 << "specualConstant=\"" << m_specularConstant << "\" " |
| 118 << "specularExponent=\"" << m_specularExponent << "\"]\n"; | 120 << "specularExponent=\"" << m_specularExponent << "\"]\n"; |
| 119 inputEffect(0)->externalRepresentation(ts, indent + 1); | 121 inputEffect(0)->externalRepresentation(ts, indent + 1); |
| 120 return ts; | 122 return ts; |
| 121 } | 123 } |
| 122 | 124 |
| 123 } // namespace blink | 125 } // namespace blink |
| OLD | NEW |