Flutter Engine
 
Loading...
Searching...
No Matches
stroke_path_geometry.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_IMPELLER_ENTITY_GEOMETRY_STROKE_PATH_GEOMETRY_H_
6#define FLUTTER_IMPELLER_ENTITY_GEOMETRY_STROKE_PATH_GEOMETRY_H_
7
14
15namespace impeller {
16
17/// @brief A |SegmentReceiver| that also accepts Arc segments for optimal
18/// handling. A path or |PathSource| will typically represent such
19/// curves using Conic segments which are harder to iterate.
21 public:
22 virtual void RecordArc(const Arc& arc,
23 const Point center,
24 const Size radii) = 0;
25};
26
27/// @brief An abstract Geometry base class that produces fillable vertices
28/// representing the stroked outline of the segments provided by
29/// the subclass in the virtual |Dispatch| method.
30///
31/// Most subclasses will be based on an instance of |PathSource| and use the
32/// |StrokePathSourceGeometry| subclass to feed the segments from that path
33/// source object, but some subclasses may be able to operate more optimally
34/// by talking directly to the |StrokePathSegmentReceiver| (mainly arcs).
36 public:
38
39 Scalar GetStrokeWidth() const;
40
41 Scalar GetMiterLimit() const;
42
43 Cap GetStrokeCap() const;
44
45 Join GetStrokeJoin() const;
46
47 Scalar ComputeAlphaCoverage(const Matrix& transform) const override;
48
49 protected:
50 explicit StrokeSegmentsGeometry(const StrokeParameters& parameters);
51
52 /// Dispatch the path segments to the StrokePathSegmentReceiver for
53 /// the provided transform scale.
54 virtual void Dispatch(PathAndArcSegmentReceiver& receiver,
55 Tessellator& tessellator,
56 Scalar scale) const = 0;
57
58 /// Provide the stroke-padded bounds for the provided bounds of the
59 /// segments themselves.
60 std::optional<Rect> GetStrokeCoverage(const Matrix& transform,
61 const Rect& segment_bounds) const;
62
63 private:
64 // |Geometry|
65 GeometryResult GetPositionBuffer(const ContentContext& renderer,
66 const Entity& entity,
67 RenderPass& pass) const override;
68
69 // |Geometry|
70 GeometryResult::Mode GetResultMode() const override;
71
72 // Private for benchmarking and debugging
73 static std::vector<Point> GenerateSolidStrokeVertices(
74 Tessellator& tessellator,
75 const PathSource& source,
76 const StrokeParameters& stroke,
77 Scalar scale);
78
81
82 bool SkipRendering() const;
83
84 const StrokeParameters stroke_;
85
87
88 StrokeSegmentsGeometry& operator=(const StrokeSegmentsGeometry&) = delete;
89};
90
91/// @brief An abstract Geometry base class that produces fillable vertices
92/// representing the stroked outline from any |PathSource| provided
93/// by the subclass.
95 protected:
96 explicit StrokePathSourceGeometry(const StrokeParameters& parameters);
97
98 /// The PathSource object that will be iterated to produce the raw
99 /// vertices to be stroked.
100 virtual const PathSource& GetSource() const = 0;
101
102 // |Geometry|
103 std::optional<Rect> GetCoverage(const Matrix& transform) const override;
104
105 // |StrokeSegmentsGeometry|
106 void Dispatch(PathAndArcSegmentReceiver& receiver,
107 Tessellator& tessellator,
108 Scalar scale) const override;
109};
110
111/// @brief A Geometry that produces fillable vertices representing the
112/// stroked outline of a |DlPath| object using the
113/// |StrokePathSourceGeometry| base class and a |DlPath| object
114/// to perform path iteration.
116 public:
118 const StrokeParameters& parameters);
119
120 protected:
121 // |StrokePathSourceGeometry|
122 const PathSource& GetSource() const override;
123
124 private:
125 const flutter::DlPath path_;
126};
127
128/// @brief A Geometry that produces fillable vertices representing the
129/// stroked outline of an |Arc| object using the base class
130/// |StrokeSegmentsGeometry| and utilizing the special |RecordArc|
131/// extension method provided by the |PathAndArcSegmentReceiver|.
133 public:
134 ArcStrokeGeometry(const Arc& arc, const StrokeParameters& parameters);
135
136 protected:
137 // |Geometry|
138 std::optional<Rect> GetCoverage(const Matrix& transform) const override;
139
140 // |StrokeSegmentsGeometry|
141 void Dispatch(PathAndArcSegmentReceiver& receiver,
142 Tessellator& tessellator,
143 Scalar scale) const override;
144
145 private:
146 const Arc arc_;
147};
148
149/// @brief A Geometry that produces fillable vertices representing the
150/// stroked outline of a pair of nested |RoundRect| objects using
151/// the |StrokePathSourceGeometry| base class.
153 public:
154 explicit StrokeDiffRoundRectGeometry(const RoundRect& outer,
155 const RoundRect& inner,
156 const StrokeParameters& parameters);
157
158 protected:
159 // |StrokePathSourceGeometry|
160 const PathSource& GetSource() const override;
161
162 private:
163 const DiffRoundRectPathSource source_;
164};
165
166/// @brief A Geometry that produces fillable vertices representing the
167/// stroked outline of a |DlPath| object using the
168/// |StrokePathSourceGeometry| base class and a |DlPath| object
169/// to perform path iteration.
171 public:
173 Point p1,
174 Scalar on_length,
175 Scalar off_length,
176 const StrokeParameters& parameters);
177
178 protected:
179 const PathSource& GetSource() const override;
180
181 private:
182 const DashedLinePathSource source_;
183};
184
185} // namespace impeller
186
187#endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_STROKE_PATH_GEOMETRY_H_
A Geometry that produces fillable vertices representing the stroked outline of an |Arc| object using ...
void Dispatch(PathAndArcSegmentReceiver &receiver, Tessellator &tessellator, Scalar scale) const override
std::optional< Rect > GetCoverage(const Matrix &transform) const override
A PathSource that generates the various segments of a dashed line.
A |SegmentReceiver| that also accepts Arc segments for optimal handling. A path or |PathSource| will ...
virtual void RecordArc(const Arc &arc, const Point center, const Size radii)=0
An interface for receiving pruned path segments.
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:30
A Geometry that produces fillable vertices representing the stroked outline of a |DlPath| object usin...
const PathSource & GetSource() const override
A Geometry that produces fillable vertices representing the stroked outline of a pair of nested |Roun...
const PathSource & GetSource() const override
A Geometry that produces fillable vertices representing the stroked outline of a |DlPath| object usin...
const PathSource & GetSource() const override
An abstract Geometry base class that produces fillable vertices representing the stroked outline from...
virtual const PathSource & GetSource() const =0
std::optional< Rect > GetCoverage(const Matrix &transform) const override
void Dispatch(PathAndArcSegmentReceiver &receiver, Tessellator &tessellator, Scalar scale) const override
An abstract Geometry base class that produces fillable vertices representing the stroked outline of t...
virtual void Dispatch(PathAndArcSegmentReceiver &receiver, Tessellator &tessellator, Scalar scale) const =0
Scalar ComputeAlphaCoverage(const Matrix &transform) const override
std::optional< Rect > GetStrokeCoverage(const Matrix &transform, const Rect &segment_bounds) const
A utility that generates triangles of the specified fill type given a polyline. This happens on the C...
Definition tessellator.h:37
Join
An enum that describes ways to join two segments of a path.
float Scalar
Definition scalar.h:19
Cap
An enum that describes ways to decorate the end of a path contour.
A 4x4 matrix using column-major storage.
Definition matrix.h:37
A structure to store all of the parameters related to stroking a path or basic geometry object.