52 const float*
ptr()
const {
return &x; }
53 float*
ptr() {
return &x; }
60 return x == v.
x && y == v.
y && z == v.
z;
66 return { a.
y*b.
z - a.
z*b.
y, a.
z*b.
x - a.
x*b.
z, a.
x*b.
y - a.
y*b.
x };
75 return { x*v.
x, y*v.
y, z*v.
z };
78 return { v.
x*s, v.
y*s, v.
z*s };
94 const float*
ptr()
const {
return &x; }
95 float*
ptr() {
return &x; }
102 return x == v.
x && y == v.
y && z == v.
z && w == v.
w;
107 return a.
x*b.
x + a.
y*b.
y + a.
z*b.
z + a.
w*b.
w;
116 return { x*v.
x, y*v.
y, z*v.
z, w*v.
w };
119 return { v.
x*s, v.
y*s, v.
z*s, v.
w*s };
129 const float*
ptr()
const {
return &x; }
130 float*
ptr() {
return &x; }
133 SkASSERT(i >= 0 && i < 4);
134 return this->ptr()[i];
137 SkASSERT(i >= 0 && i < 4);
138 return this->ptr()[i];
163 this->setConcat(a, b);
167 kUninitialized_Constructor
189 : fMat{m0, m1, m2, m3,
196 SkM44 m(kUninitialized_Constructor);
204 SkM44 m(kUninitialized_Constructor);
213 return SkM44(r[ 0], r[ 1], r[ 2], r[ 3],
214 r[ 4], r[ 5], r[ 6], r[ 7],
215 r[ 8], r[ 9], r[10], r[11],
216 r[12], r[13], r[14], r[15]);
219 return SkM44(c[0], c[4], c[ 8], c[12],
220 c[1], c[5], c[ 9], c[13],
221 c[2], c[6], c[10], c[14],
222 c[3], c[7], c[11], c[15]);
226 return SkM44(1, 0, 0, x,
233 return SkM44(x, 0, 0, 0,
240 SkM44 m(kUninitialized_Constructor);
253 return !(other == *
this);
257 memcpy(v, fMat,
sizeof(fMat));
262 SkASSERT(r >= 0 && r <= 3);
263 SkASSERT(c >= 0 && c <= 3);
264 return fMat[c*4 + r];
267 SkASSERT(r >= 0 && r <= 3);
268 SkASSERT(c >= 0 && c <= 3);
269 fMat[c*4 + r] = value;
273 SkASSERT(i >= 0 && i <= 3);
274 return {fMat[i + 0], fMat[i + 4], fMat[i + 8], fMat[i + 12]};
277 SkASSERT(i >= 0 && i <= 3);
278 return {fMat[i*4 + 0], fMat[i*4 + 1], fMat[i*4 + 2], fMat[i*4 + 3]};
282 SkASSERT(i >= 0 && i <= 3);
289 SkASSERT(i >= 0 && i <= 3);
290 memcpy(&fMat[i*4], v.
ptr(),
sizeof(v));
294 *
this = { 1, 0, 0, 0,
302 *
this = { 1, 0, 0, x,
310 *
this = { x, 0, 0, 0,
352 return this->setConcat(*
this, m);
356 return this->setConcat(m, *
this);
391 SkV4 map(
float x,
float y,
float z,
float w)
const;
393 return this->map(v.
x, v.
y, v.
z, v.
w);
396 auto v4 = this->map(v.
x, v.
y, v.
z, 0);
397 return {v4.x, v4.y, v4.z};
411 fMat[1], fMat[5], fMat[13],
412 fMat[3], fMat[7], fMat[15]);
439 friend class SkMatrixPriv;
static bool SkScalarsAreFinite(SkScalar a, SkScalar b)
Definition: SkScalar.h:70
#define SkScalarSin(radians)
Definition: SkScalar.h:43
#define SK_ScalarNaN
Definition: SkScalar.h:26
#define SkScalarCos(radians)
Definition: SkScalar.h:44
#define SkScalarSqrt(x)
Definition: SkScalar.h:40
float SkScalar
Definition: SkScalar.h:14
4x4 matrix used by SkCanvas and other parts of Skia.
Definition: SkM44.h:150
SkV4 map(float x, float y, float z, float w) const
SkV4 col(int i) const
Definition: SkM44.h:276
static SkM44 Rows(const SkV4 &r0, const SkV4 &r1, const SkV4 &r2, const SkV4 &r3)
Definition: SkM44.h:195
SkM44 & setIdentity()
Definition: SkM44.h:293
SkM44 & preConcat(const SkM44 &m)
Definition: SkM44.h:351
SkM44 & setTranslate(SkScalar x, SkScalar y, SkScalar z=0)
Definition: SkM44.h:301
SkM44 & postTranslate(SkScalar x, SkScalar y, SkScalar z=0)
SkM44 & operator=(const SkM44 &src)=default
void getColMajor(SkScalar v[]) const
Definition: SkM44.h:256
SkM44 & setRotateUnit(SkV3 axis, SkScalar radians)
Set this matrix to rotate about the specified unit-length axis vector, by an angle specified in radia...
Definition: SkM44.h:332
void getRowMajor(SkScalar v[]) const
friend SkM44 operator*(const SkM44 &a, const SkM44 &b)
Definition: SkM44.h:347
static SkM44 RowMajor(const SkScalar r[16])
Definition: SkM44.h:212
bool isFinite() const
Returns true if all elements of the matrix are finite.
Definition: SkM44.h:378
void setCol(int i, const SkV4 &v)
Definition: SkM44.h:288
SkM44 & setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle)
Set this matrix to rotate about the specified unit-length axis vector, by an angle specified by its s...
SkM44 & preScale(SkScalar x, SkScalar y)
static SkM44 RectToRect(const SkRect &src, const SkRect &dst)
void normalizePerspective()
A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 0, 1].
SkM44 & setScale(SkScalar x, SkScalar y, SkScalar z=1)
Definition: SkM44.h:309
static SkM44 ColMajor(const SkScalar c[16])
Definition: SkM44.h:218
SkM44(const SkM44 &a, const SkM44 &b)
Definition: SkM44.h:162
void setRow(int i, const SkV4 &v)
Definition: SkM44.h:281
SkScalar rc(int r, int c) const
Definition: SkM44.h:261
bool operator!=(const SkM44 &other) const
Definition: SkM44.h:252
static SkM44 Rotate(SkV3 axis, SkScalar radians)
Definition: SkM44.h:239
Uninitialized_Constructor
Definition: SkM44.h:166
SkM44(const SkM44 &src)=default
constexpr SkM44(NaN_Constructor)
Definition: SkM44.h:174
static SkM44 Translate(SkScalar x, SkScalar y, SkScalar z=0)
Definition: SkM44.h:225
SkM44(Uninitialized_Constructor)
Definition: SkM44.h:169
constexpr SkM44(SkScalar m0, SkScalar m4, SkScalar m8, SkScalar m12, SkScalar m1, SkScalar m5, SkScalar m9, SkScalar m13, SkScalar m2, SkScalar m6, SkScalar m10, SkScalar m14, SkScalar m3, SkScalar m7, SkScalar m11, SkScalar m15)
The constructor parameters are in row-major order.
Definition: SkM44.h:184
static SkM44 Perspective(float near, float far, float angle)
SkM44 & setConcat(const SkM44 &a, const SkM44 &b)
bool operator==(const SkM44 &other) const
SkV4 operator*(const SkV4 &v) const
Definition: SkM44.h:392
SkMatrix asM33() const
Definition: SkM44.h:409
void setRC(int r, int c, SkScalar value)
Definition: SkM44.h:266
bool invert(SkM44 *inverse) const
If this is invertible, return that in inverse and return true.
SkM44(const SkMatrix &src)
Definition: SkM44.h:415
SkM44 & postConcat(const SkM44 &m)
Definition: SkM44.h:355
SkM44 & setRotate(SkV3 axis, SkScalar radians)
Set this matrix to rotate about the specified axis vector, by an angle specified in radians.
NaN_Constructor
Definition: SkM44.h:171
SkV3 operator*(SkV3 v) const
Definition: SkM44.h:395
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
Definition: SkM44.h:232
static SkM44 LookAt(const SkV3 &eye, const SkV3 ¢er, const SkV3 &up)
constexpr SkM44()
Definition: SkM44.h:155
SkV4 row(int i) const
Definition: SkM44.h:272
SkM44 & preScale(SkScalar x, SkScalar y, SkScalar z)
SkM44 & preTranslate(SkScalar x, SkScalar y, SkScalar z=0)
static SkM44 Cols(const SkV4 &c0, const SkV4 &c1, const SkV4 &c2, const SkV4 &c3)
Definition: SkM44.h:203
SkM44 & preConcat(const SkMatrix &)
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Sets SkMatrix to:
Definition: SkMatrix.h:178
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
const float * ptr() const
Definition: SkM44.h:52
SkV2 normalize() const
Definition: SkM44.h:50
static SkV2 Normalize(SkV2 v)
Definition: SkM44.h:27
void operator*=(SkScalar s)
Definition: SkM44.h:42
static SkScalar Dot(SkV2 a, SkV2 b)
Definition: SkM44.h:25
SkScalar dot(SkV2 v) const
Definition: SkM44.h:48
friend SkV2 operator*(SkV2 v, SkScalar s)
Definition: SkM44.h:34
SkV2 operator*(SkV2 v) const
Definition: SkM44.h:33
float x
Definition: SkM44.h:20
void operator+=(SkV2 v)
Definition: SkM44.h:39
SkV2 operator-(SkV2 v) const
Definition: SkM44.h:31
void operator*=(SkV2 v)
Definition: SkM44.h:41
SkV2 operator-() const
Definition: SkM44.h:29
friend SkV2 operator/(SkScalar s, SkV2 v)
Definition: SkM44.h:37
void operator-=(SkV2 v)
Definition: SkM44.h:40
float * ptr()
Definition: SkM44.h:53
SkScalar lengthSquared() const
Definition: SkM44.h:45
bool operator==(const SkV2 v) const
Definition: SkM44.h:22
float y
Definition: SkM44.h:20
bool operator!=(const SkV2 v) const
Definition: SkM44.h:23
SkScalar length() const
Definition: SkM44.h:46
static SkScalar Cross(SkV2 a, SkV2 b)
Definition: SkM44.h:26
friend SkV2 operator/(SkV2 v, SkScalar s)
Definition: SkM44.h:36
void operator/=(SkScalar s)
Definition: SkM44.h:43
SkScalar cross(SkV2 v) const
Definition: SkM44.h:49
SkV2 operator+(SkV2 v) const
Definition: SkM44.h:30
friend SkV2 operator*(SkScalar s, SkV2 v)
Definition: SkM44.h:35
static SkScalar Dot(const SkV3 &a, const SkV3 &b)
Definition: SkM44.h:64
static SkV3 Normalize(const SkV3 &v)
Definition: SkM44.h:68
static SkV3 Cross(const SkV3 &a, const SkV3 &b)
Definition: SkM44.h:65
SkV3 normalize() const
Definition: SkM44.h:92
bool operator!=(const SkV3 &v) const
Definition: SkM44.h:62
float * ptr()
Definition: SkM44.h:95
void operator*=(SkV3 v)
Definition: SkM44.h:84
bool operator==(const SkV3 &v) const
Definition: SkM44.h:59
friend SkV3 operator*(SkScalar s, const SkV3 &v)
Definition: SkM44.h:80
SkV3 cross(const SkV3 &v) const
Definition: SkM44.h:91
SkScalar dot(const SkV3 &v) const
Definition: SkM44.h:90
void operator-=(SkV3 v)
Definition: SkM44.h:83
SkV3 operator-() const
Definition: SkM44.h:70
const float * ptr() const
Definition: SkM44.h:94
float y
Definition: SkM44.h:57
SkV3 operator*(const SkV3 &v) const
Definition: SkM44.h:74
float z
Definition: SkM44.h:57
SkV3 operator+(const SkV3 &v) const
Definition: SkM44.h:71
float x
Definition: SkM44.h:57
SkScalar lengthSquared() const
Definition: SkM44.h:87
friend SkV3 operator*(const SkV3 &v, SkScalar s)
Definition: SkM44.h:77
SkV3 operator-(const SkV3 &v) const
Definition: SkM44.h:72
void operator*=(SkScalar s)
Definition: SkM44.h:85
void operator+=(SkV3 v)
Definition: SkM44.h:82
SkScalar length() const
Definition: SkM44.h:88
float w
Definition: SkM44.h:99
SkScalar dot(const SkV4 &v) const
Definition: SkM44.h:126
SkV4 operator-(const SkV4 &v) const
Definition: SkM44.h:113
static SkV4 Normalize(const SkV4 &v)
Definition: SkM44.h:109
SkV4 operator+(const SkV4 &v) const
Definition: SkM44.h:112
friend SkV4 operator*(SkScalar s, const SkV4 &v)
Definition: SkM44.h:121
static SkScalar Dot(const SkV4 &a, const SkV4 &b)
Definition: SkM44.h:106
float y
Definition: SkM44.h:99
float x
Definition: SkM44.h:99
float operator[](int i) const
Definition: SkM44.h:132
const float * ptr() const
Definition: SkM44.h:129
SkScalar lengthSquared() const
Definition: SkM44.h:123
bool operator==(const SkV4 &v) const
Definition: SkM44.h:101
SkV4 operator*(const SkV4 &v) const
Definition: SkM44.h:115
float * ptr()
Definition: SkM44.h:130
float & operator[](int i)
Definition: SkM44.h:136
bool operator!=(const SkV4 &v) const
Definition: SkM44.h:104
float z
Definition: SkM44.h:99
SkScalar length() const
Definition: SkM44.h:124
SkV4 normalize() const
Definition: SkM44.h:127
friend SkV4 operator*(const SkV4 &v, SkScalar s)
Definition: SkM44.h:118
SkV4 operator-() const
Definition: SkM44.h:111