Skia
2DGraphicsLibrary
|
The SkMatrix44 class holds a 4x4 matrix. More...
#include <SkMatrix44.h>
Public Types | |
enum | Uninitialized_Constructor { kUninitialized_Constructor } |
enum | Identity_Constructor { kIdentity_Constructor } |
enum | TypeMask { kIdentity_Mask = 0, kTranslate_Mask = 0x01, kScale_Mask = 0x02, kAffine_Mask = 0x04, kPerspective_Mask = 0x08 } |
Public Member Functions | |
SkMatrix44 (Uninitialized_Constructor) | |
constexpr | SkMatrix44 (Identity_Constructor) |
bool | operator!= (const SkMatrix44 &other) const |
SkMatrix44 (const SkMatrix &) | |
SkMatrix44 & | operator= (const SkMatrix &src) |
operator SkMatrix () const | |
TypeMask | getType () const |
Returns a bitfield describing the transformations the matrix may perform. More... | |
bool | isIdentity () const |
Return true if the matrix is identity. | |
bool | isTranslate () const |
Return true if the matrix contains translate or is identity. | |
bool | isScaleTranslate () const |
Return true if the matrix only contains scale or translate or is identity. | |
bool | isScale () const |
Returns true if the matrix only contains scale or is identity. | |
bool | hasPerspective () const |
void | setIdentity () |
void | reset () |
SkMScalar | get (int row, int col) const |
get a value from the matrix. More... | |
void | set (int row, int col, SkMScalar value) |
set a value in the matrix. More... | |
double | getDouble (int row, int col) const |
void | setDouble (int row, int col, double value) |
float | getFloat (int row, int col) const |
void | setFloat (int row, int col, float value) |
void | asColMajorf (float[]) const |
These methods allow one to efficiently read matrix entries into an array. More... | |
void | asColMajord (double[]) const |
void | asRowMajorf (float[]) const |
void | asRowMajord (double[]) const |
void | setColMajorf (const float[]) |
These methods allow one to efficiently set all matrix entries from an array. More... | |
void | setColMajord (const double[]) |
void | setRowMajorf (const float[]) |
void | setRowMajord (const double[]) |
void | setColMajor (const SkMScalar data[]) |
void | setRowMajor (const SkMScalar data[]) |
void | set3x3 (SkMScalar m00, SkMScalar m01, SkMScalar m02, SkMScalar m10, SkMScalar m11, SkMScalar m12, SkMScalar m20, SkMScalar m21, SkMScalar m22) |
void | set3x3RowMajorf (const float[]) |
void | setTranslate (SkMScalar dx, SkMScalar dy, SkMScalar dz) |
void | preTranslate (SkMScalar dx, SkMScalar dy, SkMScalar dz) |
void | postTranslate (SkMScalar dx, SkMScalar dy, SkMScalar dz) |
void | setScale (SkMScalar sx, SkMScalar sy, SkMScalar sz) |
void | preScale (SkMScalar sx, SkMScalar sy, SkMScalar sz) |
void | postScale (SkMScalar sx, SkMScalar sy, SkMScalar sz) |
void | setScale (SkMScalar scale) |
void | preScale (SkMScalar scale) |
void | postScale (SkMScalar scale) |
void | setRotateDegreesAbout (SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar degrees) |
void | setRotateAbout (SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar radians) |
Rotate about the vector [x,y,z]. More... | |
void | setRotateAboutUnit (SkMScalar x, SkMScalar y, SkMScalar z, SkMScalar radians) |
Rotate about the vector [x,y,z]. More... | |
void | setConcat (const SkMatrix44 &a, const SkMatrix44 &b) |
void | preConcat (const SkMatrix44 &m) |
void | postConcat (const SkMatrix44 &m) |
bool | invert (SkMatrix44 *inverse) const |
If this is invertible, return that in inverse and return true. More... | |
void | transpose () |
Transpose this matrix in place. More... | |
void | mapScalars (const SkScalar src[4], SkScalar dst[4]) const |
Apply the matrix to the src vector, returning the new vector in dst. More... | |
void | mapScalars (SkScalar vec[4]) const |
void | map (const SkScalar src[4], SkScalar dst[4]) const |
void | map (SkScalar vec[4]) const |
void | mapMScalars (const SkMScalar src[4], SkMScalar dst[4]) const |
void | mapMScalars (SkMScalar vec[4]) const |
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', w']. More... | |
void | map2 (const double src2[], int count, double dst4[]) const |
bool | preserves2dAxisAlignment (SkMScalar epsilon=SK_ScalarNearlyZero) const |
Returns true if transformating an axis-aligned square in 2d by this matrix will produce another 2d axis-aligned square; typically means the matrix is a scale with perhaps a 90-degree rotation. More... | |
void | dump () const |
double | determinant () const |
Static Public Member Functions | |
static const SkMatrix44 & | I () |
Return a reference to a const identity matrix. | |
Private Types | |
enum | { kUnknown_Mask = 0x80, kAllPublic_Masks = 0xF } |
Private Member Functions | |
void | as3x4RowMajorf (float[]) const |
void | set3x4RowMajorf (const float[]) |
SkMScalar | transX () const |
SkMScalar | transY () const |
SkMScalar | transZ () const |
SkMScalar | scaleX () const |
SkMScalar | scaleY () const |
SkMScalar | scaleZ () const |
SkMScalar | perspX () const |
SkMScalar | perspY () const |
SkMScalar | perspZ () const |
int | computeTypeMask () const |
void | dirtyTypeMask () |
void | setTypeMask (int mask) |
bool | isTriviallyIdentity () const |
Does not take the time to 'compute' the typemask. More... | |
const SkMScalar * | values () const |
Private Attributes | |
SkMScalar | fMat [4][4] |
unsigned | fTypeMask |
Friends | |
class | SkColorSpace |
class | SkColorSpace_XYZ |
SkMatrix44 | operator* (const SkMatrix44 &a, const SkMatrix44 &b) |
SkVector4 | operator* (const SkMatrix44 &m, const SkVector4 &src) |
The SkMatrix44 class holds a 4x4 matrix.
SkMatrix44 is not thread safe unless you've first called SkMatrix44::getType().
enum SkMatrix44::TypeMask |
void SkMatrix44::asColMajorf | ( | float | [] | ) | const |
These methods allow one to efficiently read matrix entries into an array.
The given array must have room for exactly 16 entries. Whenever possible, they will try to use memcpy rather than an entry-by-entry copy.
Col major indicates that consecutive elements of columns will be stored contiguously in memory. Row major indicates that consecutive elements of rows will be stored contiguously in memory.
|
inline |
get a value from the matrix.
The row,col parameters work as follows: (0, 0) scale-x (0, 3) translate-x (3, 0) perspective-x
|
inline |
Returns a bitfield describing the transformations the matrix may perform.
The bitfield is computed conservatively, so it may include false positives. For example, when kPerspective_Mask is true, all other bits may be set to true even in the case of a pure perspective transform.
bool SkMatrix44::invert | ( | SkMatrix44 * | inverse | ) | const |
If this is invertible, return that in inverse and return true.
If it is not invertible, return false and leave the inverse parameter in an unspecified state.
|
inlineprivate |
Does not take the time to 'compute' the typemask.
Only returns true if we already know that this matrix is identity.
void SkMatrix44::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', w'].
src2 | array of [x, y] pairs, with implied z=0 and w=1 |
count | number of [x, y] pairs in src2 |
dst4 | array of [x', y', z', w'] quads as the output. |
void SkMatrix44::mapScalars | ( | const SkScalar | src[4], |
SkScalar | dst[4] | ||
) | const |
Apply the matrix to the src vector, returning the new vector in dst.
It is legal for src and dst to point to the same memory.
bool SkMatrix44::preserves2dAxisAlignment | ( | SkMScalar | epsilon = SK_ScalarNearlyZero | ) | const |
Returns true if transformating an axis-aligned square in 2d by this matrix will produce another 2d axis-aligned square; typically means the matrix is a scale with perhaps a 90-degree rotation.
A 3d rotation through 90 degrees into a perpendicular plane collapses a square to a line, but is still considered to be axis-aligned.
By default, tolerates very slight error due to float imprecisions; a 90-degree rotation can still end up with 10^-17 of "non-axis-aligned" result.
|
inline |
set a value in the matrix.
The row,col parameters work as follows: (0, 0) scale-x (0, 3) translate-x (3, 0) perspective-x
void SkMatrix44::setColMajorf | ( | const float | [] | ) |
These methods allow one to efficiently set all matrix entries from an array.
The given array must have room for exactly 16 entries. Whenever possible, they will try to use memcpy rather than an entry-by-entry copy.
Col major indicates that input memory will be treated as if consecutive elements of columns are stored contiguously in memory. Row major indicates that input memory will be treated as if consecutive elements of rows are stored contiguously in memory.
void SkMatrix44::setRotateAbout | ( | SkMScalar | x, |
SkMScalar | y, | ||
SkMScalar | z, | ||
SkMScalar | radians | ||
) |
Rotate about the vector [x,y,z].
If that vector is not unit-length, it will be automatically resized.
void SkMatrix44::setRotateAboutUnit | ( | SkMScalar | x, |
SkMScalar | y, | ||
SkMScalar | z, | ||
SkMScalar | radians | ||
) |
Rotate about the vector [x,y,z].
Does not check the length of the vector, assuming it is unit-length.
void SkMatrix44::transpose | ( | ) |
Transpose this matrix in place.