Flutter Engine
 
Loading...
Searching...
No Matches
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
12
13namespace 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|
30class RoundSuperellipseGeometry final : public Geometry {
31 public:
32 RoundSuperellipseGeometry(const Rect& bounds, const RoundingRadii& radii);
33 RoundSuperellipseGeometry(const Rect& bounds, float corner_radius);
34
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
56
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|
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_
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 Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
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 |RoundSupere...
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.