Flutter Impeller
rstransform.cc
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
#include "
flutter/impeller/geometry/rstransform.h
"
6
7
#include "
flutter/impeller/geometry/matrix.h
"
8
9
namespace
impeller
{
10
11
bool
RSTransform::IsAxisAligned
()
const
{
12
return
scaled_cos
== 0.0f ||
scaled_sin
== 0.0f;
13
}
14
15
Matrix
RSTransform::GetMatrix
()
const
{
16
// clang-format off
17
return
Matrix::MakeRow
(
scaled_cos
, -
scaled_sin
, 0.0f,
translate_x
,
18
scaled_sin
,
scaled_cos
, 0.0f,
translate_y
,
19
0.0f, 0.0f, 1.0f, 0.0f,
20
0.0f, 0.0f, 0.0f, 1.0f);
21
// clang-format on
22
}
23
24
void
RSTransform::GetQuad
(
Scalar
width,
Scalar
height,
Quad
& quad)
const
{
25
Point
origin = {
translate_x
,
translate_y
};
26
Point
dx = width *
Point
{
scaled_cos
,
scaled_sin
};
27
Point
dy = height *
Point
{-
scaled_sin
,
scaled_cos
};
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
}
36
37
Quad
RSTransform::GetQuad
(
Scalar
width,
Scalar
height)
const
{
38
Quad
quad;
39
GetQuad
(width, height, quad);
40
return
quad;
41
}
42
43
Quad
RSTransform::GetQuad
(
Size
size)
const
{
44
Quad
quad;
45
GetQuad
(size.
width
, size.
height
, quad);
46
return
quad;
47
}
48
49
std::optional<Rect>
RSTransform::GetBounds
(
Scalar
width,
Scalar
height)
const
{
50
return
Rect::MakePointBounds
(
GetQuad
(width, height));
51
}
52
53
std::optional<Rect>
RSTransform::GetBounds
(
Size
size)
const
{
54
return
Rect::MakePointBounds
(
GetQuad
(size));
55
}
56
57
}
// namespace impeller
matrix.h
impeller
Definition:
allocation.cc:12
impeller::Scalar
float Scalar
Definition:
scalar.h:19
impeller::Quad
std::array< Point, 4 > Quad
Definition:
point.h:332
rstransform.h
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition:
matrix.h:37
impeller::Matrix::MakeRow
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
impeller::RSTransform::translate_y
Scalar translate_y
Definition:
rstransform.h:46
impeller::RSTransform::GetBounds
std::optional< Rect > GetBounds(Scalar width, Scalar height) const
Definition:
rstransform.cc:49
impeller::RSTransform::GetMatrix
Matrix GetMatrix() const
Definition:
rstransform.cc:15
impeller::RSTransform::translate_x
Scalar translate_x
Definition:
rstransform.h:45
impeller::RSTransform::scaled_sin
Scalar scaled_sin
Definition:
rstransform.h:44
impeller::RSTransform::GetQuad
void GetQuad(Scalar width, Scalar height, Quad &quad) const
Definition:
rstransform.cc:24
impeller::RSTransform::scaled_cos
Scalar scaled_cos
Definition:
rstransform.h:43
impeller::RSTransform::IsAxisAligned
bool IsAxisAligned() const
Definition:
rstransform.cc:11
impeller::TPoint< Scalar >
impeller::TRect< Scalar >::MakePointBounds
constexpr static std::optional< TRect > MakePointBounds(const U &value)
Definition:
rect.h:165
impeller::TSize< Scalar >
impeller::TSize::height
Type height
Definition:
size.h:29
impeller::TSize::width
Type width
Definition:
size.h:28
impeller
geometry
rstransform.cc
Generated by
1.9.1