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

Side by Side Diff: src/core/SkLightingShader.cpp

Issue 2127233002: Added the framework for having canvas/recorder/picture record depth_set's. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Updated comments. Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
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 "SkBitmapProcShader.h" 8 #include "SkBitmapProcShader.h"
9 #include "SkBitmapProcState.h" 9 #include "SkBitmapProcState.h"
10 #include "SkColor.h" 10 #include "SkColor.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 fAmbientColorUni = uniformHandler->addUniform(kFragment_GrShaderFlag , 169 fAmbientColorUni = uniformHandler->addUniform(kFragment_GrShaderFlag ,
170 kVec3f_GrSLType, kDefa ult_GrSLPrecision, 170 kVec3f_GrSLType, kDefa ult_GrSLPrecision,
171 "AmbientColor", &ambie ntColorUniName); 171 "AmbientColor", &ambie ntColorUniName);
172 172
173 fragBuilder->codeAppendf("vec4 diffuseColor = %s;", args.fInputColor ); 173 fragBuilder->codeAppendf("vec4 diffuseColor = %s;", args.fInputColor );
174 174
175 SkString dstNormalName("dstNormal"); 175 SkString dstNormalName("dstNormal");
176 this->emitChild(0, nullptr, &dstNormalName, args); 176 this->emitChild(0, nullptr, &dstNormalName, args);
177 177
178 fragBuilder->codeAppendf("vec3 normal = %s.xyz;", dstNormalName.c_st r()); 178 fragBuilder->codeAppendf("vec3 normal = %s.xyz;", dstNormalName.c_st r());
179
jvanverth1 2016/07/07 19:08:35 Nit: if you remove this line, then this file doesn
vjiaoblack 2016/07/07 19:17:56 Done.
179 fragBuilder->codeAppendf("float NdotL = clamp(dot(normal, %s), 0.0, 1.0);", 180 fragBuilder->codeAppendf("float NdotL = clamp(dot(normal, %s), 0.0, 1.0);",
180 lightDirUniName); 181 lightDirUniName);
181 // diffuse light 182 // diffuse light
182 fragBuilder->codeAppendf("vec3 result = %s*diffuseColor.rgb*NdotL;", lightColorUniName); 183 fragBuilder->codeAppendf("vec3 result = %s*diffuseColor.rgb*NdotL;", lightColorUniName);
183 // ambient light 184 // ambient light
184 fragBuilder->codeAppendf("result += %s;", ambientColorUniName); 185 fragBuilder->codeAppendf("result += %s;", ambientColorUniName);
185 fragBuilder->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", a rgs.fOutputColor); 186 fragBuilder->codeAppendf("%s = vec4(result.rgb, diffuseColor.a);", a rgs.fOutputColor);
186 } 187 }
187 188
188 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, 189 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 std::move(lights)); 502 std::move(lights));
502 } 503 }
503 504
504 /////////////////////////////////////////////////////////////////////////////// 505 ///////////////////////////////////////////////////////////////////////////////
505 506
506 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 507 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
507 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 508 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
508 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 509 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
509 510
510 /////////////////////////////////////////////////////////////////////////////// 511 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698