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

Side by Side Diff: src/gpu/GrOvalRenderer.cpp

Issue 13895006: Expand modulate, add, subtract, extract component glsl helpers. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "GrOvalRenderer.h" 8 #include "GrOvalRenderer.h"
9 9
10 #include "GrEffect.h" 10 #include "GrEffect.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); 101 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
102 102
103 builder->fsCodeAppendf("\tfloat d = length(%s.xy);\n", fsName); 103 builder->fsCodeAppendf("\tfloat d = length(%s.xy);\n", fsName);
104 builder->fsCodeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0 );\n", fsName); 104 builder->fsCodeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0 );\n", fsName);
105 if (circleEffect.isStroked()) { 105 if (circleEffect.isStroked()) {
106 builder->fsCodeAppendf("\tfloat innerAlpha = clamp(d - %s.w, 0.0 , 1.0);\n", fsName); 106 builder->fsCodeAppendf("\tfloat innerAlpha = clamp(d - %s.w, 0.0 , 1.0);\n", fsName);
107 builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n"); 107 builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n");
108 } 108 }
109 109
110 SkString modulate; 110 SkString modulate;
111 GrGLSLModulate4f(&modulate, inputColor, "edgeAlpha"); 111 GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha");
112 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str() ); 112 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str() );
113 } 113 }
114 114
115 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 115 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
116 const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleE dgeEffect>(); 116 const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleE dgeEffect>();
117 117
118 return circleEffect.isStroked() ? 0x1 : 0x0; 118 return circleEffect.isStroked() ? 0x1 : 0x0;
119 } 119 }
120 120
121 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {} 121 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (ellipseEffect.isStroked()) { 227 if (ellipseEffect.isStroked()) {
228 builder->fsCodeAppendf("\tfloat dInner = length(%s.zw);\n", fsOf fsetsName); 228 builder->fsCodeAppendf("\tfloat dInner = length(%s.zw);\n", fsOf fsetsName);
229 229
230 // compare inner lengths against xInnerRadius 230 // compare inner lengths against xInnerRadius
231 builder->fsCodeAppendf("\tfloat innerAlpha = clamp(dInner-%s.y, 0.0, 1.0);\n", 231 builder->fsCodeAppendf("\tfloat innerAlpha = clamp(dInner-%s.y, 0.0, 1.0);\n",
232 fsRadiiName); 232 fsRadiiName);
233 builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n"); 233 builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n");
234 } 234 }
235 235
236 SkString modulate; 236 SkString modulate;
237 GrGLSLModulate4f(&modulate, inputColor, "edgeAlpha"); 237 GrGLSLModulatef<4>(&modulate, inputColor, "edgeAlpha");
238 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str() ); 238 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, modulate.c_str() );
239 } 239 }
240 240
241 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 241 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
242 const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<Ellip seEdgeEffect>(); 242 const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<Ellip seEdgeEffect>();
243 243
244 return ellipseEffect.isStroked() ? 0x1 : 0x0; 244 return ellipseEffect.isStroked() ? 0x1 : 0x0;
245 } 245 }
246 246
247 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE { 247 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom); 537 verts[3].fPos = SkPoint::Make(bounds.fRight, bounds.fBottom);
538 verts[3].fOuterXRadius = xRadius; 538 verts[3].fOuterXRadius = xRadius;
539 verts[3].fInnerXRadius = innerXRadius; 539 verts[3].fInnerXRadius = innerXRadius;
540 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius); 540 verts[3].fOuterOffset = SkPoint::Make(xRadius, outerRatio*yRadius);
541 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius); 541 verts[3].fInnerOffset = SkPoint::Make(xRadius, innerRatio*yRadius);
542 542
543 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds); 543 target->drawNonIndexed(kTriangleStrip_GrPrimitiveType, 0, 4, &bounds);
544 544
545 return true; 545 return true;
546 } 546 }
OLDNEW
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698