Flutter Impeller
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 
9 
10 namespace impeller {
11 
12 /// @brief A geometry that is created from a stroked path object.
13 class StrokePathGeometry final : public Geometry {
14  public:
16  Scalar stroke_width,
17  Scalar miter_limit,
18  Cap stroke_cap,
19  Join stroke_join);
20 
22 
23  Scalar GetStrokeWidth() const;
24 
25  Scalar GetMiterLimit() const;
26 
27  Cap GetStrokeCap() const;
28 
29  Join GetStrokeJoin() const;
30 
31  private:
32  using VS = SolidFillVertexShader;
33 
34  using CapProc =
35  std::function<void(VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
36  const Point& position,
37  const Point& offset,
38  Scalar scale,
39  bool reverse)>;
40  using JoinProc =
41  std::function<void(VertexBufferBuilder<VS::PerVertexData>& vtx_builder,
42  const Point& position,
43  const Point& start_offset,
44  const Point& end_offset,
45  Scalar miter_limit,
46  Scalar scale)>;
47 
48  // |Geometry|
49  GeometryResult GetPositionBuffer(const ContentContext& renderer,
50  const Entity& entity,
51  RenderPass& pass) const override;
52 
53  // |Geometry|
54  GeometryResult GetPositionUVBuffer(Rect texture_coverage,
55  Matrix effect_transform,
56  const ContentContext& renderer,
57  const Entity& entity,
58  RenderPass& pass) const override;
59 
60  // |Geometry|
61  GeometryVertexType GetVertexType() const override;
62 
63  // |Geometry|
64  std::optional<Rect> GetCoverage(const Matrix& transform) const override;
65 
66  bool SkipRendering() const;
67 
68  static Scalar CreateBevelAndGetDirection(
70  const Point& position,
71  const Point& start_offset,
72  const Point& end_offset);
73 
75  CreateSolidStrokeVertices(const Path& path,
76  Scalar stroke_width,
77  Scalar scaled_miter_limit,
78  const JoinProc& join_proc,
79  const CapProc& cap_proc,
80  Scalar scale);
81 
82  static StrokePathGeometry::JoinProc GetJoinProc(Join stroke_join);
83 
84  static StrokePathGeometry::CapProc GetCapProc(Cap stroke_cap);
85 
86  Path path_;
87  Scalar stroke_width_;
88  Scalar miter_limit_;
89  Cap stroke_cap_;
90  Join stroke_join_;
91 
92  StrokePathGeometry(const StrokePathGeometry&) = delete;
93 
94  StrokePathGeometry& operator=(const StrokePathGeometry&) = delete;
95 };
96 
97 } // namespace impeller
98 
99 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_STROKE_PATH_GEOMETRY_H_
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::StrokePathGeometry::~StrokePathGeometry
~StrokePathGeometry()
impeller::GeometryVertexType
GeometryVertexType
Definition: geometry.h:34
impeller::StrokePathGeometry
A geometry that is created from a stroked path object.
Definition: stroke_path_geometry.h:13
impeller::Entity
Definition: entity.h:21
impeller::Path
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition: path.h:55
impeller::VertexBufferBuilder
Definition: vertex_buffer_builder.h:24
impeller::StrokePathGeometry::GetMiterLimit
Scalar GetMiterLimit() const
Definition: stroke_path_geometry.cc:28
geometry.h
impeller::GeometryResult
Definition: geometry.h:20
impeller::StrokePathGeometry::GetStrokeCap
Cap GetStrokeCap() const
Definition: stroke_path_geometry.cc:32
impeller::StrokePathGeometry::GetStrokeJoin
Join GetStrokeJoin() const
Definition: stroke_path_geometry.cc:36
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:29
impeller::Geometry
Definition: geometry.h:58
impeller::Join
Join
Definition: path.h:24
impeller::StrokePathGeometry::StrokePathGeometry
StrokePathGeometry(Path path, Scalar stroke_width, Scalar miter_limit, Cap stroke_cap, Join stroke_join)
Definition: stroke_path_geometry.cc:11
impeller::TPoint< Scalar >
impeller
Definition: aiks_context.cc:10
impeller::ContentContext
Definition: content_context.h:332
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::StrokePathGeometry::GetStrokeWidth
Scalar GetStrokeWidth() const
Definition: stroke_path_geometry.cc:24
impeller::Cap
Cap
Definition: path.h:18