| Flutter Impeller |

round_superellipse_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_SUPERELLIPSE_GEOMETRY_H_
6 #define FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_SUPERELLIPSE_GEOMETRY_H_
7
8 #include "impeller/entity/geometry/geometry.h"
9 #include "impeller/entity/geometry/stroke_path_geometry.h"
10 #include "impeller/geometry/round_superellipse.h"
11 #include "impeller/geometry/rounding_radii.h"
12
13 namespace impeller {
14 /// @brief A Geometry class that generates fillable vertices (with or without
15 /// texture coordinates) directly from a round superellipse object
16 /// regardless of radii uniformity.
17 ///
18 /// A rounded superellipse is a shape similar to a typical rounded rectangle
19 /// (`RoundSuperellipse`), but with smoother transitions between the straight
20 /// sides and the rounded corners. It resembles the `RoundedRectangle` shape in
21 /// SwiftUI with the `.continuous` corner style. Technically, it is created by
22 /// replacing the four corners of a superellipse (also known as a Lamé curve)
23 /// with circular arcs.
24 ///
25 /// The `bounds` defines the position and size of the shape. The `corner_radius`
26 /// corresponds to SwiftUI's `cornerRadius` parameter, which is close to, but
27 /// not exactly equals to, the radius of the corner circles.
28 ///
29 /// @see |StrokeRoundSuperellipseGeometry|
30 class RoundSuperellipseGeometry final : public Geometry {
31 public:
32 RoundSuperellipseGeometry(const Rect& bounds, const RoundingRadii& radii);
33 RoundSuperellipseGeometry(const Rect& bounds, float corner_radius);
34
35 ~RoundSuperellipseGeometry() override;
36
37 // |Geometry|
38 bool CoversArea(const Matrix& transform, const Rect& rect) const override;
39
40 // |Geometry|
41 bool IsAxisAlignedRect() const override;
42
43 private:
44 // |Geometry|
45 GeometryResult GetPositionBuffer(const ContentContext& renderer,
46 const Entity& entity,
47 RenderPass& pass) const override;
48
49 // |Geometry|
50 std::optional<Rect> GetCoverage(const Matrix& transform) const override;
51
52 const Rect bounds_;
53 const RoundingRadii radii_;
54
55 RoundSuperellipseGeometry(const RoundSuperellipseGeometry&) = delete;
56
57 RoundSuperellipseGeometry& operator=(const RoundSuperellipseGeometry&) =
58 delete;
59 };
60
61 /// @brief A Geometry class that produces fillable vertices representing
62 /// the stroked outline of any |RoundSuperellipse| object regardless of
63 /// radii uniformity.
64 ///
65 /// This class uses the |StrokePathSourceGeometry| base class to do the work
66 /// by providing a |RoundSuperellipsePathSoure| iterator.
67 ///
68 /// @see |RoundSuperellipseGeometry|
69 class StrokeRoundSuperellipseGeometry final : public StrokePathSourceGeometry {
70 public:
71 StrokeRoundSuperellipseGeometry(const RoundSuperellipse& round_superellipse,
72 const StrokeParameters& parameters);
73
74 protected:
75 // |StrokePathSourceGeometry|
76 const PathSource& GetSource() const override;
77
78 private:
79 const RoundSuperellipsePathSource round_superellipse_source_;
80 };
81
82 } // namespace impeller
83
84 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_SUPERELLIPSE_GEOMETRY_H_
impeller::ContentContext
Definition: content_context.h:122
impeller::Entity
Definition: entity.h:26
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::RoundSuperellipseGeometry
A Geometry class that generates fillable vertices (with or without texture coordinates) directly from...
Definition: round_superellipse_geometry.h:30
impeller::RoundSuperellipseGeometry::~RoundSuperellipseGeometry
~RoundSuperellipseGeometry() override
Definition: round_superellipse_geometry.cc:375
impeller::RoundSuperellipseGeometry::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_superellipse_geometry.cc:443
impeller::RoundSuperellipseGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition: round_superellipse_geometry.cc:462
impeller::RoundSuperellipseGeometry::RoundSuperellipseGeometry
RoundSuperellipseGeometry(const Rect &bounds, const RoundingRadii &radii)
Definition: round_superellipse_geometry.cc:366
impeller::RoundSuperellipsePathSource
Definition: round_superellipse.h:142
impeller::StrokePathSourceGeometry
An abstract Geometry base class that produces fillable vertices representing the stroked outline from...
Definition: stroke_path_geometry.h:94
impeller::StrokeRoundSuperellipseGeometry
A Geometry class that produces fillable vertices representing the stroked outline of any |RoundSupere...
Definition: round_superellipse_geometry.h:69
impeller::StrokeRoundSuperellipseGeometry::StrokeRoundSuperellipseGeometry
StrokeRoundSuperellipseGeometry(const RoundSuperellipse &round_superellipse, const StrokeParameters &parameters)
Definition: round_superellipse_geometry.cc:466
impeller::StrokeRoundSuperellipseGeometry::GetSource
const PathSource & GetSource() const override
Definition: round_superellipse_geometry.cc:472
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:312
geometry.h
impeller
Definition: allocation.cc:12
round_superellipse.h
rounding_radii.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::RoundSuperellipse
Definition: round_superellipse.h:18
impeller::RoundingRadii
Definition: rounding_radii.h:14
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 >