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

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

Issue 25023003: Implement color filter as GrGLEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments 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
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrPaint.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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); 110 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str());
111 111
112 builder->fsCodeAppendf("\tfloat d = length(%s.xy);\n", fsName); 112 builder->fsCodeAppendf("\tfloat d = length(%s.xy);\n", fsName);
113 builder->fsCodeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0 );\n", fsName); 113 builder->fsCodeAppendf("\tfloat edgeAlpha = clamp(%s.z - d, 0.0, 1.0 );\n", fsName);
114 if (circleEffect.isStroked()) { 114 if (circleEffect.isStroked()) {
115 builder->fsCodeAppendf("\tfloat innerAlpha = clamp(d - %s.w, 0.0 , 1.0);\n", fsName); 115 builder->fsCodeAppendf("\tfloat innerAlpha = clamp(d - %s.w, 0.0 , 1.0);\n", fsName);
116 builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n"); 116 builder->fsCodeAppend("\tedgeAlpha *= innerAlpha;\n");
117 } 117 }
118 118
119 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 119 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
120 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("e dgeAlpha")).c_str()); 120 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeA lpha")).c_str());
121 } 121 }
122 122
123 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 123 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
124 const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleE dgeEffect>(); 124 const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleE dgeEffect>();
125 125
126 return circleEffect.isStroked() ? 0x1 : 0x0; 126 return circleEffect.isStroked() ? 0x1 : 0x0;
127 } 127 }
128 128
129 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {} 129 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {}
130 130
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // for inner curve 242 // for inner curve
243 if (ellipseEffect.isStroked()) { 243 if (ellipseEffect.isStroked()) {
244 builder->fsCodeAppendf("\tscaledOffset = %s*%s.zw;\n", fsOffsetN ame, fsRadiiName); 244 builder->fsCodeAppendf("\tscaledOffset = %s*%s.zw;\n", fsOffsetN ame, fsRadiiName);
245 builder->fsCodeAppend("\ttest = dot(scaledOffset, scaledOffset) - 1.0;\n"); 245 builder->fsCodeAppend("\ttest = dot(scaledOffset, scaledOffset) - 1.0;\n");
246 builder->fsCodeAppendf("\tgrad = 2.0*scaledOffset*%s.zw;\n", fsR adiiName); 246 builder->fsCodeAppendf("\tgrad = 2.0*scaledOffset*%s.zw;\n", fsR adiiName);
247 builder->fsCodeAppend("\tinvlen = inversesqrt(dot(grad, grad));\ n"); 247 builder->fsCodeAppend("\tinvlen = inversesqrt(dot(grad, grad));\ n");
248 builder->fsCodeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);\n"); 248 builder->fsCodeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);\n");
249 } 249 }
250 250
251 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 251 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
252 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("e dgeAlpha")).c_str()); 252 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeA lpha")).c_str());
253 } 253 }
254 254
255 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 255 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
256 const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<Ellip seEdgeEffect>(); 256 const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<Ellip seEdgeEffect>();
257 257
258 return ellipseEffect.isStroked() ? 0x1 : 0x0; 258 return ellipseEffect.isStroked() ? 0x1 : 0x0;
259 } 259 }
260 260
261 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE { 261 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {
262 } 262 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 builder->fsCodeAppendf("\tduvdx = dFdx(%s);\n", fsOffsetName1); 400 builder->fsCodeAppendf("\tduvdx = dFdx(%s);\n", fsOffsetName1);
401 builder->fsCodeAppendf("\tduvdy = dFdy(%s);\n", fsOffsetName1); 401 builder->fsCodeAppendf("\tduvdy = dFdy(%s);\n", fsOffsetName1);
402 builder->fsCodeAppendf("\tgrad = vec2(2.0*%s.x*duvdx.x + 2.0*%s. y*duvdx.y,\n" 402 builder->fsCodeAppendf("\tgrad = vec2(2.0*%s.x*duvdx.x + 2.0*%s. y*duvdx.y,\n"
403 "\t 2.0*%s.x*duvdy.x + 2.0*%s. y*duvdy.y);\n", 403 "\t 2.0*%s.x*duvdy.x + 2.0*%s. y*duvdy.y);\n",
404 fsOffsetName1, fsOffsetName1, fsOffsetNam e1, fsOffsetName1); 404 fsOffsetName1, fsOffsetName1, fsOffsetNam e1, fsOffsetName1);
405 builder->fsCodeAppend("\tinvlen = inversesqrt(dot(grad, grad));\ n"); 405 builder->fsCodeAppend("\tinvlen = inversesqrt(dot(grad, grad));\ n");
406 builder->fsCodeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);\n"); 406 builder->fsCodeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);\n");
407 } 407 }
408 408
409 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, 409 builder->fsCodeAppendf("\t%s = %s;\n", outputColor,
410 (GrGLSLExpr<4>(inputColor) * GrGLSLExpr<1>("e dgeAlpha")).c_str()); 410 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeA lpha")).c_str());
411 } 411 }
412 412
413 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) { 413 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG LCaps&) {
414 const DIEllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<DIE llipseEdgeEffect>(); 414 const DIEllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<DIE llipseEdgeEffect>();
415 415
416 return ellipseEffect.getMode(); 416 return ellipseEffect.getMode();
417 } 417 }
418 418
419 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE { 419 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_ OVERRIDE {
420 } 420 }
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 } 1132 }
1133 1133
1134 // drop out the middle quad if we're stroked 1134 // drop out the middle quad if we're stroked
1135 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO UNT(gRRectIndices); 1135 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO UNT(gRRectIndices);
1136 target->setIndexSourceToBuffer(indexBuffer); 1136 target->setIndexSourceToBuffer(indexBuffer);
1137 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds); 1137 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds);
1138 } 1138 }
1139 1139
1140 return true; 1140 return true;
1141 } 1141 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawState.cpp ('k') | src/gpu/GrPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698