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 
6 
8 
9 namespace impeller {
10 
12  return scaled_cos == 0.0f || scaled_sin == 0.0f;
13 }
14 
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 }
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 
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
float Scalar
Definition: scalar.h:19
std::array< Point, 4 > Quad
Definition: point.h:332
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
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
std::optional< Rect > GetBounds(Scalar width, Scalar height) const
Definition: rstransform.cc:49
Matrix GetMatrix() const
Definition: rstransform.cc:15
void GetQuad(Scalar width, Scalar height, Quad &quad) const
Definition: rstransform.cc:24
bool IsAxisAligned() const
Definition: rstransform.cc:11
constexpr static std::optional< TRect > MakePointBounds(const U &value)
Definition: rect.h:165
Type height
Definition: size.h:29
Type width
Definition: size.h:28