Fix up some issues introduced by https://codereview.chromium.org/1013773002/
authorjvanverth <jvanverth@google.com>
Mon, 16 Mar 2015 19:58:43 +0000 (12:58 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 16 Mar 2015 19:58:44 +0000 (12:58 -0700)
Need to check for zero-length gradients when using the new correction.
Make sure we use the old text sizes for color emoji test in dftext GM.

BUG=skia:3540

Review URL: https://codereview.chromium.org/1009973004

gm/dftext.cpp
src/gpu/effects/GrDistanceFieldTextureEffect.cpp

index 2ce28c39304b1748e566a74404eb42ac664caa24..f3d39e527c06523cffb3fd4f03b0f32f8b657c35 100755 (executable)
@@ -201,19 +201,24 @@ protected:
             paint.setLCDRenderText(false);
             SkAutoCanvasRestore acr(canvas, true);
             canvas->skew(0.0f, 0.151515f);
-            paint.setTextSize(32);
+            paint.setTextSize(SkIntToScalar(32));
             canvas->drawText(text, textLen, 745, 70, paint);
         }
         {
             paint.setLCDRenderText(true);
             SkAutoCanvasRestore acr(canvas, true);
             canvas->skew(0.5f, 0.0f);
-            paint.setTextSize(32);
+            paint.setTextSize(SkIntToScalar(32));
             canvas->drawText(text, textLen, 580, 230, paint);
         }
 
         // check color emoji
         paint.setTypeface(fTypeface);
+#ifdef SK_BUILD_FOR_ANDROID
+        paint.setTextSize(SkIntToScalar(19));
+#else
+        paint.setTextSize(SkIntToScalar(22));
+#endif
         canvas->drawText(text, textLen, 670, 100, paint);
 
 #if SK_SUPPORT_GPU
index c1c84b58715ba3bff1f0dcbdfde5c943b0f0f442..fc7fe54501e6bda8b71a649e23f6bcd9f5a3e94d 100755 (executable)
@@ -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);");