 Chromium Code Reviews
 Chromium Code Reviews Issue 2198933002:
  Making a sample for shadow maps for more intensive development  (Closed) 
  Base URL: https://skia.googlesource.com/skia@shadow-gm
    
  
    Issue 2198933002:
  Making a sample for shadow maps for more intensive development  (Closed) 
  Base URL: https://skia.googlesource.com/skia@shadow-gm| Index: src/core/SkShadowShader.cpp | 
| diff --git a/src/core/SkShadowShader.cpp b/src/core/SkShadowShader.cpp | 
| index c5a99e9e91511f2e8afff585c40c0e3c606b272a..6da3662869171390d348edf345ca4ceb07995503 100644 | 
| --- a/src/core/SkShadowShader.cpp | 
| +++ b/src/core/SkShadowShader.cpp | 
| @@ -14,7 +14,7 @@ | 
| //////////////////////////////////////////////////////////////////////////// | 
| #ifdef SK_EXPERIMENTAL_SHADOWING | 
| 
robertphillips
2016/08/04 15:17:35
Can this actually go inside SkShadowShaderImpl ?
 
vjiaoblack
2016/08/04 18:03:59
Done.
 | 
| -#define SK_MAX_NON_AMBIENT_LIGHTS 4 | 
| +static constexpr int kMaxNonAmbientLights = 4; | 
| /** \class SkShadowShaderImpl | 
| This subclass of shader applies shadowing | 
| @@ -116,10 +116,10 @@ public: | 
| for (int i = 0; i < lights->numLights(); ++i) { | 
| if (SkLights::Light::kAmbient_LightType == lights->light(i).type()) { | 
| fAmbientColor += lights->light(i).color(); | 
| - } else if (fNumDirLights < SK_MAX_NON_AMBIENT_LIGHTS){ | 
| + } else if (fNumDirLights < kMaxNonAmbientLights){ | 
| fLightColor[fNumDirLights] = lights->light(i).color(); | 
| fLightDir[fNumDirLights] = lights->light(i).dir(); | 
| - SkImage_Base* shadowMap = ((SkImage_Base*)lights->light(i).getShadowMap().get()); | 
| + SkImage_Base* shadowMap = ((SkImage_Base*)lights->light(i).getShadowMap()); | 
| // this sk_sp gets deleted when the ShadowFP is destroyed, and frees the GrTexture* | 
| fTexture[fNumDirLights] = sk_sp<GrTexture>(shadowMap->asTextureRef(context, | 
| @@ -154,13 +154,13 @@ public: | 
| // add uniforms | 
| int32_t numLights = args.fFp.cast<ShadowFP>().fNumDirLights; | 
| - SkASSERT(numLights <= SK_MAX_NON_AMBIENT_LIGHTS); | 
| + SkASSERT(numLights <= kMaxNonAmbientLights); | 
| - const char* lightDirUniName[SK_MAX_NON_AMBIENT_LIGHTS] = {nullptr}; | 
| - const char* lightColorUniName[SK_MAX_NON_AMBIENT_LIGHTS] = {nullptr}; | 
| + const char* lightDirUniName[kMaxNonAmbientLights] = {nullptr}; | 
| + const char* lightColorUniName[kMaxNonAmbientLights] = {nullptr}; | 
| - const char* depthMapWidthUniName[SK_MAX_NON_AMBIENT_LIGHTS] = {nullptr}; | 
| - const char* depthMapHeightUniName[SK_MAX_NON_AMBIENT_LIGHTS] = {nullptr}; | 
| + const char* depthMapWidthUniName[kMaxNonAmbientLights] = {nullptr}; | 
| + const char* depthMapHeightUniName[kMaxNonAmbientLights] = {nullptr}; | 
| SkString lightDirUniNameBase("lightDir"); | 
| SkString lightColorUniNameBase("lightColor"); | 
| @@ -222,7 +222,7 @@ public: | 
| SkString diffuseColor("inDiffuseColor"); | 
| this->emitChild(1, nullptr, &diffuseColor, args); | 
| - SkString depthMaps[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| + SkString depthMaps[kMaxNonAmbientLights]; | 
| for (int i = 0; i < numLights; i++) { | 
| SkString povCoord("povCoord"); | 
| @@ -354,15 +354,15 @@ public: | 
| } | 
| private: | 
| - SkVector3 fLightDir[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - GrGLSLProgramDataManager::UniformHandle fLightDirUni[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - SkColor3f fLightColor[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - GrGLSLProgramDataManager::UniformHandle fLightColorUni[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| + SkVector3 fLightDir[kMaxNonAmbientLights]; | 
| + GrGLSLProgramDataManager::UniformHandle fLightDirUni[kMaxNonAmbientLights]; | 
| + SkColor3f fLightColor[kMaxNonAmbientLights]; | 
| + GrGLSLProgramDataManager::UniformHandle fLightColorUni[kMaxNonAmbientLights]; | 
| - int fDepthMapWidth[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - GrGLSLProgramDataManager::UniformHandle fDepthMapWidthUni[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - int fDepthMapHeight[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - GrGLSLProgramDataManager::UniformHandle fDepthMapHeightUni[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| + int fDepthMapWidth[kMaxNonAmbientLights]; | 
| + GrGLSLProgramDataManager::UniformHandle fDepthMapWidthUni[kMaxNonAmbientLights]; | 
| + int fDepthMapHeight[kMaxNonAmbientLights]; | 
| + GrGLSLProgramDataManager::UniformHandle fDepthMapHeightUni[kMaxNonAmbientLights]; | 
| int fWidth; | 
| GrGLSLProgramDataManager::UniformHandle fWidthUni; | 
| @@ -436,13 +436,13 @@ private: | 
| int fNumDirLights; | 
| - SkVector3 fLightDir[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - SkColor3f fLightColor[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - GrTextureAccess fDepthMapAccess[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - sk_sp<GrTexture> fTexture[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| + SkVector3 fLightDir[kMaxNonAmbientLights]; | 
| + SkColor3f fLightColor[kMaxNonAmbientLights]; | 
| + GrTextureAccess fDepthMapAccess[kMaxNonAmbientLights]; | 
| + sk_sp<GrTexture> fTexture[kMaxNonAmbientLights]; | 
| - int fDepthMapWidth[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| - int fDepthMapHeight[SK_MAX_NON_AMBIENT_LIGHTS]; | 
| + int fDepthMapWidth[kMaxNonAmbientLights]; | 
| + int fDepthMapHeight[kMaxNonAmbientLights]; | 
| int fHeight; | 
| int fWidth; | 
| @@ -647,7 +647,7 @@ void SkShadowShaderImpl::flatten(SkWriteBuffer& buf) const { | 
| buf.writeScalarArray(&light.dir().fX, 3); | 
| } | 
| - buf.writeImage(light.getShadowMap().get()); | 
| + buf.writeImage(light.getShadowMap()); | 
| } | 
| buf.writeInt(fDiffuseWidth); |