aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/lighting.cpp
diff options
context:
space:
mode:
authorGravatar ericrk <ericrk@chromium.org>2015-10-19 14:44:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-10-19 14:44:56 -0700
commitc84ccb070258db2803a9e8f532bfe7239a737063 (patch)
treea88d5eab3360be254e4ccd69240a9dfd50dc2729 /gm/lighting.cpp
parentaf96fce87937aba4aa5d394ee6316ba790308490 (diff)
Update feSpotLight to match spec
This change updates feSpotLight to match the spec via two changes: 1) specularExponent is ignored if the spotlight has no coneAngle (GPU bug only). This change updates the GPU path so that it matches the CPU path and the spec in this regard. 2) specularExponent is clamped to the 1-128 range. The spec does not specify a clamp for the specularExponent attribute of feSpotLight. Note that the spec *does* specify this clamp for the specularExponent attribute of feSpecularLighting. It looks like we incorrectly applied this to both specularExponent attributes. This change (along with a parallel change in Blink) allows us to pass the SVG filter effects conformance test here: http://www.w3.org/Graphics/SVG/Test/20110816/harness/htmlObject/filters-light-01-f.html Additionally, this brings our behavior in line with Safari and Edge’s behavior on this filter. Two new cases were added to gm/lighting.cpp to catch these issues: - The existing spotlight case exercised the path where our specular exponent was between 1-128 and had a limiting cone angle. - The first new spotlight case exercises the path where our specular exponent is between 1-128 and we do not have a limiting cone angle. - The second new spotlight case exercises the path where the specular exponent is not within the 1-128 range, to ensure that we don’t incorrectly clip to this range. BUG=472849 Review URL: https://codereview.chromium.org/1403403003
Diffstat (limited to 'gm/lighting.cpp')
-rw-r--r--gm/lighting.cpp62
1 files changed, 55 insertions, 7 deletions
diff --git a/gm/lighting.cpp b/gm/lighting.cpp
index af102d7d03..0ce9599bc1 100644
--- a/gm/lighting.cpp
+++ b/gm/lighting.cpp
@@ -10,7 +10,7 @@
#include "SkOffsetImageFilter.h"
#include "SkPoint3.h"
-#define WIDTH 330
+#define WIDTH 550
#define HEIGHT 660
namespace skiagm {
@@ -69,8 +69,10 @@ protected:
SkIntToScalar(-10),
SkIntToScalar(20));
SkPoint3 spotTarget = SkPoint3::Make(SkIntToScalar(40), SkIntToScalar(40), 0);
- SkScalar spotExponent = SK_Scalar1;
- SkScalar cutoffAngle = SkIntToScalar(15);
+ SkScalar spotExponent1 = SK_Scalar1;
+ SkScalar spotExponent0 = SkIntToScalar(0);
+ SkScalar cutoffAngleSmall = SkIntToScalar(15);
+ SkScalar cutoffAngleNone = SkIntToScalar(180);
SkScalar kd = SkIntToScalar(2);
SkScalar ks = SkIntToScalar(1);
SkScalar shininess = SkIntToScalar(8);
@@ -104,8 +106,8 @@ protected:
paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation,
spotTarget,
- spotExponent,
- cutoffAngle,
+ spotExponent1,
+ cutoffAngleSmall,
white,
surfaceScale,
kd,
@@ -113,6 +115,28 @@ protected:
cr))->unref();
drawClippedBitmap(canvas, paint, 220, y);
+ paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation,
+ spotTarget,
+ spotExponent1,
+ cutoffAngleNone,
+ white,
+ surfaceScale,
+ kd,
+ input,
+ cr))->unref();
+ drawClippedBitmap(canvas, paint, 330, y);
+
+ paint.setImageFilter(SkLightingImageFilter::CreateSpotLitDiffuse(spotLocation,
+ spotTarget,
+ spotExponent0,
+ cutoffAngleNone,
+ white,
+ surfaceScale,
+ kd,
+ input,
+ cr))->unref();
+ drawClippedBitmap(canvas, paint, 440, y);
+
y += 110;
paint.setImageFilter(SkLightingImageFilter::CreatePointLitSpecular(pointLocation,
@@ -135,8 +159,8 @@ protected:
paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(spotLocation,
spotTarget,
- spotExponent,
- cutoffAngle,
+ spotExponent1,
+ cutoffAngleSmall,
white,
surfaceScale,
ks,
@@ -145,6 +169,30 @@ protected:
cr))->unref();
drawClippedBitmap(canvas, paint, 220, y);
+ paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(spotLocation,
+ spotTarget,
+ spotExponent1,
+ cutoffAngleNone,
+ white,
+ surfaceScale,
+ ks,
+ shininess,
+ input,
+ cr))->unref();
+ drawClippedBitmap(canvas, paint, 330, y);
+
+ paint.setImageFilter(SkLightingImageFilter::CreateSpotLitSpecular(spotLocation,
+ spotTarget,
+ spotExponent0,
+ cutoffAngleNone,
+ white,
+ surfaceScale,
+ ks,
+ shininess,
+ input,
+ cr))->unref();
+ drawClippedBitmap(canvas, paint, 440, y);
+
y += 110;
}
}