| 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 "GrDistanceFieldTextureEffect.h" | 8 #include "GrDistanceFieldTextureEffect.h" |
| 9 #include "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
| 10 #include "GrTexture.h" | 10 #include "GrTexture.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 vsBuilder->emitAttributes(dfTexEffect); | 50 vsBuilder->emitAttributes(dfTexEffect); |
| 51 | 51 |
| 52 GrGLVertToFrag v(kVec2f_GrSLType); | 52 GrGLVertToFrag v(kVec2f_GrSLType); |
| 53 args.fPB->addVarying("TextureCoords", &v); | 53 args.fPB->addVarying("TextureCoords", &v); |
| 54 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 54 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 55 | 55 |
| 56 // Setup pass through color | 56 // Setup pass through color |
| 57 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 57 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, |
| 58 dfTexEffect.inColor(), &fColorUniform); | 58 dfTexEffect.inColor(), &fColorUniform); |
| 59 | 59 |
| 60 // setup uniform viewMatrix | |
| 61 this->addUniformViewMatrix(pb); | |
| 62 | |
| 63 // Setup position | 60 // Setup position |
| 64 SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName, | 61 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
| 65 dfTexEffect.viewMatrix(), this->uViewM()); | |
| 66 | 62 |
| 67 // emit transforms | 63 // emit transforms |
| 68 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, | 64 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
| 69 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); | 65 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); |
| 70 | 66 |
| 71 const char* textureSizeUniName = NULL; | 67 const char* textureSizeUniName = NULL; |
| 72 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, | 68 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, |
| 73 kVec2f_GrSLType, kDefault_GrSLPre
cision, | 69 kVec2f_GrSLType, kDefault_GrSLPre
cision, |
| 74 "TextureSize", &textureSizeUniNam
e); | 70 "TextureSize", &textureSizeUniNam
e); |
| 75 | 71 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 | 346 |
| 351 GrGLVertToFrag v(kVec2f_GrSLType); | 347 GrGLVertToFrag v(kVec2f_GrSLType); |
| 352 args.fPB->addVarying("TextureCoords", &v); | 348 args.fPB->addVarying("TextureCoords", &v); |
| 353 | 349 |
| 354 // setup pass through color | 350 // setup pass through color |
| 355 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 351 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, |
| 356 dfTexEffect.inColor(), &fColorUniform); | 352 dfTexEffect.inColor(), &fColorUniform); |
| 357 | 353 |
| 358 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 354 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 359 | 355 |
| 360 // setup uniform viewMatrix | |
| 361 this->addUniformViewMatrix(pb); | |
| 362 | |
| 363 // Setup position | 356 // Setup position |
| 364 SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName, | 357 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
| 365 dfTexEffect.viewMatrix(), this->uViewM()); | |
| 366 | 358 |
| 367 // emit transforms | 359 // emit transforms |
| 368 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, | 360 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
| 369 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); | 361 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); |
| 370 | 362 |
| 371 const char* textureSizeUniName = NULL; | 363 const char* textureSizeUniName = NULL; |
| 372 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, | 364 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, |
| 373 kVec2f_GrSLType, kDefault_GrSLPrec
ision, | 365 kVec2f_GrSLType, kDefault_GrSLPrec
ision, |
| 374 "TextureSize", &textureSizeUniName
); | 366 "TextureSize", &textureSizeUniName
); |
| 375 | 367 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 vsBuilder->emitAttributes(dfTexEffect); | 587 vsBuilder->emitAttributes(dfTexEffect); |
| 596 | 588 |
| 597 GrGLVertToFrag v(kVec2f_GrSLType); | 589 GrGLVertToFrag v(kVec2f_GrSLType); |
| 598 args.fPB->addVarying("TextureCoords", &v); | 590 args.fPB->addVarying("TextureCoords", &v); |
| 599 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 591 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 600 | 592 |
| 601 // setup pass through color | 593 // setup pass through color |
| 602 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, | 594 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, |
| 603 &fColorUniform); | 595 &fColorUniform); |
| 604 | 596 |
| 605 // setup uniform viewMatrix | |
| 606 this->addUniformViewMatrix(pb); | |
| 607 | |
| 608 // Setup position | 597 // Setup position |
| 609 SetupPosition(vsBuilder, gpArgs, dfTexEffect.inPosition()->fName, | 598 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
| 610 dfTexEffect.viewMatrix(), this->uViewM()); | |
| 611 | 599 |
| 612 // emit transforms | 600 // emit transforms |
| 613 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, | 601 this->emitTransforms(args.fPB, gpArgs->fPositionVar, dfTexEffect.inPosit
ion()->fName, |
| 614 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); | 602 dfTexEffect.localMatrix(), args.fTransformsIn, args
.fTransformsOut); |
| 615 | 603 |
| 616 const char* textureSizeUniName = NULL; | 604 const char* textureSizeUniName = NULL; |
| 617 // width, height, 1/(3*width) | 605 // width, height, 1/(3*width) |
| 618 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, | 606 fTextureSizeUni = args.fPB->addUniform(GrGLProgramBuilder::kFragment_Vis
ibility, |
| 619 kVec3f_GrSLType, kDefault_GrSLPrec
ision, | 607 kVec3f_GrSLType, kDefault_GrSLPrec
ision, |
| 620 "TextureSize", &textureSizeUniName
); | 608 "TextureSize", &textureSizeUniName
); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 878 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 891 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 879 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 892 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 880 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 893 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), | 881 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), |
| 894 GrProcessorUnitTest::TestMatr
ix(random), | 882 GrProcessorUnitTest::TestMatr
ix(random), |
| 895 textures[texIdx], params, | 883 textures[texIdx], params, |
| 896 textures[texIdx2], params2, | 884 textures[texIdx2], params2, |
| 897 textColor, | 885 textColor, |
| 898 flags); | 886 flags); |
| 899 } | 887 } |
| OLD | NEW |