diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp b/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp index 9aeb26341ae..aec1320062f 100644 --- a/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp +++ b/chromium/third_party/WebKit/Source/platform/graphics/filters/SpotLightSource.cpp @@ -40,7 +40,7 @@ namespace WebCore { // according to the SVG 1.1 SE light regression tests static const float antiAliasTreshold = 0.016f; -void SpotLightSource::initPaintingData(PaintingData& paintingData) +void SpotLightSource::initPaintingData(PaintingData& paintingData) const { paintingData.privateColorVector = paintingData.colorVector; paintingData.directionVector.setX(m_direction.x() - m_position.x()); @@ -60,17 +60,9 @@ void SpotLightSource::initPaintingData(PaintingData& paintingData) paintingData.coneCutOffLimit = cosf(deg2rad(180.0f - limitingConeAngle)); paintingData.coneFullLight = paintingData.coneCutOffLimit - antiAliasTreshold; } - - // Optimization for common specularExponent values - if (!m_specularExponent) - paintingData.specularExponent = 0; - else if (m_specularExponent == 1.0f) - paintingData.specularExponent = 1; - else // It is neither 0.0f nor 1.0f - paintingData.specularExponent = 2; } -void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z) +void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z) const { paintingData.lightVector.setX(m_position.x() - x); paintingData.lightVector.setY(m_position.y() - y); @@ -88,16 +80,10 @@ void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int // Set the color of the pixel float lightStrength; - switch (paintingData.specularExponent) { - case 0: - lightStrength = 1.0f; // -cosineOfAngle ^ 0 == 1 - break; - case 1: + if (1.0f == m_specularExponent) { lightStrength = -cosineOfAngle; // -cosineOfAngle ^ 1 == -cosineOfAngle - break; - default: + } else { lightStrength = powf(-cosineOfAngle, m_specularExponent); - break; } if (cosineOfAngle > paintingData.coneFullLight) @@ -161,6 +147,7 @@ bool SpotLightSource::setPointsAtZ(float pointsAtZ) bool SpotLightSource::setSpecularExponent(float specularExponent) { + specularExponent = std::min(std::max(specularExponent, 1.0f), 128.0f); if (m_specularExponent == specularExponent) return false; m_specularExponent = specularExponent; |