add gm for tricky arc

Very likely, reimplementing this routine using doubles would also
improve results, given the many divides, subtracts, and trig calls.

Bug: skia:9272
Change-Id: I78a3dd9a11a8de1c0ef7a4406a227a0b7d9aecf7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/230123
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
Mike Reed 2019-07-26 13:16:52 -04:00 committed by Skia Commit-Bot
parent ac0e466154
commit 6397fa30ab
2 changed files with 27 additions and 0 deletions

View File

@ -38,3 +38,21 @@ DEF_SIMPLE_GM(shallow_angle_path_arcto, canvas, 300, 300) {
canvas->translate(-200, -50);
canvas->drawPath(path, paint);
};
#include "include/utils/SkParsePath.h"
DEF_SIMPLE_GM(arcto_skbug_9272, canvas, 150, 150) {
const char* str = "M66.652,65.509c0.663,-2 -0.166,-4.117 -2.117,-5.212 -0.673,-0.378 -1.36,-0.733 -2.04,-1.1a1647300864,1647300864 0,0 1,-31.287 -16.86c-5.39,-2.903 -10.78,-5.808 -16.171,-8.713 -1.626,-0.876 -3.253,-1.752 -4.88,-2.63 -1.224,-0.659 -2.4,-1.413 -3.851,-1.413 -1.135,0 -2.242,0.425 -3.049,1.197 0.08,-0.083 0.164,-0.164 0.248,-0.246l5.309,-5.13 9.37,-9.054 9.525,-9.204 5.903,-5.704C34.237,0.836 34.847,0.297 35.75,0.13c0.982,-0.182 1.862,0.127 2.703,0.592l6.23,3.452L55.76,10.31l11.951,6.62 9.02,4.996c1.74,0.963 4.168,1.854 4.205,4.21 0.011,0.678 -0.246,1.28 -0.474,1.9l-1.005,2.733 -5.665,15.42 -7.106,19.338 -0.034,-0.018z";
SkPath path;
SkParsePath::FromSVGString(str, &path);
const char* str2 = "M10.156,30.995l4.881,2.63 16.17,8.713a1647300736,1647300736 0,0 0,31.287 16.86c0.68,0.366 1.368,0.721 2.041,1.1 2.242,1.257 3.002,3.864 1.72,6.094 -0.659,1.147 -1.296,2.31 -1.978,3.442 -1.276,2.117 -3.973,2.632 -6.102,1.536 -0.244,-0.125 -0.485,-0.259 -0.727,-0.388l-4.102,-2.19 -15.401,-8.225 -18.536,-9.9 -13.893,-7.419c-0.939,-0.501 -1.88,-0.998 -2.816,-1.504C1.2,40.935 0.087,39.5 0.004,37.75c-0.08,-1.672 1.078,-3.277 1.826,-4.702 0.248,-0.471 0.479,-0.958 0.75,-1.416 0.772,-1.306 2.224,-2.05 3.726,-2.05 1.45,0 2.627,0.754 3.85,1.414z";
SkPath path2;
SkParsePath::FromSVGString(str2, &path2);
SkPaint paint;
paint.setStyle(SkPaint::kStroke_Style);
canvas->translate(30, 30);
canvas->drawPath(path, paint);
canvas->drawPath(path2, paint);
}

View File

@ -1486,6 +1486,15 @@ SkPath& SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize
} else if (thetaArc > 0 && arcSweep) { // arcSweep flipped from the original implementation
thetaArc -= SK_ScalarPI * 2;
}
// Very tiny angles cause our subsequent math to go wonky (skbug.com/9272)
// so we do a quick check here. The precise tolerance amount is just made up.
// PI/million happens to fix the bug in 9272, but a larger value is probably
// ok too.
if (SkScalarAbs(thetaArc) < (SK_ScalarPI / (1000 * 1000))) {
return this->lineTo(x, y);
}
pointTransform.setRotate(angle);
pointTransform.preScale(rx, ry);