OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> | 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 4 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
5 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> |
6 * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> | 6 * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org> |
7 * Copyright (C) 2011 University of Szeged | 7 * Copyright (C) 2011 University of Szeged |
8 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> | 8 * Copyright (C) 2011 Renata Hodovan <reni@webkit.org> |
9 * | 9 * |
10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "platform/graphics/filters/SpotLightSource.h" | 33 #include "platform/graphics/filters/SpotLightSource.h" |
34 | 34 |
35 #include "platform/text/TextStream.h" | 35 #include "platform/text/TextStream.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 // spot-light edge darkening depends on an absolute treshold | 39 // spot-light edge darkening depends on an absolute treshold |
40 // according to the SVG 1.1 SE light regression tests | 40 // according to the SVG 1.1 SE light regression tests |
41 static const float antiAliasTreshold = 0.016f; | 41 static const float antiAliasTreshold = 0.016f; |
42 | 42 |
43 void SpotLightSource::initPaintingData(PaintingData& paintingData) | 43 void SpotLightSource::initPaintingData(PaintingData& paintingData) const |
44 { | 44 { |
45 paintingData.privateColorVector = paintingData.colorVector; | 45 paintingData.privateColorVector = paintingData.colorVector; |
46 paintingData.directionVector.setX(m_direction.x() - m_position.x()); | 46 paintingData.directionVector.setX(m_direction.x() - m_position.x()); |
47 paintingData.directionVector.setY(m_direction.y() - m_position.y()); | 47 paintingData.directionVector.setY(m_direction.y() - m_position.y()); |
48 paintingData.directionVector.setZ(m_direction.z() - m_position.z()); | 48 paintingData.directionVector.setZ(m_direction.z() - m_position.z()); |
49 paintingData.directionVector.normalize(); | 49 paintingData.directionVector.normalize(); |
50 | 50 |
51 if (!m_limitingConeAngle) { | 51 if (!m_limitingConeAngle) { |
52 paintingData.coneCutOffLimit = 0.0f; | 52 paintingData.coneCutOffLimit = 0.0f; |
53 paintingData.coneFullLight = -antiAliasTreshold; | 53 paintingData.coneFullLight = -antiAliasTreshold; |
54 } else { | 54 } else { |
55 float limitingConeAngle = m_limitingConeAngle; | 55 float limitingConeAngle = m_limitingConeAngle; |
56 if (limitingConeAngle < 0.0f) | 56 if (limitingConeAngle < 0.0f) |
57 limitingConeAngle = -limitingConeAngle; | 57 limitingConeAngle = -limitingConeAngle; |
58 if (limitingConeAngle > 90.0f) | 58 if (limitingConeAngle > 90.0f) |
59 limitingConeAngle = 90.0f; | 59 limitingConeAngle = 90.0f; |
60 paintingData.coneCutOffLimit = cosf(deg2rad(180.0f - limitingConeAngle))
; | 60 paintingData.coneCutOffLimit = cosf(deg2rad(180.0f - limitingConeAngle))
; |
61 paintingData.coneFullLight = paintingData.coneCutOffLimit - antiAliasTre
shold; | 61 paintingData.coneFullLight = paintingData.coneCutOffLimit - antiAliasTre
shold; |
62 } | 62 } |
63 | 63 |
64 // Optimization for common specularExponent values | 64 // Optimization for common specularExponent values |
65 if (!m_specularExponent) | 65 if (!m_specularExponent) |
66 paintingData.specularExponent = 0; | 66 paintingData.specularExponent = 0; |
67 else if (m_specularExponent == 1.0f) | 67 else if (m_specularExponent == 1.0f) |
68 paintingData.specularExponent = 1; | 68 paintingData.specularExponent = 1; |
69 else // It is neither 0.0f nor 1.0f | 69 else // It is neither 0.0f nor 1.0f |
70 paintingData.specularExponent = 2; | 70 paintingData.specularExponent = 2; |
71 } | 71 } |
72 | 72 |
73 void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int
y, float z) | 73 void SpotLightSource::updatePaintingData(PaintingData& paintingData, int x, int
y, float z) const |
74 { | 74 { |
75 paintingData.lightVector.setX(m_position.x() - x); | 75 paintingData.lightVector.setX(m_position.x() - x); |
76 paintingData.lightVector.setY(m_position.y() - y); | 76 paintingData.lightVector.setY(m_position.y() - y); |
77 paintingData.lightVector.setZ(m_position.z() - z); | 77 paintingData.lightVector.setZ(m_position.z() - z); |
78 paintingData.lightVectorLength = paintingData.lightVector.length(); | 78 paintingData.lightVectorLength = paintingData.lightVector.length(); |
79 | 79 |
80 float cosineOfAngle = (paintingData.lightVector * paintingData.directionVect
or) / paintingData.lightVectorLength; | 80 float cosineOfAngle = (paintingData.lightVector * paintingData.directionVect
or) / paintingData.lightVectorLength; |
81 if (cosineOfAngle > paintingData.coneCutOffLimit) { | 81 if (cosineOfAngle > paintingData.coneCutOffLimit) { |
82 // No light is produced, scanlines are not updated | 82 // No light is produced, scanlines are not updated |
83 paintingData.colorVector.setX(0.0f); | 83 paintingData.colorVector.setX(0.0f); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 { | 185 { |
186 ts << "[type=SPOT-LIGHT] "; | 186 ts << "[type=SPOT-LIGHT] "; |
187 ts << "[position=\"" << position() << "\"]"; | 187 ts << "[position=\"" << position() << "\"]"; |
188 ts << "[direction=\"" << direction() << "\"]"; | 188 ts << "[direction=\"" << direction() << "\"]"; |
189 ts << "[specularExponent=\"" << specularExponent() << "\"]"; | 189 ts << "[specularExponent=\"" << specularExponent() << "\"]"; |
190 ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]"; | 190 ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]"; |
191 return ts; | 191 return ts; |
192 } | 192 } |
193 | 193 |
194 }; // namespace WebCore | 194 }; // namespace WebCore |
OLD | NEW |