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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 static inline void GenKey(const GrGeometryProcessor& processor, | 162 static inline void GenKey(const GrGeometryProcessor& processor, |
163 const GrBatchTracker& bt, | 163 const GrBatchTracker& bt, |
164 const GrGLCaps&, | 164 const GrGLCaps&, |
165 GrProcessorKeyBuilder* b) { | 165 GrProcessorKeyBuilder* b) { |
166 const GrDistanceFieldTextureEffect& dfTexEffect = | 166 const GrDistanceFieldTextureEffect& dfTexEffect = |
167 processor.cast<GrDistanceFieldTextureEffect>(); | 167 processor.cast<GrDistanceFieldTextureEffect>(); |
168 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); | 168 const DistanceFieldBatchTracker& local = bt.cast<DistanceFieldBatchTrack
er>(); |
169 b->add32(dfTexEffect.getFlags()); | 169 uint32_t key = dfTexEffect.getFlags(); |
170 b->add32(local.fInputColorType); | 170 key |= local.fInputColorType << 16; |
| 171 key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective(
) ? 0x1 << 24: 0x0; |
| 172 b->add32(key); |
171 } | 173 } |
172 | 174 |
173 private: | 175 private: |
174 GrColor fColor; | 176 GrColor fColor; |
175 UniformHandle fColorUniform; | 177 UniformHandle fColorUniform; |
176 UniformHandle fTextureSizeUni; | 178 UniformHandle fTextureSizeUni; |
177 SkISize fTextureSize; | 179 SkISize fTextureSize; |
178 UniformHandle fLuminanceUni; | 180 UniformHandle fLuminanceUni; |
179 float fLuminance; | 181 float fLuminance; |
180 | 182 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 417 } |
416 | 418 |
417 static inline void GenKey(const GrGeometryProcessor& proc, | 419 static inline void GenKey(const GrGeometryProcessor& proc, |
418 const GrBatchTracker& bt, | 420 const GrBatchTracker& bt, |
419 const GrGLCaps&, | 421 const GrGLCaps&, |
420 GrProcessorKeyBuilder* b) { | 422 GrProcessorKeyBuilder* b) { |
421 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = | 423 const GrDistanceFieldNoGammaTextureEffect& dfTexEffect = |
422 proc.cast<GrDistanceFieldNoGammaTextureEffect>(); | 424 proc.cast<GrDistanceFieldNoGammaTextureEffect>(); |
423 | 425 |
424 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG
ammaBatchTracker>(); | 426 const DistanceFieldNoGammaBatchTracker& local = bt.cast<DistanceFieldNoG
ammaBatchTracker>(); |
425 b->add32(dfTexEffect.getFlags()); | 427 uint32_t key = dfTexEffect.getFlags(); |
426 b->add32(local.fInputColorType); | 428 key |= local.fInputColorType << 16; |
| 429 key |= local.fUsesLocalCoords && proc.localMatrix().hasPerspective() ? 0
x1 << 24: 0x0; |
| 430 b->add32(key); |
427 } | 431 } |
428 | 432 |
429 private: | 433 private: |
430 UniformHandle fColorUniform; | 434 UniformHandle fColorUniform; |
431 UniformHandle fTextureSizeUni; | 435 UniformHandle fTextureSizeUni; |
432 GrColor fColor; | 436 GrColor fColor; |
433 SkISize fTextureSize; | 437 SkISize fTextureSize; |
434 | 438 |
435 typedef GrGLGeometryProcessor INHERITED; | 439 typedef GrGLGeometryProcessor INHERITED; |
436 }; | 440 }; |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 721 } |
718 | 722 |
719 static inline void GenKey(const GrGeometryProcessor& processor, | 723 static inline void GenKey(const GrGeometryProcessor& processor, |
720 const GrBatchTracker& bt, | 724 const GrBatchTracker& bt, |
721 const GrGLCaps&, | 725 const GrGLCaps&, |
722 GrProcessorKeyBuilder* b) { | 726 GrProcessorKeyBuilder* b) { |
723 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 727 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
724 processor.cast<GrDistanceFieldLCDTextureEffect>(); | 728 processor.cast<GrDistanceFieldLCDTextureEffect>(); |
725 | 729 |
726 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); | 730 const DistanceFieldLCDBatchTracker& local = bt.cast<DistanceFieldLCDBatc
hTracker>(); |
727 b->add32(dfTexEffect.getFlags()); | 731 uint32_t key = dfTexEffect.getFlags(); |
728 b->add32(local.fInputColorType); | 732 key |= local.fInputColorType << 16; |
| 733 key |= local.fUsesLocalCoords && processor.localMatrix().hasPerspective(
) ? 0x1 << 24: 0x0; |
| 734 b->add32(key); |
729 } | 735 } |
730 | 736 |
731 private: | 737 private: |
732 GrColor fColor; | 738 GrColor fColor; |
733 UniformHandle fColorUniform; | 739 UniformHandle fColorUniform; |
734 UniformHandle fTextureSizeUni; | 740 UniformHandle fTextureSizeUni; |
735 SkISize fTextureSize; | 741 SkISize fTextureSize; |
736 UniformHandle fTextColorUni; | 742 UniformHandle fTextColorUni; |
737 SkColor fTextColor; | 743 SkColor fTextColor; |
738 | 744 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 random->nextULessThan(256), | 837 random->nextULessThan(256), |
832 random->nextULessThan(256)); | 838 random->nextULessThan(256)); |
833 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 839 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
834 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 840 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
835 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 841 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
836 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), textur
es[texIdx], params, | 842 return GrDistanceFieldLCDTextureEffect::Create(GrRandomColor(random), textur
es[texIdx], params, |
837 textures[texIdx2], params2, | 843 textures[texIdx2], params2, |
838 textColor, | 844 textColor, |
839 flags); | 845 flags); |
840 } | 846 } |
OLD | NEW |