| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrGLProgramEffects.h" | 8 #include "GrGLProgramEffects.h" |
| 9 #include "GrDrawEffect.h" | 9 #include "GrDrawEffect.h" |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 transforms[t].fType = kMat33f_GrSLType; | 334 transforms[t].fType = kMat33f_GrSLType; |
| 335 uniName = "StageMatrix"; | 335 uniName = "StageMatrix"; |
| 336 varyingType = kVec2f_GrSLType; | 336 varyingType = kVec2f_GrSLType; |
| 337 break; | 337 break; |
| 338 case kGeneral_MatrixType: | 338 case kGeneral_MatrixType: |
| 339 transforms[t].fType = kMat33f_GrSLType; | 339 transforms[t].fType = kMat33f_GrSLType; |
| 340 uniName = "StageMatrix"; | 340 uniName = "StageMatrix"; |
| 341 varyingType = kVec3f_GrSLType; | 341 varyingType = kVec3f_GrSLType; |
| 342 break; | 342 break; |
| 343 default: | 343 default: |
| 344 GrCrash("Unexpected key."); | 344 SkFAIL("Unexpected key."); |
| 345 } | 345 } |
| 346 SkString suffixedUniName; | 346 SkString suffixedUniName; |
| 347 if (kVoid_GrSLType != transforms[t].fType) { | 347 if (kVoid_GrSLType != transforms[t].fType) { |
| 348 if (0 != t) { | 348 if (0 != t) { |
| 349 suffixedUniName.append(uniName); | 349 suffixedUniName.append(uniName); |
| 350 suffixedUniName.appendf("_%i", t); | 350 suffixedUniName.appendf("_%i", t); |
| 351 uniName = suffixedUniName.c_str(); | 351 uniName = suffixedUniName.c_str(); |
| 352 } | 352 } |
| 353 transforms[t].fHandle = builder->addUniform(GrGLShaderBuilder::kVert
ex_Visibility, | 353 transforms[t].fHandle = builder->addUniform(GrGLShaderBuilder::kVert
ex_Visibility, |
| 354 transforms[t].fType, | 354 transforms[t].fType, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (kVec2f_GrSLType == varyingType) { | 386 if (kVec2f_GrSLType == varyingType) { |
| 387 builder->vsCodeAppendf("\t%s = (%s * vec3(%s, 1)).xy;\n", | 387 builder->vsCodeAppendf("\t%s = (%s * vec3(%s, 1)).xy;\n", |
| 388 vsVaryingName, uniName, coords.c_str(
)); | 388 vsVaryingName, uniName, coords.c_str(
)); |
| 389 } else { | 389 } else { |
| 390 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n", | 390 builder->vsCodeAppendf("\t%s = %s * vec3(%s, 1);\n", |
| 391 vsVaryingName, uniName, coords.c_str(
)); | 391 vsVaryingName, uniName, coords.c_str(
)); |
| 392 } | 392 } |
| 393 break; | 393 break; |
| 394 } | 394 } |
| 395 default: | 395 default: |
| 396 GrCrash("Unexpected uniform type."); | 396 SkFAIL("Unexpected uniform type."); |
| 397 } | 397 } |
| 398 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, | 398 SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, |
| 399 (SkString(fsVaryingName), varyingType)); | 399 (SkString(fsVaryingName), varyingType)); |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, | 403 void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, |
| 404 const GrGLUniformManager& uniformManager, | 404 const GrGLUniformManager& uniformManager, |
| 405 const GrEffectStage* effectStages[]) { | 405 const GrEffectStage* effectStages[]) { |
| 406 int numEffects = fGLEffects.count(); | 406 int numEffects = fGLEffects.count(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 439 } |
| 440 case kMat33f_GrSLType: { | 440 case kMat33f_GrSLType: { |
| 441 const SkMatrix& matrix = get_transform_matrix(drawEffect, t); | 441 const SkMatrix& matrix = get_transform_matrix(drawEffect, t); |
| 442 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { | 442 if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { |
| 443 uniformManager.setSkMatrix(transforms[t].fHandle, matrix); | 443 uniformManager.setSkMatrix(transforms[t].fHandle, matrix); |
| 444 transforms[t].fCurrentValue = matrix; | 444 transforms[t].fCurrentValue = matrix; |
| 445 } | 445 } |
| 446 break; | 446 break; |
| 447 } | 447 } |
| 448 default: | 448 default: |
| 449 GrCrash("Unexpected uniform type."); | 449 SkFAIL("Unexpected uniform type."); |
| 450 } | 450 } |
| 451 } | 451 } |
| 452 } | 452 } |
| 453 | 453 |
| 454 GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB
uilder* builder, | 454 GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullShaderB
uilder* builder, |
| 455 int reserveCoun
t) | 455 int reserveCoun
t) |
| 456 : fBuilder(builder) | 456 : fBuilder(builder) |
| 457 , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects, | 457 , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects, |
| 458 (reserveCount, fBuilder->hasExplicitLocalCoords
()))) { | 458 (reserveCount, fBuilder->hasExplicitLocalCoords
()))) { |
| 459 } | 459 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 break; | 565 break; |
| 566 } | 566 } |
| 567 case kGeneral_MatrixType: { | 567 case kGeneral_MatrixType: { |
| 568 const SkMatrix& transform = get_transform_matrix(drawEffect, t); | 568 const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
| 569 gpu->enablePathTexGen(texCoordIndex++, | 569 gpu->enablePathTexGen(texCoordIndex++, |
| 570 GrGpuGL::kSTR_PathTexGenComponents, | 570 GrGpuGL::kSTR_PathTexGenComponents, |
| 571 transform); | 571 transform); |
| 572 break; | 572 break; |
| 573 } | 573 } |
| 574 default: | 574 default: |
| 575 GrCrash("Unexpected matrixs type."); | 575 SkFAIL("Unexpected matrixs type."); |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 | 579 |
| 580 GrGLPathTexGenProgramEffectsBuilder::GrGLPathTexGenProgramEffectsBuilder( | 580 GrGLPathTexGenProgramEffectsBuilder::GrGLPathTexGenProgramEffectsBuilder( |
| 581 GrGLFragmentOnlyShaderBuilder* builder, | 581 GrGLFragmentOnlyShaderBuilder* builder, |
| 582 int reserveCount) | 582 int reserveCount) |
| 583 : fBuilder(builder) | 583 : fBuilder(builder) |
| 584 , fProgramEffects(SkNEW_ARGS(GrGLPathTexGenProgramEffects, (reserveCount)))
{ | 584 , fProgramEffects(SkNEW_ARGS(GrGLPathTexGenProgramEffects, (reserveCount)))
{ |
| 585 } | 585 } |
| 586 | 586 |
| 587 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, | 587 void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, |
| 588 GrGLProgramEffects::EffectK
ey key, | 588 GrGLProgramEffects::EffectK
ey key, |
| 589 const char* outColor, | 589 const char* outColor, |
| 590 const char* inColor, | 590 const char* inColor, |
| 591 int stageIndex) { | 591 int stageIndex) { |
| 592 SkASSERT(NULL != fProgramEffects.get()); | 592 SkASSERT(NULL != fProgramEffects.get()); |
| 593 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn
dex); | 593 fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIn
dex); |
| 594 } | 594 } |
| OLD | NEW |