| 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 "gl/builders/GrGLProgramBuilder.h" | 8 #include "gl/builders/GrGLProgramBuilder.h" |
| 9 #include "GrDistanceFieldTextureEffect.h" | 9 #include "GrDistanceFieldTextureEffect.h" |
| 10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 // Assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/
2 | 29 // Assuming a radius of the diagonal of the fragment, hence a factor of sqrt(2)/
2 |
| 30 #define SK_DistanceFieldAAFactor "0.7071" | 30 #define SK_DistanceFieldAAFactor "0.7071" |
| 31 | 31 |
| 32 class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor { | 32 class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor { |
| 33 public: | 33 public: |
| 34 GrGLDistanceFieldTextureEffect(const GrBackendEffectFactory& factory, | 34 GrGLDistanceFieldTextureEffect(const GrBackendEffectFactory& factory, |
| 35 const GrDrawEffect& drawEffect) | 35 const GrDrawEffect& drawEffect) |
| 36 : INHERITED (factory) | 36 : INHERITED (factory) |
| 37 , fTextureSize(SkISize::Make(-1,-1)) {} | 37 , fTextureSize(SkISize::Make(-1,-1)) |
| 38 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 39 , fLuminance(-1.0f) |
| 40 #endif |
| 41 {} |
| 38 | 42 |
| 39 virtual void emitCode(GrGLFullProgramBuilder* builder, | 43 virtual void emitCode(GrGLFullProgramBuilder* builder, |
| 40 const GrDrawEffect& drawEffect, | 44 const GrDrawEffect& drawEffect, |
| 41 const GrEffectKey& key, | 45 const GrEffectKey& key, |
| 42 const char* outputColor, | 46 const char* outputColor, |
| 43 const char* inputColor, | 47 const char* inputColor, |
| 44 const TransformedCoordsArray&, | 48 const TransformedCoordsArray&, |
| 45 const TextureSamplerArray& samplers) SK_OVERRIDE { | 49 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 46 const GrDistanceFieldTextureEffect& dfTexEffect = | 50 const GrDistanceFieldTextureEffect& dfTexEffect = |
| 47 drawEffect.castEffect<GrDistanceFi
eldTextureEffect>(); | 51 drawEffect.castEffect<GrDistanceFi
eldTextureEffect>(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 kSimilarity_DistanceFieldEff
ectFlag : 0); | 259 kSimilarity_DistanceFieldEff
ectFlag : 0); |
| 256 } | 260 } |
| 257 | 261 |
| 258 /////////////////////////////////////////////////////////////////////////////// | 262 /////////////////////////////////////////////////////////////////////////////// |
| 259 | 263 |
| 260 class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { | 264 class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor { |
| 261 public: | 265 public: |
| 262 GrGLDistanceFieldLCDTextureEffect(const GrBackendEffectFactory& factory, | 266 GrGLDistanceFieldLCDTextureEffect(const GrBackendEffectFactory& factory, |
| 263 const GrDrawEffect& drawEffect) | 267 const GrDrawEffect& drawEffect) |
| 264 : INHERITED (factory) | 268 : INHERITED (factory) |
| 265 , fTextureSize(SkISize::Make(-1,-1)) {} | 269 , fTextureSize(SkISize::Make(-1,-1)) |
| 270 , fTextColor(GrColor_ILLEGAL) {} |
| 266 | 271 |
| 267 virtual void emitCode(GrGLFullProgramBuilder* builder, | 272 virtual void emitCode(GrGLFullProgramBuilder* builder, |
| 268 const GrDrawEffect& drawEffect, | 273 const GrDrawEffect& drawEffect, |
| 269 const GrEffectKey& key, | 274 const GrEffectKey& key, |
| 270 const char* outputColor, | 275 const char* outputColor, |
| 271 const char* inputColor, | 276 const char* inputColor, |
| 272 const TransformedCoordsArray&, | 277 const TransformedCoordsArray&, |
| 273 const TextureSamplerArray& samplers) SK_OVERRIDE { | 278 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 274 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 279 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
| 275 drawEffect.castEffect<GrDistanceField
LCDTextureEffect>(); | 280 drawEffect.castEffect<GrDistanceField
LCDTextureEffect>(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 random->nextULessThan(256), | 521 random->nextULessThan(256), |
| 517 random->nextULessThan(256)); | 522 random->nextULessThan(256)); |
| 518 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; | 523 uint32_t flags = kUseLCD_DistanceFieldEffectFlag; |
| 519 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; | 524 flags |= random->nextBool() ? kUniformScale_DistanceFieldEffectMask : 0; |
| 520 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; | 525 flags |= random->nextBool() ? kBGR_DistanceFieldEffectFlag : 0; |
| 521 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, | 526 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, |
| 522 textures[texIdx2], params2, | 527 textures[texIdx2], params2, |
| 523 textColor, | 528 textColor, |
| 524 flags); | 529 flags); |
| 525 } | 530 } |
| OLD | NEW |