robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
| 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/SkMatrix.h" |
| 12 | #include "include/core/SkPaint.h" |
| 13 | #include "include/core/SkPath.h" |
| 14 | #include "include/core/SkPoint.h" |
| 15 | #include "include/core/SkRect.h" |
| 16 | #include "include/core/SkScalar.h" |
| 17 | #include "include/core/SkSize.h" |
| 18 | #include "include/core/SkString.h" |
| 19 | #include "include/core/SkTypes.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/core/SkPathPriv.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 21 | |
| 22 | #include <memory> |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 23 | |
| 24 | static void create_ngon(int n, SkPoint* pts, SkScalar width, SkScalar height) { |
Brian Osman | 4428f2c | 2019-04-02 10:59:28 -0400 | [diff] [blame] | 25 | float angleStep = 360.0f / n, angle = 0.0f; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 26 | if ((n % 2) == 1) { |
| 27 | angle = angleStep/2.0f; |
| 28 | } |
| 29 | |
| 30 | for (int i = 0; i < n; ++i) { |
Brian Osman | 4428f2c | 2019-04-02 10:59:28 -0400 | [diff] [blame] | 31 | pts[i].fX = -SkScalarSin(SkDegreesToRadians(angle)) * width; |
| 32 | pts[i].fY = SkScalarCos(SkDegreesToRadians(angle)) * height; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 33 | angle += angleStep; |
| 34 | } |
| 35 | } |
| 36 | |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 37 | namespace ConvexLineOnlyData { |
| 38 | // narrow rect |
| 39 | const SkPoint gPoints0[] = { |
| 40 | { -1.5f, -50.0f }, |
| 41 | { 1.5f, -50.0f }, |
| 42 | { 1.5f, 50.0f }, |
| 43 | { -1.5f, 50.0f } |
| 44 | }; |
| 45 | // narrow rect on an angle |
| 46 | const SkPoint gPoints1[] = { |
| 47 | { -50.0f, -49.0f }, |
| 48 | { -49.0f, -50.0f }, |
| 49 | { 50.0f, 49.0f }, |
| 50 | { 49.0f, 50.0f } |
| 51 | }; |
| 52 | // trap - narrow on top - wide on bottom |
| 53 | const SkPoint gPoints2[] = { |
| 54 | { -10.0f, -50.0f }, |
| 55 | { 10.0f, -50.0f }, |
| 56 | { 50.0f, 50.0f }, |
| 57 | { -50.0f, 50.0f } |
| 58 | }; |
| 59 | // wide skewed rect |
| 60 | const SkPoint gPoints3[] = { |
| 61 | { -50.0f, -50.0f }, |
| 62 | { 0.0f, -50.0f }, |
| 63 | { 50.0f, 50.0f }, |
| 64 | { 0.0f, 50.0f } |
| 65 | }; |
| 66 | // thin rect with colinear-ish lines |
| 67 | const SkPoint gPoints4[] = { |
| 68 | { -6.0f, -50.0f }, |
| 69 | { 4.0f, -50.0f }, |
Cary Clark | c9b7c72 | 2018-12-12 14:50:23 -0500 | [diff] [blame] | 70 | { 5.0f, -25.0f }, // remove if collinear diagonal points are not concave |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 71 | { 6.0f, 0.0f }, |
Cary Clark | c9b7c72 | 2018-12-12 14:50:23 -0500 | [diff] [blame] | 72 | { 5.0f, 25.0f }, // remove if collinear diagonal points are not concave |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 73 | { 4.0f, 50.0f }, |
| 74 | { -4.0f, 50.0f } |
| 75 | }; |
| 76 | // degenerate |
| 77 | const SkPoint gPoints5[] = { |
| 78 | { -0.025f, -0.025f }, |
| 79 | { 0.025f, -0.025f }, |
| 80 | { 0.025f, 0.025f }, |
| 81 | { -0.025f, 0.025f } |
| 82 | }; |
| 83 | // Triangle in which the first point should fuse with last |
| 84 | const SkPoint gPoints6[] = { |
| 85 | { -20.0f, -13.0f }, |
| 86 | { -20.0f, -13.05f }, |
| 87 | { 20.0f, -13.0f }, |
| 88 | { 20.0f, 27.0f } |
| 89 | }; |
| 90 | // thin rect with colinear lines |
| 91 | const SkPoint gPoints7[] = { |
| 92 | { -10.0f, -50.0f }, |
| 93 | { 10.0f, -50.0f }, |
| 94 | { 10.0f, -25.0f }, |
| 95 | { 10.0f, 0.0f }, |
| 96 | { 10.0f, 25.0f }, |
| 97 | { 10.0f, 50.0f }, |
| 98 | { -10.0f, 50.0f } |
| 99 | }; |
| 100 | // capped teardrop |
| 101 | const SkPoint gPoints8[] = { |
| 102 | { 50.00f, 50.00f }, |
| 103 | { 0.00f, 50.00f }, |
| 104 | { -15.45f, 47.55f }, |
| 105 | { -29.39f, 40.45f }, |
| 106 | { -40.45f, 29.39f }, |
| 107 | { -47.55f, 15.45f }, |
| 108 | { -50.00f, 0.00f }, |
| 109 | { -47.55f, -15.45f }, |
| 110 | { -40.45f, -29.39f }, |
| 111 | { -29.39f, -40.45f }, |
| 112 | { -15.45f, -47.55f }, |
| 113 | { 0.00f, -50.00f }, |
| 114 | { 50.00f, -50.00f } |
| 115 | }; |
| 116 | // teardrop |
| 117 | const SkPoint gPoints9[] = { |
| 118 | { 4.39f, 40.45f }, |
| 119 | { -9.55f, 47.55f }, |
| 120 | { -25.00f, 50.00f }, |
| 121 | { -40.45f, 47.55f }, |
| 122 | { -54.39f, 40.45f }, |
| 123 | { -65.45f, 29.39f }, |
| 124 | { -72.55f, 15.45f }, |
| 125 | { -75.00f, 0.00f }, |
| 126 | { -72.55f, -15.45f }, |
| 127 | { -65.45f, -29.39f }, |
| 128 | { -54.39f, -40.45f }, |
| 129 | { -40.45f, -47.55f }, |
| 130 | { -25.0f, -50.0f }, |
| 131 | { -9.55f, -47.55f }, |
| 132 | { 4.39f, -40.45f }, |
| 133 | { 75.00f, 0.00f } |
| 134 | }; |
| 135 | // clipped triangle |
| 136 | const SkPoint gPoints10[] = { |
| 137 | { -10.0f, -50.0f }, |
| 138 | { 10.0f, -50.0f }, |
| 139 | { 50.0f, 31.0f }, |
| 140 | { 40.0f, 50.0f }, |
| 141 | { -40.0f, 50.0f }, |
| 142 | { -50.0f, 31.0f }, |
| 143 | }; |
| 144 | |
| 145 | const SkPoint* gPoints[] = { |
| 146 | gPoints0, gPoints1, gPoints2, gPoints3, gPoints4, gPoints5, gPoints6, |
| 147 | gPoints7, gPoints8, gPoints9, gPoints10, |
| 148 | }; |
| 149 | |
| 150 | const size_t gSizes[] = { |
| 151 | SK_ARRAY_COUNT(gPoints0), |
| 152 | SK_ARRAY_COUNT(gPoints1), |
| 153 | SK_ARRAY_COUNT(gPoints2), |
| 154 | SK_ARRAY_COUNT(gPoints3), |
| 155 | SK_ARRAY_COUNT(gPoints4), |
| 156 | SK_ARRAY_COUNT(gPoints5), |
| 157 | SK_ARRAY_COUNT(gPoints6), |
| 158 | SK_ARRAY_COUNT(gPoints7), |
| 159 | SK_ARRAY_COUNT(gPoints8), |
| 160 | SK_ARRAY_COUNT(gPoints9), |
| 161 | SK_ARRAY_COUNT(gPoints10), |
| 162 | }; |
| 163 | static_assert(SK_ARRAY_COUNT(gSizes) == SK_ARRAY_COUNT(gPoints), "array_mismatch"); |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 164 | } // namespace ConvexLineOnlyData |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 165 | |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 166 | namespace skiagm { |
| 167 | |
| 168 | // This GM is intended to exercise Ganesh's handling of convex line-only |
| 169 | // paths |
| 170 | class ConvexLineOnlyPathsGM : public GM { |
| 171 | public: |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 172 | ConvexLineOnlyPathsGM(bool doStrokeAndFill) : fDoStrokeAndFill(doStrokeAndFill) { |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 173 | this->setBGColor(0xFFFFFFFF); |
| 174 | } |
| 175 | |
| 176 | protected: |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 177 | SkString onShortName() override { |
| 178 | if (fDoStrokeAndFill) { |
| 179 | return SkString("convex-lineonly-paths-stroke-and-fill"); |
| 180 | } |
| 181 | return SkString("convex-lineonly-paths"); |
| 182 | } |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 183 | SkISize onISize() override { return SkISize::Make(kGMWidth, kGMHeight); } |
| 184 | bool runAsBench() const override { return true; } |
| 185 | |
Mike Reed | 30bc527 | 2019-11-22 18:34:02 +0000 | [diff] [blame] | 186 | static SkPath GetPath(int index, SkPathDirection dir) { |
Ben Wagner | 7ecc596 | 2016-11-02 17:07:33 -0400 | [diff] [blame] | 187 | std::unique_ptr<SkPoint[]> data(nullptr); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 188 | const SkPoint* points; |
| 189 | int numPts; |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 190 | if (index < (int) SK_ARRAY_COUNT(ConvexLineOnlyData::gPoints)) { |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 191 | // manually specified |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 192 | points = ConvexLineOnlyData::gPoints[index]; |
| 193 | numPts = (int)ConvexLineOnlyData::gSizes[index]; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 194 | } else { |
| 195 | // procedurally generated |
| 196 | SkScalar width = kMaxPathHeight/2; |
| 197 | SkScalar height = kMaxPathHeight/2; |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 198 | switch (index-SK_ARRAY_COUNT(ConvexLineOnlyData::gPoints)) { |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 199 | case 0: |
| 200 | numPts = 3; |
| 201 | break; |
| 202 | case 1: |
| 203 | numPts = 4; |
| 204 | break; |
| 205 | case 2: |
| 206 | numPts = 5; |
| 207 | break; |
| 208 | case 3: // squashed pentagon |
| 209 | numPts = 5; |
| 210 | width = kMaxPathHeight/5; |
| 211 | break; |
| 212 | case 4: |
| 213 | numPts = 6; |
| 214 | break; |
| 215 | case 5: |
| 216 | numPts = 8; |
| 217 | break; |
| 218 | case 6: // squashed octogon |
| 219 | numPts = 8; |
| 220 | width = kMaxPathHeight/5; |
| 221 | break; |
| 222 | case 7: |
| 223 | numPts = 20; |
| 224 | break; |
| 225 | case 8: |
| 226 | numPts = 100; |
| 227 | break; |
| 228 | default: |
| 229 | numPts = 3; |
| 230 | break; |
| 231 | } |
| 232 | |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 233 | data = std::make_unique<SkPoint[]>(numPts); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 234 | |
| 235 | create_ngon(numPts, data.get(), width, height); |
| 236 | points = data.get(); |
| 237 | } |
| 238 | |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 239 | SkPathBuilder builder; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 240 | |
Mike Reed | 30bc527 | 2019-11-22 18:34:02 +0000 | [diff] [blame] | 241 | if (SkPathDirection::kCW == dir) { |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 242 | builder.moveTo(points[0]); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 243 | for (int i = 1; i < numPts; ++i) { |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 244 | builder.lineTo(points[i]); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 245 | } |
| 246 | } else { |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 247 | builder.moveTo(points[numPts-1]); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 248 | for (int i = numPts-2; i >= 0; --i) { |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 249 | builder.lineTo(points[i]); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 253 | builder.close(); |
| 254 | SkPath path = builder.detach(); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 255 | #ifdef SK_DEBUG |
| 256 | // Each path this method returns should be convex, only composed of |
| 257 | // lines, wound the right direction, and short enough to fit in one |
| 258 | // of the GMs rows. |
| 259 | SkASSERT(path.isConvex()); |
| 260 | SkASSERT(SkPath::kLine_SegmentMask == path.getSegmentMasks()); |
reed | 026beb5 | 2015-06-10 14:23:15 -0700 | [diff] [blame] | 261 | SkPathPriv::FirstDirection actualDir; |
| 262 | SkASSERT(SkPathPriv::CheapComputeFirstDirection(path, &actualDir)); |
| 263 | SkASSERT(SkPathPriv::AsFirstDirection(dir) == actualDir); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 264 | SkRect bounds = path.getBounds(); |
| 265 | SkASSERT(SkScalarNearlyEqual(bounds.centerX(), 0.0f)); |
| 266 | SkASSERT(bounds.height() <= kMaxPathHeight); |
| 267 | #endif |
| 268 | return path; |
| 269 | } |
| 270 | |
| 271 | // Draw a single path several times, shrinking it, flipping its direction |
| 272 | // and changing its start vertex each time. |
robertphillips | 2a97462 | 2015-05-08 07:08:13 -0700 | [diff] [blame] | 273 | void drawPath(SkCanvas* canvas, int index, SkPoint* offset) { |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 274 | |
| 275 | SkPoint center; |
| 276 | { |
Mike Reed | 30bc527 | 2019-11-22 18:34:02 +0000 | [diff] [blame] | 277 | SkPath path = GetPath(index, SkPathDirection::kCW); |
robertphillips | 2a97462 | 2015-05-08 07:08:13 -0700 | [diff] [blame] | 278 | if (offset->fX+path.getBounds().width() > kGMWidth) { |
| 279 | offset->fX = 0; |
| 280 | offset->fY += kMaxPathHeight; |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 281 | if (fDoStrokeAndFill) { |
| 282 | offset->fX += kStrokeWidth / 2.0f; |
| 283 | offset->fY += kStrokeWidth / 2.0f; |
| 284 | } |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 285 | } |
robertphillips | 2a97462 | 2015-05-08 07:08:13 -0700 | [diff] [blame] | 286 | center = { offset->fX + SkScalarHalf(path.getBounds().width()), offset->fY}; |
| 287 | offset->fX += path.getBounds().width(); |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 288 | if (fDoStrokeAndFill) { |
| 289 | offset->fX += kStrokeWidth; |
| 290 | } |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | const SkColor colors[2] = { SK_ColorBLACK, SK_ColorWHITE }; |
Mike Reed | 30bc527 | 2019-11-22 18:34:02 +0000 | [diff] [blame] | 294 | const SkPathDirection dirs[2] = { SkPathDirection::kCW, SkPathDirection::kCCW }; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 295 | const float scales[] = { 1.0f, 0.75f, 0.5f, 0.25f, 0.1f, 0.01f, 0.001f }; |
mtklein | dbfd7ab | 2016-09-01 11:24:54 -0700 | [diff] [blame] | 296 | const SkPaint::Join joins[3] = { SkPaint::kRound_Join, |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 297 | SkPaint::kBevel_Join, |
| 298 | SkPaint::kMiter_Join }; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 299 | |
| 300 | SkPaint paint; |
| 301 | paint.setAntiAlias(true); |
| 302 | |
| 303 | for (size_t i = 0; i < SK_ARRAY_COUNT(scales); ++i) { |
Brian Salomon | ab664fa | 2017-03-24 16:07:20 +0000 | [diff] [blame] | 304 | SkPath path = GetPath(index, dirs[i%2]); |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 305 | if (fDoStrokeAndFill) { |
| 306 | paint.setStyle(SkPaint::kStrokeAndFill_Style); |
| 307 | paint.setStrokeJoin(joins[i%3]); |
| 308 | paint.setStrokeWidth(SkIntToScalar(kStrokeWidth)); |
| 309 | } |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 310 | |
| 311 | canvas->save(); |
| 312 | canvas->translate(center.fX, center.fY); |
| 313 | canvas->scale(scales[i], scales[i]); |
| 314 | paint.setColor(colors[i%2]); |
| 315 | canvas->drawPath(path, paint); |
| 316 | canvas->restore(); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | void onDraw(SkCanvas* canvas) override { |
robertphillips | 2a97462 | 2015-05-08 07:08:13 -0700 | [diff] [blame] | 321 | // the right edge of the last drawn path |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 322 | SkPoint offset = { 0, SkScalarHalf(kMaxPathHeight) }; |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 323 | if (fDoStrokeAndFill) { |
| 324 | offset.fX += kStrokeWidth / 2.0f; |
| 325 | offset.fY += kStrokeWidth / 2.0f; |
| 326 | } |
robertphillips | 2a97462 | 2015-05-08 07:08:13 -0700 | [diff] [blame] | 327 | |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 328 | for (int i = 0; i < kNumPaths; ++i) { |
robertphillips | 2a97462 | 2015-05-08 07:08:13 -0700 | [diff] [blame] | 329 | this->drawPath(canvas, i, &offset); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 330 | } |
| 331 | |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 332 | { |
Brian Salomon | 0235c64 | 2018-08-31 12:04:18 -0400 | [diff] [blame] | 333 | // Repro for crbug.com/472723 (Missing AA on portions of graphic with GPU rasterization) |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 334 | |
| 335 | SkPaint p; |
| 336 | p.setAntiAlias(true); |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 337 | if (fDoStrokeAndFill) { |
| 338 | p.setStyle(SkPaint::kStrokeAndFill_Style); |
| 339 | p.setStrokeJoin(SkPaint::kMiter_Join); |
| 340 | p.setStrokeWidth(SkIntToScalar(kStrokeWidth)); |
| 341 | } |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 342 | |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 343 | SkPath p1 = SkPath::Polygon({ |
| 344 | {60.8522949f, 364.671021f}, |
| 345 | {59.4380493f, 364.671021f}, |
| 346 | {385.414276f, 690.647217f}, |
| 347 | {386.121399f, 689.940125f}, |
| 348 | }, false); |
Brian Salomon | 0235c64 | 2018-08-31 12:04:18 -0400 | [diff] [blame] | 349 | canvas->save(); |
| 350 | canvas->translate(356.0f, 50.0f); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 351 | canvas->drawPath(p1, p); |
Brian Salomon | 0235c64 | 2018-08-31 12:04:18 -0400 | [diff] [blame] | 352 | canvas->restore(); |
| 353 | |
| 354 | // Repro for crbug.com/869172 (SVG path incorrectly simplified when using GPU |
| 355 | // Rasterization). This will only draw anything in the stroke-and-fill version. |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 356 | SkPath p2 = SkPath::Polygon({ |
| 357 | {10.f, 0.f}, |
| 358 | {38.f, 0.f}, |
| 359 | {66.f, 0.f}, |
| 360 | {94.f, 0.f}, |
| 361 | {122.f, 0.f}, |
| 362 | {150.f, 0.f}, |
| 363 | {150.f, 0.f}, |
| 364 | {122.f, 0.f}, |
| 365 | {94.f, 0.f}, |
| 366 | {66.f, 0.f}, |
| 367 | {38.f, 0.f}, |
| 368 | {10.f, 0.f}, |
| 369 | }, true); |
Brian Salomon | 0235c64 | 2018-08-31 12:04:18 -0400 | [diff] [blame] | 370 | canvas->save(); |
| 371 | canvas->translate(0.0f, 500.0f); |
| 372 | canvas->drawPath(p2, p); |
| 373 | canvas->restore(); |
Brian Salomon | 8e449eb | 2018-09-05 15:08:49 -0400 | [diff] [blame] | 374 | |
| 375 | // Repro for crbug.com/856137. This path previously caused GrAAConvexTessellator to turn |
| 376 | // inset rings into outsets when adjacent bisector angles converged outside the previous |
| 377 | // ring due to accumulated error. |
Mike Reed | e9d783c | 2020-08-17 14:14:13 -0400 | [diff] [blame^] | 378 | SkPath p3 = SkPath::Polygon({ |
| 379 | {1184.96f, 982.557f}, |
| 380 | {1183.71f, 982.865f}, |
| 381 | {1180.99f, 982.734f}, |
| 382 | {1178.5f, 981.541f}, |
| 383 | {1176.35f, 979.367f}, |
| 384 | {1178.94f, 938.854f}, |
| 385 | {1181.35f, 936.038f}, |
| 386 | {1183.96f, 934.117f}, |
| 387 | {1186.67f, 933.195f}, |
| 388 | {1189.36f, 933.342f}, |
| 389 | {1191.58f, 934.38f}, |
| 390 | }, true, SkPathFillType::kEvenOdd); |
Brian Salomon | 8e449eb | 2018-09-05 15:08:49 -0400 | [diff] [blame] | 391 | canvas->save(); |
| 392 | SkMatrix m; |
| 393 | m.setAll(0.0893210843f, 0, 79.1197586f, 0, 0.0893210843f, 300, 0, 0, 1); |
| 394 | canvas->concat(m); |
| 395 | canvas->drawPath(p3, p); |
| 396 | canvas->restore(); |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | |
| 400 | private: |
mtklein | dbfd7ab | 2016-09-01 11:24:54 -0700 | [diff] [blame] | 401 | static constexpr int kStrokeWidth = 10; |
| 402 | static constexpr int kNumPaths = 20; |
| 403 | static constexpr int kMaxPathHeight = 100; |
| 404 | static constexpr int kGMWidth = 512; |
| 405 | static constexpr int kGMHeight = 512; |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 406 | |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 407 | bool fDoStrokeAndFill; |
| 408 | |
robertphillips | 7272935 | 2015-04-28 07:42:04 -0700 | [diff] [blame] | 409 | typedef GM INHERITED; |
| 410 | }; |
| 411 | |
| 412 | ////////////////////////////////////////////////////////////////////////////// |
| 413 | |
robertphillips | ad23446 | 2016-08-26 05:30:19 -0700 | [diff] [blame] | 414 | DEF_GM(return new ConvexLineOnlyPathsGM(false);) |
| 415 | DEF_GM(return new ConvexLineOnlyPathsGM(true);) |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 416 | } // namespace skiagm |