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

Unified Diff: src/gpu/effects/GrDistanceFieldTextureEffect.cpp

Issue 1009973004: Fix up some issues introduced by https://codereview.chromium.org/1013773002/ (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/dftext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrDistanceFieldTextureEffect.cpp
diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
index c1c84b58715ba3bff1f0dcbdfde5c943b0f0f442..fc7fe54501e6bda8b71a649e23f6bcd9f5a3e94d 100755
--- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
+++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp
@@ -100,17 +100,15 @@ public:
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
fsBuilder->codeAppend("vec2 dist_grad = vec2(dFdx(distance), dFdy(distance));");
- if (args.fPB->ctxInfo().caps()->dropsTileOnZeroDivide()) {
- // this is to compensate for the Adreno, which likes to drop tiles on division by 0
- fsBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
- fsBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fsBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
- fsBuilder->codeAppend("} else {");
- fsBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
- fsBuilder->codeAppend("}");
- } else {
- fsBuilder->codeAppend("dist_grad = normalize(dist_grad);\n");
- }
+ // the length of the gradient may be 0, so we need to check for this
+ // this also compensates for the Adreno, which likes to drop tiles on division by 0
+ fsBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
+ fsBuilder->codeAppend("if (dg_len2 < 0.0001) {");
+ fsBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fsBuilder->codeAppend("} else {");
+ fsBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
+ fsBuilder->codeAppend("}");
+
fsBuilder->codeAppend("vec2 Jdx = dFdx(st);");
fsBuilder->codeAppend("vec2 Jdy = dFdy(st);");
fsBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
@@ -387,17 +385,15 @@ public:
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
fsBuilder->codeAppend("vec2 dist_grad = vec2(dFdx(distance), dFdy(distance));");
- if (args.fPB->ctxInfo().caps()->dropsTileOnZeroDivide()) {
- // this is to compensate for the Adreno, which likes to drop tiles on division by 0
- fsBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
- fsBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fsBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
- fsBuilder->codeAppend("} else {");
- fsBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
- fsBuilder->codeAppend("}");
- } else {
- fsBuilder->codeAppend("dist_grad = normalize(dist_grad);");
- }
+ // the length of the gradient may be 0, so we need to check for this
+ // this also compensates for the Adreno, which likes to drop tiles on division by 0
+ fsBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
+ fsBuilder->codeAppend("if (dg_len2 < 0.0001) {");
+ fsBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fsBuilder->codeAppend("} else {");
+ fsBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
+ fsBuilder->codeAppend("}");
+
fsBuilder->codeAppend("vec2 Jdx = dFdx(st);");
fsBuilder->codeAppend("vec2 Jdy = dFdy(st);");
fsBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
@@ -671,17 +667,14 @@ public:
// vector pointing along the SDF gradient direction by the Jacobian of the st coords
// (which is the inverse transform for this fragment) and take the length of the result.
fsBuilder->codeAppend("vec2 dist_grad = vec2(dFdx(distance.r), dFdy(distance.r));");
- if (args.fPB->ctxInfo().caps()->dropsTileOnZeroDivide()) {
- // this is to compensate for the Adreno, which likes to drop tiles on division by 0
- fsBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
- fsBuilder->codeAppend("if (dg_len2 < 0.0001) {");
- fsBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
- fsBuilder->codeAppend("} else {");
- fsBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
- fsBuilder->codeAppend("}");
- } else {
- fsBuilder->codeAppend("dist_grad = normalize(dist_grad);\n");
- }
+ // the length of the gradient may be 0, so we need to check for this
+ // this also compensates for the Adreno, which likes to drop tiles on division by 0
+ fsBuilder->codeAppend("float dg_len2 = dot(dist_grad, dist_grad);");
+ fsBuilder->codeAppend("if (dg_len2 < 0.0001) {");
+ fsBuilder->codeAppend("dist_grad = vec2(0.7071, 0.7071);");
+ fsBuilder->codeAppend("} else {");
+ fsBuilder->codeAppend("dist_grad = dist_grad*inversesqrt(dg_len2);");
+ fsBuilder->codeAppend("}");
fsBuilder->codeAppend("vec2 grad = vec2(dist_grad.x*Jdx.x + dist_grad.y*Jdy.x,");
fsBuilder->codeAppend(" dist_grad.x*Jdx.y + dist_grad.y*Jdy.y);");
« no previous file with comments | « gm/dftext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698