| 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/geometry/rounding_radii.h"
10
11 namespace impeller {
12
13 /// Geometry class that can generate vertices for a rounded superellipse.
14 ///
15 /// A rounded superellipse is a shape similar to a typical rounded rectangle
16 /// (`RoundRect`), but with smoother transitions between the straight sides and
17 /// the rounded corners. It resembles the `RoundedRectangle` shape in SwiftUI
18 /// with the `.continuous` corner style. Technically, it is created by replacing
19 /// the four corners of a superellipse (also known as a Lamé curve) with
20 /// circular arcs.
21 ///
22 /// The `bounds` defines the position and size of the shape. The `corner_radius`
23 /// corresponds to SwiftUI's `cornerRadius` parameter, which is close to, but
24 /// not exactly equals to, the radius of the corner circles.
25 class RoundSuperellipseGeometry final : public Geometry {
26 public:
27 RoundSuperellipseGeometry(const Rect& bounds, const RoundingRadii& radii);
28 RoundSuperellipseGeometry(const Rect& bounds, float corner_radius);
29
30 ~RoundSuperellipseGeometry() override;
31
32 // |Geometry|
33 bool CoversArea(const Matrix& transform, const Rect& rect) const override;
34
35 // |Geometry|
36 bool IsAxisAlignedRect() const override;
37
38 private:
39 // |Geometry|
40 GeometryResult GetPositionBuffer(const ContentContext& renderer,
41 const Entity& entity,
42 RenderPass& pass) const override;
43
44 // |Geometry|
45 std::optional<Rect> GetCoverage(const Matrix& transform) const override;
46
47 const Rect bounds_;
48 const RoundingRadii radii_;
49
50 RoundSuperellipseGeometry(const RoundSuperellipseGeometry&) = delete;
51
52 RoundSuperellipseGeometry& operator=(const RoundSuperellipseGeometry&) =
53 delete;
54 };
55
56 } // namespace impeller
57
58 #endif // FLUTTER_IMPELLER_ENTITY_GEOMETRY_ROUND_SUPERELLIPSE_GEOMETRY_H_
impeller::ContentContext
Definition: content_context.h:138
impeller::Entity
Definition: entity.h:20
impeller::Geometry
Definition: geometry.h:50
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::RoundSuperellipseGeometry
Definition: round_superellipse_geometry.h:25
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:442
impeller::RoundSuperellipseGeometry::IsAxisAlignedRect
bool IsAxisAlignedRect() const override
Definition: round_superellipse_geometry.cc:461
impeller::RoundSuperellipseGeometry::RoundSuperellipseGeometry
RoundSuperellipseGeometry(const Rect &bounds, const RoundingRadii &radii)
Definition: round_superellipse_geometry.cc:366
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
geometry.h
impeller
Definition: allocation.cc:12
rounding_radii.h
impeller::GeometryResult
Definition: geometry.h:21
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::RoundingRadii
Definition: rounding_radii.h:14
impeller::TRect< Scalar >