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

Side by Side Diff: src/effects/SkLightingImageFilter.cpp

Issue 1403403003: 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 unified diff | Download patch
« no previous file with comments | « gm/lighting.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 class SkSpotLight : public SkImageFilterLight { 848 class SkSpotLight : public SkImageFilterLight {
849 public: 849 public:
850 SkSpotLight(const SkPoint3& location, 850 SkSpotLight(const SkPoint3& location,
851 const SkPoint3& target, 851 const SkPoint3& target,
852 SkScalar specularExponent, 852 SkScalar specularExponent,
853 SkScalar cutoffAngle, 853 SkScalar cutoffAngle,
854 SkColor color) 854 SkColor color)
855 : INHERITED(color), 855 : INHERITED(color),
856 fLocation(location), 856 fLocation(location),
857 fTarget(target), 857 fTarget(target),
858 fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSp ecularExponentMax)) 858 fSpecularExponent(specularExponent)
Stephen White 2015/10/16 15:03:10 Although it may not be spec-correct, this was adde
ericrk 2015/10/16 18:36:23 Per offline discussion - going to remove and see i
859 { 859 {
860 fS = target - location; 860 fS = target - location;
861 fast_normalize(&fS); 861 fast_normalize(&fS);
862 fCosOuterConeAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle)); 862 fCosOuterConeAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle));
863 const SkScalar antiAliasThreshold = 0.016f; 863 const SkScalar antiAliasThreshold = 0.016f;
864 fCosInnerConeAngle = fCosOuterConeAngle + antiAliasThreshold; 864 fCosInnerConeAngle = fCosOuterConeAngle + antiAliasThreshold;
865 fConeScale = SkScalarInvert(antiAliasThreshold); 865 fConeScale = SkScalarInvert(antiAliasThreshold);
866 } 866 }
867 867
868 SkImageFilterLight* transform(const SkMatrix& matrix) const override { 868 SkImageFilterLight* transform(const SkMatrix& matrix) const override {
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 SkString lightColorBody; 1989 SkString lightColorBody;
1990 lightColorBody.appendf("\tfloat cosAngle = -dot(surfaceToLight, %s);\n", s); 1990 lightColorBody.appendf("\tfloat cosAngle = -dot(surfaceToLight, %s);\n", s);
1991 lightColorBody.appendf("\tif (cosAngle < %s) {\n", cosOuter); 1991 lightColorBody.appendf("\tif (cosAngle < %s) {\n", cosOuter);
1992 lightColorBody.appendf("\t\treturn vec3(0);\n"); 1992 lightColorBody.appendf("\t\treturn vec3(0);\n");
1993 lightColorBody.appendf("\t}\n"); 1993 lightColorBody.appendf("\t}\n");
1994 lightColorBody.appendf("\tfloat scale = pow(cosAngle, %s);\n", exponent); 1994 lightColorBody.appendf("\tfloat scale = pow(cosAngle, %s);\n", exponent);
1995 lightColorBody.appendf("\tif (cosAngle < %s) {\n", cosInner); 1995 lightColorBody.appendf("\tif (cosAngle < %s) {\n", cosInner);
1996 lightColorBody.appendf("\t\treturn %s * scale * (cosAngle - %s) * %s;\n", 1996 lightColorBody.appendf("\t\treturn %s * scale * (cosAngle - %s) * %s;\n",
1997 color, cosOuter, coneScale); 1997 color, cosOuter, coneScale);
1998 lightColorBody.appendf("\t}\n"); 1998 lightColorBody.appendf("\t}\n");
1999 lightColorBody.appendf("\treturn %s;\n", color); 1999 lightColorBody.appendf("\treturn %s * scale;\n", color);
2000 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 2000 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
2001 fsBuilder->emitFunction(kVec3f_GrSLType, 2001 fsBuilder->emitFunction(kVec3f_GrSLType,
2002 "lightColor", 2002 "lightColor",
2003 SK_ARRAY_COUNT(gLightColorArgs), 2003 SK_ARRAY_COUNT(gLightColorArgs),
2004 gLightColorArgs, 2004 gLightColorArgs,
2005 lightColorBody.c_str(), 2005 lightColorBody.c_str(),
2006 &fLightColorFunc); 2006 &fLightColorFunc);
2007 2007
2008 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 2008 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
2009 } 2009 }
2010 2010
2011 #endif 2011 #endif
2012 2012
2013 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 2013 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
2014 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 2014 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
2015 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 2015 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
2016 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 2016 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« 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