Flutter Engine
The Flutter Engine
Functions
ChromeMDRefreshTab.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (ChromeMDRefreshTab, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( ChromeMDRefreshTab  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file ChromeMDRefreshTab.cpp.

4 {
5SkPath GetBorderPath(float scale,
6 bool unscale_at_end,
7 bool extend_to_top,
8 float endcap_width,
9 const SkISize& size) {
10 // const float top = scale - 1;
11 const float right = size.fWidth * scale;
12 const float bottom = size.fHeight * scale;
13 const float scaled_endcap_radius = (endcap_width / 2) * scale;
14
16 path.moveTo(0, bottom - 1);
17 // bottom left
18 path.arcTo(scaled_endcap_radius - 1, scaled_endcap_radius - 1, 90, SkPath::kSmall_ArcSize,
19 SkPathDirection::kCCW, scaled_endcap_radius - 1,
20 bottom - 1 - scaled_endcap_radius);
21 // path.rLineTo(0, -1);
22 // path.rCubicTo(0.75 * scale, 0, 1.625 * scale, -0.5 * scale, 2 * scale,
23 // -1.5 * scale);
24 path.lineTo(scaled_endcap_radius - 1, scaled_endcap_radius + 1);
25 // path.lineTo((endcap_width - 2) * scale, top + 1.5 * scale);
26 // top left
27 path.arcTo(scaled_endcap_radius + 1, scaled_endcap_radius + 1, 90, SkPath::kSmall_ArcSize,
28 SkPathDirection::kCW, scaled_endcap_radius * 2, -1);
29
30 // if (extend_to_top) {
31 // Create the vertical extension by extending the side diagonals until
32 // they reach the top of the bounds.
33 // const float dy = 2.5 * scale - 1;
34 // const float dx = Tab::GetInverseDiagonalSlope() * dy;
35 // path.rLineTo(dx, -dy);
36 // path.lineTo(right - (endcap_width - 2) * scale - dx, 0);
37 // path.rLineTo(dx, dy);
38 //} else {
39 // path.rCubicTo(0.375 * scale, -scale, 1.25 * scale, -1.5 * scale, 2 * scale,
40 // -1.5 * scale);
41 // path.lineTo(right - endcap_width * scale, top);
42 // path.rCubicTo(0.75 * scale, 0, 1.625 * scale, 0.5 * scale, 2 * scale,
43 // 1.5 * scale);
44 //}
45 path.lineTo(right - scaled_endcap_radius * 2, -1);
46 // path.lineTo(right - 2 * scale, bottom - 1 - 1.5 * scale);
47
48 // top right
49 path.arcTo(scaled_endcap_radius + 1, scaled_endcap_radius + 1, 90, SkPath::kSmall_ArcSize,
50 SkPathDirection::kCW, right - scaled_endcap_radius + 1,
51 scaled_endcap_radius + 1);
52 // path.arcTo(SkRect::MakeLTRB(right - 2 * scale, bottom - 1 - 1.5 * scale,
53 // right - 2 * scale + 4, bottom - 1 - 1.5 * scale + 4), 90, 90, true);
54 // path.rCubicTo(0.375 * scale, scale, 1.25 * scale, 1.5 * scale, 2 * scale,
55 // 1.5 * scale);
56
57 path.lineTo(right - scaled_endcap_radius + 1, bottom - 1 - scaled_endcap_radius);
58 // path.rLineTo(0, 1);
59
60 // bottom right
61 path.arcTo(scaled_endcap_radius - 1, scaled_endcap_radius - 1, 90, SkPath::kSmall_ArcSize,
62 SkPathDirection::kCCW, right, bottom - 1);
63 path.close();
64
65 if (unscale_at_end && (scale != 1)) path.transform(SkMatrix::Scale(1.f / scale,
66 1.f / scale));
67
68 return path;
69}
70
71SkPath GetInteriorPath(
72 float scale, const SkISize& size, float endcap_width, float horizontal_inset = 0) {
73 const float right = size.fWidth * scale;
74 // The bottom of the tab needs to be pixel-aligned or else when we call
75 // ClipPath with anti-aliasing enabled it can cause artifacts.
76 const float bottom = std::ceil(size.fHeight * scale);
77
78 // const float scaled_horizontal_inset = horizontal_inset * scale;
79
80 const float scaled_endcap_radius = (endcap_width / 2) * scale;
81
82 // Construct the interior path by intersecting paths representing the left
83 // and right halves of the tab. Compared to computing the full path at once,
84 // this makes it easier to avoid overdraw in the top center near minimum
85 // width, and to implement cases where |horizontal_inset| != 0.
86 SkPath right_path;
87
88 right_path.moveTo(right, bottom);
89 // right_path.moveTo(right - 1 - scaled_horizontal_inset, bottom);
90
91 right_path.arcTo(scaled_endcap_radius, scaled_endcap_radius, 90, SkPath::kSmall_ArcSize,
92 SkPathDirection::kCW, right - scaled_endcap_radius,
93 bottom - scaled_endcap_radius);
94 // right_path.rCubicTo(-0.75 * scale, 0, -1.625 * scale, -0.5 * scale,
95 // -2 * scale, -1.5 * scale);
96
97 right_path.lineTo(right - scaled_endcap_radius, scaled_endcap_radius);
98 // right_path.lineTo(
99 // right - 1 - scaled_horizontal_inset - (endcap_width - 2) * scale,
100 // 2.5 * scale);
101
102 right_path.arcTo(scaled_endcap_radius, scaled_endcap_radius, 90, SkPath::kSmall_ArcSize,
103 SkPathDirection::kCCW, right - scaled_endcap_radius * 2, 0);
104 // right_path.rCubicTo(-0.375 * scale, -1 * scale, -1.25 * scale, -1.5 * scale,
105 // -2 * scale, -1.5 * scale);
106
107 right_path.lineTo(0, 0);
108 right_path.lineTo(0, bottom);
109 right_path.close();
110
111 SkPath left_path;
112 // const float scaled_endcap_width = 1 + endcap_width * scale;
113 left_path.moveTo(scaled_endcap_radius * 2, 0);
114 // left_path.moveTo(scaled_endcap_width + scaled_horizontal_inset, scale);
115
116 left_path.arcTo(scaled_endcap_radius, scaled_endcap_radius, 90, SkPath::kSmall_ArcSize,
117 SkPathDirection::kCCW, scaled_endcap_radius, scaled_endcap_radius);
118 // left_path.rCubicTo(-0.75 * scale, 0, -1.625 * scale, 0.5 * scale, -2 * scale,
119 // 1.5 * scale);
120
121 left_path.lineTo(scaled_endcap_radius, bottom - scaled_endcap_radius);
122 // left_path.lineTo(1 + scaled_horizontal_inset + 2 * scale,
123 // bottom - 1.5 * scale);
124
125 left_path.arcTo(scaled_endcap_radius, scaled_endcap_radius, 90, SkPath::kSmall_ArcSize,
126 SkPathDirection::kCW, 0, bottom);
127 // left_path.rCubicTo(-0.375 * scale, scale, -1.25 * scale, 1.5 * scale,
128 // -2 * scale, 1.5 * scale);
129
130 left_path.lineTo(right, bottom);
131 left_path.lineTo(right, 0);
132 left_path.close();
133
134 SkPath complete_path;
135 Op(left_path, right_path, SkPathOp::kIntersect_SkPathOp, &complete_path);
136 return complete_path;
137}
138
139void draw(SkCanvas* canvas) {
140 SkPaint p;
141 p.setColor(SK_ColorRED);
142 p.setAntiAlias(true);
143 p.setStyle(SkPaint::kStroke_Style);
144 p.setStrokeWidth(1);
145 SkPath path = GetInteriorPath(1.f, SkISize::Make(250, 36), 16);
146 path.transform(SkMatrix::Translate(0, 30));
147 canvas->drawPath(path, p);
148
149 p.setColor(SK_ColorBLUE);
150 SkPath border_path = GetBorderPath(1.f, false, false, 16, SkISize::Make(250, 36));
151 border_path.transform(SkMatrix::Translate(0, 30));
152 canvas->drawPath(border_path, p);
153
154 // canvas->drawLine(20, 20, 100, 100, p);
155}
156} // END FIDDLE
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
@ kIntersect_SkPathOp
intersect the two paths
Definition: SkPathOps.h:24
static bool right(const SkPoint &p0, const SkPoint &p1)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
static SkMatrix Scale(SkScalar sx, SkScalar sy)
Definition: SkMatrix.h:75
static SkMatrix Translate(SkScalar dx, SkScalar dy)
Definition: SkMatrix.h:91
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
SkPath & arcTo(const SkRect &oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
Definition: SkPath.cpp:1220
SkPath & moveTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:688
SkPath & lineTo(SkScalar x, SkScalar y)
Definition: SkPath.cpp:728
@ kSmall_ArcSize
smaller of arc pair
Definition: SkPath.h:924
SkPath & close()
Definition: SkPath.cpp:823
void transform(const SkMatrix &matrix, SkPath *dst, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
Definition: SkPath.cpp:1711
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702
const Scalar scale
Definition: SkSize.h:16
static constexpr SkISize Make(int32_t w, int32_t h)
Definition: SkSize.h:20