Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/gpu/effects/GrBezierEffect.cpp

Issue 25048002: Express (GLSL expression, possibly known value) pairs as a class (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 break; 232 break;
234 } 233 }
235 case kFillNoAA_GrBezierEdgeType: { 234 case kFillNoAA_GrBezierEdgeType: {
236 builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsNa me, fsName, 235 builder->fsCodeAppendf("\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fsNa me, fsName,
237 fsName); 236 fsName);
238 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); 237 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
239 break; 238 break;
240 } 239 }
241 } 240 }
242 241
243 SkString modulate; 242 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
244 GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha"); 243 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha ")).c_str());
245 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str()); 244
246 245
247 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); 246 vertexBuilder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
248 } 247 }
249 248
250 GrGLEffect::EffectKey GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, con st GrGLCaps&) { 249 GrGLEffect::EffectKey GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, con st GrGLCaps&) {
251 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>(); 250 const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>();
252 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 251 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
253 } 252 }
254 253
255 ////////////////////////////////////////////////////////////////////////////// 254 //////////////////////////////////////////////////////////////////////////////
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 break; 377 break;
379 } 378 }
380 case kFillNoAA_GrBezierEdgeType: { 379 case kFillNoAA_GrBezierEdgeType: {
381 builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x*%s.x - %s.y*%s.z;\ n", 380 builder->fsCodeAppendf("\t\tedgeAlpha = %s.x*%s.x*%s.x - %s.y*%s.z;\ n",
382 fsName, fsName, fsName, fsName, fsName); 381 fsName, fsName, fsName, fsName, fsName);
383 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n"); 382 builder->fsCodeAppend("\t\tedgeAlpha = float(edgeAlpha < 0.0);\n");
384 break; 383 break;
385 } 384 }
386 } 385 }
387 386
388 SkString modulate; 387 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
389 GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha"); 388 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("edgeAlpha ")).c_str());
390 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str());
391 } 389 }
392 390
393 GrGLEffect::EffectKey GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, co nst GrGLCaps&) { 391 GrGLEffect::EffectKey GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, co nst GrGLCaps&) {
394 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); 392 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>();
395 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 393 return ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
396 } 394 }
397 395
398 ////////////////////////////////////////////////////////////////////////////// 396 //////////////////////////////////////////////////////////////////////////////
399 397
400 GrCubicEffect::~GrCubicEffect() {} 398 GrCubicEffect::~GrCubicEffect() {}
(...skipping 16 matching lines...) Expand all
417 415
418 GR_DEFINE_EFFECT_TEST(GrCubicEffect); 416 GR_DEFINE_EFFECT_TEST(GrCubicEffect);
419 417
420 GrEffectRef* GrCubicEffect::TestCreate(SkRandom* random, 418 GrEffectRef* GrCubicEffect::TestCreate(SkRandom* random,
421 GrContext*, 419 GrContext*,
422 const GrDrawTargetCaps& caps, 420 const GrDrawTargetCaps& caps,
423 GrTexture*[]) { 421 GrTexture*[]) {
424 const GrBezierEdgeType edgeType = static_cast<GrBezierEdgeType>(random->next ULessThan(3)); 422 const GrBezierEdgeType edgeType = static_cast<GrBezierEdgeType>(random->next ULessThan(3));
425 return GrCubicEffect::Create(edgeType, caps); 423 return GrCubicEffect::Create(edgeType, caps);
426 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698