Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: src/effects/SkLightingImageFilter.cpp

Issue 1417463006: Revert of Update feSpotLight to match spec (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/lighting.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkLightingImageFilter.cpp
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 31d36925550a5db488d9146046283fd9a600e6ab..4265f6e1e53c23137f5ca9db523169c44bde5c40 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -683,7 +683,7 @@
class SkImageFilterLight : public SkRefCnt {
public:
-
+
enum LightType {
kDistant_LightType,
@@ -820,8 +820,8 @@
// 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 = SkPoint3::Make(location2.fX,
- location2.fY,
+ SkPoint3 location = SkPoint3::Make(location2.fX,
+ location2.fY,
SkScalarAve(locationZ.fX, locationZ.fY));
return new SkPointLight(location, color());
}
@@ -855,7 +855,7 @@
: INHERITED(color),
fLocation(location),
fTarget(target),
- fSpecularExponent(specularExponent)
+ fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSpecularExponentMax))
{
fS = target - location;
fast_normalize(&fS);
@@ -985,6 +985,9 @@
}
private:
+ static const SkScalar kSpecularExponentMin;
+ static const SkScalar kSpecularExponentMax;
+
SkPoint3 fLocation;
SkPoint3 fTarget;
SkScalar fSpecularExponent;
@@ -995,6 +998,11 @@
typedef SkImageFilterLight INHERITED;
};
+
+// According to the spec, the specular term should be in the range [1, 128] :
+// http://www.w3.org/TR/SVG/filters.html#feSpecularLightingSpecularExponentAttribute
+const SkScalar SkSpotLight::kSpecularExponentMin = 1.0f;
+const SkScalar SkSpotLight::kSpecularExponentMax = 128.0f;
///////////////////////////////////////////////////////////////////////////////
@@ -1988,7 +1996,7 @@
lightColorBody.appendf("\t\treturn %s * scale * (cosAngle - %s) * %s;\n",
color, cosOuter, coneScale);
lightColorBody.appendf("\t}\n");
- lightColorBody.appendf("\treturn %s * scale;\n", color);
+ lightColorBody.appendf("\treturn %s;\n", color);
GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
fsBuilder->emitFunction(kVec3f_GrSLType,
"lightColor",
« no previous file with comments | « gm/lighting.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698