diff options
author | 2016-12-07 10:40:09 -0500 | |
---|---|---|
committer | 2016-12-07 16:48:35 +0000 | |
commit | 92964124c5ff61729357a51dc212ca5938093e89 (patch) | |
tree | e4e4dac59f38efcc87c1e9dfbeb0e68d914efc70 /gm | |
parent | d7e16661bb36924b2c8f717c527b876dabb595f3 (diff) |
Fix SDF generation for pixel-aligned paths
BUG=668550
Change-Id: Ib496db82c7391aca61b31afaeb5445260170cc49
Reviewed-on: https://skia-review.googlesource.com/5549
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'gm')
-rw-r--r-- | gm/pathfill.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/gm/pathfill.cpp b/gm/pathfill.cpp index 3496cfd04d..ae49a9dbd6 100644 --- a/gm/pathfill.cpp +++ b/gm/pathfill.cpp @@ -50,15 +50,15 @@ static SkScalar make_oval(SkPath* path) { return SkIntToScalar(30); } -static SkScalar make_sawtooth(SkPath* path) { +static SkScalar make_sawtooth(SkPath* path, int teeth) { SkScalar x = SkIntToScalar(20); SkScalar y = SkIntToScalar(20); const SkScalar x0 = x; - const SkScalar dx = SK_Scalar1 * 5; - const SkScalar dy = SK_Scalar1 * 10; + const SkScalar dx = SkIntToScalar(5); + const SkScalar dy = SkIntToScalar(10); path->moveTo(x, y); - for (int i = 0; i < 32; i++) { + for (int i = 0; i < teeth; i++) { x += dx; path->lineTo(x, y - dy); x += dx; @@ -70,6 +70,33 @@ static SkScalar make_sawtooth(SkPath* path) { return SkIntToScalar(30); } +static SkScalar make_sawtooth_3(SkPath* path) { return make_sawtooth(path, 3); } +static SkScalar make_sawtooth_32(SkPath* path) { return make_sawtooth(path, 32); } + +static SkScalar make_house(SkPath* path) { + path->moveTo(21, 23); + path->lineTo(21, 11.534f); + path->lineTo(22.327f, 12.741f); + path->lineTo(23.673f, 11.261f); + path->lineTo(12, 0.648f); + path->lineTo(8, 4.285f); + path->lineTo(8, 2); + path->lineTo(4, 2); + path->lineTo(4, 7.921f); + path->lineTo(0.327f, 11.26f); + path->lineTo(1.673f, 12.74f); + path->lineTo(3, 11.534f); + path->lineTo(3, 23); + path->lineTo(11, 23); + path->lineTo(11, 18); + path->lineTo(13, 18); + path->lineTo(13, 23); + path->lineTo(21, 23); + path->close(); + path->offset(20, 0); + return SkIntToScalar(30); +} + static SkScalar make_star(SkPath* path, int n) { const SkScalar c = SkIntToScalar(45); const SkScalar r = SkIntToScalar(20); @@ -107,10 +134,12 @@ constexpr MakePathProc gProcs[] = { make_triangle, make_rect, make_oval, - make_sawtooth, + make_sawtooth_32, make_star_5, make_star_13, make_line, + make_house, + make_sawtooth_3, }; #define N SK_ARRAY_COUNT(gProcs) |