 |
Skia
2D Graphics Library
|
Go to the documentation of this file.
8 #ifndef SkMatrix44_DEFINED
9 #define SkMatrix44_DEFINED
25 this->
set(0, 0, 0, 1);
65 kUninitialized_Constructor
77 : fMat{{ 1, 0, 0, 0, },
81 , fTypeMask(kIdentity_Mask) {}
88 , fTypeMask(kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask) {}
97 this->setConcat(a, b);
102 return !(other == *
this);
117 #ifndef SK_SUPPORT_LEGACY_IMPLICIT_CONVERSION_MATRIX44
130 kTranslate_Mask = 1 << 0,
131 kScale_Mask = 1 << 1,
132 kAffine_Mask = 1 << 2,
133 kPerspective_Mask = 1 << 3,
149 return kIdentity_Mask == this->getType();
156 return !(this->getType() & ~kTranslate_Mask);
163 return !(this->getType() & ~(kScale_Mask | kTranslate_Mask));
170 return !(this->getType() & ~kScale_Mask);
174 return SkToBool(this->getType() & kPerspective_Mask);
178 inline void reset() { this->setIdentity();}
189 return fMat[col][row];
201 fMat[col][row] = value;
202 this->recomputeTypeMask();
206 return double(this->get(row, col));
209 this->set(row, col,
SkScalar(value));
212 return float(this->get(row, col));
214 inline void setFloat(
int row,
int col,
float value) {
215 this->set(row, col, value);
272 return this->setScale(scale, scale, scale);
275 return this->preScale(scale, scale, scale);
278 return this->postScale(scale, scale, scale);
282 this->setRotateAbout(x, y, z, degrees *
SK_ScalarPI / 180);
296 this->setConcat(*
this, m);
299 this->setConcat(m, *
this);
320 this->mapScalars(vec, vec);
337 void map2(
const float src2[],
int count,
float dst4[])
const;
338 void map2(
const double src2[],
int count,
double dst4[])
const;
361 static constexpr
int kAllPublic_Masks = 0xF;
363 void as3x4RowMajorf(
float[])
const;
364 void set3x4RowMajorf(
const float[]);
366 SkScalar transX()
const {
return fMat[3][0]; }
367 SkScalar transY()
const {
return fMat[3][1]; }
368 SkScalar transZ()
const {
return fMat[3][2]; }
370 SkScalar scaleX()
const {
return fMat[0][0]; }
371 SkScalar scaleY()
const {
return fMat[1][1]; }
372 SkScalar scaleZ()
const {
return fMat[2][2]; }
374 SkScalar perspX()
const {
return fMat[0][3]; }
375 SkScalar perspY()
const {
return fMat[1][3]; }
376 SkScalar perspZ()
const {
return fMat[2][3]; }
378 void recomputeTypeMask();
380 inline void setTypeMask(TypeMask mask) {
381 SkASSERT(0 == (~kAllPublic_Masks & mask));
385 inline const SkScalar* values()
const {
return &fMat[0][0]; }
void setRowMajorf(const float[])
void setRotateAboutUnit(SkScalar x, SkScalar y, SkScalar z, SkScalar radians)
Rotate about the vector [x,y,z].
bool isTranslate() const
Return true if the matrix contains translate or is identity.
Definition: SkMatrix44.h:155
SkMatrix44 & setScale(SkScalar sx, SkScalar sy, SkScalar sz)
SkVector4 & operator=(const SkVector4 &src)
Definition: SkMatrix44.h:37
void setColMajord(const double[])
void postConcat(const SkMatrix44 &m)
Definition: SkMatrix44.h:298
void setColMajorf(const float[])
These methods allow one to efficiently set all matrix entries from an array.
SkMatrix44(const SkMatrix44 &src)=default
SkMatrix44 & preScale(SkScalar sx, SkScalar sy, SkScalar sz)
static const SkMatrix44 & I()
Return a reference to a const identity matrix.
4x4 matrix used by SkCanvas and other parts of Skia.
Definition: SkM44.h:133
void set4x4(SkScalar m_00, SkScalar m_10, SkScalar m_20, SkScalar m_30, SkScalar m_01, SkScalar m_11, SkScalar m_21, SkScalar m_31, SkScalar m_02, SkScalar m_12, SkScalar m_22, SkScalar m_32, SkScalar m_03, SkScalar m_13, SkScalar m_23, SkScalar m_33)
bool operator==(const SkMatrix44 &other) const
bool isScaleTranslate() const
Return true if the matrix only contains scale or translate or is identity.
Definition: SkMatrix44.h:162
bool operator!=(const SkVector4 &v) const
Definition: SkMatrix44.h:46
SkMatrix44(const SkMatrix44 &a, const SkMatrix44 &b)
Definition: SkMatrix44.h:96
SkMatrix44 & preScale(SkScalar scale)
Definition: SkMatrix44.h:274
void asColMajord(double[]) const
void set3x3(SkScalar m_00, SkScalar m_10, SkScalar m_20, SkScalar m_01, SkScalar m_11, SkScalar m_21, SkScalar m_02, SkScalar m_12, SkScalar m_22)
friend SkVector4 operator*(const SkMatrix44 &m, const SkVector4 &src)
Definition: SkMatrix44.h:323
void setColMajor(const SkScalar data[])
Definition: SkMatrix44.h:247
SkVector4()
Definition: SkMatrix44.h:24
#define SK_ScalarNaN
Definition: SkScalar.h:27
SkMatrix44 & postTranslate(SkScalar dx, SkScalar dy, SkScalar dz)
constexpr SkMatrix44(Identity_Constructor)
Definition: SkMatrix44.h:76
void setConcat(const SkMatrix44 &a, const SkMatrix44 &b)
bool isIdentity() const
Return true if the matrix is identity.
Definition: SkMatrix44.h:148
Identity_Constructor
Definition: SkMatrix44.h:67
bool operator!=(const SkMatrix44 &other) const
Definition: SkMatrix44.h:101
void mapScalars(const SkScalar src[4], SkScalar dst[4]) const
Apply the matrix to the src vector, returning the new vector in dst.
bool operator==(const SkVector4 &v) const
Definition: SkMatrix44.h:42
SkVector4(const SkVector4 &src)
Definition: SkMatrix44.h:27
static constexpr bool SkToBool(const T &x)
Definition: SkTypes.h:497
#define SK_API
Definition: SkTypes.h:181
#define SkASSERT(cond)
Definition: SkTypes.h:460
#define SK_ScalarNearlyZero
Definition: SkScalar.h:134
double determinant() const
SkMatrix44(NaN_Constructor)
Definition: SkMatrix44.h:83
#define SK_ScalarPI
Definition: SkScalar.h:21
uint8_t TypeMask
Definition: SkMatrix44.h:127
SkMatrix44 & postScale(SkScalar scale)
Definition: SkMatrix44.h:277
float getFloat(int row, int col) const
Definition: SkMatrix44.h:211
Uninitialized_Constructor
Definition: SkMatrix44.h:64
Definition: SkMatrix44.h:21
friend SkMatrix44 operator*(const SkMatrix44 &a, const SkMatrix44 &b)
Definition: SkMatrix44.h:302
Definition: SkCanvas.h:87
void set(int row, int col, SkScalar value)
set a value in the matrix.
Definition: SkMatrix44.h:198
SkMatrix44 & operator=(const SkMatrix &src)
void setFloat(int row, int col, float value)
Definition: SkMatrix44.h:214
void setRowMajor(const SkScalar data[])
Definition: SkMatrix44.h:248
#define SK_Scalar1
Definition: SkScalar.h:18
TypeMask getType() const
Returns a bitfield describing the transformations the matrix may perform.
Definition: SkMatrix44.h:143
bool isScale() const
Returns true if the matrix only contains scale or is identity.
Definition: SkMatrix44.h:169
void map2(const float src2[], int count, float dst4[]) const
map an array of [x, y, 0, 1] through the matrix, returning an array of [x', y', z',...
void asColMajorf(float[]) const
These methods allow one to efficiently read matrix entries into an array.
float SkScalar
Definition: SkScalar.h:16
bool hasPerspective() const
Definition: SkMatrix44.h:173
SkMatrix44(Uninitialized_Constructor)
Definition: SkMatrix44.h:74
SkMatrix44 & preTranslate(SkScalar dx, SkScalar dy, SkScalar dz)
void transpose()
Transpose this matrix in place.
void setRotateAbout(SkScalar x, SkScalar y, SkScalar z, SkScalar radians)
Rotate about the vector [x,y,z].
void mapScalars(SkScalar vec[4]) const
Definition: SkMatrix44.h:319
bool invert(SkMatrix44 *inverse) const
If this is invertible, return that in inverse and return true.
SkMatrix44 & setScale(SkScalar scale)
Definition: SkMatrix44.h:271
bool preserves2dAxisAlignment(SkScalar epsilon=SK_ScalarNearlyZero) const
Returns true if transformating an axis-aligned square in 2d by this matrix will produce another 2d ax...
Definition: SkMatrix.h:48
void setRotateDegreesAbout(SkScalar x, SkScalar y, SkScalar z, SkScalar degrees)
Definition: SkMatrix44.h:281
void preConcat(const SkMatrix44 &m)
Definition: SkMatrix44.h:295
Definition: SkMatrix44.h:61
SkScalar get(int row, int col) const
get a value from the matrix.
Definition: SkMatrix44.h:186
double getDouble(int row, int col) const
Definition: SkMatrix44.h:205
SkMatrix44 & postScale(SkScalar sx, SkScalar sy, SkScalar sz)
SkScalar fData[4]
Definition: SkMatrix44.h:22
SkMatrix44(const SkMatrix &)
void asRowMajord(double[]) const
void reset()
Definition: SkMatrix44.h:178
void set3x3RowMajorf(const float[])
void setRowMajord(const double[])
void map2(const double src2[], int count, double dst4[]) const
SkMatrix44 & operator=(const SkMatrix44 &src)=default
void setDouble(int row, int col, double value)
Definition: SkMatrix44.h:208
void set(SkScalar x, SkScalar y, SkScalar z, SkScalar w=SK_Scalar1)
Definition: SkMatrix44.h:52
SkVector4(SkScalar x, SkScalar y, SkScalar z, SkScalar w=SK_Scalar1)
Definition: SkMatrix44.h:30
SkMatrix44 & setTranslate(SkScalar dx, SkScalar dy, SkScalar dz)
constexpr SkMatrix44()
Definition: SkMatrix44.h:90
void asRowMajorf(float[]) const
bool equals(SkScalar x, SkScalar y, SkScalar z, SkScalar w=SK_Scalar1)
Definition: SkMatrix44.h:47
NaN_Constructor
Definition: SkMatrix44.h:70
Definition: SkColorSpace.h:104