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 "GrBezierEffect.h" | 8 #include "GrBezierEffect.h" |
9 | 9 |
10 #include "gl/GrGLEffect.h" | 10 #include "gl/GrGLEffect.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 case kFillNoAA_GrBezierEdgeType: { | 105 case kFillNoAA_GrBezierEdgeType: { |
106 builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x - %s.y*%s.z;\n", f
sName, fsName, | 106 builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x - %s.y*%s.z;\n", f
sName, fsName, |
107 fsName, fsName); | 107 fsName, fsName); |
108 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); | 108 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); |
109 break; | 109 break; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, | 113 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
114 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha
")).c_str()); | 114 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).
c_str()); |
115 } | 115 } |
116 | 116 |
117 GrGLEffect::EffectKey GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, co
nst GrGLCaps&) { | 117 GrGLEffect::EffectKey GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, co
nst GrGLCaps&) { |
118 const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>(); | 118 const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>(); |
119 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 119 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
120 } | 120 } |
121 | 121 |
122 ////////////////////////////////////////////////////////////////////////////// | 122 ////////////////////////////////////////////////////////////////////////////// |
123 | 123 |
124 GrConicEffect::~GrConicEffect() {} | 124 GrConicEffect::~GrConicEffect() {} |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 case kFillNoAA_GrBezierEdgeType: { | 233 case kFillNoAA_GrBezierEdgeType: { |
234 builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsNa
me, fsName, | 234 builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsNa
me, fsName, |
235 fsName); | 235 fsName); |
236 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); | 236 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); |
237 break; | 237 break; |
238 } | 238 } |
239 } | 239 } |
240 | 240 |
241 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, | 241 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
242 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha
")).c_str()); | 242 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).
c_str()); |
243 | 243 |
244 | 244 |
245 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); | 245 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); |
246 } | 246 } |
247 | 247 |
248 GrGLEffect::EffectKey GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, con
st GrGLCaps&) { | 248 GrGLEffect::EffectKey GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, con
st GrGLCaps&) { |
249 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>(); | 249 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>(); |
250 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 250 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
251 } | 251 } |
252 | 252 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 } | 376 } |
377 case kFillNoAA_GrBezierEdgeType: { | 377 case kFillNoAA_GrBezierEdgeType: { |
378 builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x*%s.x - %s.y*%s.z;\
n", | 378 builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x*%s.x - %s.y*%s.z;\
n", |
379 fsName, fsName, fsName, fsName, fsName); | 379 fsName, fsName, fsName, fsName, fsName); |
380 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); | 380 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); |
381 break; | 381 break; |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, | 385 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
386 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha
")).c_str()); | 386 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).
c_str()); |
387 } | 387 } |
388 | 388 |
389 GrGLEffect::EffectKey GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, co
nst GrGLCaps&) { | 389 GrGLEffect::EffectKey GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, co
nst GrGLCaps&) { |
390 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); | 390 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); |
391 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 391 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
392 } | 392 } |
393 | 393 |
394 ////////////////////////////////////////////////////////////////////////////// | 394 ////////////////////////////////////////////////////////////////////////////// |
395 | 395 |
396 GrCubicEffect::~GrCubicEffect() {} | 396 GrCubicEffect::~GrCubicEffect() {} |
(...skipping 16 matching lines...) Expand all Loading... |
413 | 413 |
414 GR_DEFINE_EFFECT_TEST(GrCubicEffect); | 414 GR_DEFINE_EFFECT_TEST(GrCubicEffect); |
415 | 415 |
416 GrEffectRef* GrCubicEffect::TestCreate(SkRandom* random, | 416 GrEffectRef* GrCubicEffect::TestCreate(SkRandom* random, |
417 GrContext*, | 417 GrContext*, |
418 const GrDrawTargetCaps& caps, | 418 const GrDrawTargetCaps& caps, |
419 GrTexture*[]) { | 419 GrTexture*[]) { |
420 const GrBezierEdgeType edgeType = static_cast<GrBezierEdgeType>(random->next
ULessThan(3)); | 420 const GrBezierEdgeType edgeType = static_cast<GrBezierEdgeType>(random->next
ULessThan(3)); |
421 return GrCubicEffect::Create(edgeType, caps); | 421 return GrCubicEffect::Create(edgeType, caps); |
422 } | 422 } |
OLD | NEW |