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

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

Issue 212953008: Revert of Distance field fixes for Android (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 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
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/GrTextStrike.h » ('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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[1]); 225 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice s()[1]);
226 builder->vsCodeAppendf("\t%s = %s;\n", vsRadiiName, attr1Name->c_str ()); 226 builder->vsCodeAppendf("\t%s = %s;\n", vsRadiiName, attr1Name->c_str ());
227 227
228 // for outer curve 228 // for outer curve
229 builder->fsCodeAppendf("\tvec2 scaledOffset = %s*%s.xy;\n", fsOffset Name, fsRadiiName); 229 builder->fsCodeAppendf("\tvec2 scaledOffset = %s*%s.xy;\n", fsOffset Name, fsRadiiName);
230 builder->fsCodeAppend("\tfloat test = dot(scaledOffset, scaledOffset ) - 1.0;\n"); 230 builder->fsCodeAppend("\tfloat test = dot(scaledOffset, scaledOffset ) - 1.0;\n");
231 builder->fsCodeAppendf("\tvec2 grad = 2.0*scaledOffset*%s.xy;\n", fs RadiiName); 231 builder->fsCodeAppendf("\tvec2 grad = 2.0*scaledOffset*%s.xy;\n", fs RadiiName);
232 builder->fsCodeAppend("\tfloat grad_dot = dot(grad, grad);\n"); 232 builder->fsCodeAppend("\tfloat grad_dot = dot(grad, grad);\n");
233 // we need to clamp the length^2 of the gradiant vector to a non-zer o value, because 233 // we need to clamp the length^2 of the gradiant vector to a non-zer o value, because
234 // on the Nexus 4 the undefined result of inversesqrt(0) drops out a n entire tile 234 // on the Nexus 4 the undefined result of inversesqrt(0) drops out a n entire tile
235 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { 235 // TODO: restrict this to Adreno-only
236 builder->fsCodeAppend("\tgrad_dot = max(grad_dot, 1.0e-4);\n"); 236 builder->fsCodeAppend("\tgrad_dot = max(grad_dot, 1.0e-4);\n");
237 }
238 builder->fsCodeAppend("\tfloat invlen = inversesqrt(grad_dot);\n"); 237 builder->fsCodeAppend("\tfloat invlen = inversesqrt(grad_dot);\n");
239 builder->fsCodeAppend("\tfloat edgeAlpha = clamp(0.5-test*invlen, 0. 0, 1.0);\n"); 238 builder->fsCodeAppend("\tfloat edgeAlpha = clamp(0.5-test*invlen, 0. 0, 1.0);\n");
240 239
241 // for inner curve 240 // for inner curve
242 if (ellipseEffect.isStroked()) { 241 if (ellipseEffect.isStroked()) {
243 builder->fsCodeAppendf("\tscaledOffset = %s*%s.zw;\n", fsOffsetN ame, fsRadiiName); 242 builder->fsCodeAppendf("\tscaledOffset = %s*%s.zw;\n", fsOffsetN ame, fsRadiiName);
244 builder->fsCodeAppend("\ttest = dot(scaledOffset, scaledOffset) - 1.0;\n"); 243 builder->fsCodeAppend("\ttest = dot(scaledOffset, scaledOffset) - 1.0;\n");
245 builder->fsCodeAppendf("\tgrad = 2.0*scaledOffset*%s.zw;\n", fsR adiiName); 244 builder->fsCodeAppendf("\tgrad = 2.0*scaledOffset*%s.zw;\n", fsR adiiName);
246 builder->fsCodeAppend("\tinvlen = inversesqrt(dot(grad, grad));\ n"); 245 builder->fsCodeAppend("\tinvlen = inversesqrt(dot(grad, grad));\ n");
247 builder->fsCodeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);\n"); 246 builder->fsCodeAppend("\tedgeAlpha *= clamp(0.5+test*invlen, 0.0 , 1.0);\n");
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 builder->fsCodeAppend("\tfloat test = dot(scaledOffset, scaledOffset ) - 1.0;\n"); 373 builder->fsCodeAppend("\tfloat test = dot(scaledOffset, scaledOffset ) - 1.0;\n");
375 builder->fsCodeAppendf("\tvec2 duvdx = dFdx(%s);\n", fsOffsetName0); 374 builder->fsCodeAppendf("\tvec2 duvdx = dFdx(%s);\n", fsOffsetName0);
376 builder->fsCodeAppendf("\tvec2 duvdy = dFdy(%s);\n", fsOffsetName0); 375 builder->fsCodeAppendf("\tvec2 duvdy = dFdy(%s);\n", fsOffsetName0);
377 builder->fsCodeAppendf("\tvec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s .y*duvdx.y,\n" 376 builder->fsCodeAppendf("\tvec2 grad = vec2(2.0*%s.x*duvdx.x + 2.0*%s .y*duvdx.y,\n"
378 "\t 2.0*%s.x*duvdy.x + 2.0*%s .y*duvdy.y);\n", 377 "\t 2.0*%s.x*duvdy.x + 2.0*%s .y*duvdy.y);\n",
379 fsOffsetName0, fsOffsetName0, fsOffsetName0, fsOffsetName0); 378 fsOffsetName0, fsOffsetName0, fsOffsetName0, fsOffsetName0);
380 379
381 builder->fsCodeAppend("\tfloat grad_dot = dot(grad, grad);\n"); 380 builder->fsCodeAppend("\tfloat grad_dot = dot(grad, grad);\n");
382 // we need to clamp the length^2 of the gradiant vector to a non-zer o value, because 381 // we need to clamp the length^2 of the gradiant vector to a non-zer o value, because
383 // on the Nexus 4 the undefined result of inversesqrt(0) drops out a n entire tile 382 // on the Nexus 4 the undefined result of inversesqrt(0) drops out a n entire tile
384 if (builder->ctxInfo().caps()->dropsTileOnZeroDivide()) { 383 // TODO: restrict this to Adreno-only
385 builder->fsCodeAppend("\tgrad_dot = max(grad_dot, 1.0e-4);\n"); 384 builder->fsCodeAppend("\tgrad_dot = max(grad_dot, 1.0e-4);\n");
386 }
387 builder->fsCodeAppend("\tfloat invlen = inversesqrt(grad_dot);\n"); 385 builder->fsCodeAppend("\tfloat invlen = inversesqrt(grad_dot);\n");
388 if (kHairline == ellipseEffect.getMode()) { 386 if (kHairline == ellipseEffect.getMode()) {
389 // can probably do this with one step 387 // can probably do this with one step
390 builder->fsCodeAppend("\tfloat edgeAlpha = clamp(1.0-test*invlen , 0.0, 1.0);\n"); 388 builder->fsCodeAppend("\tfloat edgeAlpha = clamp(1.0-test*invlen , 0.0, 1.0);\n");
391 builder->fsCodeAppend("\tedgeAlpha *= clamp(1.0+test*invlen, 0.0 , 1.0);\n"); 389 builder->fsCodeAppend("\tedgeAlpha *= clamp(1.0+test*invlen, 0.0 , 1.0);\n");
392 } else { 390 } else {
393 builder->fsCodeAppend("\tfloat edgeAlpha = clamp(0.5-test*invlen , 0.0, 1.0);\n"); 391 builder->fsCodeAppend("\tfloat edgeAlpha = clamp(0.5-test*invlen , 0.0, 1.0);\n");
394 } 392 }
395 393
396 // for inner curve 394 // for inner curve
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 } 1138 }
1141 1139
1142 // drop out the middle quad if we're stroked 1140 // drop out the middle quad if we're stroked
1143 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO UNT(gRRectIndices); 1141 int indexCnt = isStroked ? GR_ARRAY_COUNT(gRRectIndices)-6 : GR_ARRAY_CO UNT(gRRectIndices);
1144 target->setIndexSourceToBuffer(indexBuffer); 1142 target->setIndexSourceToBuffer(indexBuffer);
1145 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds); 1143 target->drawIndexed(kTriangles_GrPrimitiveType, 0, 0, 16, indexCnt, &bou nds);
1146 } 1144 }
1147 1145
1148 return true; 1146 return true;
1149 } 1147 }
OLDNEW
« no previous file with comments | « src/gpu/GrDistanceFieldTextContext.cpp ('k') | src/gpu/GrTextStrike.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698