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 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 GrGLDistanceFieldTextureEffect(const GrGeometryProcessor&, | 29 GrGLDistanceFieldTextureEffect(const GrGeometryProcessor&, |
30 const GrBatchTracker&) | 30 const GrBatchTracker&) |
31 : fColor(GrColor_ILLEGAL) | 31 : fColor(GrColor_ILLEGAL) |
32 , fTextureSize(SkISize::Make(-1,-1)) | 32 , fTextureSize(SkISize::Make(-1,-1)) |
33 #ifdef SK_GAMMA_APPLY_TO_A8 | 33 #ifdef SK_GAMMA_APPLY_TO_A8 |
34 , fLuminance(-1.0f) | 34 , fLuminance(-1.0f) |
35 #endif | 35 #endif |
36 {} | 36 {} |
37 | 37 |
38 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 38 void emitCode(const EmitArgs& args) SK_OVERRIDE { |
39 const GrDistanceFieldTextureEffect& dfTexEffect = | 39 const GrDistanceFieldTextureEffect& dfTexEffect = |
40 args.fGP.cast<GrDistanceFieldTextureEffect>(); | 40 args.fGP.cast<GrDistanceFieldTextureEffect>(); |
41 const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatc
hTracker>(); | 41 const DistanceFieldBatchTracker& local = args.fBT.cast<DistanceFieldBatc
hTracker>(); |
42 GrGLGPBuilder* pb = args.fPB; | 42 GrGLGPBuilder* pb = args.fPB; |
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 GrGLVertToFrag v(kVec2f_GrSLType); | 48 GrGLVertToFrag v(kVec2f_GrSLType); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 GrColor fColor; | 314 GrColor fColor; |
315 bool fUsesLocalCoords; | 315 bool fUsesLocalCoords; |
316 }; | 316 }; |
317 | 317 |
318 class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor { | 318 class GrGLDistanceFieldNoGammaTextureEffect : public GrGLGeometryProcessor { |
319 public: | 319 public: |
320 GrGLDistanceFieldNoGammaTextureEffect(const GrGeometryProcessor&, | 320 GrGLDistanceFieldNoGammaTextureEffect(const GrGeometryProcessor&, |
321 const GrBatchTracker&) | 321 const GrBatchTracker&) |
322 : fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {} | 322 : fColor(GrColor_ILLEGAL), fTextureSize(SkISize::Make(-1, -1)) {} |
323 | 323 |
324 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 324 void emitCode(const EmitArgs& args) SK_OVERRIDE { |
325 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = | 325 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = |
326 args.fGP.cast<GrDistanceFieldNoGammaTextureEffect>(); | 326 args.fGP.cast<GrDistanceFieldNoGammaTextureEffect>(); |
327 | 327 |
328 const DistanceFieldNoGammaBatchTracker& local = | 328 const DistanceFieldNoGammaBatchTracker& local = |
329 args.fBT.cast<DistanceFieldNoGammaBatchTracker>(); | 329 args.fBT.cast<DistanceFieldNoGammaBatchTracker>(); |
330 GrGLGPBuilder* pb = args.fPB; | 330 GrGLGPBuilder* pb = args.fPB; |
331 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 331 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
332 SkAssertResult(fsBuilder->enableFeature( | 332 SkAssertResult(fsBuilder->enableFeature( |
333 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); | 333 GrGLFragmentShaderBuilder::kStandardDerivat
ives_GLSLFeature)); |
334 | 334 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 }; | 555 }; |
556 | 556 |
557 class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { | 557 class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { |
558 public: | 558 public: |
559 GrGLDistanceFieldLCDTextureEffect(const GrGeometryProcessor&, | 559 GrGLDistanceFieldLCDTextureEffect(const GrGeometryProcessor&, |
560 const GrBatchTracker&) | 560 const GrBatchTracker&) |
561 : fColor(GrColor_ILLEGAL) | 561 : fColor(GrColor_ILLEGAL) |
562 , fTextureSize(SkISize::Make(-1,-1)) | 562 , fTextureSize(SkISize::Make(-1,-1)) |
563 , fTextColor(GrColor_ILLEGAL) {} | 563 , fTextColor(GrColor_ILLEGAL) {} |
564 | 564 |
565 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 565 void emitCode(const EmitArgs& args) SK_OVERRIDE { |
566 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 566 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
567 args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); | 567 args.fGP.cast<GrDistanceFieldLCDTextureEffect>(); |
568 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); | 568 const DistanceFieldLCDBatchTracker& local = args.fBT.cast<DistanceFieldL
CDBatchTracker>(); |
569 GrGLGPBuilder* pb = args.fPB; | 569 GrGLGPBuilder* pb = args.fPB; |
570 | 570 |
571 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); | 571 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
572 GrGLVertToFrag v(kVec2f_GrSLType); | 572 GrGLVertToFrag v(kVec2f_GrSLType); |
573 args.fPB->addVarying("TextureCoords", &v); | 573 args.fPB->addVarying("TextureCoords", &v); |
574 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); | 574 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), dfTexEffect.inTextureCoord
s()->fName); |
575 | 575 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 860 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
861 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 861 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
862 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 862 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
863 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), | 863 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), |
864 GrProcessorUnitTest::TestMatr
ix(random), | 864 GrProcessorUnitTest::TestMatr
ix(random), |
865 textures[texIdx], params, | 865 textures[texIdx], params, |
866 textures[texIdx2], params2, | 866 textures[texIdx2], params2, |
867 textColor, | 867 textColor, |
868 flags); | 868 flags); |
869 } | 869 } |
OLD | NEW |