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
This commit is contained in:
jvanverth 2015-03-16 12:58:43 -07:00 committed by Commit bot
parent 95a4fe3737
commit d68a550ec8
2 changed files with 33 additions and 35 deletions

View File

@ -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

View File

@ -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);");