Flutter Engine
 
Loading...
Searching...
No Matches
dl_path_builder.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_DISPLAY_LIST_GEOMETRY_DL_PATH_BUILDER_H_
6#define FLUTTER_DISPLAY_LIST_GEOMETRY_DL_PATH_BUILDER_H_
7
10#include "flutter/third_party/skia/include/core/SkPath.h"
11
12namespace flutter {
13
15 public:
16 /// Used for approximating quarter circle arcs with cubic curves. This is
17 /// the control point distance which results in the smallest possible unit
18 /// circle integration for a right angle arc. It can be used to approximate
19 /// arcs less than 90 degrees to great effect by simply reducing it
20 /// proportionally to the angle. However, accuracy rapidly diminishes if
21 /// magnified for obtuse angle arcs, and so multiple cubic curves should
22 /// be used when approximating arcs greater than 90 degrees.
23 constexpr static const DlScalar kArcApproximationMagic = 0.551915024494f;
24
25 /// @brief Set the fill type that should be used to determine the interior
26 /// of this path to the indicated |fill_type|.
27 ///
28 /// @see |DlPathFillType|
30
31 /// @brief Start a new contour that will originate at the indicated
32 /// point p2.
34
35 /// @brief Draw a line from the current point to the indicated point p2.
36 ///
37 /// If the path is empty, a new contour will automatically be started from
38 /// the point (0, 0) as if |MoveTo| had been called.
40
41 /// @brief Draw a quadratic bezier curve from the current point to the
42 /// indicated point p2, using the indicated point cp as a control
43 /// point.
44 ///
45 /// If the path is empty, a new contour will automatically be started from
46 /// the point (0, 0) as if |MoveTo| had been called.
48
49 /// @brief Draw a conic curve (a rational quadratic bezier curve) from
50 /// the current point to the indicated point p2, using the
51 /// indicated point cp as a control point and the indicated
52 /// weight to control the contribution of the control point.
53 ///
54 /// A weight of less than 0, or NaN, is treated is if it were 0 which
55 /// produces a curve that is identical to a line segment and will be
56 /// inserted as a line segment in lieu of the conic.
57 ///
58 /// A weight of (sqrt(2)/2) will produce a quarter section of an
59 /// elliptical path.
60 ///
61 /// A weight of 1.0 is identical to a quadratic bezier curve and will be
62 /// inserted as a quadratic curve in lieu of the conic.
63 ///
64 /// If the path is empty, a new contour will automatically be started from
65 /// the point (0, 0) as if |MoveTo| had been called.
67
68 /// @brief Draw a cubic bezier curve from the current point to the
69 /// indicated point p2, using the indicated points cp1 and cp2
70 /// as control points.
71 ///
72 /// If the path is empty, a new contour will automatically be started from
73 /// the point (0, 0) as if |MoveTo| had been called.
75
76 /// @brief The path is closed back to the location of the most recent
77 /// MoveTo call. Contours that are filled are always implicitly
78 /// assumed to be closed, but contours that are stroked will
79 /// either:
80 /// - If closed, draw the stroke back to the contour origin and
81 /// insert a join decoration back to the leading vertex of the
82 /// contour's first segment.
83 /// - If not closed, draw cap decorations at the first and last
84 /// vertices in the contour.
86
87 /// @brief Append a closed rectangular contour to the path.
88 DlPathBuilder& AddRect(const DlRect& rect);
89
90 /// @brief Append a closed elliptical contour to the path inscribed in
91 /// the provided bounds.
92 DlPathBuilder& AddOval(const DlRect& bounds);
93
94 /// @brief Append a closed circular contour to the path centered on the
95 /// provided point at the provided radius.
96 DlPathBuilder& AddCircle(DlPoint center, DlScalar radius);
97
98 /// @brief Append a closed rounded rect contour to the path.
99 DlPathBuilder& AddRoundRect(const DlRoundRect& round_rect);
100
101 /// @brief Append a closed rounded super-ellipse contour to the path.
103
104 /// @brief Append an arc contour to the path which:
105 /// - is a portion of an ellipse inscribed in the provided
106 /// bounds starting at the indicated angle and sweeping
107 /// by the indicated sweep, clockwise for positive sweeps
108 /// or counter-clockwise for negative sweeps.
109 /// - if use_center is false, starts and ends on the ellipse
110 /// at the specified angles forming a portion of the ellipse
111 /// sliced at the indicated angles.
112 /// - if use_center is false, starts and ends at the center of
113 /// the ellipse forming a pie or pacman shape depending on
114 /// how large the sweep is.
115 DlPathBuilder& AddArc(const DlRect& bounds,
116 DlDegrees start,
117 DlDegrees sweep,
118 bool use_center = false);
119
120 /// @brief Append the provided path to this path as if the commands
121 /// used to construct it were repeated on this path. The fill
122 /// type of the current path will continue to be used, ignoring
123 /// the fill type of the indicated path.
125
126 /// @brief Returns the path constructed by this path builder so far and
127 /// retains all current geometry to continue building the path.
128 const DlPath CopyPath();
129
130 /// @brief Returns the path constructed by this path builder and resets
131 /// its internal state to the default state when it was constructed.
132 const DlPath TakePath();
133
134 private:
135 SkPath path_;
136};
137
138} // namespace flutter
139
140#endif // FLUTTER_DISPLAY_LIST_GEOMETRY_DL_PATH_BUILDER_H_
DlPathBuilder & AddRoundSuperellipse(const DlRoundSuperellipse &rse)
Append a closed rounded super-ellipse contour to the path.
DlPathBuilder & LineTo(DlPoint p2)
Draw a line from the current point to the indicated point p2.
DlPathBuilder & AddPath(const DlPath &path)
Append the provided path to this path as if the commands used to construct it were repeated on this p...
static constexpr const DlScalar kArcApproximationMagic
DlPathBuilder & MoveTo(DlPoint p2)
Start a new contour that will originate at the indicated point p2.
const DlPath CopyPath()
Returns the path constructed by this path builder so far and retains all current geometry to continue...
DlPathBuilder & SetFillType(DlPathFillType fill_type)
Set the fill type that should be used to determine the interior of this path to the indicated |fill_t...
const DlPath TakePath()
Returns the path constructed by this path builder and resets its internal state to the default state ...
DlPathBuilder & ConicCurveTo(DlPoint cp, DlPoint p2, DlScalar weight)
Draw a conic curve (a rational quadratic bezier curve) from the current point to the indicated point ...
DlPathBuilder & AddCircle(DlPoint center, DlScalar radius)
Append a closed circular contour to the path centered on the provided point at the provided radius.
DlPathBuilder & AddRect(const DlRect &rect)
Append a closed rectangular contour to the path.
DlPathBuilder & AddRoundRect(const DlRoundRect &round_rect)
Append a closed rounded rect contour to the path.
DlPathBuilder & QuadraticCurveTo(DlPoint cp, DlPoint p2)
Draw a quadratic bezier curve from the current point to the indicated point p2, using the indicated p...
DlPathBuilder & Close()
The path is closed back to the location of the most recent MoveTo call. Contours that are filled are ...
DlPathBuilder & AddArc(const DlRect &bounds, DlDegrees start, DlDegrees sweep, bool use_center=false)
Append an arc contour to the path which:
DlPathBuilder & AddOval(const DlRect &bounds)
Append a closed elliptical contour to the path inscribed in the provided bounds.
DlPathBuilder & CubicCurveTo(DlPoint cp1, DlPoint cp2, DlPoint p2)
Draw a cubic bezier curve from the current point to the indicated point p2, using the indicated point...
impeller::Scalar DlScalar
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 switch_defs.h:52