Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
third_party
skia
gm
crbug_996140.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2019 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/SkColor.h
"
11
#include "
include/core/SkPaint.h
"
12
#include "
include/core/SkPathBuilder.h
"
13
14
/*
15
* Canvas example. Expected large blue stroked circle, white middle, small red circle.
16
* GPU-accelerated canvas produces large blue stroked circle, white middle, NO red circle.
17
*
18
* 1: var c = document.getElementById("myCanvas");
19
* 2: var ctx = c.getContext("2d");
20
* 3: ctx.beginPath();
21
* 4: ctx.scale(203.20, 203.20);
22
* 5: ctx.translate(-14.55, -711.51);
23
* 6: ctx.fillStyle = "red";
24
* 7: ctx.strokeStyle = "blue";
25
* 8: //ctx.lineWidth = 1/203.20;
26
* 9: ctx.arc(19.221, 720-6.76,0.0295275590551181,0,2*Math.PI);
27
* 10: ctx.stroke();
28
* 11: ctx.fill();
29
* 12: ctx.closePath();
30
*/
31
DEF_SIMPLE_GM_BG
(crbug_996140, canvas, 300, 300,
SK_ColorWHITE
) {
32
// Specific parameters taken from the canvas minimum working example
33
SkScalar
cx = 19.221f;
34
SkScalar
cy = 720-6.76f;
35
SkScalar
radius = 0.0295275590551181f;
36
37
SkScalar
s
= 203.20f;
38
SkScalar
tx = -14.55f;
39
SkScalar
ty = -711.51f;
40
41
// 0: The test canvas was 1920x574 and the circle was located in the bottom left, but that's
42
// not necessary to reproduce the problem, so translate to make a smaller GM.
43
canvas->translate(-800, -200);
44
45
// 3: ctx.beginPath();
46
47
// 4: ctx.scale(203.20, 203.20);
48
canvas->scale(
s
,
s
);
49
// 5: ctx.translate(-14.55, -711.51);
50
canvas->translate(tx, ty);
51
52
// 6: ctx.fillStyle = "red";
53
SkPaint
fill;
54
fill.
setColor
(
SK_ColorRED
);
55
fill.
setStyle
(
SkPaint::kFill_Style
);
56
fill.
setAntiAlias
(
true
);
57
58
// 7: ctx.strokeStyle = "blue";
59
SkPaint
stroke;
60
stroke.
setColor
(
SK_ColorBLUE
);
61
stroke.
setStrokeWidth
(1.f);
62
stroke.
setStyle
(
SkPaint::kStroke_Style
);
63
stroke.
setAntiAlias
(
true
);
64
65
// 9: ctx.arc(19.221, 720-6.76,0.0295275590551181,0,2*Math.PI);
66
// This matches how Canvas prepares an arc(x, y, radius, 0, 2pi) call
67
SkRect
boundingBox =
SkRect::MakeLTRB
(cx - radius, cy - radius, cx + radius, cy + radius);
68
69
auto
path =
SkPathBuilder
().
arcTo
(boundingBox, 0, 180.f,
false
)
70
.
arcTo
(boundingBox, 180.f, 180.f,
false
)
71
.
detach
();
72
73
// 12: ctx.closePath();
74
// path.close();
75
76
// 10: ctx.stroke(); (NOT NEEDED TO REPRODUCE FAILING RED CIRCLE)
77
canvas->drawPath(path, stroke);
78
// 11: ctx.fill()
79
canvas->drawPath(path, fill);
80
}
SkCanvas.h
SkColor.h
SK_ColorBLUE
constexpr SkColor SK_ColorBLUE
Definition
SkColor.h:135
SK_ColorRED
constexpr SkColor SK_ColorRED
Definition
SkColor.h:126
SK_ColorWHITE
constexpr SkColor SK_ColorWHITE
Definition
SkColor.h:122
SkPaint.h
SkPathBuilder.h
SkPaint
Definition
SkPaint.h:44
SkPaint::setStyle
void setStyle(Style style)
Definition
SkPaint.cpp:105
SkPaint::setColor
void setColor(SkColor color)
Definition
SkPaint.cpp:119
SkPaint::setAntiAlias
void setAntiAlias(bool aa)
Definition
SkPaint.h:170
SkPaint::kStroke_Style
@ kStroke_Style
set to stroke geometry
Definition
SkPaint.h:194
SkPaint::kFill_Style
@ kFill_Style
set to fill geometry
Definition
SkPaint.h:193
SkPaint::setStrokeWidth
void setStrokeWidth(SkScalar width)
Definition
SkPaint.cpp:159
SkPathBuilder
Definition
SkPathBuilder.h:25
SkPathBuilder::arcTo
SkPathBuilder & arcTo(const SkRect &oval, SkScalar startAngleDeg, SkScalar sweepAngleDeg, bool forceMoveTo)
Definition
SkPathBuilder.cpp:331
SkPathBuilder::detach
SkPath detach()
Definition
SkPathBuilder.cpp:239
SkScalar
float SkScalar
Definition
extension.cpp:12
s
struct MyStruct s
gm.h
DEF_SIMPLE_GM_BG
#define DEF_SIMPLE_GM_BG(NAME, CANVAS, W, H, BGCOLOR)
Definition
gm.h:52
SkRect
Definition
extension.cpp:13
SkRect::MakeLTRB
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition
SkRect.h:646
Generated on Fri Apr 26 2024 06:16:02 for Flutter Engine by
1.9.8