Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
gfx::Transform Class Reference

#include <transform.h>

Public Member Functions

 Transform ()
 
 Transform (float col1row1, float col2row1, float col3row1, float col4row1, float col1row2, float col2row2, float col3row2, float col4row2, float col1row3, float col2row3, float col3row3, float col4row3, float col1row4, float col2row4, float col3row4, float col4row4)
 
 Transform (float col1row1, float col2row1, float col1row2, float col2row2, float x_translation, float y_translation)
 
bool operator== (const Transform &rhs) const
 
bool operator!= (const Transform &rhs) const
 
float operator[] (int index) const
 
bool IsIdentity () const
 
void Scale (float x, float y)
 
void TransformRect (RectF *rect) const
 
void TransformPoint (PointF *point) const
 
std::string ToString () const
 

Detailed Description

Definition at line 20 of file transform.h.

Constructor & Destructor Documentation

◆ Transform() [1/3]

gfx::Transform::Transform ( )

Definition at line 11 of file transform.cc.

12 : matrix_{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1},
13 is_identity_(true) {}

◆ Transform() [2/3]

gfx::Transform::Transform ( float  col1row1,
float  col2row1,
float  col3row1,
float  col4row1,
float  col1row2,
float  col2row2,
float  col3row2,
float  col4row2,
float  col1row3,
float  col2row3,
float  col3row3,
float  col4row3,
float  col1row4,
float  col2row4,
float  col3row4,
float  col4row4 
)

Definition at line 15 of file transform.cc.

31 : matrix_{col1row1, col2row1, col3row1, col4row1, col1row2, col2row2,
32 col3row2, col4row2, col1row3, col2row3, col3row3, col4row3,
33 col4row4, col2row4, col3row4, col4row4} {
34 UpdateIdentity();
35}

◆ Transform() [3/3]

gfx::Transform::Transform ( float  col1row1,
float  col2row1,
float  col1row2,
float  col2row2,
float  x_translation,
float  y_translation 
)

Definition at line 37 of file transform.cc.

43 : matrix_{col1row1,
44 col2row1,
45 x_translation,
46 0,
47 col1row2,
48 col2row2,
49 y_translation,
50 0,
51 0,
52 0,
53 1,
54 0,
55 0,
56 0,
57 0,
58 1} {
59 UpdateIdentity();
60}

Member Function Documentation

◆ IsIdentity()

bool gfx::Transform::IsIdentity ( ) const

Definition at line 72 of file transform.cc.

72 {
73 return is_identity_;
74}

◆ operator!=()

bool gfx::Transform::operator!= ( const Transform rhs) const
inline

Definition at line 51 of file transform.h.

51{ return !(*this == rhs); };

◆ operator==()

bool gfx::Transform::operator== ( const Transform rhs) const

Definition at line 62 of file transform.cc.

62 {
63 return matrix_[0] == rhs[0] && matrix_[1] == rhs[1] && matrix_[2] == rhs[2] &&
64 matrix_[3] == rhs[3] && matrix_[4] == rhs[4] && matrix_[5] == rhs[5] &&
65 matrix_[6] == rhs[6] && matrix_[7] == rhs[7] && matrix_[8] == rhs[8] &&
66 matrix_[9] == rhs[9] && matrix_[10] == rhs[10] &&
67 matrix_[11] == rhs[11] && matrix_[12] == rhs[12] &&
68 matrix_[13] == rhs[13] && matrix_[14] == rhs[14] &&
69 matrix_[15] == rhs[15];
70}

◆ operator[]()

float gfx::Transform::operator[] ( int  index) const
inline

Definition at line 53 of file transform.h.

53 {
54 BASE_DCHECK((unsigned)index < 16);
55 return matrix_[index];
56 }
#define BASE_DCHECK(condition)
Definition: logging.h:63

◆ Scale()

void gfx::Transform::Scale ( float  x,
float  y 
)

Definition at line 87 of file transform.cc.

87 {
88 matrix_[0] *= x;
89 matrix_[5] *= y;
90 UpdateIdentity();
91}
double y
double x

◆ ToString()

std::string gfx::Transform::ToString ( ) const

Definition at line 76 of file transform.cc.

76 {
77 return base::StringPrintf(
78 "[ %+0.4f %+0.4f %+0.4f %+0.4f \n"
79 " %+0.4f %+0.4f %+0.4f %+0.4f \n"
80 " %+0.4f %+0.4f %+0.4f %+0.4f \n"
81 " %+0.4f %+0.4f %+0.4f %+0.4f ]\n",
82 matrix_[0], matrix_[1], matrix_[2], matrix_[3], matrix_[4], matrix_[5],
83 matrix_[6], matrix_[7], matrix_[8], matrix_[9], matrix_[10], matrix_[11],
84 matrix_[12], matrix_[13], matrix_[14], matrix_[15]);
85}
std::string StringPrintf(const std::string &format, Args... args)
Definition: string_utils.h:18

◆ TransformPoint()

void gfx::Transform::TransformPoint ( PointF point) const

Definition at line 107 of file transform.cc.

107 {
108 if (IsIdentity())
109 return;
110 float x = point->x();
111 float y = point->y();
112 point->SetPoint(x * matrix_[0] + y * matrix_[1] + matrix_[2],
113 x * matrix_[4] + y * matrix_[5] + matrix_[6]);
114 return;
115}
bool IsIdentity() const
Definition: transform.cc:72

◆ TransformRect()

void gfx::Transform::TransformRect ( RectF rect) const

Definition at line 93 of file transform.cc.

93 {
94 if (IsIdentity())
95 return;
96 PointF origin = rect->origin();
97 PointF top_right = rect->top_right();
98 PointF bottom_left = rect->bottom_left();
99 TransformPoint(&origin);
100 TransformPoint(&top_right);
101 TransformPoint(&bottom_left);
102 rect->set_origin(origin);
103 rect->set_width(top_right.x() - origin.x());
104 rect->set_height(bottom_left.y() - origin.y());
105}
void TransformPoint(PointF *point) const
Definition: transform.cc:107
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

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