OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkReadBuffer.h" | 9 #include "SkReadBuffer.h" |
10 #include "SkShadowShader.h" | 10 #include "SkShadowShader.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if (SkLights::Light::kPoint_LightType == lights->light(i).type()
) { | 125 if (SkLights::Light::kPoint_LightType == lights->light(i).type()
) { |
126 fLightDirOrPos[fNumNonAmbLights] = lights->light(i).pos(); | 126 fLightDirOrPos[fNumNonAmbLights] = lights->light(i).pos(); |
127 fLightColor[fNumNonAmbLights].scale(lights->light(i).intensi
ty()); | 127 fLightColor[fNumNonAmbLights].scale(lights->light(i).intensi
ty()); |
128 } else { | 128 } else { |
129 fLightDirOrPos[fNumNonAmbLights] = lights->light(i).dir(); | 129 fLightDirOrPos[fNumNonAmbLights] = lights->light(i).dir(); |
130 } | 130 } |
131 | 131 |
132 fIsPointLight[fNumNonAmbLights] = | 132 fIsPointLight[fNumNonAmbLights] = |
133 SkLights::Light::kPoint_LightType == lights->light(i).ty
pe(); | 133 SkLights::Light::kPoint_LightType == lights->light(i).ty
pe(); |
134 | 134 |
| 135 fIsRadialLight[fNumNonAmbLights] = lights->light(i).isRadial(); |
| 136 |
135 SkImage_Base* shadowMap = ((SkImage_Base*)lights->light(i).getSh
adowMap()); | 137 SkImage_Base* shadowMap = ((SkImage_Base*)lights->light(i).getSh
adowMap()); |
136 | 138 |
137 // gets deleted when the ShadowFP is destroyed, and frees the Gr
Texture* | 139 // gets deleted when the ShadowFP is destroyed, and frees the Gr
Texture* |
138 fTexture[fNumNonAmbLights] = sk_sp<GrTexture>(shadowMap->asTextu
reRef(context, | 140 fTexture[fNumNonAmbLights] = sk_sp<GrTexture>(shadowMap->asTextu
reRef(context, |
139 GrTextureParams::Clam
pNoFilter(), | 141 GrTextureParams::Clam
pNoFilter(), |
140 SkSourceGammaTreatmen
t::kIgnore)); | 142 SkSourceGammaTreatmen
t::kIgnore)); |
141 fDepthMapAccess[fNumNonAmbLights].reset(fTexture[fNumNonAmbLight
s].get()); | 143 fDepthMapAccess[fNumNonAmbLights].reset(fTexture[fNumNonAmbLight
s].get()); |
142 this->addTextureAccess(&fDepthMapAccess[fNumNonAmbLights]); | 144 this->addTextureAccess(&fDepthMapAccess[fNumNonAmbLights]); |
143 | 145 |
144 fDepthMapHeight[fNumNonAmbLights] = shadowMap->height(); | 146 fDepthMapHeight[fNumNonAmbLights] = shadowMap->height(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // Note: vMatrixCoord_0_1_Stage0 is the texture sampler coordinates. | 276 // Note: vMatrixCoord_0_1_Stage0 is the texture sampler coordinates. |
275 fragBuilder->codeAppendf("worldCor = vec3(vMatrixCoord_0_1_Stage0 *
" | 277 fragBuilder->codeAppendf("worldCor = vec3(vMatrixCoord_0_1_Stage0 *
" |
276 "vec2(%s, %s), %s.b * 255);", | 278 "vec2(%s, %s), %s.b * 255);", |
277 widthUniName, heightUniName, povDepth.c_str
()); | 279 widthUniName, heightUniName, povDepth.c_str
()); |
278 | 280 |
279 // Applies the offset indexing that goes from our view space into th
e light's space. | 281 // Applies the offset indexing that goes from our view space into th
e light's space. |
280 for (int i = 0; i < shadowFP.fNumNonAmbLights; i++) { | 282 for (int i = 0; i < shadowFP.fNumNonAmbLights; i++) { |
281 SkString povCoord("povCoord"); | 283 SkString povCoord("povCoord"); |
282 povCoord.appendf("%d", i); | 284 povCoord.appendf("%d", i); |
283 | 285 |
284 // povDepth.b * 255 scales it to 0 - 255, bringing it to world s
pace, | |
285 // and the / vec2(width, height) brings it back to a sampler coo
rdinate | |
286 SkString offset("offset"); | 286 SkString offset("offset"); |
287 offset.appendf("%d", i); | 287 offset.appendf("%d", i); |
288 | |
289 SkString scaleVec("scaleVec"); | |
290 scaleVec.appendf("%d", i); | |
291 | |
292 fragBuilder->codeAppendf("vec2 %s;", offset.c_str()); | 288 fragBuilder->codeAppendf("vec2 %s;", offset.c_str()); |
293 | 289 |
294 // note that we flip the y-coord of the offset and then later ad
d | |
295 // a value just to the y-coord of povCoord. This is to account f
or | |
296 // the shifted origins from switching from raster into GPU. | |
297 if (shadowFP.fIsPointLight[i]) { | 290 if (shadowFP.fIsPointLight[i]) { |
298 fragBuilder->codeAppendf("vec3 fragToLight%d = %s - worldCor
;", | 291 fragBuilder->codeAppendf("vec3 fragToLight%d = %s - worldCor
;", |
299 i, lightDirOrPosUniName[i]); | 292 i, lightDirOrPosUniName[i]); |
300 fragBuilder->codeAppendf("float distsq%d = dot(fragToLight%d
, " | 293 fragBuilder->codeAppendf("float distsq%d = dot(fragToLight%d
, " |
301 "fragToLight%d
);", | 294 "fragToLight%d);", |
302 i, i, i); | 295 i, i, i); |
303 fragBuilder->codeAppendf("%s = vec2(-fragToLight%d) * povDep
th.b;", | 296 fragBuilder->codeAppendf("%s = vec2(-fragToLight%d) * povDep
th.b;", |
304 offset.c_str(), i); | 297 offset.c_str(), i); |
305 fragBuilder->codeAppendf("fragToLight%d = normalize(fragToLi
ght%d);", | 298 fragBuilder->codeAppendf("fragToLight%d = normalize(fragToLi
ght%d);", |
306 i, i); | 299 i, i); |
| 300 } |
307 | 301 |
308 // the 0.375s are precalculated transform values, given that
the depth | 302 if (shadowFP.fIsRadialLight[i]) { |
309 // maps for pt lights are 4x the size (linearly) as diffuse
maps. | 303 fragBuilder->codeAppendf("vec2 %s = vec2(vMatrixCoord_0_1_St
age0.x, " |
310 // The vec2(0.375, -0.375) is used to transform us to the ce
nter of the map. | 304 "1 - vMatrixCoord_0_
1_Stage0.y);\n", |
311 fragBuilder->codeAppendf("vec2 %s = ((vec2(%s, %s) *" | 305 povCoord.c_str()); |
312 "vMatrixCoord_0_1_Stage0 +" | 306 |
313 "vec2(0,%s - %s)" | 307 fragBuilder->codeAppendf("%s = (%s) * 2.0 - 1.0 + (vec2(%s)/
vec2(%s,%s) - 0.5)" |
314 "+ %s) / (vec2(%s, %s))) +" | 308 "* vec2(-2
.0, 2.0);\n", |
315 "vec2(0.375, -0.375);", | 309 povCoord.c_str(), povCoord.c_str(), |
316 povCoord.c_str(), | 310 lightDirOrPosUniName[i], |
317 widthUniName, heightUniName, | 311 widthUniName, heightUniName); |
318 depthMapHeightUniName[i], heightUni
Name, | 312 |
319 offset.c_str(), | 313 fragBuilder->codeAppendf("float theta = atan(%s.y, %s.x);", |
320 depthMapWidthUniName[i], depthMapWi
dthUniName[i]); | 314 povCoord.c_str(), povCoord.c_str())
; |
| 315 fragBuilder->codeAppendf("float r = length(%s);", povCoord.c
_str()); |
| 316 |
| 317 // map output of atan to [0, 1] |
| 318 fragBuilder->codeAppendf("%s.x = (theta + 3.1415) / (2.0 * 3
.1415);", |
| 319 povCoord.c_str()); |
| 320 fragBuilder->codeAppendf("%s.y = 0.0;", povCoord.c_str()); |
321 } else { | 321 } else { |
322 fragBuilder->codeAppendf("%s = vec2(%s) * povDepth.b * vec2(
255.0, -255.0);", | 322 // note that we flip the y-coord of the offset and then late
r add |
323 offset.c_str(), lightDirOrPosUniNam
e[i]); | 323 // a value just to the y-coord of povCoord. This is to accou
nt for |
| 324 // the shifted origins from switching from raster into GPU. |
| 325 if (shadowFP.fIsPointLight[i]) { |
| 326 // the 0.375s are precalculated transform values, given
that the depth |
| 327 // maps for pt lights are 4x the size (linearly) as diff
use maps. |
| 328 // The vec2(0.375, -0.375) is used to transform us to |
| 329 // the center of the map. |
| 330 fragBuilder->codeAppendf("vec2 %s = ((vec2(%s, %s) *" |
| 331 "vMatrixCoord_0_1_Stage
0 +" |
| 332 "vec2(0,%s - %s)" |
| 333 "+ %s) / (vec2(%s, %s))
) +" |
| 334 "vec2(0.375, -0.375);", |
| 335 povCoord.c_str(), |
| 336 widthUniName, heightUniName, |
| 337 depthMapHeightUniName[i], heigh
tUniName, |
| 338 offset.c_str(), |
| 339 depthMapWidthUniName[i], |
| 340 depthMapWidthUniName[i]); |
| 341 } else { |
| 342 fragBuilder->codeAppendf("%s = vec2(%s) * povDepth.b * " |
| 343 "vec2(255.0, -255.0);", |
| 344 offset.c_str(), lightDirOrPosUn
iName[i]); |
324 | 345 |
325 fragBuilder->codeAppendf("vec2 %s = ((vec2(%s, %s) *" | 346 fragBuilder->codeAppendf("vec2 %s = ((vec2(%s, %s) *" |
326 "vMatrixCoord_0_1_Stage0 +" | 347 "vMatrixCoord_0_1_Stage
0 +" |
327 "vec2(0,%s - %s)" | 348 "vec2(0,%s - %s)" |
328 "+ %s) / vec2(%s, %s));", | 349 "+ %s) / vec2(%s, %s));
", |
329 povCoord.c_str(), | 350 povCoord.c_str(), |
330 widthUniName, heightUniName, | 351 widthUniName, heightUniName, |
331 depthMapHeightUniName[i], heightUni
Name, | 352 depthMapHeightUniName[i], heigh
tUniName, |
332 offset.c_str(), | 353 offset.c_str(), |
333 depthMapWidthUniName[i], depthMapWi
dthUniName[i]); | 354 depthMapWidthUniName[i], |
| 355 depthMapWidthUniName[i]); |
| 356 } |
334 } | 357 } |
335 | 358 |
336 fragBuilder->appendTextureLookup(&depthMaps[i], args.fTexSampler
s[i], | 359 fragBuilder->appendTextureLookup(&depthMaps[i], args.fTexSampler
s[i], |
337 povCoord.c_str(), | 360 povCoord.c_str(), |
338 kVec2f_GrSLType); | 361 kVec2f_GrSLType); |
339 | |
340 } | 362 } |
341 | 363 |
342 // helper variables for calculating shadowing | 364 // helper variables for calculating shadowing |
343 | 365 |
344 // variance of depth at this fragment in the context of surrounding
area | 366 // variance of depth at this fragment in the context of surrounding
area |
345 // (area size and weighting dependent on blur size and type) | 367 // (area size and weighting dependent on blur size and type) |
346 fragBuilder->codeAppendf("float variance;"); | 368 fragBuilder->codeAppendf("float variance;"); |
347 | 369 |
348 // the difference in depth between the user POV and light POV. | 370 // the difference in depth between the user POV and light POV. |
349 fragBuilder->codeAppendf("float d;"); | 371 fragBuilder->codeAppendf("float d;"); |
350 | 372 |
351 // add up light contributions from all lights to totalLightColor | 373 // add up light contributions from all lights to totalLightColor |
352 for (int i = 0; i < numLights; i++) { | 374 for (int i = 0; i < numLights; i++) { |
353 fragBuilder->codeAppendf("lightProbability = 1;"); | 375 fragBuilder->codeAppendf("lightProbability = 1;"); |
354 | 376 |
355 // 1/512 == .00195... is less than half a pixel; imperceptible | 377 if (shadowFP.fIsRadialLight[i]) { |
356 fragBuilder->codeAppendf("if (%s.b <= %s.b + .001953125) {", | 378 fragBuilder->codeAppend("totalLightColor = vec3(0);"); |
357 povDepth.c_str(), depthMaps[i].c_str())
; | |
358 if (blurAlgorithm == SkShadowParams::kVariance_ShadowType) { | |
359 // We mess with depth and depth^2 in their given scales. | |
360 // (i.e. between 0 and 1) | |
361 fragBuilder->codeAppendf("vec2 moments%d = vec2(%s.b, %s.g);
", | |
362 i, depthMaps[i].c_str(), depthMaps[
i].c_str()); | |
363 | 379 |
364 // variance biasing lessens light bleeding | 380 fragBuilder->codeAppend("vec2 tc = vec2(povCoord0.x, 0.0);")
; |
365 fragBuilder->codeAppendf("variance = max(moments%d.y - " | 381 fragBuilder->codeAppend("float depth = texture(uTextureSampl
er0_Stage1," |
366 "(moments%d.x * mome
nts%d.x)," | 382 "povCoord0).b
* 2.0;"); |
367 "%s);", i, i, i, | |
368 minVarianceUniName); | |
369 | 383 |
370 fragBuilder->codeAppendf("d = (%s.b) - moments%d.x;", | 384 fragBuilder->codeAppendf("lightProbability = step(r, depth);
"); |
371 povDepth.c_str(), i); | |
372 fragBuilder->codeAppendf("lightProbability = " | |
373 "(variance / (variance + d
* d));"); | |
374 | 385 |
375 SkString clamp("clamp"); | 386 fragBuilder->codeAppendf("if (%s.b != 0 || depth == 0) {" |
376 clamp.appendf("%d", i); | 387 "lightProbability = 1.0; }"
, |
| 388 povDepth.c_str()); |
| 389 } else { |
| 390 // 1/512 == .00195... is less than half a pixel; imperceptib
le |
| 391 fragBuilder->codeAppendf("if (%s.b <= %s.b + .001953125) {", |
| 392 povDepth.c_str(), depthMaps[i].c_st
r()); |
| 393 if (blurAlgorithm == SkShadowParams::kVariance_ShadowType) { |
| 394 // We mess with depth and depth^2 in their given scales. |
| 395 // (i.e. between 0 and 1) |
| 396 fragBuilder->codeAppendf("vec2 moments%d = vec2(%s.b, %s
.g);", |
| 397 i, depthMaps[i].c_str(), depthM
aps[i].c_str()); |
377 | 398 |
378 // choosing between light artifacts or correct shape shadows | 399 // variance biasing lessens light bleeding |
379 // linstep | 400 fragBuilder->codeAppendf("variance = max(moments%d.y - " |
380 fragBuilder->codeAppendf("float %s = clamp((lightProbability
- %s) /" | 401 "(moments%d.x * moments
%d.x)," |
381 "(1 - %s), 0, 1);"
, | 402 "%s);", i, i, i, |
382 clamp.c_str(), shBiasUniName, shBia
sUniName); | 403 minVarianceUniName); |
383 | 404 |
384 fragBuilder->codeAppendf("lightProbability = %s;", clamp.c_s
tr()); | 405 fragBuilder->codeAppendf("d = (%s.b) - moments%d.x;", |
385 } else { | 406 povDepth.c_str(), i); |
386 fragBuilder->codeAppendf("if (%s.b >= %s.b) {", | 407 fragBuilder->codeAppendf("lightProbability = " |
387 povDepth.c_str(), depthMaps[i].c_st
r()); | 408 "(variance / (variance
+ d * d));"); |
388 fragBuilder->codeAppendf("lightProbability = 1;"); | 409 |
389 fragBuilder->codeAppendf("} else { lightProbability = 0; }")
; | 410 SkString clamp("clamp"); |
| 411 clamp.appendf("%d", i); |
| 412 |
| 413 // choosing between light artifacts or correct shape sha
dows |
| 414 // linstep |
| 415 fragBuilder->codeAppendf("float %s = clamp((lightProbabi
lity - %s) /" |
| 416 "(1 - %s), 0, 1);", |
| 417 clamp.c_str(), shBiasUniName, s
hBiasUniName); |
| 418 |
| 419 fragBuilder->codeAppendf("lightProbability = %s;", clamp
.c_str()); |
| 420 } else { |
| 421 fragBuilder->codeAppendf("if (%s.b >= %s.b) {", |
| 422 povDepth.c_str(), depthMaps[i].
c_str()); |
| 423 fragBuilder->codeAppendf("lightProbability = 1;"); |
| 424 fragBuilder->codeAppendf("} else { lightProbability = 0;
}"); |
| 425 } |
| 426 |
| 427 // VSM: The curved shadows near plane edges are artifacts fr
om blurring |
| 428 // lightDir.z is equal to the lightDir dot the surface norma
l. |
| 429 fragBuilder->codeAppendf("}"); |
390 } | 430 } |
391 | 431 |
392 // VSM: The curved shadows near plane edges are artifacts from b
lurring | |
393 // lightDir.z is equal to the lightDir dot the surface normal. | |
394 fragBuilder->codeAppendf("}"); | |
395 | |
396 if (shadowFP.isPointLight(i)) { | 432 if (shadowFP.isPointLight(i)) { |
397 fragBuilder->codeAppendf("totalLightColor += max(fragToLight
%d.z, 0) * %s /" | 433 fragBuilder->codeAppendf("totalLightColor += max(fragToLight
%d.z, 0) * %s /" |
398 "(1 + distsq%d)
*" | 434 "(1 + distsq%d) * lightProb
ability;", |
399 "lightProbabilit
y;", | |
400 i, lightColorUniName[i], i); | 435 i, lightColorUniName[i], i); |
401 } else { | 436 } else { |
402 fragBuilder->codeAppendf("totalLightColor += %s.z * %s * lig
htProbability;", | 437 fragBuilder->codeAppendf("totalLightColor += %s.z * %s * lig
htProbability;", |
403 lightDirOrPosUniName[i], | 438 lightDirOrPosUniName[i], |
404 lightColorUniName[i]); | 439 lightColorUniName[i]); |
405 } | 440 } |
| 441 |
| 442 fragBuilder->codeAppendf("totalLightColor += %s;", ambientColorU
niName); |
| 443 fragBuilder->codeAppendf("%s = resultDiffuseColor * vec4(totalLi
ghtColor, 1);", |
| 444 args.fOutputColor); |
406 } | 445 } |
407 | 446 |
408 fragBuilder->codeAppendf("totalLightColor += %s;", ambientColorUniNa
me); | |
409 fragBuilder->codeAppendf("%s = resultDiffuseColor * vec4(totalLightC
olor, 1);", | |
410 args.fOutputColor); | |
411 } | 447 } |
412 | 448 |
413 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, | 449 static void GenKey(const GrProcessor& proc, const GrGLSLCaps&, |
414 GrProcessorKeyBuilder* b) { | 450 GrProcessorKeyBuilder* b) { |
415 const ShadowFP& shadowFP = proc.cast<ShadowFP>(); | 451 const ShadowFP& shadowFP = proc.cast<ShadowFP>(); |
416 b->add32(shadowFP.fNumNonAmbLights); | 452 b->add32(shadowFP.fNumNonAmbLights); |
417 int isPL = 0; | 453 int isPLR = 0; |
418 for (int i = 0; i < SkShadowShader::kMaxNonAmbientLights; i++) { | 454 for (int i = 0; i < SkShadowShader::kMaxNonAmbientLights; i++) { |
419 isPL = isPL | ((shadowFP.fIsPointLight[i] ? 1 : 0) << i); | 455 isPLR = isPLR | ((shadowFP.fIsPointLight[i] ? 1 : 0) << i); |
| 456 isPLR = isPLR | ((shadowFP.fIsRadialLight[i] ? 1 : 0) << (i+4)); |
420 } | 457 } |
421 b->add32(isPL); | 458 b->add32(isPLR); |
422 b->add32(shadowFP.fShadowParams.fType); | 459 b->add32(shadowFP.fShadowParams.fType); |
423 } | 460 } |
424 | 461 |
425 protected: | 462 protected: |
426 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&
proc) override { | 463 void onSetData(const GrGLSLProgramDataManager& pdman, const GrProcessor&
proc) override { |
427 const ShadowFP &shadowFP = proc.cast<ShadowFP>(); | 464 const ShadowFP &shadowFP = proc.cast<ShadowFP>(); |
428 | 465 |
429 for (int i = 0; i < shadowFP.numLights(); i++) { | 466 for (int i = 0; i < shadowFP.numLights(); i++) { |
430 const SkVector3& lightDirOrPos = shadowFP.lightDirOrPos(i); | 467 const SkVector3& lightDirOrPos = shadowFP.lightDirOrPos(i); |
431 if (lightDirOrPos != fLightDirOrPos[i]) { | 468 if (lightDirOrPos != fLightDirOrPos[i]) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 558 |
522 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { | 559 void onComputeInvariantOutput(GrInvariantOutput* inout) const override { |
523 inout->mulByUnknownFourComponents(); | 560 inout->mulByUnknownFourComponents(); |
524 } | 561 } |
525 int32_t numLights() const { return fNumNonAmbLights; } | 562 int32_t numLights() const { return fNumNonAmbLights; } |
526 const SkColor3f& ambientColor() const { return fAmbientColor; } | 563 const SkColor3f& ambientColor() const { return fAmbientColor; } |
527 bool isPointLight(int i) const { | 564 bool isPointLight(int i) const { |
528 SkASSERT(i < fNumNonAmbLights); | 565 SkASSERT(i < fNumNonAmbLights); |
529 return fIsPointLight[i]; | 566 return fIsPointLight[i]; |
530 } | 567 } |
| 568 bool isRadialLight(int i) const { |
| 569 SkASSERT(i < fNumNonAmbLights); |
| 570 return fIsRadialLight[i]; |
| 571 } |
531 const SkVector3& lightDirOrPos(int i) const { | 572 const SkVector3& lightDirOrPos(int i) const { |
532 SkASSERT(i < fNumNonAmbLights); | 573 SkASSERT(i < fNumNonAmbLights); |
533 return fLightDirOrPos[i]; | 574 return fLightDirOrPos[i]; |
534 } | 575 } |
535 const SkVector3& lightColor(int i) const { | 576 const SkVector3& lightColor(int i) const { |
536 SkASSERT(i < fNumNonAmbLights); | 577 SkASSERT(i < fNumNonAmbLights); |
537 return fLightColor[i]; | 578 return fLightColor[i]; |
538 } | 579 } |
539 int depthMapWidth(int i) const { | 580 int depthMapWidth(int i) const { |
540 SkASSERT(i < fNumNonAmbLights); | 581 SkASSERT(i < fNumNonAmbLights); |
(...skipping 18 matching lines...) Expand all Loading... |
559 return false; | 600 return false; |
560 } | 601 } |
561 | 602 |
562 if (fWidth != shadowFP.fWidth || fHeight != shadowFP.fHeight) { | 603 if (fWidth != shadowFP.fWidth || fHeight != shadowFP.fHeight) { |
563 return false; | 604 return false; |
564 } | 605 } |
565 | 606 |
566 for (int i = 0; i < fNumNonAmbLights; i++) { | 607 for (int i = 0; i < fNumNonAmbLights; i++) { |
567 if (fLightDirOrPos[i] != shadowFP.fLightDirOrPos[i] || | 608 if (fLightDirOrPos[i] != shadowFP.fLightDirOrPos[i] || |
568 fLightColor[i] != shadowFP.fLightColor[i] || | 609 fLightColor[i] != shadowFP.fLightColor[i] || |
569 fIsPointLight[i] != shadowFP.fIsPointLight[i]) { | 610 fIsPointLight[i] != shadowFP.fIsPointLight[i] || |
| 611 fIsRadialLight[i] != shadowFP.fIsRadialLight[i]) { |
570 return false; | 612 return false; |
571 } | 613 } |
572 | 614 |
573 if (fDepthMapWidth[i] != shadowFP.fDepthMapWidth[i] || | 615 if (fDepthMapWidth[i] != shadowFP.fDepthMapWidth[i] || |
574 fDepthMapHeight[i] != shadowFP.fDepthMapHeight[i]) { | 616 fDepthMapHeight[i] != shadowFP.fDepthMapHeight[i]) { |
575 return false; | 617 return false; |
576 } | 618 } |
577 } | 619 } |
578 | 620 |
579 return true; | 621 return true; |
580 } | 622 } |
581 | 623 |
582 int fNumNonAmbLights; | 624 int fNumNonAmbLights; |
583 | 625 |
584 bool fIsPointLight[SkShadowShader::kMaxNonAmbientLights]; | 626 bool fIsPointLight[SkShadowShader::kMaxNonAmbientLights]; |
| 627 bool fIsRadialLight[SkShadowShader::kMaxNonAmbientLights]; |
585 SkVector3 fLightDirOrPos[SkShadowShader::kMaxNonAmbientLights]; | 628 SkVector3 fLightDirOrPos[SkShadowShader::kMaxNonAmbientLights]; |
586 SkColor3f fLightColor[SkShadowShader::kMaxNonAmbientLights]; | 629 SkColor3f fLightColor[SkShadowShader::kMaxNonAmbientLights]; |
587 GrTextureAccess fDepthMapAccess[SkShadowShader::kMaxNonAmbientLights]; | 630 GrTextureAccess fDepthMapAccess[SkShadowShader::kMaxNonAmbientLights]; |
588 sk_sp<GrTexture> fTexture[SkShadowShader::kMaxNonAmbientLights]; | 631 sk_sp<GrTexture> fTexture[SkShadowShader::kMaxNonAmbientLights]; |
589 | 632 |
590 int fDepthMapWidth[SkShadowShader::kMaxNonAmbientLights]; | 633 int fDepthMapWidth[SkShadowShader::kMaxNonAmbientLights]; |
591 int fDepthMapHeight[SkShadowShader::kMaxNonAmbientLights]; | 634 int fDepthMapHeight[SkShadowShader::kMaxNonAmbientLights]; |
592 | 635 |
593 int fHeight; | 636 int fHeight; |
594 int fWidth; | 637 int fWidth; |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 | 947 |
905 /////////////////////////////////////////////////////////////////////////////// | 948 /////////////////////////////////////////////////////////////////////////////// |
906 | 949 |
907 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkShadowShader) | 950 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkShadowShader) |
908 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkShadowShaderImpl) | 951 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkShadowShaderImpl) |
909 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 952 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
910 | 953 |
911 /////////////////////////////////////////////////////////////////////////////// | 954 /////////////////////////////////////////////////////////////////////////////// |
912 | 955 |
913 #endif | 956 #endif |
OLD | NEW |