2011-02-10 Renata Hodovan <reni@webkit.org>
authorreni@webkit.org <reni@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Feb 2011 12:23:48 +0000 (12:23 +0000)
committerreni@webkit.org <reni@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Feb 2011 12:23:48 +0000 (12:23 +0000)
        Reviewed by Dirk Schulze.

        Move the light source implementations into their own files.
        https://bugs.webkit.org/show_bug.cgi?id=53996

        Splitting LightSource.cpp into 3 files.

        No new tests are added since this is a refactoring.

        * Android.mk:
        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * platform/graphics/filters/DistantLightSource.cpp: Added.
        (WebCore::DistantLightSource::initPaintingData):
        (WebCore::DistantLightSource::updatePaintingData):
        (WebCore::DistantLightSource::setAzimuth):
        (WebCore::DistantLightSource::setElevation):
        (WebCore::DistantLightSource::externalRepresentation):
        * platform/graphics/filters/LightSource.cpp:
        * platform/graphics/filters/PointLightSource.cpp: Added.
        (WebCore::PointLightSource::initPaintingData):
        (WebCore::PointLightSource::updatePaintingData):
        (WebCore::PointLightSource::setX):
        (WebCore::PointLightSource::setY):
        (WebCore::PointLightSource::setZ):
        (WebCore::operator<<):
        (WebCore::PointLightSource::externalRepresentation):
        * platform/graphics/filters/SpotLightSource.cpp: Added.
        (WebCore::SpotLightSource::initPaintingData):
        (WebCore::SpotLightSource::updatePaintingData):
        (WebCore::SpotLightSource::setX):
        (WebCore::SpotLightSource::setY):
        (WebCore::SpotLightSource::setZ):
        (WebCore::SpotLightSource::setPointsAtX):
        (WebCore::SpotLightSource::setPointsAtY):
        (WebCore::SpotLightSource::setPointsAtZ):
        (WebCore::SpotLightSource::setSpecularExponent):
        (WebCore::SpotLightSource::setLimitingConeAngle):
        (WebCore::operator<<):
        (WebCore::SpotLightSource::externalRepresentation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@78194 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/Android.mk
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/filters/DistantLightSource.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/filters/LightSource.cpp
Source/WebCore/platform/graphics/filters/PointLightSource.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/filters/SpotLightSource.cpp [new file with mode: 0644]

index 3cd8745..682a718 100644 (file)
@@ -543,6 +543,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
 
 ifeq ($(ENABLE_SVG), true)
 LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
+       platform/graphics/filters/DistantLightSource.cpp \
        platform/graphics/filters/FEBlend.cpp \
        platform/graphics/filters/FEColorMatrix.cpp \
        platform/graphics/filters/FEComponentTransfer.cpp \
@@ -557,7 +558,9 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
        platform/graphics/filters/FESpecularLighting.cpp \
        platform/graphics/filters/FETile.cpp \
        platform/graphics/filters/FETurbulence.cpp \
-       platform/graphics/filters/LightSource.cpp
+       platform/graphics/filters/LightSource.cpp \
+       platform/graphics/filters/PointLightSource.cpp \
+       platform/graphics/filters/SpotLightSource.cpp
 endif
 
 LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
index f797589..064bf16 100644 (file)
@@ -1222,6 +1222,7 @@ SET(WebCore_SOURCES
     platform/graphics/StringTruncator.cpp
     platform/graphics/WidthIterator.cpp
 
+    platform/graphics/filters/DistantLightSource.cpp
     platform/graphics/filters/FEBlend.cpp
     platform/graphics/filters/FEColorMatrix.cpp
     platform/graphics/filters/FEComponentTransfer.cpp
@@ -1240,6 +1241,8 @@ SET(WebCore_SOURCES
     platform/graphics/filters/FETurbulence.cpp
     platform/graphics/filters/FilterEffect.cpp
     platform/graphics/filters/LightSource.cpp
+    platform/graphics/filters/PointLightSource.cpp
+    platform/graphics/filters/SpotLightSource.cpp
     platform/graphics/filters/SourceAlpha.cpp
     platform/graphics/filters/SourceGraphic.cpp
 
index ab16bd1..3f7a2cc 100644 (file)
@@ -1,3 +1,50 @@
+2011-02-10  Renata Hodovan  <reni@webkit.org>
+
+        Reviewed by Dirk Schulze.
+
+        Move the light source implementations into their own files.
+        https://bugs.webkit.org/show_bug.cgi?id=53996
+
+        Splitting LightSource.cpp into 3 files.
+
+        No new tests are added since this is a refactoring.
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/filters/DistantLightSource.cpp: Added.
+        (WebCore::DistantLightSource::initPaintingData):
+        (WebCore::DistantLightSource::updatePaintingData):
+        (WebCore::DistantLightSource::setAzimuth):
+        (WebCore::DistantLightSource::setElevation):
+        (WebCore::DistantLightSource::externalRepresentation):
+        * platform/graphics/filters/LightSource.cpp:
+        * platform/graphics/filters/PointLightSource.cpp: Added.
+        (WebCore::PointLightSource::initPaintingData):
+        (WebCore::PointLightSource::updatePaintingData):
+        (WebCore::PointLightSource::setX):
+        (WebCore::PointLightSource::setY):
+        (WebCore::PointLightSource::setZ):
+        (WebCore::operator<<):
+        (WebCore::PointLightSource::externalRepresentation):
+        * platform/graphics/filters/SpotLightSource.cpp: Added.
+        (WebCore::SpotLightSource::initPaintingData):
+        (WebCore::SpotLightSource::updatePaintingData):
+        (WebCore::SpotLightSource::setX):
+        (WebCore::SpotLightSource::setY):
+        (WebCore::SpotLightSource::setZ):
+        (WebCore::SpotLightSource::setPointsAtX):
+        (WebCore::SpotLightSource::setPointsAtY):
+        (WebCore::SpotLightSource::setPointsAtZ):
+        (WebCore::SpotLightSource::setSpecularExponent):
+        (WebCore::SpotLightSource::setLimitingConeAngle):
+        (WebCore::operator<<):
+        (WebCore::SpotLightSource::externalRepresentation):
+
 2011-02-10  Avi Drissman  <avi@google.com>
 
         Reviewed by Darin Fisher.
index 04c093e..36f72ab 100644 (file)
@@ -2343,6 +2343,7 @@ webcore_sources += \
        Source/WebCore/platform/graphics/ContextShadow.cpp \
        Source/WebCore/platform/graphics/ContextShadow.h \
        Source/WebCore/platform/graphics/DashArray.h \
+       Source/WebCore/platform/graphics/filters/DistantLightSource.cpp \
        Source/WebCore/platform/graphics/filters/DistantLightSource.h \
        Source/WebCore/platform/graphics/filters/FEBlend.cpp \
        Source/WebCore/platform/graphics/filters/FEBlend.h \
@@ -2381,11 +2382,13 @@ webcore_sources += \
        Source/WebCore/platform/graphics/filters/Filter.h \
        Source/WebCore/platform/graphics/filters/LightSource.cpp \
        Source/WebCore/platform/graphics/filters/LightSource.h \
+       Source/WebCore/platform/graphics/filters/PointLightSource.cpp \
        Source/WebCore/platform/graphics/filters/PointLightSource.h \
        Source/WebCore/platform/graphics/filters/SourceAlpha.cpp \
        Source/WebCore/platform/graphics/filters/SourceAlpha.h \
        Source/WebCore/platform/graphics/filters/SourceGraphic.cpp \
        Source/WebCore/platform/graphics/filters/SourceGraphic.h \
+       Source/WebCore/platform/graphics/filters/SpotLightSource.cpp \
        Source/WebCore/platform/graphics/filters/SpotLightSource.h \
        Source/WebCore/platform/graphics/FloatPoint3D.cpp \
        Source/WebCore/platform/graphics/FloatPoint3D.h \
index 37411e0..ba9e313 100644 (file)
             'platform/graphics/chromium/WebGLLayerChromium.h',
             'platform/graphics/cocoa/FontPlatformData.h',
             'platform/graphics/cocoa/FontPlatformDataCocoa.mm',
+            'platform/graphics/filters/DistantLightSource.cpp',
             'platform/graphics/filters/DistantLightSource.h',
             'platform/graphics/filters/FEBlend.cpp',
             'platform/graphics/filters/FEBlend.h',
             'platform/graphics/filters/FETurbulence.h',
             'platform/graphics/filters/LightSource.cpp',
             'platform/graphics/filters/LightSource.h',
+            'platform/graphics/filters/PointLightSource.cpp',
             'platform/graphics/filters/PointLightSource.h',
+            'platform/graphics/filters/SpotLightSource.cpp',
             'platform/graphics/filters/SpotLightSource.h',
             'platform/graphics/filters/Filter.h',
             'platform/graphics/filters/FilterEffect.cpp',
index 926c154..dcdb7a5 100644 (file)
@@ -3353,6 +3353,7 @@ contains(DEFINES, ENABLE_XSLT=1) {
 
 contains(DEFINES, ENABLE_FILTERS=1) {
     SOURCES += \
+        platform/graphics/filters/DistantLightSource.cpp \
         platform/graphics/filters/FEBlend.cpp \
         platform/graphics/filters/FEColorMatrix.cpp \
         platform/graphics/filters/FEComponentTransfer.cpp \
@@ -3371,6 +3372,8 @@ contains(DEFINES, ENABLE_FILTERS=1) {
         platform/graphics/filters/FETurbulence.cpp \
         platform/graphics/filters/FilterEffect.cpp \
         platform/graphics/filters/LightSource.cpp \
+        platform/graphics/filters/PointLightSource.cpp \
+        platform/graphics/filters/SpotLightSource.cpp \
         platform/graphics/filters/SourceAlpha.cpp \
         platform/graphics/filters/SourceGraphic.cpp
 }
index 8737a84..0cc4fd2 100755 (executable)
                                        Name="filters"
                                        >
                                        <File
+                                               RelativePath="..\platform\graphics\filters\DistantLightSource.cpp"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\platform\graphics\filters\DistantLightSource.h"
                                                >
                                        </File>
                                                >
                                        </File>
                                        <File
+                                               RelativePath="..\platform\graphics\filters\PointLightSource.cpp"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\platform\graphics\filters\PointLightSource.h"
                                                >
                                        </File>
                                                >
                                        </File>
                                        <File
+                                               RelativePath="..\platform\graphics\filters\SpotLightSource.cpp"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\platform\graphics\filters\SpotLightSource.h"
                                                >
                                        </File>
index 2b24495..9f3e246 100644 (file)
                A136A00D1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h in Headers */ = {isa = PBXBuildFile; fileRef = A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */; };
                A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */; };
                A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */; };
+               A1E1154413015C3D0054AC8C /* DistantLightSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1154313015C3D0054AC8C /* DistantLightSource.cpp */; };
+               A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1154513015C4E0054AC8C /* PointLightSource.cpp */; };
+               A1E1154813015C5D0054AC8C /* SpotLightSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1E1154713015C5D0054AC8C /* SpotLightSource.cpp */; };
                A409C984116D0DDD007197BD /* AccessibilityProgressIndicator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A409C982116D0DDD007197BD /* AccessibilityProgressIndicator.cpp */; };
                A409C985116D0DDD007197BD /* AccessibilityProgressIndicator.h in Headers */ = {isa = PBXBuildFile; fileRef = A409C983116D0DDD007197BD /* AccessibilityProgressIndicator.h */; };
                A4226E5A1163D667008B8397 /* JSHTMLProgressElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A4226E591163D667008B8397 /* JSHTMLProgressElement.cpp */; };
                A136A00B1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLHttpRequestProgressEventThrottle.h; sourceTree = "<group>"; };
                A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; };
                A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; };
+               A1E1154313015C3D0054AC8C /* DistantLightSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DistantLightSource.cpp; path = filters/DistantLightSource.cpp; sourceTree = "<group>"; };
+               A1E1154513015C4E0054AC8C /* PointLightSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PointLightSource.cpp; path = filters/PointLightSource.cpp; sourceTree = "<group>"; };
+               A1E1154713015C5D0054AC8C /* SpotLightSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SpotLightSource.cpp; path = filters/SpotLightSource.cpp; sourceTree = "<group>"; };
                A409C982116D0DDD007197BD /* AccessibilityProgressIndicator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityProgressIndicator.cpp; sourceTree = "<group>"; };
                A409C983116D0DDD007197BD /* AccessibilityProgressIndicator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityProgressIndicator.h; sourceTree = "<group>"; };
                A4226E591163D667008B8397 /* JSHTMLProgressElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLProgressElement.cpp; sourceTree = "<group>"; };
                A75E8B7F0E1DE2B0007F2481 /* filters */ = {
                        isa = PBXGroup;
                        children = (
+                               A1E1154713015C5D0054AC8C /* SpotLightSource.cpp */,
+                               A1E1154513015C4E0054AC8C /* PointLightSource.cpp */,
+                               A1E1154313015C3D0054AC8C /* DistantLightSource.cpp */,
                                84730D5A1248F0B300D3A9C9 /* DistantLightSource.h */,
                                A75E8B800E1DE2D6007F2481 /* FEBlend.cpp */,
                                A75E8B810E1DE2D6007F2481 /* FEBlend.h */,
                                9343CB8112F25E510033C5EE /* TextCodecUTF8.cpp in Sources */,
                                977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
                                0F29C16E1300C2E2002D794E /* AccessibilityAllInOne.cpp in Sources */,
+                               A1E1154413015C3D0054AC8C /* DistantLightSource.cpp in Sources */,
+                               A1E1154613015C4E0054AC8C /* PointLightSource.cpp in Sources */,
+                               A1E1154813015C5D0054AC8C /* SpotLightSource.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Source/WebCore/platform/graphics/filters/DistantLightSource.cpp b/Source/WebCore/platform/graphics/filters/DistantLightSource.cpp
new file mode 100644 (file)
index 0000000..4c3b49b
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
+ * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
+ * Copyright (C) 2011 University of Szeged
+ * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(FILTERS)
+#include "DistantLightSource.h"
+
+#include "RenderTreeAsText.h"
+
+namespace WebCore {
+
+void DistantLightSource::initPaintingData(PaintingData& paintingData)
+{
+    float azimuth = deg2rad(m_azimuth);
+    float elevation = deg2rad(m_elevation);
+    paintingData.lightVector.setX(cosf(azimuth) * cosf(elevation));
+    paintingData.lightVector.setY(sinf(azimuth) * cosf(elevation));
+    paintingData.lightVector.setZ(sinf(elevation));
+    paintingData.lightVectorLength = 1;
+}
+
+void DistantLightSource::updatePaintingData(PaintingData&, int, int, float)
+{
+}
+
+bool DistantLightSource::setAzimuth(float azimuth)
+{
+    if (m_azimuth == azimuth)
+        return false;
+    m_azimuth = azimuth;
+    return true;
+}
+
+bool DistantLightSource::setElevation(float elevation)
+{
+    if (m_elevation == elevation)
+        return false;
+    m_elevation = elevation;
+    return true;
+}
+
+TextStream& DistantLightSource::externalRepresentation(TextStream& ts) const
+{
+    ts << "[type=DISTANT-LIGHT] ";
+    ts << "[azimuth=\"" << azimuth() << "\"]";
+    ts << "[elevation=\"" << elevation() << "\"]";
+    return ts;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILTERS)
index e50e62d..cf262e8 100644 (file)
@@ -3,6 +3,7 @@
  * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
  * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
  * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
+ * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>, University of Szeged.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 namespace WebCore {
 
-void PointLightSource::initPaintingData(PaintingData&)
-{
-}
-
-void PointLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z)
-{
-    paintingData.lightVector.setX(m_position.x() - x);
-    paintingData.lightVector.setY(m_position.y() - y);
-    paintingData.lightVector.setZ(m_position.z() - z);
-    paintingData.lightVectorLength = paintingData.lightVector.length();
-}
-
-bool PointLightSource::setX(float x)
-{
-    if (m_position.x() == x)
-        return false;
-    m_position.setX(x);
-    return true;
-}
-
-bool PointLightSource::setY(float y)
-{
-    if (m_position.y() == y)
-        return false;
-    m_position.setY(y);
-    return true;
-}
-
-bool PointLightSource::setZ(float z)
-{
-    if (m_position.z() == z)
-        return false;
-    m_position.setZ(z);
-    return true;
-}
-
-// spot-light edge darkening depends on an absolute treshold
-// according to the SVG 1.1 SE light regression tests
-static const float antiAliasTreshold = 0.016f;
-
-void SpotLightSource::initPaintingData(PaintingData& paintingData)
-{
-    paintingData.privateColorVector = paintingData.colorVector;
-    paintingData.directionVector.setX(m_direction.x() - m_position.x());
-    paintingData.directionVector.setY(m_direction.y() - m_position.y());
-    paintingData.directionVector.setZ(m_direction.z() - m_position.z());
-    paintingData.directionVector.normalize();
-
-    if (!m_limitingConeAngle) {
-        paintingData.coneCutOffLimit = 0.0f;
-        paintingData.coneFullLight = -antiAliasTreshold;
-    } else {
-        float limitingConeAngle = m_limitingConeAngle;
-        if (limitingConeAngle < 0.0f)
-            limitingConeAngle = -limitingConeAngle;
-        if (limitingConeAngle > 90.0f)
-            limitingConeAngle = 90.0f;
-        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)
-{
-    paintingData.lightVector.setX(m_position.x() - x);
-    paintingData.lightVector.setY(m_position.y() - y);
-    paintingData.lightVector.setZ(m_position.z() - z);
-    paintingData.lightVectorLength = paintingData.lightVector.length();
-
-    float cosineOfAngle = (paintingData.lightVector * paintingData.directionVector) / paintingData.lightVectorLength;
-    if (cosineOfAngle > paintingData.coneCutOffLimit) {
-        // No light is produced, scanlines are not updated
-        paintingData.colorVector.setX(0.0f);
-        paintingData.colorVector.setY(0.0f);
-        paintingData.colorVector.setZ(0.0f);
-        return;
-    }
-
-    // Set the color of the pixel
-    float lightStrength;
-    switch (paintingData.specularExponent) {
-    case 0:
-        lightStrength = 1.0f; // -cosineOfAngle ^ 0 == 1
-        break;
-    case 1:
-        lightStrength = -cosineOfAngle; // -cosineOfAngle ^ 1 == -cosineOfAngle
-        break;
-    default:
-        lightStrength = powf(-cosineOfAngle, m_specularExponent);
-        break;
-    }
-
-    if (cosineOfAngle > paintingData.coneFullLight)
-        lightStrength *= (paintingData.coneCutOffLimit - cosineOfAngle) / (paintingData.coneCutOffLimit - paintingData.coneFullLight);
-
-    if (lightStrength > 1.0f)
-        lightStrength = 1.0f;
-
-    paintingData.colorVector.setX(paintingData.privateColorVector.x() * lightStrength);
-    paintingData.colorVector.setY(paintingData.privateColorVector.y() * lightStrength);
-    paintingData.colorVector.setZ(paintingData.privateColorVector.z() * lightStrength);
-}
-
-bool SpotLightSource::setX(float x)
-{
-    if (m_position.x() == x)
-        return false;
-    m_position.setX(x);
-    return true;
-}
-
-bool SpotLightSource::setY(float y)
-{
-    if (m_position.y() == y)
-        return false;
-    m_position.setY(y);
-    return true;
-}
-
-bool SpotLightSource::setZ(float z)
-{
-    if (m_position.z() == z)
-        return false;
-    m_position.setZ(z);
-    return true;
-}
-
-bool SpotLightSource::setPointsAtX(float pointsAtX)
-{
-    if (m_direction.x() == pointsAtX)
-        return false;
-    m_direction.setX(pointsAtX);
-    return true;
-}
-
-bool SpotLightSource::setPointsAtY(float pointsAtY)
-{
-    if (m_direction.y() == pointsAtY)
-        return false;
-    m_direction.setY(pointsAtY);
-    return true;
-}
-
-bool SpotLightSource::setPointsAtZ(float pointsAtZ)
-{
-    if (m_direction.z() == pointsAtZ)
-        return false;
-    m_direction.setZ(pointsAtZ);
-    return true;
-}
-
-bool SpotLightSource::setSpecularExponent(float specularExponent)
-{
-    if (m_specularExponent == specularExponent)
-        return false;
-    m_specularExponent = specularExponent;
-    return true;
-}
-
-bool SpotLightSource::setLimitingConeAngle(float limitingConeAngle)
-{
-    if (m_limitingConeAngle == limitingConeAngle)
-        return false;
-    m_limitingConeAngle = limitingConeAngle;
-    return true;
-}
-
-void DistantLightSource::initPaintingData(PaintingData& paintingData)
-{
-    float azimuth = deg2rad(m_azimuth);
-    float elevation = deg2rad(m_elevation);
-    paintingData.lightVector.setX(cosf(azimuth) * cosf(elevation));
-    paintingData.lightVector.setY(sinf(azimuth) * cosf(elevation));
-    paintingData.lightVector.setZ(sinf(elevation));
-    paintingData.lightVectorLength = 1;
-}
-
-void DistantLightSource::updatePaintingData(PaintingData&, int, int, float)
-{
-}
-
-bool DistantLightSource::setAzimuth(float azimuth)
-{
-    if (m_azimuth == azimuth)
-        return false;
-    m_azimuth = azimuth;
-    return true;
-}
-
-bool DistantLightSource::setElevation(float elevation)
-{
-    if (m_elevation == elevation)
-        return false;
-    m_elevation = elevation;
-    return true;
-}
-
 bool LightSource::setAzimuth(float azimuth)
 {
     if (m_type == LS_DISTANT)
@@ -314,37 +110,6 @@ bool LightSource::setLimitingConeAngle(float limitingConeAngle)
     return false;
 }
 
-static TextStream& operator<<(TextStream& ts, const FloatPoint3D& p)
-{
-    ts << "x=" << p.x() << " y=" << p.y() << " z=" << p.z();
-    return ts;
-}
-
-TextStream& PointLightSource::externalRepresentation(TextStream& ts) const
-{
-    ts << "[type=POINT-LIGHT] ";
-    ts << "[position=\"" << position() << "\"]";
-    return ts;
-}
-
-TextStream& SpotLightSource::externalRepresentation(TextStream& ts) const
-{
-    ts << "[type=SPOT-LIGHT] ";
-    ts << "[position=\"" << position() << "\"]";
-    ts << "[direction=\"" << direction() << "\"]";
-    ts << "[specularExponent=\"" << specularExponent() << "\"]";
-    ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]";
-    return ts;
-}
-
-TextStream& DistantLightSource::externalRepresentation(TextStream& ts) const
-{
-    ts << "[type=DISTANT-LIGHT] ";
-    ts << "[azimuth=\"" << azimuth() << "\"]";
-    ts << "[elevation=\"" << elevation() << "\"]";
-    return ts;
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(FILTERS)
diff --git a/Source/WebCore/platform/graphics/filters/PointLightSource.cpp b/Source/WebCore/platform/graphics/filters/PointLightSource.cpp
new file mode 100644 (file)
index 0000000..207ed8e
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
+ * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
+ * Copyright (C) 2011 University of Szeged
+ * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(FILTERS)
+#include "PointLightSource.h"
+
+#include "TextStream.h"
+
+namespace WebCore {
+
+void PointLightSource::initPaintingData(PaintingData&)
+{
+}
+
+void PointLightSource::updatePaintingData(PaintingData& paintingData, int x, int y, float z)
+{
+    paintingData.lightVector.setX(m_position.x() - x);
+    paintingData.lightVector.setY(m_position.y() - y);
+    paintingData.lightVector.setZ(m_position.z() - z);
+    paintingData.lightVectorLength = paintingData.lightVector.length();
+}
+
+bool PointLightSource::setX(float x)
+{
+    if (m_position.x() == x)
+        return false;
+    m_position.setX(x);
+    return true;
+}
+
+bool PointLightSource::setY(float y)
+{
+    if (m_position.y() == y)
+        return false;
+    m_position.setY(y);
+    return true;
+}
+
+bool PointLightSource::setZ(float z)
+{
+    if (m_position.z() == z)
+        return false;
+    m_position.setZ(z);
+    return true;
+}
+
+static TextStream& operator<<(TextStream& ts, const FloatPoint3D& p)
+{
+    ts << "x=" << p.x() << " y=" << p.y() << " z=" << p.z();
+    return ts;
+}
+
+TextStream& PointLightSource::externalRepresentation(TextStream& ts) const
+{
+    ts << "[type=POINT-LIGHT] ";
+    ts << "[position=\"" << position() << "\"]";
+    return ts;
+}
+
+}; // namespace WebCore
+
+#endif // ENABLE(FILTERS)
diff --git a/Source/WebCore/platform/graphics/filters/SpotLightSource.cpp b/Source/WebCore/platform/graphics/filters/SpotLightSource.cpp
new file mode 100644 (file)
index 0000000..648fcae
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com>
+ * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
+ * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
+ * Copyright (C) 2010 Zoltan Herczeg <zherczeg@webkit.org>
+ * Copyright (C) 2011 University of Szeged
+ * Copyright (C) 2011 Renata Hodovan <reni@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+
+#if ENABLE(FILTERS)
+#include "SpotLightSource.h"
+
+#include "TextStream.h"
+
+namespace WebCore {
+
+// spot-light edge darkening depends on an absolute treshold
+// according to the SVG 1.1 SE light regression tests
+static const float antiAliasTreshold = 0.016f;
+
+void SpotLightSource::initPaintingData(PaintingData& paintingData)
+{
+    paintingData.privateColorVector = paintingData.colorVector;
+    paintingData.directionVector.setX(m_direction.x() - m_position.x());
+    paintingData.directionVector.setY(m_direction.y() - m_position.y());
+    paintingData.directionVector.setZ(m_direction.z() - m_position.z());
+    paintingData.directionVector.normalize();
+
+    if (!m_limitingConeAngle) {
+        paintingData.coneCutOffLimit = 0.0f;
+        paintingData.coneFullLight = -antiAliasTreshold;
+    } else {
+        float limitingConeAngle = m_limitingConeAngle;
+        if (limitingConeAngle < 0.0f)
+            limitingConeAngle = -limitingConeAngle;
+        if (limitingConeAngle > 90.0f)
+            limitingConeAngle = 90.0f;
+        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)
+{
+    paintingData.lightVector.setX(m_position.x() - x);
+    paintingData.lightVector.setY(m_position.y() - y);
+    paintingData.lightVector.setZ(m_position.z() - z);
+    paintingData.lightVectorLength = paintingData.lightVector.length();
+
+    float cosineOfAngle = (paintingData.lightVector * paintingData.directionVector) / paintingData.lightVectorLength;
+    if (cosineOfAngle > paintingData.coneCutOffLimit) {
+        // No light is produced, scanlines are not updated
+        paintingData.colorVector.setX(0.0f);
+        paintingData.colorVector.setY(0.0f);
+        paintingData.colorVector.setZ(0.0f);
+        return;
+    }
+
+    // Set the color of the pixel
+    float lightStrength;
+    switch (paintingData.specularExponent) {
+    case 0:
+        lightStrength = 1.0f; // -cosineOfAngle ^ 0 == 1
+        break;
+    case 1:
+        lightStrength = -cosineOfAngle; // -cosineOfAngle ^ 1 == -cosineOfAngle
+        break;
+    default:
+        lightStrength = powf(-cosineOfAngle, m_specularExponent);
+        break;
+    }
+
+    if (cosineOfAngle > paintingData.coneFullLight)
+        lightStrength *= (paintingData.coneCutOffLimit - cosineOfAngle) / (paintingData.coneCutOffLimit - paintingData.coneFullLight);
+
+    if (lightStrength > 1.0f)
+        lightStrength = 1.0f;
+
+    paintingData.colorVector.setX(paintingData.privateColorVector.x() * lightStrength);
+    paintingData.colorVector.setY(paintingData.privateColorVector.y() * lightStrength);
+    paintingData.colorVector.setZ(paintingData.privateColorVector.z() * lightStrength);
+}
+
+bool SpotLightSource::setX(float x)
+{
+    if (m_position.x() == x)
+        return false;
+    m_position.setX(x);
+    return true;
+}
+
+bool SpotLightSource::setY(float y)
+{
+    if (m_position.y() == y)
+        return false;
+    m_position.setY(y);
+    return true;
+}
+
+bool SpotLightSource::setZ(float z)
+{
+    if (m_position.z() == z)
+        return false;
+    m_position.setZ(z);
+    return true;
+}
+
+bool SpotLightSource::setPointsAtX(float pointsAtX)
+{
+    if (m_direction.x() == pointsAtX)
+        return false;
+    m_direction.setX(pointsAtX);
+    return true;
+}
+
+bool SpotLightSource::setPointsAtY(float pointsAtY)
+{
+    if (m_direction.y() == pointsAtY)
+        return false;
+    m_direction.setY(pointsAtY);
+    return true;
+}
+
+bool SpotLightSource::setPointsAtZ(float pointsAtZ)
+{
+    if (m_direction.z() == pointsAtZ)
+        return false;
+    m_direction.setZ(pointsAtZ);
+    return true;
+}
+
+bool SpotLightSource::setSpecularExponent(float specularExponent)
+{
+    if (m_specularExponent == specularExponent)
+        return false;
+    m_specularExponent = specularExponent;
+    return true;
+}
+
+bool SpotLightSource::setLimitingConeAngle(float limitingConeAngle)
+{
+    if (m_limitingConeAngle == limitingConeAngle)
+        return false;
+    m_limitingConeAngle = limitingConeAngle;
+    return true;
+}
+
+static TextStream& operator<<(TextStream& ts, const FloatPoint3D& p)
+{
+    ts << "x=" << p.x() << " y=" << p.y() << " z=" << p.z();
+    return ts;
+}
+
+TextStream& SpotLightSource::externalRepresentation(TextStream& ts) const
+{
+    ts << "[type=SPOT-LIGHT] ";
+    ts << "[position=\"" << position() << "\"]";
+    ts << "[direction=\"" << direction() << "\"]";
+    ts << "[specularExponent=\"" << specularExponent() << "\"]";
+    ts << "[limitingConeAngle=\"" << limitingConeAngle() << "\"]";
+    return ts;
+}
+
+}; // namespace WebCore
+
+#endif // ENABLE(FILTERS)