diff options
author | caryclark <caryclark@google.com> | 2015-10-20 10:04:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-20 10:04:03 -0700 |
commit | 0bccd8749bdce79b2d71518fe65783b1a9b06445 (patch) | |
tree | 9391a008cfaeb526fbfe7ef792796c350c2368fb /src | |
parent | 13ccbf8a681d69e4685849d9dedeabea0fea7773 (diff) |
Revert of Update feSpotLight to match spec (patchset #2 id:20001 of https://codereview.chromium.org/1403403003/ )
Reason for revert:
re-land once layout test have been disabled (so they can be rebased)
Original issue's description:
> 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
>
> Committed: https://skia.googlesource.com/skia/+/c84ccb070258db2803a9e8f532bfe7239a737063
TBR=senorblanco@google.com,senorblanco@chromium.org,bsalomon@google.com,ericrk@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=472849
Review URL: https://codereview.chromium.org/1417463006
Diffstat (limited to 'src')
-rw-r--r-- | src/effects/SkLightingImageFilter.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index f0f2c66d6f..199bb4d684 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -682,7 +682,7 @@ class GrGLLight; class SkImageFilterLight : public SkRefCnt { public: - + enum LightType { kDistant_LightType, @@ -819,8 +819,8 @@ public: // 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()); } @@ -854,7 +854,7 @@ public: : INHERITED(color), fLocation(location), fTarget(target), - fSpecularExponent(specularExponent) + fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSpecularExponentMax)) { fS = target - location; fast_normalize(&fS); @@ -984,6 +984,9 @@ protected: } private: + static const SkScalar kSpecularExponentMin; + static const SkScalar kSpecularExponentMax; + SkPoint3 fLocation; SkPoint3 fTarget; SkScalar fSpecularExponent; @@ -995,6 +998,11 @@ private: 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; + /////////////////////////////////////////////////////////////////////////////// void SkImageFilterLight::flattenLight(SkWriteBuffer& buffer) const { @@ -1985,7 +1993,7 @@ void GrGLSpotLight::emitLightColor(GrGLFPBuilder* builder, 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", |