| 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 "gl/GrGLEffect.h" | 9 #include "gl/GrGLEffect.h" |
| 10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 #endif | 121 #endif |
| 122 | 122 |
| 123 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, | 123 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
| 124 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("val")
).c_str()); | 124 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("val")
).c_str()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual void setData(const GrGLUniformManager& uman, | 127 virtual void setData(const GrGLUniformManager& uman, |
| 128 const GrDrawEffect& drawEffect) SK_OVERRIDE { | 128 const GrDrawEffect& drawEffect) SK_OVERRIDE { |
| 129 SkASSERT(fTextureSizeUni.isValid()); | 129 SkASSERT(fTextureSizeUni.isValid()); |
| 130 | 130 |
| 131 GrTexture* texture = drawEffect.effect()->get()->texture(0); | 131 GrTexture* texture = drawEffect.effect()->texture(0); |
| 132 if (texture->width() != fTextureSize.width() || | 132 if (texture->width() != fTextureSize.width() || |
| 133 texture->height() != fTextureSize.height()) { | 133 texture->height() != fTextureSize.height()) { |
| 134 fTextureSize = SkISize::Make(texture->width(), texture->height()); | 134 fTextureSize = SkISize::Make(texture->width(), texture->height()); |
| 135 uman.set2f(fTextureSizeUni, | 135 uman.set2f(fTextureSizeUni, |
| 136 SkIntToScalar(fTextureSize.width()), | 136 SkIntToScalar(fTextureSize.width()), |
| 137 SkIntToScalar(fTextureSize.height())); | 137 SkIntToScalar(fTextureSize.height())); |
| 138 } | 138 } |
| 139 #ifdef SK_GAMMA_APPLY_TO_A8 | 139 #ifdef SK_GAMMA_APPLY_TO_A8 |
| 140 const GrDistanceFieldTextureEffect& dfTexEffect = | 140 const GrDistanceFieldTextureEffect& dfTexEffect = |
| 141 drawEffect.castEffect<GrDistanceFi
eldTextureEffect>(); | 141 drawEffect.castEffect<GrDistanceFi
eldTextureEffect>(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 (GrGLSLExpr4(inputColor) * GrGLSLExpr4("val")).c_
str()); | 379 (GrGLSLExpr4(inputColor) * GrGLSLExpr4("val")).c_
str()); |
| 380 } | 380 } |
| 381 | 381 |
| 382 virtual void setData(const GrGLUniformManager& uman, | 382 virtual void setData(const GrGLUniformManager& uman, |
| 383 const GrDrawEffect& drawEffect) SK_OVERRIDE { | 383 const GrDrawEffect& drawEffect) SK_OVERRIDE { |
| 384 SkASSERT(fTextureSizeUni.isValid()); | 384 SkASSERT(fTextureSizeUni.isValid()); |
| 385 SkASSERT(fTextColorUni.isValid()); | 385 SkASSERT(fTextColorUni.isValid()); |
| 386 | 386 |
| 387 const GrDistanceFieldLCDTextureEffect& dfTexEffect = | 387 const GrDistanceFieldLCDTextureEffect& dfTexEffect = |
| 388 drawEffect.castEffect<GrDistanceFieldLCDText
ureEffect>(); | 388 drawEffect.castEffect<GrDistanceFieldLCDText
ureEffect>(); |
| 389 GrTexture* texture = drawEffect.effect()->get()->texture(0); | 389 GrTexture* texture = drawEffect.effect()->texture(0); |
| 390 if (texture->width() != fTextureSize.width() || | 390 if (texture->width() != fTextureSize.width() || |
| 391 texture->height() != fTextureSize.height()) { | 391 texture->height() != fTextureSize.height()) { |
| 392 fTextureSize = SkISize::Make(texture->width(), texture->height()); | 392 fTextureSize = SkISize::Make(texture->width(), texture->height()); |
| 393 float delta = 1.0f/(3.0f*texture->width()); | 393 float delta = 1.0f/(3.0f*texture->width()); |
| 394 if (dfTexEffect.useBGR()) { | 394 if (dfTexEffect.useBGR()) { |
| 395 delta = -delta; | 395 delta = -delta; |
| 396 } | 396 } |
| 397 uman.set3f(fTextureSizeUni, | 397 uman.set3f(fTextureSizeUni, |
| 398 SkIntToScalar(fTextureSize.width()), | 398 SkIntToScalar(fTextureSize.width()), |
| 399 SkIntToScalar(fTextureSize.height()), | 399 SkIntToScalar(fTextureSize.height()), |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 GrTextureParams::kNone_FilterMode); | 491 GrTextureParams::kNone_FilterMode); |
| 492 GrColor textColor = GrColorPackRGBA(random->nextULessThan(256), | 492 GrColor textColor = GrColorPackRGBA(random->nextULessThan(256), |
| 493 random->nextULessThan(256), | 493 random->nextULessThan(256), |
| 494 random->nextULessThan(256), | 494 random->nextULessThan(256), |
| 495 random->nextULessThan(256)); | 495 random->nextULessThan(256)); |
| 496 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, | 496 return GrDistanceFieldLCDTextureEffect::Create(textures[texIdx], params, |
| 497 textures[texIdx2], params2, | 497 textures[texIdx2], params2, |
| 498 textColor, | 498 textColor, |
| 499 random->nextBool(), random->n
extBool()); | 499 random->nextBool(), random->n
extBool()); |
| 500 } | 500 } |
| OLD | NEW |