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