Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
impeller::UberSDFParameters Struct Reference

Parameters for rendering shapes using the UberSDF shader. More...

#include <uber_sdf_parameters.h>

Public Types

enum class  Type {
  kCircle ,
  kRect ,
  kOval ,
  kRoundedRect ,
  kRoundedSuperellipse
}
 The type of primitive shape. More...
 

Static Public Member Functions

static UberSDFParameters MakeRect (Color color, const Rect &rect, std::optional< StrokeParameters > stroke)
 Creates UberSDFParameters for a rectangle.
 
static UberSDFParameters MakeCircle (Color color, const Point &center, Scalar radius, std::optional< StrokeParameters > stroke)
 Creates UberSDFParameters for a circle.
 
static UberSDFParameters MakeOval (Color color, const Rect &bounds, std::optional< StrokeParameters > stroke)
 Creates UberSDFParameters for an Oval.
 
static UberSDFParameters MakeRoundedRect (Color color, const Rect &rect, const RoundingRadii &radii, std::optional< StrokeParameters > stroke)
 Creates UberSDFParameters for a rounded rectangle.
 
static UberSDFParameters MakeRoundedSuperellipse (Color color, Rect bounds, Point superellipse_degree, Point superellipse_a, RoundingRadii radii, Point corner_angle_span, Point corner_circle_center_top, Point corner_circle_center_right, Scalar superellipse_c, Point superellipse_scale, std::optional< StrokeParameters > stroke)
 Creates UberSDFParameters for a symmetric round superellipse.
 

Public Attributes

Type type
 The type of shape to render.
 
Color color
 The color used for filling or stroking the shape.
 
Point center
 The center point of the shape in local coordinates.
 
Point size
 
std::optional< StrokeParametersstroke
 The stroke parameters. If std::nullopt, the shape is filled.
 
RoundingRadii radii
 
Point superellipse_degree
 The degrees of the top (.x) and right (.y) octants of a RoundSuperellipse.
 
Point superellipse_a
 The semi-axes of the top (.x) and right (.y) superellipse segments.
 
Point corner_angle_span
 The spans of the top (.x) and right (.y) circular arcs.
 
Point corner_circle_center_top
 The center of the top circular arc in a RoundSuperellipse.
 
Point corner_circle_center_right
 The center of the right circular arc in a RoundSuperellipse.
 
Scalar superellipse_c
 The offset of the octants in a RoundSuperellipse.
 
Point superellipse_scale
 The scale of the superellipse.
 

Static Public Attributes

static constexpr Scalar kAntialiasPixels = 1.0f
 

Detailed Description

Parameters for rendering shapes using the UberSDF shader.

Definition at line 20 of file uber_sdf_parameters.h.

Member Enumeration Documentation

◆ Type

The type of primitive shape.

Enumerator
kCircle 
kRect 
kOval 
kRoundedRect 
kRoundedSuperellipse 

Definition at line 26 of file uber_sdf_parameters.h.

Member Function Documentation

◆ MakeCircle()

UberSDFParameters impeller::UberSDFParameters::MakeCircle ( Color  color,
const Point center,
Scalar  radius,
std::optional< StrokeParameters stroke 
)
static

Creates UberSDFParameters for a circle.

Definition at line 31 of file uber_sdf_parameters.cc.

35 {
36 // Both size parameters are the same, but this allows us to treat this
37 // case as if it were an oval to share code down the line. We can also
38 // share bounds calculations without having to test for circle vs rect.
39 Point size = Point(radius, radius);
40
41 return UberSDFParameters{.type = Type::kCircle,
42 .color = color,
43 .center = center,
44 .size = size,
45 .stroke = stroke};
46}
TPoint< Scalar > Point
Definition point.h:426
Color color
The color used for filling or stroking the shape.
Point center
The center point of the shape in local coordinates.
std::optional< StrokeParameters > stroke
The stroke parameters. If std::nullopt, the shape is filled.

References center, color, kCircle, size, stroke, and type.

