From ecdb686a5cae733ecd914c8bd5fd407b45ee2594 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Tue, 13 Dec 2016 18:17:47 -0500 Subject: Fix SDF generation for pixel-aligned paths (take two) BUG=668550 Change-Id: Ic771818bd5a4a46b83fdb82b69b98cb6b93a23a2 Reviewed-on: https://skia-review.googlesource.com/5697 Commit-Queue: Jim Van Verth Reviewed-by: Brian Salomon --- gm/pathfill.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) (limited to 'gm/pathfill.cpp') diff --git a/gm/pathfill.cpp b/gm/pathfill.cpp index 3496cfd04d..da0efea243 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,44 @@ 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->lineTo(9, 16); + path->lineTo(9, 21); + path->lineTo(5, 21); + path->lineTo(5, 9.715f); + path->lineTo(12, 3.351f); + path->lineTo(19, 9.715f); + path->lineTo(19, 21); + path->lineTo(15, 21); + path->lineTo(15, 16); + path->lineTo(9, 16); + 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 +145,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) -- cgit v1.2.3