| 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 "GrFontAtlasSizes.h" | 9 #include "GrFontAtlasSizes.h" |
| 10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 43 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 44 SkAssertResult(fsBuilder->enableFeature( | 44 SkAssertResult(fsBuilder->enableFeature( |
| 45 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); | 45 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)); |
| 46 | 46 |
| 47 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 47 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 48 | 48 |
| 49 // emit attributes | 49 // emit attributes |
| 50 vsBuilder->emitAttributes(dfTexEffect); | 50 vsBuilder->emitAttributes(dfTexEffect); |
| 51 | 51 |
| 52 GrGLVertToFrag st(kVec2f_GrSLType); | 52 GrGLVertToFrag st(kVec2f_GrSLType); |
| 53 args.fPB->addVarying("IntTextureCoords", &st); | 53 args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); |
| 54 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor
ds()->fName); | 54 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor
ds()->fName); |
| 55 | 55 |
| 56 GrGLVertToFrag uv(kVec2f_GrSLType); | 56 GrGLVertToFrag uv(kVec2f_GrSLType); |
| 57 args.fPB->addVarying("TextureCoords", &uv); | 57 args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); |
| 58 // this is only used with text, so our texture bounds always match the g
lyph atlas | 58 // this is only used with text, so our texture bounds always match the g
lyph atlas |
| 59 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", " | 59 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", " |
| 60 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", uv.vsOut(), | 60 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", uv.vsOut(), |
| 61 dfTexEffect.inTextureCoords()->fName); | 61 dfTexEffect.inTextureCoords()->fName); |
| 62 | 62 |
| 63 // Setup pass through color | 63 // Setup pass through color |
| 64 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 64 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, |
| 65 dfTexEffect.inColor(), &fColorUniform); | 65 dfTexEffect.inColor(), &fColorUniform); |
| 66 | 66 |
| 67 // Setup position | 67 // Setup position |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 328 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 329 SkAssertResult(fsBuilder->enableFeature( | 329 SkAssertResult(fsBuilder->enableFeature( |
| 330 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); | 330 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); |
| 331 | 331 |
| 332 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 332 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 333 | 333 |
| 334 // emit attributes | 334 // emit attributes |
| 335 vsBuilder->emitAttributes(dfTexEffect); | 335 vsBuilder->emitAttributes(dfTexEffect); |
| 336 | 336 |
| 337 GrGLVertToFrag v(kVec2f_GrSLType); | 337 GrGLVertToFrag v(kVec2f_GrSLType); |
| 338 args.fPB->addVarying("TextureCoords", &v); | 338 args.fPB->addVarying("TextureCoords", &v, kHigh_GrSLPrecision); |
| 339 | 339 |
| 340 // setup pass through color | 340 // setup pass through color |
| 341 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, | 341 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, |
| 342 dfTexEffect.inColor(), &fColorUniform); | 342 dfTexEffect.inColor(), &fColorUniform); |
| 343 | 343 |
| 344 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 344 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
| 345 | 345 |
| 346 // Setup position | 346 // Setup position |
| 347 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); | 347 this->setupPosition(pb, gpArgs, dfTexEffect.inPosition()->fName, dfTexEf
fect.viewMatrix()); |
| 348 | 348 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); | 569 args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); |
| 570 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); | 570 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); |
| 571 GrGLGPBuilder* pb = args.fPB; | 571 GrGLGPBuilder* pb = args.fPB; |
| 572 | 572 |
| 573 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 573 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 574 | 574 |
| 575 // emit attributes | 575 // emit attributes |
| 576 vsBuilder->emitAttributes(dfTexEffect); | 576 vsBuilder->emitAttributes(dfTexEffect); |
| 577 | 577 |
| 578 GrGLVertToFrag st(kVec2f_GrSLType); | 578 GrGLVertToFrag st(kVec2f_GrSLType); |
| 579 args.fPB->addVarying("IntTextureCoords", &st); | 579 args.fPB->addVarying("IntTextureCoords", &st, kHigh_GrSLPrecision); |
| 580 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor
ds()->fName); | 580 vsBuilder->codeAppendf("%s = %s;", st.vsOut(), dfTexEffect.inTextureCoor
ds()->fName); |
| 581 | 581 |
| 582 GrGLVertToFrag uv(kVec2f_GrSLType); | 582 GrGLVertToFrag uv(kVec2f_GrSLType); |
| 583 args.fPB->addVarying("TextureCoords", &uv); | 583 args.fPB->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision); |
| 584 // this is only used with text, so our texture bounds always match the g
lyph atlas | 584 // this is only used with text, so our texture bounds always match the g
lyph atlas |
| 585 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", " | 585 vsBuilder->codeAppendf("%s = vec2(" GR_FONT_ATLAS_RECIP_WIDTH ", " |
| 586 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", uv.vsOut(), | 586 GR_FONT_ATLAS_RECIP_HEIGHT ")*%s;", uv.vsOut(), |
| 587 dfTexEffect.inTextureCoords()->fName); | 587 dfTexEffect.inTextureCoords()->fName); |
| 588 | 588 |
| 589 // setup pass through color | 589 // setup pass through color |
| 590 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, | 590 this->setupColorPassThrough(pb, local.fInputColorType, args.fOutputColor
, NULL, |
| 591 &fColorUniform); | 591 &fColorUniform); |
| 592 | 592 |
| 593 // Setup position | 593 // Setup position |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 856 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 857 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 857 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 858 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 858 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 859 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), | 859 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), |
| 860 GrProcessorUnitTest::TestMatr
ix(random), | 860 GrProcessorUnitTest::TestMatr
ix(random), |
| 861 textures[texIdx], params, | 861 textures[texIdx], params, |
| 862 textures[texIdx2], params2, | 862 textures[texIdx2], params2, |
| 863 textColor, | 863 textColor, |
| 864 flags); | 864 flags); |
| 865 } | 865 } |
| OLD | NEW |