| 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
8 #include "impeller/entity/geometry/fill_path_geometry.h"
9 #include "impeller/entity/geometry/geometry.h"
10 #include "impeller/entity/geometry/stroke_path_geometry.h"
11 #include "impeller/geometry/round_rect.h"
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 Rect& 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.
59 class FillRoundRectGeometry final : public FillPathSourceGeometry {
60 public:
61 explicit FillRoundRectGeometry(const RoundRect& round_rect);
62
63 // |Geometry|
64 bool CoversArea(const Matrix& transform, const Rect& 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.
80 class StrokeRoundRectGeometry final : public StrokePathSourceGeometry {
81 public:
82 StrokeRoundRectGeometry(const RoundRect& rect,
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_
impeller::ContentContext
Definition: content_context.h:122
impeller::Entity
Definition: entity.h:26
impeller::FillPathSourceGeometry
An abstract Geometry base class that produces fillable vertices for the interior of any |PathSource| ...
Definition: fill_path_geometry.h:19
impeller::FillRoundRectGeometry
A Geometry class that produces fillable vertices from any |RoundRect| object regardless of radii unif...
Definition: round_rect_geometry.h:59
impeller::FillRoundRectGeometry::GetSource
const PathSource & GetSource() const override
Definition: round_rect_geometry.cc:69
impeller::FillRoundRectGeometry::FillRoundRectGeometry
FillRoundRectGeometry(const RoundRect &round_rect)
Definition: round_rect_geometry.cc:66
impeller::FillRoundRectGeometry::CoversArea
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
Definition: round_rect_geometry.cc:73
impeller::Geometry
Definition: geometry.h:50
impeller::PathSource
Definition: path_source.h:55
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::RoundRectGeometry
A Geometry class that generates fillable vertices (with or without texture coordinates) directly from...
Definition: round_rect_geometry.h:25
impeller::RoundRectGeometry::~RoundRectGeometry
~RoundRectGeometry() override
impeller::RoundRectGeometry::RoundRectGeometry
RoundRectGeometry(const Rect &bounds, const Size &radii)
Definition: round_rect_geometry.cc:9
impeller::RoundRectGeometry::CoversArea
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
Definition: round_rect_geometry.cc:29
impeller::RoundRectGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition: round_rect_geometry.cc:62
impeller::RoundRectPathSource
Definition: round_rect.h:145
impeller::StrokePathSourceGeometry
An abstract Geometry base class that produces fillable vertices representing the stroked outline from...
Definition: stroke_path_geometry.h:94
impeller::StrokeRoundRectGeometry
A Geometry class that produces fillable vertices representing the stroked outline of any |Roundrect| ...
Definition: round_rect_geometry.h:80
impeller::StrokeRoundRectGeometry::StrokeRoundRectGeometry
StrokeRoundRectGeometry(const RoundRect &rect, const StrokeParameters &parameters)
Definition: round_rect_geometry.cc:120
impeller::StrokeRoundRectGeometry::GetSource
const PathSource & GetSource() const override
Definition: round_rect_geometry.cc:125
fill_path_geometry.h
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:312
geometry.h
impeller
Definition: allocation.cc:12
round_rect.h
stroke_path_geometry.h
impeller::GeometryResult
Definition: geometry.h:21
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::RoundRect
Definition: round_rect.h:16
impeller::StrokeParameters
A structure to store all of the parameters related to stroking a path or basic geometry object.
Definition: stroke_parameters.h:28
impeller::TRect< Scalar >
impeller::TSize< Scalar >