blob: 69fab47894b68eb13fb93aebedbd8700a3859e39 [file] [log] [blame]
Michael Ludwig43d8d232020-08-11 14:40:41 -04001/*
2 * Copyright 2020 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
8#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
10#include "include/core/SkPaint.h"
Mike Reede9d783c2020-08-17 14:14:13 -040011#include "include/core/SkPathBuilder.h"
Michael Ludwig43d8d232020-08-11 14:40:41 -040012
13// See crbug.com/1086705. The convex linearizing path renderer would collapse too many of the
14// very-near duplicate vertices and turn the path into a triangle. Since the stroke width is larger
15// than the radius of the circle, there's the separate issue of what to do when stroke
16// self-intersects
17DEF_SIMPLE_GM(crbug_1086705, canvas, 200, 200) {
18 SkPaint paint;
19 paint.setStyle(SkPaint::kStroke_Style);
20 paint.setStrokeWidth(5.f);
21 paint.setAntiAlias(true);
22
23 SkPoint circleVertices[700];
24 for (int i = 0; i < 700; ++i) {
25 SkScalar angleRads = 2 * SK_ScalarPI * i / 700.f;
26 circleVertices[i] = {100.f + 2.f * SkScalarCos(angleRads),
27 100.f + 2.f * SkScalarSin(angleRads)};
28 }
29
Mike Reede9d783c2020-08-17 14:14:13 -040030 SkPathBuilder circle;
Michael Ludwig43d8d232020-08-11 14:40:41 -040031 circle.moveTo(circleVertices[0]);
32 for (int i = 1; i < 700; ++i) {
33 circle.lineTo(circleVertices[i]);
34 }
35 circle.close();
36
Mike Reede9d783c2020-08-17 14:14:13 -040037 canvas->drawPath(circle.detach(), paint);
Michael Ludwig43d8d232020-08-11 14:40:41 -040038}