Flutter Impeller
round_rect_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_ROUND_RECT_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_RECT_GEOMETRY_H_
7 
12 
13 namespace impeller {
14 
15 /// @brief A Geometry class that generates fillable vertices (with or without
16 /// texture coordinates) directly from a round rect object with uniform
17 /// radii at every corner.
18 ///
19 /// Generating vertices for a stroked ellipse would require a lot more work
20 /// since the line width must be applied perpendicular to the distorted
21 /// ellipse shape.
22 ///
23 /// @see |FillRoundRectGeometry|
24 /// @see |StrokeRoundRectGeometry|
25 class RoundRectGeometry final : public Geometry {
26  public:
27  explicit RoundRectGeometry(const Rect& bounds, const Size& radii);
28 
29  ~RoundRectGeometry() override;
30 
31  // |Geometry|
32  bool CoversArea(const Matrix& transform, const IRect& rect) const override;
33 
34  // |Geometry|
35  bool IsAxisAlignedRect() const override;
36 
37  private:
38  // |Geometry|
39  GeometryResult GetPositionBuffer(const ContentContext& renderer,
40  const Entity& entity,
41  RenderPass& pass) const override;
42 
43  // |Geometry|
44  std::optional<Rect> GetCoverage(const Matrix& transform) const override;
45 
46  const Rect bounds_;
47  const Size radii_;
48 
49  RoundRectGeometry(const RoundRectGeometry&) = delete;
50 
51  RoundRectGeometry& operator=(const RoundRectGeometry&) = delete;
52 };
53 
54 /// @brief A Geometry class that produces fillable vertices from any
55 /// |RoundRect| object regardless of radii uniformity.
56 ///
57 /// This class uses the |FillPathSourceGeometry| base class to do the work
58 /// by providing a |RoundRectPathSoure| iterator.
60  public:
61  explicit FillRoundRectGeometry(const RoundRect& round_rect);
62 
63  // |Geometry|
64  bool CoversArea(const Matrix& transform, const IRect& rect) const override;
65 
66  protected:
67  // |FillPathSourceGeometry|
68  const PathSource& GetSource() const override;
69 
70  private:
71  const RoundRectPathSource round_rect_source_;
72 };
73 
74 /// @brief A Geometry class that produces fillable vertices representing
75 /// the stroked outline of any |Roundrect| object regardless of
76 /// radii uniformity.
77 ///
78 /// This class uses the |StrokePathSourceGeometry| base class to do the work
79 /// by providing a |RoundRectPathSoure| iterator.
81  public:
83  const StrokeParameters& parameters);
84 
85  protected:
86  // |StrokePathSourceGeometry|
87  const PathSource& GetSource() const override;
88 
89  private:
90  const RoundRectPathSource round_rect_source_;
91 };
92 
93 } // namespace impeller
94 
95 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_RECT_GEOMETRY_H_
An abstract Geometry base class that produces fillable vertices for the interior of any |PathSource| ...
A Geometry class that produces fillable vertices from any |RoundRect| object regardless of radii unif...
bool CoversArea(const Matrix &transform, const IRect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all of the pix...
const PathSource & GetSource() const override
FillRoundRectGeometry(const RoundRect &round_rect)
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
A Geometry class that generates fillable vertices (with or without texture coordinates) directly from...
bool CoversArea(const Matrix &transform, const IRect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all of the pix...
RoundRectGeometry(const Rect &bounds, const Size &radii)
bool IsAxisAlignedRect() const override
An abstract Geometry base class that produces fillable vertices representing the stroked outline from...
A Geometry class that produces fillable vertices representing the stroked outline of any |Roundrect| ...
StrokeRoundRectGeometry(const RoundRect &rect, const StrokeParameters &parameters)
const PathSource & GetSource() const override
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.