diff options
author | 2014-03-13 19:45:41 +0000 | |
---|---|---|
committer | 2014-03-13 19:45:41 +0000 | |
commit | 1037d92bbc10cafb61d050638e8cbe5a3aa6706f (patch) | |
tree | 49f4e5edaddcbe0c772914904913e2492d656b71 /src/effects | |
parent | 3da3b621c34810514a6d415a1dc782bd21648c3c (diff) |
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
Diffstat (limited to 'src/effects')
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index f4d0ea26a6..ec33c2930c 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -641,7 +641,10 @@ public: 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 @@ public: 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 { |