Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
crbug_1086705.cpp
Go to the documentation of this file.
1
/*
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
"
11
#include "
include/core/SkPathBuilder.h
"
12
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
17
DEF_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
30
SkPathBuilder
circle;
31
circle.
moveTo
(circleVertices[0]);
32
for
(
int
i = 1; i < 700; ++i) {
33
circle.
lineTo
(circleVertices[i]);
34
}
35
circle.
close
();
36
37
canvas->drawPath(circle.
detach
(),
paint
);
38
}
SkCanvas.h
SkPaint.h
SkPathBuilder.h
SkScalarSin
#define SkScalarSin(radians)
Definition
SkScalar.h:45
SkScalarCos
#define SkScalarCos(radians)
Definition
SkScalar.h:46
SK_ScalarPI
#define SK_ScalarPI
Definition
SkScalar.h:21
SkPaint
Definition
SkPaint.h:44
SkPaint::kStroke_Style
@ kStroke_Style
set to stroke geometry
Definition
SkPaint.h:194
SkPathBuilder
Definition
SkPathBuilder.h:25
SkPathBuilder::close
SkPathBuilder & close()
Definition
SkPathBuilder.cpp:155
SkPathBuilder::lineTo
SkPathBuilder & lineTo(SkPoint pt)
Definition
SkPathBuilder.cpp:107
SkPathBuilder::detach
SkPath detach()
Definition
SkPathBuilder.cpp:239
SkPathBuilder::moveTo
SkPathBuilder & moveTo(SkPoint pt)
Definition
SkPathBuilder.cpp:95
paint
const Paint & paint
Definition
color_source.cc:38
SkScalar
float SkScalar
Definition
extension.cpp:12
gm.h
DEF_SIMPLE_GM
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition
gm.h:50
SkPoint
Definition
SkPoint_impl.h:163
Generated on Fri Apr 26 2024 06:16:01 for Flutter Engine by
1.9.8