Flutter Engine
 
Loading...
Searching...
No Matches
impeller::RSTransform Struct Reference

#include <rstransform.h>

Public Member Functions

constexpr RSTransform ()
 
constexpr RSTransform (Scalar scaled_cos, Scalar scaled_sin, Scalar translate_x, Scalar translate_y)
 
bool IsAxisAligned () const
 
Matrix GetMatrix () const
 
void GetQuad (Scalar width, Scalar height, Quad &quad) const
 
Quad GetQuad (Scalar width, Scalar height) const
 
Quad GetQuad (Size size) const
 
std::optional< RectGetBounds (Scalar width, Scalar height) const
 
std::optional< RectGetBounds (Size size) const
 

Static Public Member Functions

static RSTransform Make (Point origin, Scalar scale, Radians radians)
 

Public Attributes

Scalar scaled_cos
 
Scalar scaled_sin
 
Scalar translate_x
 
Scalar translate_y
 

Detailed Description

A utility struct that stores a simple transform composed of a translation, a rotation, and a uniform scale.

This transform is used by drawAtlas to transform the sprites. This structure mirrors the Flutter RSTransform class.

Definition at line 20 of file rstransform.h.

Constructor & Destructor Documentation

◆ RSTransform() [1/2]

constexpr impeller::RSTransform::RSTransform ( )
inlineconstexpr

Definition at line 21 of file rstransform.h.

22 : scaled_cos(1.0f),
23 scaled_sin(0.0f),
24 translate_x(0.0f),
25 translate_y(0.0f) {}

◆ RSTransform() [2/2]

constexpr impeller::RSTransform::RSTransform ( Scalar  scaled_cos,
Scalar  scaled_sin,
Scalar  translate_x,
Scalar  translate_y 
)
inlineconstexpr

Member Function Documentation

◆ GetBounds() [1/2]

std::optional< Rect > impeller::RSTransform::GetBounds ( Scalar  width,
Scalar  height 
) const

Returns the bounds of the 4 corner points of the transformed quad for a sub-image of the indicated size.

Definition at line 49 of file rstransform.cc.

49 {
51}
int32_t height
int32_t width
void GetQuad(Scalar width, Scalar height, Quad &quad) const
static constexpr std::optional< TRect > MakePointBounds(const U &value)
Definition rect.h:165

References GetQuad(), height, impeller::TRect< Scalar >::MakePointBounds(), and width.

Referenced by impeller::DlAtlasGeometry::ComputeBoundingBox().

◆ GetBounds() [2/2]

std::optional< Rect > impeller::RSTransform::GetBounds ( Size  size) const

Definition at line 53 of file rstransform.cc.

53 {
54 return Rect::MakePointBounds(GetQuad(size));
55}

References GetQuad(), and impeller::TRect< Scalar >::MakePointBounds().

◆ GetMatrix()

Matrix impeller::RSTransform::GetMatrix ( ) const

Definition at line 15 of file rstransform.cc.

15 {
16 // clang-format off
19 0.0f, 0.0f, 1.0f, 0.0f,
20 0.0f, 0.0f, 0.0f, 1.0f);
21 // clang-format on
22}
static constexpr Matrix MakeRow(Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15)
Definition matrix.h:83

References impeller::Matrix::MakeRow(), scaled_cos, scaled_sin, translate_x, and translate_y.

◆ GetQuad() [1/3]

Quad impeller::RSTransform::GetQuad ( Scalar  width,
Scalar  height 
) const

Definition at line 37 of file rstransform.cc.

37 {
38 Quad quad;
39 GetQuad(width, height, quad);
40 return quad;
41}
std::array< Point, 4 > Quad
Definition point.h:332

References GetQuad(), height, and width.

◆ GetQuad() [2/3]

void impeller::RSTransform::GetQuad ( Scalar  width,
Scalar  height,
Quad quad 
) const

Returns the 4 corner points of the transformed quad for a sub-image of the indicated size in the same order as Rect::GetPoints.

The order is UpperLeft, UpperRight, LowerLeft, LowerRight

Definition at line 24 of file rstransform.cc.

24 {
25 Point origin = {translate_x, translate_y};
28 quad = {
29 // Ordered in the same Z pattern as Rect::GetPoints()
30 origin,
31 origin + dx,
32 origin + dy,
33 origin + dx + dy,
34 };
35}
TPoint< Scalar > Point
Definition point.h:327

References height, scaled_cos, scaled_sin, translate_x, translate_y, and width.

Referenced by impeller::DlAtlasGeometry::CreateBlendVertexBuffer(), impeller::DlAtlasGeometry::CreateSimpleVertexBuffer(), GetBounds(), GetBounds(), GetQuad(), GetQuad(), and flutter::testing::TEST().

◆ GetQuad() [3/3]

Quad impeller::RSTransform::GetQuad ( Size  size) const

Definition at line 43 of file rstransform.cc.

43 {
44 Quad quad;
45 GetQuad(size.width, size.height, quad);
46 return quad;
47}
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size

References GetQuad().

◆ IsAxisAligned()

bool impeller::RSTransform::IsAxisAligned ( ) const

Returns true iff the resulting transformed quad will be aligned with the axes, even if rotated by a quadrant rotation.

Definition at line 11 of file rstransform.cc.

11 {
12 return scaled_cos == 0.0f || scaled_sin == 0.0f;
13}

References scaled_cos, and scaled_sin.

◆ Make()

static RSTransform impeller::RSTransform::Make ( Point  origin,
Scalar  scale,
Radians  radians 
)
inlinestatic

Constructs an RSTransform from the indicated origin, uniform scale, and radians rotation.

Definition at line 38 of file rstransform.h.

38 {
39 auto scaled_cos_sin = Matrix::CosSin(radians) * scale;
40 return {scaled_cos_sin.x, scaled_cos_sin.y, origin.x, origin.y};
41 }
static Vector2 CosSin(Radians radians)
Definition matrix.h:685

References impeller::Matrix::CosSin(), impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by flutter::testing::CreateAllRenderingOps(), flutter::testing::TEST(), flutter::testing::TEST(), impeller::testing::TEST(), impeller::testing::TEST(), flutter::testing::TEST_F(), and flutter::testing::TEST_F().

Member Data Documentation

◆ scaled_cos

Scalar impeller::RSTransform::scaled_cos

Definition at line 43 of file rstransform.h.

Referenced by GetMatrix(), GetQuad(), IsAxisAligned(), and std::operator<<().

◆ scaled_sin

Scalar impeller::RSTransform::scaled_sin

Definition at line 44 of file rstransform.h.

Referenced by GetMatrix(), GetQuad(), IsAxisAligned(), and std::operator<<().

◆ translate_x

Scalar impeller::RSTransform::translate_x

Definition at line 45 of file rstransform.h.

Referenced by GetMatrix(), GetQuad(), and std::operator<<().

◆ translate_y

Scalar impeller::RSTransform::translate_y

Definition at line 46 of file rstransform.h.

Referenced by GetMatrix(), GetQuad(), and std::operator<<().


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