epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
bungeman | d3ebb48 | 2015-08-05 13:57:49 -0700 | [diff] [blame] | 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkCanvas.h" |
| 10 | #include "include/core/SkColor.h" |
| 11 | #include "include/core/SkPaint.h" |
Mike Reed | cfb130c | 2020-08-03 11:02:20 -0400 | [diff] [blame] | 12 | #include "include/core/SkPathBuilder.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 13 | #include "include/core/SkRect.h" |
| 14 | #include "include/core/SkScalar.h" |
| 15 | #include "include/core/SkSize.h" |
| 16 | #include "include/core/SkString.h" |
| 17 | #include "include/core/SkTypes.h" |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 18 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 19 | namespace { |
| 20 | struct PathDY { |
| 21 | SkPath path; |
| 22 | SkScalar dy; |
| 23 | }; |
John Stiles | 3215385 | 2020-08-23 18:30:07 -0400 | [diff] [blame] | 24 | } |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 25 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 26 | typedef PathDY (*MakePathProc)(); |
| 27 | |
| 28 | static PathDY make_frame() { |
bungeman@google.com | 3c14d0f | 2011-05-20 14:05:03 +0000 | [diff] [blame] | 29 | SkRect r = { SkIntToScalar(10), SkIntToScalar(10), |
| 30 | SkIntToScalar(630), SkIntToScalar(470) }; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 31 | SkPath path = SkPath::RRect(SkRRect::MakeRectXY(r, 15, 15)); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 32 | SkPaint paint; |
| 33 | paint.setStyle(SkPaint::kStroke_Style); |
bungeman@google.com | 3c14d0f | 2011-05-20 14:05:03 +0000 | [diff] [blame] | 34 | paint.setStrokeWidth(SkIntToScalar(5)); |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 35 | paint.getFillPath(path, &path); |
| 36 | return {path, 15}; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 39 | static PathDY make_triangle() { |
mtklein | dbfd7ab | 2016-09-01 11:24:54 -0700 | [diff] [blame] | 40 | constexpr int gCoord[] = { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 41 | 10, 20, 15, 5, 30, 30 |
| 42 | }; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 43 | return { |
| 44 | SkPathBuilder().moveTo(SkIntToScalar(gCoord[0]), SkIntToScalar(gCoord[1])) |
| 45 | .lineTo(SkIntToScalar(gCoord[2]), SkIntToScalar(gCoord[3])) |
| 46 | .lineTo(SkIntToScalar(gCoord[4]), SkIntToScalar(gCoord[5])) |
| 47 | .close() |
| 48 | .offset(10, 0) |
| 49 | .detach(), |
| 50 | 30 |
| 51 | }; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 54 | static PathDY make_rect() { |
bungeman@google.com | 3c14d0f | 2011-05-20 14:05:03 +0000 | [diff] [blame] | 55 | SkRect r = { SkIntToScalar(10), SkIntToScalar(10), |
| 56 | SkIntToScalar(30), SkIntToScalar(30) }; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 57 | return { |
| 58 | SkPathBuilder().addRect(r).offset(10, 0).detach(), |
| 59 | 30 |
| 60 | }; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 63 | static PathDY make_oval() { |
bungeman@google.com | 3c14d0f | 2011-05-20 14:05:03 +0000 | [diff] [blame] | 64 | SkRect r = { SkIntToScalar(10), SkIntToScalar(10), |
| 65 | SkIntToScalar(30), SkIntToScalar(30) }; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 66 | return { |
| 67 | SkPathBuilder().addOval(r).offset(10, 0).detach(), |
| 68 | 30 |
| 69 | }; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 72 | static PathDY make_sawtooth(int teeth) { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 73 | SkScalar x = SkIntToScalar(20); |
| 74 | SkScalar y = SkIntToScalar(20); |
| 75 | const SkScalar x0 = x; |
Jim Van Verth | ecdb686 | 2016-12-13 18:17:47 -0500 | [diff] [blame] | 76 | const SkScalar dx = SkIntToScalar(5); |
| 77 | const SkScalar dy = SkIntToScalar(10); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 78 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 79 | SkPathBuilder builder; |
| 80 | builder.moveTo(x, y); |
Jim Van Verth | ecdb686 | 2016-12-13 18:17:47 -0500 | [diff] [blame] | 81 | for (int i = 0; i < teeth; i++) { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 82 | x += dx; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 83 | builder.lineTo(x, y - dy); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 84 | x += dx; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 85 | builder.lineTo(x, y + dy); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 86 | } |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 87 | builder.lineTo(x, y + (2 * dy)); |
| 88 | builder.lineTo(x0, y + (2 * dy)); |
| 89 | builder.close(); |
| 90 | |
| 91 | return {builder.detach(), 30}; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 94 | static PathDY make_sawtooth_3() { return make_sawtooth(3); } |
| 95 | static PathDY make_sawtooth_32() { return make_sawtooth(32); } |
Jim Van Verth | ecdb686 | 2016-12-13 18:17:47 -0500 | [diff] [blame] | 96 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 97 | static PathDY make_house() { |
| 98 | SkPathBuilder builder; |
| 99 | builder.addPolygon({ |
| 100 | {21, 23}, |
| 101 | {21, 11.534f}, |
| 102 | {22.327f, 12.741f}, |
| 103 | {23.673f, 11.261f}, |
| 104 | {12, 0.648f}, |
| 105 | {8, 4.285f}, |
| 106 | {8, 2}, |
| 107 | {4, 2}, |
| 108 | {4, 7.921f}, |
| 109 | {0.327f, 11.26f}, |
| 110 | {1.673f, 12.74f}, |
| 111 | {3, 11.534f}, |
| 112 | {3, 23}, |
| 113 | {11, 23}, |
| 114 | {11, 18}, |
| 115 | {13, 18}, |
| 116 | {13, 23}, |
| 117 | {21, 23}}, true) |
| 118 | .polylineTo({ |
| 119 | {9, 16}, |
| 120 | {9, 21}, |
| 121 | {5, 21}, |
| 122 | {5, 9.715f}, |
| 123 | {12, 3.351f}, |
| 124 | {19, 9.715f}, |
| 125 | {19, 21}, |
| 126 | {15, 21}, |
| 127 | {15, 16}, |
| 128 | {9, 16}}) |
| 129 | .close() |
| 130 | .offset(20, 0); |
| 131 | return {builder.detach(), 30}; |
Jim Van Verth | ecdb686 | 2016-12-13 18:17:47 -0500 | [diff] [blame] | 132 | } |
| 133 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 134 | static PathDY make_star(int n) { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 135 | const SkScalar c = SkIntToScalar(45); |
| 136 | const SkScalar r = SkIntToScalar(20); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 137 | |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 138 | SkScalar rad = -SK_ScalarPI / 2; |
| 139 | const SkScalar drad = (n >> 1) * SK_ScalarPI * 2 / n; |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 140 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 141 | SkPathBuilder builder; |
| 142 | builder.moveTo(c, c - r); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 143 | for (int i = 1; i < n; i++) { |
| 144 | rad += drad; |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 145 | builder.lineTo(c + SkScalarCos(rad) * r, c + SkScalarSin(rad) * r); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 146 | } |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 147 | builder.close(); |
| 148 | |
| 149 | return {builder.detach(), r * 2 * 6 / 5}; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 152 | static PathDY make_star_5() { return make_star(5); } |
| 153 | static PathDY make_star_13() { return make_star(13); } |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 154 | |
vandebo@chromium.org | 683001c | 2012-05-09 17:17:51 +0000 | [diff] [blame] | 155 | // We don't expect any output from this path. |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 156 | static PathDY make_line() { |
| 157 | return { |
| 158 | SkPathBuilder().moveTo(30, 30) |
| 159 | .lineTo(120, 40) |
| 160 | .close() |
| 161 | .moveTo(150, 30) |
| 162 | .lineTo(150, 30) |
| 163 | .lineTo(300, 40) |
| 164 | .close() |
| 165 | .detach(), |
| 166 | 40 |
| 167 | }; |
vandebo@chromium.org | 683001c | 2012-05-09 17:17:51 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 170 | static SkPath make_info() { |
| 171 | SkPathBuilder path; |
| 172 | path.moveTo(24, 4); |
| 173 | path.cubicTo(12.94999980926514f, 4, |
| 174 | 4, 12.94999980926514f, |
| 175 | 4, 24); |
| 176 | path.cubicTo(4, 35.04999923706055f, |
| 177 | 12.94999980926514f, 44, |
| 178 | 24, 44); |
| 179 | path.cubicTo(35.04999923706055f, 44, |
| 180 | 44, 35.04999923706055f, |
| 181 | 44, 24); |
| 182 | path.cubicTo(44, 12.95000076293945f, |
| 183 | 35.04999923706055f, 4, |
| 184 | 24, 4); |
| 185 | path.close(); |
| 186 | path.moveTo(26, 34); |
| 187 | path.lineTo(22, 34); |
| 188 | path.lineTo(22, 22); |
| 189 | path.lineTo(26, 22); |
| 190 | path.lineTo(26, 34); |
| 191 | path.close(); |
| 192 | path.moveTo(26, 18); |
| 193 | path.lineTo(22, 18); |
| 194 | path.lineTo(22, 14); |
| 195 | path.lineTo(26, 14); |
| 196 | path.lineTo(26, 18); |
| 197 | path.close(); |
| 198 | return path.detach(); |
Jim Van Verth | f9e678d | 2017-02-15 15:46:52 -0500 | [diff] [blame] | 199 | } |
Jim Van Verth | 7704754 | 2017-01-11 14:17:00 -0500 | [diff] [blame] | 200 | |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 201 | static SkPath make_accessibility() { |
| 202 | SkPathBuilder path; |
| 203 | path.moveTo(12, 2); |
| 204 | path.cubicTo(13.10000038146973f, 2, |
| 205 | 14, 2.900000095367432f, |
| 206 | 14, 4); |
| 207 | path.cubicTo(14, 5.099999904632568f, |
| 208 | 13.10000038146973f, 6, |
| 209 | 12, 6); |
| 210 | path.cubicTo(10.89999961853027f, 6, |
| 211 | 10, 5.099999904632568f, |
| 212 | 10, 4); |
| 213 | path.cubicTo(10, 2.900000095367432f, |
| 214 | 10.89999961853027f, 2, |
| 215 | 12, 2); |
| 216 | path.close(); |
| 217 | path.moveTo(21, 9); |
| 218 | path.lineTo(15, 9); |
| 219 | path.lineTo(15, 22); |
| 220 | path.lineTo(13, 22); |
| 221 | path.lineTo(13, 16); |
| 222 | path.lineTo(11, 16); |
| 223 | path.lineTo(11, 22); |
| 224 | path.lineTo(9, 22); |
| 225 | path.lineTo(9, 9); |
| 226 | path.lineTo(3, 9); |
| 227 | path.lineTo(3, 7); |
| 228 | path.lineTo(21, 7); |
| 229 | path.lineTo(21, 9); |
| 230 | path.close(); |
| 231 | return path.detach(); |
Jim Van Verth | 7704754 | 2017-01-11 14:17:00 -0500 | [diff] [blame] | 232 | } |
| 233 | |
Jim Van Verth | 33632d8 | 2017-02-28 10:24:39 -0500 | [diff] [blame] | 234 | // test case for http://crbug.com/695196 |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 235 | static SkPath make_visualizer() { |
| 236 | SkPathBuilder path; |
| 237 | path.moveTo(1.9520f, 2.0000f); |
| 238 | path.conicTo(1.5573f, 1.9992f, 1.2782f, 2.2782f, 0.9235f); |
| 239 | path.conicTo(0.9992f, 2.5573f, 1.0000f, 2.9520f, 0.9235f); |
| 240 | path.lineTo(1.0000f, 5.4300f); |
| 241 | path.lineTo(17.0000f, 5.4300f); |
| 242 | path.lineTo(17.0000f, 2.9520f); |
| 243 | path.conicTo(17.0008f, 2.5573f, 16.7218f, 2.2782f, 0.9235f); |
| 244 | path.conicTo(16.4427f, 1.9992f, 16.0480f, 2.0000f, 0.9235f); |
| 245 | path.lineTo(1.9520f, 2.0000f); |
| 246 | path.close(); |
| 247 | path.moveTo(2.7140f, 3.1430f); |
| 248 | path.conicTo(3.0547f, 3.1287f, 3.2292f, 3.4216f, 0.8590f); |
| 249 | path.conicTo(3.4038f, 3.7145f, 3.2292f, 4.0074f, 0.8590f); |
| 250 | path.conicTo(3.0547f, 4.3003f, 2.7140f, 4.2860f, 0.8590f); |
| 251 | path.conicTo(2.1659f, 4.2631f, 2.1659f, 3.7145f, 0.7217f); |
| 252 | path.conicTo(2.1659f, 3.1659f, 2.7140f, 3.1430f, 0.7217f); |
| 253 | path.lineTo(2.7140f, 3.1430f); |
| 254 | path.close(); |
| 255 | path.moveTo(5.0000f, 3.1430f); |
| 256 | path.conicTo(5.3407f, 3.1287f, 5.5152f, 3.4216f, 0.8590f); |
| 257 | path.conicTo(5.6898f, 3.7145f, 5.5152f, 4.0074f, 0.8590f); |
| 258 | path.conicTo(5.3407f, 4.3003f, 5.0000f, 4.2860f, 0.8590f); |
| 259 | path.conicTo(4.4519f, 4.2631f, 4.4519f, 3.7145f, 0.7217f); |
| 260 | path.conicTo(4.4519f, 3.1659f, 5.0000f, 3.1430f, 0.7217f); |
| 261 | path.lineTo(5.0000f, 3.1430f); |
| 262 | path.close(); |
| 263 | path.moveTo(7.2860f, 3.1430f); |
| 264 | path.conicTo(7.6267f, 3.1287f, 7.8012f, 3.4216f, 0.8590f); |
| 265 | path.conicTo(7.9758f, 3.7145f, 7.8012f, 4.0074f, 0.8590f); |
| 266 | path.conicTo(7.6267f, 4.3003f, 7.2860f, 4.2860f, 0.8590f); |
| 267 | path.conicTo(6.7379f, 4.2631f, 6.7379f, 3.7145f, 0.7217f); |
| 268 | path.conicTo(6.7379f, 3.1659f, 7.2860f, 3.1430f, 0.7217f); |
| 269 | path.close(); |
| 270 | path.moveTo(1.0000f, 6.1900f); |
| 271 | path.lineTo(1.0000f, 14.3810f); |
| 272 | path.conicTo(0.9992f, 14.7757f, 1.2782f, 15.0548f, 0.9235f); |
| 273 | path.conicTo(1.5573f, 15.3338f, 1.9520f, 15.3330f, 0.9235f); |
| 274 | path.lineTo(16.0480f, 15.3330f); |
| 275 | path.conicTo(16.4427f, 15.3338f, 16.7218f, 15.0548f, 0.9235f); |
| 276 | path.conicTo(17.0008f, 14.7757f, 17.0000f, 14.3810f, 0.9235f); |
| 277 | path.lineTo(17.0000f, 6.1910f); |
| 278 | path.lineTo(1.0000f, 6.1910f); |
| 279 | path.lineTo(1.0000f, 6.1900f); |
| 280 | path.close(); |
| 281 | return path.detach(); |
Jim Van Verth | 33632d8 | 2017-02-28 10:24:39 -0500 | [diff] [blame] | 282 | } |
| 283 | |
mtklein | dbfd7ab | 2016-09-01 11:24:54 -0700 | [diff] [blame] | 284 | constexpr MakePathProc gProcs[] = { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 285 | make_frame, |
| 286 | make_triangle, |
| 287 | make_rect, |
| 288 | make_oval, |
Jim Van Verth | ecdb686 | 2016-12-13 18:17:47 -0500 | [diff] [blame] | 289 | make_sawtooth_32, |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 290 | make_star_5, |
vandebo@chromium.org | 683001c | 2012-05-09 17:17:51 +0000 | [diff] [blame] | 291 | make_star_13, |
| 292 | make_line, |
Jim Van Verth | ecdb686 | 2016-12-13 18:17:47 -0500 | [diff] [blame] | 293 | make_house, |
| 294 | make_sawtooth_3, |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 295 | }; |
| 296 | |
| 297 | #define N SK_ARRAY_COUNT(gProcs) |
| 298 | |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 299 | class PathFillGM : public skiagm::GM { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 300 | SkPath fPath[N]; |
| 301 | SkScalar fDY[N]; |
Jim Van Verth | 7704754 | 2017-01-11 14:17:00 -0500 | [diff] [blame] | 302 | SkPath fInfoPath; |
Jim Van Verth | f9e678d | 2017-02-15 15:46:52 -0500 | [diff] [blame] | 303 | SkPath fAccessibilityPath; |
Jim Van Verth | 33632d8 | 2017-02-28 10:24:39 -0500 | [diff] [blame] | 304 | SkPath fVisualizerPath; |
caryclark | 88c748a | 2015-02-18 10:56:00 -0800 | [diff] [blame] | 305 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 306 | void onOnceBeforeDraw() override { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 307 | for (size_t i = 0; i < N; i++) { |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 308 | auto [path, dy] = gProcs[i](); |
| 309 | fPath[i] = path; |
| 310 | fDY[i] = dy; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 311 | } |
Jim Van Verth | 7704754 | 2017-01-11 14:17:00 -0500 | [diff] [blame] | 312 | |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 313 | fInfoPath = make_info(); |
| 314 | fAccessibilityPath = make_accessibility(); |
| 315 | fVisualizerPath = make_visualizer(); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 316 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 317 | |
commit-bot@chromium.org | a90c680 | 2014-04-30 13:20:45 +0000 | [diff] [blame] | 318 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 319 | SkString onShortName() override { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 320 | return SkString("pathfill"); |
| 321 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 322 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 323 | SkISize onISize() override { |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 324 | return SkISize::Make(640, 480); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 325 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 326 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 327 | void onDraw(SkCanvas* canvas) override { |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 328 | SkPaint paint; |
| 329 | paint.setAntiAlias(true); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 330 | |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 331 | for (size_t i = 0; i < N; i++) { |
| 332 | canvas->drawPath(fPath[i], paint); |
bungeman@google.com | 3c14d0f | 2011-05-20 14:05:03 +0000 | [diff] [blame] | 333 | canvas->translate(SkIntToScalar(0), fDY[i]); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 334 | } |
Jim Van Verth | 7704754 | 2017-01-11 14:17:00 -0500 | [diff] [blame] | 335 | |
Jim Van Verth | f9e678d | 2017-02-15 15:46:52 -0500 | [diff] [blame] | 336 | canvas->save(); |
Jim Van Verth | 7704754 | 2017-01-11 14:17:00 -0500 | [diff] [blame] | 337 | canvas->scale(0.300000011920929f, 0.300000011920929f); |
| 338 | canvas->translate(50, 50); |
| 339 | canvas->drawPath(fInfoPath, paint); |
Jim Van Verth | f9e678d | 2017-02-15 15:46:52 -0500 | [diff] [blame] | 340 | canvas->restore(); |
| 341 | |
| 342 | canvas->scale(2, 2); |
| 343 | canvas->translate(5, 15); |
| 344 | canvas->drawPath(fAccessibilityPath, paint); |
Jim Van Verth | 33632d8 | 2017-02-28 10:24:39 -0500 | [diff] [blame] | 345 | |
| 346 | canvas->scale(0.5f, 0.5f); |
| 347 | canvas->translate(5, 50); |
| 348 | canvas->drawPath(fVisualizerPath, paint); |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 349 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 350 | |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 351 | private: |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 352 | using INHERITED = skiagm::GM; |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 353 | }; |
| 354 | |
| 355 | // test inverse-fill w/ a clip that completely excludes the geometry |
| 356 | class PathInverseFillGM : public skiagm::GM { |
| 357 | SkPath fPath[N]; |
| 358 | SkScalar fDY[N]; |
caryclark | 88c748a | 2015-02-18 10:56:00 -0800 | [diff] [blame] | 359 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 360 | void onOnceBeforeDraw() override { |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 361 | for (size_t i = 0; i < N; i++) { |
Mike Reed | d16d654 | 2020-08-22 15:08:27 -0400 | [diff] [blame] | 362 | auto [path, dy] = gProcs[i](); |
| 363 | fPath[i] = path; |
| 364 | fDY[i] = dy; |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 365 | } |
| 366 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 367 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 368 | SkString onShortName() override { |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 369 | return SkString("pathinvfill"); |
| 370 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 371 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 372 | SkISize onISize() override { |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 373 | return SkISize::Make(450, 220); |
| 374 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 375 | |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 376 | static void show(SkCanvas* canvas, const SkPath& path, const SkPaint& paint, |
| 377 | const SkRect* clip, SkScalar top, const SkScalar bottom) { |
| 378 | canvas->save(); |
| 379 | if (clip) { |
| 380 | SkRect r = *clip; |
| 381 | r.fTop = top; |
| 382 | r.fBottom = bottom; |
| 383 | canvas->clipRect(r); |
| 384 | } |
| 385 | canvas->drawPath(path, paint); |
| 386 | canvas->restore(); |
| 387 | } |
| 388 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 389 | void onDraw(SkCanvas* canvas) override { |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 390 | SkPath path = SkPathBuilder().addCircle(50, 50, 40) |
| 391 | .toggleInverseFillType() |
| 392 | .detach(); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 393 | |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 394 | SkRect clipR = {0, 0, 100, 200}; |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 395 | |
Mike Reed | 92f6eb1 | 2020-08-25 11:48:41 -0400 | [diff] [blame] | 396 | canvas->translate(10, 10); |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 397 | |
| 398 | for (int doclip = 0; doclip <= 1; ++doclip) { |
| 399 | for (int aa = 0; aa <= 1; ++aa) { |
| 400 | SkPaint paint; |
| 401 | paint.setAntiAlias(SkToBool(aa)); |
| 402 | |
| 403 | canvas->save(); |
| 404 | canvas->clipRect(clipR); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 405 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 406 | const SkRect* clipPtr = doclip ? &clipR : nullptr; |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 407 | |
| 408 | show(canvas, path, paint, clipPtr, clipR.fTop, clipR.centerY()); |
| 409 | show(canvas, path, paint, clipPtr, clipR.centerY(), clipR.fBottom); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 410 | |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 411 | canvas->restore(); |
| 412 | canvas->translate(SkIntToScalar(110), 0); |
| 413 | } |
| 414 | } |
| 415 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 416 | |
reed@google.com | 5ee6491 | 2012-06-11 17:30:33 +0000 | [diff] [blame] | 417 | private: |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 418 | using INHERITED = skiagm::GM; |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 419 | }; |
| 420 | |
caryclark | e3e8c72 | 2016-03-01 09:42:03 -0800 | [diff] [blame] | 421 | DEF_SIMPLE_GM(rotatedcubicpath, canvas, 200, 200) { |
| 422 | SkPaint p; |
| 423 | p.setAntiAlias(true); |
| 424 | p.setStyle(SkPaint::kFill_Style); |
| 425 | |
| 426 | canvas->translate(50, 50); |
| 427 | SkPath path; |
| 428 | path.moveTo(48,-23); |
| 429 | path.cubicTo(48,-29.5, 6,-30, 6,-30); |
| 430 | path.cubicTo(6,-30, 2,0, 2,0); |
| 431 | path.cubicTo(2,0, 44,-21.5, 48,-23); |
| 432 | path.close(); |
| 433 | |
| 434 | p.setColor(SK_ColorBLUE); |
| 435 | canvas->drawPath(path, p); |
| 436 | |
| 437 | // Rotated path, which is not antialiased on GPU |
| 438 | p.setColor(SK_ColorRED); |
| 439 | canvas->rotate(90); |
| 440 | canvas->drawPath(path, p); |
| 441 | } |
| 442 | |
reed@google.com | c280700 | 2011-04-11 13:57:04 +0000 | [diff] [blame] | 443 | /////////////////////////////////////////////////////////////////////////////// |
| 444 | |
scroggo | 96f16e8 | 2015-12-10 13:31:59 -0800 | [diff] [blame] | 445 | DEF_GM( return new PathFillGM; ) |
| 446 | DEF_GM( return new PathInverseFillGM; ) |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 447 | |
Cary Clark | 4eb6f7a | 2018-04-17 13:34:37 -0400 | [diff] [blame] | 448 | DEF_SIMPLE_GM(bug7792, canvas, 800, 800) { |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 449 | // from skbug.com/7792 bug description |
| 450 | SkPaint p; |
| 451 | SkPath path; |
| 452 | path.moveTo(10, 10); |
| 453 | path.moveTo(75, 75); |
| 454 | path.lineTo(150, 75); |
| 455 | path.lineTo(150, 150); |
| 456 | path.lineTo(75, 150); |
| 457 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 458 | // from skbug.com/7792#c3 |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 459 | canvas->translate(200, 0); |
| 460 | path.reset(); |
| 461 | path.moveTo(75, 50); |
| 462 | path.moveTo(100, 75); |
| 463 | path.lineTo(150, 75); |
| 464 | path.lineTo(150, 150); |
| 465 | path.lineTo(75, 150); |
| 466 | path.lineTo(75, 50); |
| 467 | path.close(); |
| 468 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 469 | // from skbug.com/7792#c9 |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 470 | canvas->translate(200, 0); |
| 471 | path.reset(); |
| 472 | path.moveTo(10, 10); |
| 473 | path.moveTo(75, 75); |
| 474 | path.lineTo(150, 75); |
| 475 | path.lineTo(150, 150); |
| 476 | path.lineTo(75, 150); |
| 477 | path.close(); |
| 478 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 479 | // from skbug.com/7792#c11 |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 480 | canvas->translate(-200 * 2, 200); |
| 481 | path.reset(); |
| 482 | path.moveTo(75, 150); |
| 483 | path.lineTo(75, 75); |
| 484 | path.lineTo(150, 75); |
| 485 | path.lineTo(150, 150); |
| 486 | path.lineTo(75, 150); |
| 487 | path.moveTo(75, 150); |
| 488 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 489 | // from skbug.com/7792#c14 |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 490 | canvas->translate(200, 0); |
| 491 | path.reset(); |
| 492 | path.moveTo(250, 75); |
| 493 | path.moveTo(250, 75); |
| 494 | path.moveTo(250, 75); |
| 495 | path.moveTo(100, 75); |
| 496 | path.lineTo(150, 75); |
| 497 | path.lineTo(150, 150); |
| 498 | path.lineTo(75, 150); |
| 499 | path.lineTo(75, 75); |
| 500 | path.close(); |
| 501 | path.lineTo(0, 0); |
| 502 | path.close(); |
| 503 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 504 | // from skbug.com/7792#c15 |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 505 | canvas->translate(200, 0); |
| 506 | path.reset(); |
| 507 | path.moveTo(75, 75); |
| 508 | path.lineTo(150, 75); |
| 509 | path.lineTo(150, 150); |
| 510 | path.lineTo(75, 150); |
| 511 | path.moveTo(250, 75); |
| 512 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 513 | // from skbug.com/7792#c17 |
Cary Clark | 31608c0 | 2018-04-12 10:29:46 -0400 | [diff] [blame] | 514 | canvas->translate(-200 * 2, 200); |
| 515 | path.reset(); |
| 516 | path.moveTo(75, 10); |
| 517 | path.moveTo(75, 75); |
| 518 | path.lineTo(150, 75); |
| 519 | path.lineTo(150, 150); |
| 520 | path.lineTo(75, 150); |
| 521 | path.lineTo(75, 10); |
| 522 | path.close(); |
| 523 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 524 | // from skbug.com/7792#c19 |
Cary Clark | 88ba971 | 2018-04-12 14:00:24 -0400 | [diff] [blame] | 525 | canvas->translate(200, 0); |
| 526 | path.reset(); |
| 527 | path.moveTo(75, 75); |
| 528 | path.lineTo(75, 75); |
| 529 | path.lineTo(75, 75); |
| 530 | path.lineTo(75, 75); |
| 531 | path.lineTo(150, 75); |
| 532 | path.lineTo(150, 150); |
| 533 | path.lineTo(75, 150); |
| 534 | path.close(); |
| 535 | path.moveTo(10, 10); |
| 536 | path.lineTo(30, 10); |
| 537 | path.lineTo(10, 30); |
| 538 | canvas->drawPath(path, p); |
Cary Clark | d422847 | 2018-04-13 07:07:04 -0400 | [diff] [blame] | 539 | // from skbug.com/7792#c23 |
| 540 | canvas->translate(200, 0); |
| 541 | path.reset(); |
| 542 | path.moveTo(75, 75); |
| 543 | path.lineTo(75, 75); |
| 544 | path.moveTo(75, 75); |
| 545 | path.lineTo(75, 75); |
| 546 | path.lineTo(150, 75); |
| 547 | path.lineTo(150, 150); |
| 548 | path.lineTo(75, 150); |
| 549 | path.close(); |
| 550 | canvas->drawPath(path, p); |
Cary Clark | 48c464a | 2018-04-16 12:06:07 -0400 | [diff] [blame] | 551 | // from skbug.com/7792#c29 |
| 552 | canvas->translate(-200 * 2, 200); |
| 553 | path.reset(); |
| 554 | path.moveTo(75, 75); |
| 555 | path.lineTo(150, 75); |
| 556 | path.lineTo(150, 150); |
| 557 | path.lineTo(75, 150); |
| 558 | path.lineTo(75, 250); |
| 559 | path.moveTo(75, 75); |
| 560 | path.close(); |
| 561 | canvas->drawPath(path, p); |
Cary Clark | a765156 | 2018-04-17 09:30:14 -0400 | [diff] [blame] | 562 | // from skbug.com/7792#c31 |
| 563 | canvas->translate(200, 0); |
| 564 | path.reset(); |
| 565 | path.moveTo(75, 75); |
| 566 | path.lineTo(150, 75); |
| 567 | path.lineTo(150, 150); |
| 568 | path.lineTo(75, 150); |
| 569 | path.lineTo(75, 10); |
| 570 | path.moveTo(75, 75); |
| 571 | path.close(); |
| 572 | canvas->drawPath(path, p); |
Cary Clark | 1cd6098 | 2018-04-17 11:53:34 -0400 | [diff] [blame] | 573 | // from skbug.com/7792#c36 |
| 574 | canvas->translate(200, 0); |
| 575 | path.reset(); |
| 576 | path.moveTo(75, 75); |
| 577 | path.lineTo(150, 75); |
| 578 | path.lineTo(150, 150); |
| 579 | path.lineTo(10, 150); |
| 580 | path.moveTo(75, 75); |
| 581 | path.lineTo(75, 75); |
| 582 | canvas->drawPath(path, p); |
Cary Clark | 4eb6f7a | 2018-04-17 13:34:37 -0400 | [diff] [blame] | 583 | // from skbug.com/7792#c39 |
| 584 | canvas->translate(200, -200 * 3); |
| 585 | path.reset(); |
| 586 | path.moveTo(150, 75); |
| 587 | path.lineTo(150, 150); |
| 588 | path.lineTo(75, 150); |
| 589 | path.lineTo(75, 100); |
| 590 | canvas->drawPath(path, p); |
Cary Clark | b120e92 | 2018-04-18 12:25:08 -0400 | [diff] [blame] | 591 | // from zero_length_paths_aa |
| 592 | canvas->translate(0, 200); |
| 593 | path.reset(); |
| 594 | path.moveTo(150, 100); |
| 595 | path.lineTo(150, 100); |
| 596 | path.lineTo(150, 150); |
| 597 | path.lineTo(75, 150); |
| 598 | path.lineTo(75, 100); |
| 599 | path.lineTo(75, 75); |
| 600 | path.lineTo(150, 75); |
| 601 | path.close(); |
| 602 | canvas->drawPath(path, p); |
Cary Clark | dbc59ba | 2018-04-19 07:37:29 -0400 | [diff] [blame] | 603 | // from skbug.com/7792#c41 |
| 604 | canvas->translate(0, 200); |
| 605 | path.reset(); |
| 606 | path.moveTo(75, 75); |
| 607 | path.lineTo(150, 75); |
| 608 | path.lineTo(150, 150); |
| 609 | path.lineTo(140, 150); |
| 610 | path.lineTo(140, 75); |
| 611 | path.moveTo(75, 75); |
| 612 | path.close(); |
| 613 | canvas->drawPath(path, p); |
| 614 | // from skbug.com/7792#c53 |
| 615 | canvas->translate(0, 200); |
| 616 | path.reset(); |
| 617 | path.moveTo(75, 75); |
| 618 | path.lineTo(150, 75); |
| 619 | path.lineTo(150, 150); |
| 620 | path.lineTo(140, 150); |
| 621 | path.lineTo(140, 75); |
| 622 | path.moveTo(75, 75); |
| 623 | path.close(); |
| 624 | canvas->drawPath(path, p); |
Cary Clark | 8540e11 | 2018-04-11 14:30:27 -0400 | [diff] [blame] | 625 | } |
Mike Reed | 1ae3e75 | 2020-04-26 17:20:22 -0400 | [diff] [blame] | 626 | |
| 627 | #include "include/core/SkSurface.h" |
| 628 | |
| 629 | DEF_SIMPLE_GM(path_stroke_clip_crbug1070835, canvas, 25, 50) { |
| 630 | SkCanvas* orig = canvas; |
| 631 | auto surf = SkSurface::MakeRasterN32Premul(25, 25); |
| 632 | canvas = surf->getCanvas(); |
| 633 | |
| 634 | SkPaint p; |
| 635 | p.setColor(SK_ColorRED); |
| 636 | p.setAntiAlias(true); |
| 637 | p.setStyle(SkPaint::kStroke_Style); |
| 638 | p.setStrokeWidth(2); |
| 639 | |
| 640 | canvas->scale(4.16666651f/2, 4.16666651f/2); |
| 641 | |
| 642 | SkPath path; |
| 643 | |
| 644 | SkPoint pts[] = { |
| 645 | {11, 12}, |
| 646 | {11, 18.0751324f}, |
| 647 | {6.07513189f, 23}, |
| 648 | {-4.80825292E-7f, 23}, |
| 649 | {-6.07513332f, 23}, |
| 650 | {-11, 18.0751324f}, |
| 651 | {-11, 11.999999f}, |
| 652 | {-10.999999f, 5.92486763f}, |
| 653 | {-6.07513189f, 1}, |
| 654 | {1.31173692E-7f, 1}, |
| 655 | {6.07513141f, 1}, |
| 656 | {10.9999981f, 5.92486572f}, |
| 657 | {11, 11.9999971f}, |
| 658 | }; |
| 659 | path.moveTo(pts[0]).cubicTo(pts[1], pts[2], pts[3]) |
| 660 | .cubicTo(pts[4], pts[5], pts[6]) |
| 661 | .cubicTo(pts[7], pts[8], pts[9]) |
| 662 | .cubicTo(pts[10],pts[11],pts[12]); |
| 663 | |
| 664 | canvas->drawPath(path, p); |
| 665 | |
Mike Reed | b746b1f | 2021-01-06 08:43:51 -0500 | [diff] [blame] | 666 | surf->draw(orig, 0, 0); |
Mike Reed | 1ae3e75 | 2020-04-26 17:20:22 -0400 | [diff] [blame] | 667 | } |
Mike Reed | 3c411f5 | 2020-04-28 15:17:48 -0400 | [diff] [blame] | 668 | |
| 669 | DEF_SIMPLE_GM(path_arcto_skbug_9077, canvas, 200, 200) { |
| 670 | SkPaint p; |
| 671 | p.setColor(SK_ColorRED); |
| 672 | p.setAntiAlias(true); |
| 673 | p.setStyle(SkPaint::kStroke_Style); |
| 674 | p.setStrokeWidth(2); |
| 675 | |
Mike Reed | cfb130c | 2020-08-03 11:02:20 -0400 | [diff] [blame] | 676 | SkPathBuilder path; |
Mike Reed | 3c411f5 | 2020-04-28 15:17:48 -0400 | [diff] [blame] | 677 | SkPoint pts[] = { {20, 20}, {100, 20}, {100, 60}, {130, 150}, {180, 160} }; |
| 678 | SkScalar radius = 60; |
| 679 | path.moveTo(pts[0]); |
| 680 | path.lineTo(pts[1]); |
| 681 | path.lineTo(pts[2]); |
| 682 | path.close(); |
| 683 | path.arcTo(pts[3], pts[4], radius); |
Mike Reed | cfb130c | 2020-08-03 11:02:20 -0400 | [diff] [blame] | 684 | canvas->drawPath(path.detach(), p); |
Mike Reed | 3c411f5 | 2020-04-28 15:17:48 -0400 | [diff] [blame] | 685 | } |
Michael Ludwig | 3e8ff3e | 2021-04-23 15:47:14 -0400 | [diff] [blame] | 686 | |
| 687 | DEF_SIMPLE_GM(path_skbug_11859, canvas, 512, 512) { |
| 688 | SkPaint paint; |
| 689 | paint.setColor(SK_ColorRED); |
| 690 | paint.setAntiAlias(true); |
| 691 | |
| 692 | SkPath path; |
| 693 | path.moveTo(258, -2); |
| 694 | path.lineTo(258, 258); |
| 695 | path.lineTo(237, 258); |
| 696 | path.lineTo(240, -2); |
| 697 | path.lineTo(258, -2); |
| 698 | path.moveTo(-2, -2); |
| 699 | path.lineTo(240, -2); |
| 700 | path.lineTo(238, 131); |
| 701 | path.lineTo(-2, 131); |
| 702 | path.lineTo(-2, -2); |
| 703 | |
| 704 | canvas->scale(2, 2); |
| 705 | canvas->drawPath(path, paint); |
| 706 | } |
Michael Ludwig | 4e9d5e2 | 2021-05-11 10:00:12 -0400 | [diff] [blame] | 707 | |
| 708 | DEF_SIMPLE_GM(path_skbug_11886, canvas, 256, 256) { |
| 709 | SkPoint m = {0.f, 770.f}; |
| 710 | SkPath path; |
| 711 | path.moveTo(m); |
| 712 | path.cubicTo(m + SkPoint{0.f, 1.f}, m + SkPoint{20.f, -750.f}, m + SkPoint{83.f, -746.f}); |
| 713 | SkPaint paint; |
| 714 | paint.setAntiAlias(true); |
| 715 | canvas->drawPath(path, paint); |
| 716 | } |