Referenced by impeller::Canvas::DrawCircle(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ MakeOval()

UberSDFParameters impeller::UberSDFParameters::MakeOval ( Color  color,
const Rect bounds,
std::optional< StrokeParameters stroke 
)
static

Creates UberSDFParameters for an Oval.

Definition at line 48 of file uber_sdf_parameters.cc.

51 {
52 Point size = Point(bounds.GetSize() * 0.5f);
53 return UberSDFParameters{.type = Type::kOval,
54 .color = color,
55 .center = bounds.GetCenter(),
56 .size = size,
57 .stroke = stroke};
58}

References color, impeller::TRect< T >::GetCenter(), impeller::TRect< T >::GetSize(), kOval, size, stroke, and type.

Referenced by impeller::Canvas::DrawOval(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ MakeRect()

UberSDFParameters impeller::UberSDFParameters::MakeRect ( Color  color,
const Rect rect,
std::optional< StrokeParameters stroke 
)
static

Creates UberSDFParameters for a rectangle.

Definition at line 9 of file uber_sdf_parameters.cc.

12 {
13 // Size is the x and y extents from the center of the rect.
14 Point size = Point(rect.GetSize() * 0.5f);
15
16 // Stroke may be changed from miter to bevel joins depending on the miter
17 // limit.
18 std::optional<StrokeParameters> adjusted_stroke =
19 stroke && stroke->join == Join::kMiter && stroke->miter_limit < kSqrt2
20 ? std::make_optional(StrokeParameters(
21 {.width = stroke->width, .join = Join::kBevel}))
22 : stroke;
23
24 return UberSDFParameters{.type = Type::kRect,
25 .color = color,
26 .center = rect.GetCenter(),
27 .size = size,
28 .stroke = adjusted_stroke};
29}
constexpr float kSqrt2
Definition constants.h:47

References color, impeller::TRect< T >::GetCenter(), impeller::TRect< T >::GetSize(), impeller::kBevel, impeller::kMiter, kRect, impeller::kSqrt2, size, stroke, and type.

Referenced by impeller::Canvas::DrawRect(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ MakeRoundedRect()

UberSDFParameters impeller::UberSDFParameters::MakeRoundedRect ( Color  color,
const Rect rect,
const RoundingRadii radii,
std::optional< StrokeParameters stroke 
)
static

Creates UberSDFParameters for a rounded rectangle.

Definition at line 60 of file uber_sdf_parameters.cc.

64 {
65 Point size = Point(rect.GetSize() * 0.5f);
66 return UberSDFParameters{.type = Type::kRoundedRect,
67 .color = color,
68 .center = rect.GetCenter(),
69 .size = size,
70 .stroke = stroke,
71 .radii = radii};
72}

References color, impeller::TRect< T >::GetCenter(), impeller::TRect< T >::GetSize(), kRoundedRect, radii, size, stroke, and type.

Referenced by impeller::Canvas::DrawRoundRect(), and impeller::testing::TEST().

◆ MakeRoundedSuperellipse()

UberSDFParameters impeller::UberSDFParameters::MakeRoundedSuperellipse ( Color  color,
Rect  bounds,
Point  superellipse_degree,
Point  superellipse_a,
RoundingRadii  radii,
Point  corner_angle_span,
Point  corner_circle_center_top,
Point  corner_circle_center_right,
Scalar  superellipse_c,
Point  superellipse_scale,
std::optional< StrokeParameters stroke 
)
static

Creates UberSDFParameters for a symmetric round superellipse.

Definition at line 74 of file uber_sdf_parameters.cc.

85 {
86 Point size = Point(rect.GetSize() * 0.5f);
87 return UberSDFParameters{
89 .color = color,
90 .center = rect.GetCenter(),
91 .size = size,
92 .stroke = stroke,
93 .radii = radii,
94 .superellipse_degree = superellipse_degree,
95 .superellipse_a = superellipse_a,
96 .corner_angle_span = corner_angle_span,
97 .corner_circle_center_top = corner_circle_center_top,
98 .corner_circle_center_right = corner_circle_center_right,
99 .superellipse_c = superellipse_c,
100 .superellipse_scale = superellipse_scale};
101}
Point superellipse_a
The semi-axes of the top (.x) and right (.y) superellipse segments.
Point corner_circle_center_right
The center of the right circular arc in a RoundSuperellipse.
Point superellipse_degree
The degrees of the top (.x) and right (.y) octants of a RoundSuperellipse.
Point corner_angle_span
The spans of the top (.x) and right (.y) circular arcs.
Point superellipse_scale
The scale of the superellipse.
Point corner_circle_center_top
The center of the top circular arc in a RoundSuperellipse.
Scalar superellipse_c
The offset of the octants in a RoundSuperellipse.

References color, corner_angle_span, corner_circle_center_right, corner_circle_center_top, impeller::TRect< T >::GetCenter(), impeller::TRect< T >::GetSize(), kRoundedSuperellipse, radii, size, stroke, superellipse_a, superellipse_c, superellipse_degree, superellipse_scale, and type.

Referenced by impeller::Canvas::DrawRoundSuperellipse().

Member Data Documentation

◆ center

Point impeller::UberSDFParameters::center

The center point of the shape in local coordinates.

Definition at line 78 of file uber_sdf_parameters.h.

Referenced by impeller::UberSDFGeometry::CoversArea(), MakeCircle(), and impeller::UberSDFContents::Render().

◆ color

Color impeller::UberSDFParameters::color

◆ corner_angle_span

Point impeller::UberSDFParameters::corner_angle_span

The spans of the top (.x) and right (.y) circular arcs.

Definition at line 101 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ corner_circle_center_right

Point impeller::UberSDFParameters::corner_circle_center_right

The center of the right circular arc in a RoundSuperellipse.

Definition at line 107 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ corner_circle_center_top

Point impeller::UberSDFParameters::corner_circle_center_top

The center of the top circular arc in a RoundSuperellipse.

Definition at line 104 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ kAntialiasPixels

constexpr Scalar impeller::UberSDFParameters::kAntialiasPixels = 1.0f
staticconstexpr

The amount by which the UberSDF shader fades the edge of the drawn shapes, in pixels.

Definition at line 23 of file uber_sdf_parameters.h.

Referenced by impeller::UberSDFGeometry::CoversArea(), and impeller::UberSDFContents::Render().

◆ radii

RoundingRadii impeller::UberSDFParameters::radii

The corner radii for a rounded shapes.

For RoundSuperellipse, the 'width' component holds the top-octant radius and the 'height' component holds the right-octant radius.

Definition at line 92 of file uber_sdf_parameters.h.

Referenced by MakeRoundedRect(), MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ size

Point impeller::UberSDFParameters::size

For a rectangle, this is half the width and height. For a circle, this is the radius in both dimensions. For an oval, this is half the width and height of the bounds.

Definition at line 83 of file uber_sdf_parameters.h.

Referenced by impeller::UberSDFGeometry::CoversArea(), MakeCircle(), MakeOval(), MakeRect(), MakeRoundedRect(), MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ stroke

std::optional<StrokeParameters> impeller::UberSDFParameters::stroke

◆ superellipse_a

Point impeller::UberSDFParameters::superellipse_a

The semi-axes of the top (.x) and right (.y) superellipse segments.

Definition at line 98 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ superellipse_c

Scalar impeller::UberSDFParameters::superellipse_c

The offset of the octants in a RoundSuperellipse.

Definition at line 110 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ superellipse_degree

Point impeller::UberSDFParameters::superellipse_degree

The degrees of the top (.x) and right (.y) octants of a RoundSuperellipse.

Definition at line 95 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ superellipse_scale

Point impeller::UberSDFParameters::superellipse_scale

The scale of the superellipse.

Definition at line 113 of file uber_sdf_parameters.h.

Referenced by MakeRoundedSuperellipse(), and impeller::UberSDFContents::Render().

◆ type


The documentation for this struct was generated from the following files: