Flutter Engine
The Flutter Engine
third_party
accessibility
gfx
transform.h
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
#ifndef UI_GFX_TRANSFORM_H_
6
#define UI_GFX_TRANSFORM_H_
7
8
#include <iosfwd>
9
#include <string>
10
11
#include "
geometry/rect_f.h
"
12
#include "
gfx_export.h
"
13
14
namespace
gfx
{
15
16
class
RectF;
17
18
// 4x4 transformation matrix. Transform is cheap and explicitly allows
19
// copy/assign.
20
class
GFX_EXPORT
Transform
{
21
public
:
22
Transform
();
23
24
Transform
(
float
col1row1,
25
float
col2row1,
26
float
col3row1,
27
float
col4row1,
28
float
col1row2,
29
float
col2row2,
30
float
col3row2,
31
float
col4row2,
32
float
col1row3,
33
float
col2row3,
34
float
col3row3,
35
float
col4row3,
36
float
col1row4,
37
float
col2row4,
38
float
col3row4,
39
float
col4row4);
40
// Constructs a transform from explicit 2d elements. All other matrix
41
// elements remain the same as the corresponding elements of an identity
42
// matrix.
43
Transform
(
float
col1row1,
44
float
col2row1,
45
float
col1row2,
46
float
col2row2,
47
float
x_translation,
48
float
y_translation);
49
50
bool
operator==
(
const
Transform
& rhs)
const
;
51
bool
operator!=
(
const
Transform
& rhs)
const
{
return
!(*
this
== rhs); };
52
53
float
operator[]
(
int
index)
const
{
54
BASE_DCHECK
((
unsigned
)index < 16);
55
return
matrix_[index];
56
}
57
58
// Returns true if this is the identity matrix.
59
bool
IsIdentity()
const
;
60
61
// Applies the current transformation on a scaling and assigns the result
62
// to |this|.
63
void
Scale
(
float
x
,
float
y
);
64
65
// Applies transformation on the given rect. After the function completes,
66
// |rect| will be the smallest axis aligned bounding rect containing the
67
// transformed rect.
68
void
TransformRect(
RectF
*
rect
)
const
;
69
70
// Applies transformation on the given point
71
void
TransformPoint(
PointF
* point)
const
;
72
73
std::string
ToString
()
const
;
74
75
private
:
76
// Row-major array
77
float
matrix_[16];
78
bool
is_identity_;
79
80
void
UpdateIdentity();
81
};
82
83
// This is declared here for use in gtest-based unit tests but is defined in
84
// the //ui/gfx:test_support target. Depend on that to use this in your unit
85
// test. This should not be used in production code - call ToString() instead.
86
void
PrintTo
(
const
Transform
&
transform
, ::std::ostream* os);
87
88
}
// namespace gfx
89
90
#endif
// UI_GFX_TRANSFORM_H_
gfx::PointF
Definition:
point_f.h:19
gfx::RectF
Definition:
rect_f.h:26
gfx::Transform
Definition:
transform.h:20
gfx::Transform::operator!=
bool operator!=(const Transform &rhs) const
Definition:
transform.h:51
gfx::Transform::operator[]
float operator[](int index) const
Definition:
transform.h:53
gfx_export.h
GFX_EXPORT
#define GFX_EXPORT
Definition:
gfx_export.h:26
Scale
Definition:
dart.idl:629
y
double y
Definition:
mouse-input-test.cc:83
x
double x
Definition:
mouse-input-test.cc:82
SkRecords::rect
sk_sp< SkBlender > blender SkRect rect
Definition:
SkRecords.h:350
gfx
Definition:
insets.cc:10
gfx::PrintTo
void PrintTo(const Point &point, ::std::ostream *os)
Definition:
gfx_util.cc:74
gfx::operator==
bool operator==(const Point &lhs, const Point &rhs)
Definition:
point.h:96
impeller::compiler::ToString
static std::string ToString(CompilerBackend::Type type)
Definition:
reflector.cc:559
sktext::gpu::Transform
skgpu::graphite::Transform Transform
Definition:
GraphiteVertexFiller.cpp:52
transform
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition:
p3.cpp:47
rect_f.h
BASE_DCHECK
#define BASE_DCHECK(condition)
Definition:
logging.h:63
Generated on Sun Jun 23 2024 21:55:21 for Flutter Engine by
1.9.4