Added Z scale when X and Y scale to spot lights and point lights

Z scale is set as the average of X scale and Y scale.

BUG=skia:
R=senorblanco@google.com, senorblanco@chromium.org

Author: sugoi@chromium.org

Review URL: https://codereview.chromium.org/198013002

git-svn-id: http://skia.googlecode.com/svn/trunk@13798 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index f4d0ea2..ec33c29 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -641,7 +641,10 @@
     virtual SkLight* transform(const SkMatrix& matrix) const {
         SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY);
         matrix.mapPoints(&location2, 1);
-        SkPoint3 location(location2.fX, location2.fY, fLocation.fZ);
+        // Use X scale and Y scale on Z and average the result
+        SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ);
+        matrix.mapVectors(&locationZ, 1);
+        SkPoint3 location(location2.fX, location2.fY, SkScalarAve(locationZ.fX, locationZ.fY));
         return new SkPointLight(location, color());
     }
 
@@ -682,11 +685,18 @@
     virtual SkLight* transform(const SkMatrix& matrix) const {
         SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY);
         matrix.mapPoints(&location2, 1);
-        SkPoint3 location(location2.fX, location2.fY, fLocation.fZ);
+        // Use X scale and Y scale on Z and average the result
+        SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ);
+        matrix.mapVectors(&locationZ, 1);
+        SkPoint3 location(location2.fX, location2.fY, SkScalarAve(locationZ.fX, locationZ.fY));
         SkPoint target2 = SkPoint::Make(fTarget.fX, fTarget.fY);
         matrix.mapPoints(&target2, 1);
-        SkPoint3 target(target2.fX, target2.fY, fTarget.fZ);
-        return new SkSpotLight(location, target, fSpecularExponent, fCosOuterConeAngle, fCosInnerConeAngle, fConeScale, fS, color());
+        SkPoint targetZ = SkPoint::Make(fTarget.fZ, fTarget.fZ);
+        matrix.mapVectors(&targetZ, 1);
+        SkPoint3 target(target2.fX, target2.fY, SkScalarAve(targetZ.fX, targetZ.fY));
+        SkPoint3 s = target - location;
+        s.normalize();
+        return new SkSpotLight(location, target, fSpecularExponent, fCosOuterConeAngle, fCosInnerConeAngle, fConeScale, s, color());
     }
 
     SkPoint3 surfaceToLight(int x, int y, int z, SkScalar surfaceScale) const {