Skia
2D Graphics Library
SkM44 Class Reference

4x4 matrix used by SkCanvas and other parts of Skia. More...

#include <SkM44.h>

Public Types

enum  Uninitialized_Constructor { kUninitialized_Constructor }
 
enum  NaN_Constructor { kNaN_Constructor }
 

Public Member Functions

 SkM44 (const SkM44 &src)=default
 
SkM44operator= (const SkM44 &src)=default
 
constexpr SkM44 ()
 
 SkM44 (const SkM44 &a, const SkM44 &b)
 
 SkM44 (Uninitialized_Constructor)
 
constexpr SkM44 (NaN_Constructor)
 
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. More...
 
bool operator== (const SkM44 &other) const
 
bool operator!= (const SkM44 &other) const
 
void getColMajor (SkScalar v[]) const
 
void getRowMajor (SkScalar v[]) const
 
SkScalar rc (int r, int c) const
 
void setRC (int r, int c, SkScalar value)
 
SkV4 row (int i) const
 
SkV4 col (int i) const
 
void setRow (int i, const SkV4 &v)
 
void setCol (int i, const SkV4 &v)
 
SkM44setIdentity ()
 
SkM44setTranslate (SkScalar x, SkScalar y, SkScalar z=0)
 
SkM44setScale (SkScalar x, SkScalar y, SkScalar z=1)
 
SkM44setRotateUnitSinCos (SkV3 axis, SkScalar sinAngle, SkScalar cosAngle)
 Set this matrix to rotate about the specified unit-length axis vector, by an angle specified by its sin() and cos(). More...
 
SkM44setRotateUnit (SkV3 axis, SkScalar radians)
 Set this matrix to rotate about the specified unit-length axis vector, by an angle specified in radians. More...
 
SkM44setRotate (SkV3 axis, SkScalar radians)
 Set this matrix to rotate about the specified axis vector, by an angle specified in radians. More...
 
SkM44setConcat (const SkM44 &a, const SkM44 &b)
 
SkM44preConcat (const SkM44 &m)
 
SkM44postConcat (const SkM44 &m)
 
void normalizePerspective ()
 A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 0, 1]. More...
 
bool isFinite () const
 Returns true if all elements of the matrix are finite. More...
 
bool invert (SkM44 *inverse) const
 If this is invertible, return that in inverse and return true. More...
 
SkM44 transpose () const
 
void dump () const
 
SkV4 map (float x, float y, float z, float w) const
 
SkV4 operator* (const SkV4 &v) const
 
SkV3 operator* (SkV3 v) const
 
SkMatrix asM33 () const
 
 SkM44 (const SkMatrix &src)
 
SkM44preTranslate (SkScalar x, SkScalar y, SkScalar z=0)
 
SkM44postTranslate (SkScalar x, SkScalar y, SkScalar z=0)
 
SkM44preScale (SkScalar x, SkScalar y)
 
SkM44preScale (SkScalar x, SkScalar y, SkScalar z)
 
SkM44preConcat (const SkMatrix &)
 

Static Public Member Functions

static SkM44 Rows (const SkV4 &r0, const SkV4 &r1, const SkV4 &r2, const SkV4 &r3)
 
static SkM44 Cols (const SkV4 &c0, const SkV4 &c1, const SkV4 &c2, const SkV4 &c3)
 
static SkM44 RowMajor (const SkScalar r[16])
 
static SkM44 ColMajor (const SkScalar c[16])
 
static SkM44 Translate (SkScalar x, SkScalar y, SkScalar z=0)
 
static SkM44 Scale (SkScalar x, SkScalar y, SkScalar z=1)
 
static SkM44 Rotate (SkV3 axis, SkScalar radians)
 
static SkM44 RectToRect (const SkRect &src, const SkRect &dst)
 
static SkM44 LookAt (const SkV3 &eye, const SkV3 &center, const SkV3 &up)
 
static SkM44 Perspective (float near, float far, float angle)
 

Friends

class SkMatrixPriv
 
SkM44 operator* (const SkM44 &a, const SkM44 &b)
 

Detailed Description

4x4 matrix used by SkCanvas and other parts of Skia.

Skia assumes a right-handed coordinate system: +X goes to the right +Y goes down +Z goes into the screen (away from the viewer)

Member Enumeration Documentation

◆ NaN_Constructor

Enumerator
kNaN_Constructor 

◆ Uninitialized_Constructor

Enumerator
kUninitialized_Constructor 

Constructor & Destructor Documentation

◆ SkM44() [1/7]

SkM44::SkM44 ( const SkM44 src)
default

◆ SkM44() [2/7]

constexpr SkM44::SkM44 ( )
inlineconstexpr

◆ SkM44() [3/7]

SkM44::SkM44 ( const SkM44 a,
const SkM44 b 
)
inline

◆ SkM44() [4/7]

SkM44::SkM44 ( Uninitialized_Constructor  )
inline

◆ SkM44() [5/7]

constexpr SkM44::SkM44 ( NaN_Constructor  )
inlineconstexpr

◆ SkM44() [6/7]

constexpr SkM44::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 
)
inlineconstexpr

The constructor parameters are in row-major order.

◆ SkM44() [7/7]

SkM44::SkM44 ( const SkMatrix src)
inlineexplicit

Member Function Documentation

◆ asM33()

SkMatrix SkM44::asM33 ( ) const
inline

◆ col()

SkV4 SkM44::col ( int  i) const
inline

◆ ColMajor()

static SkM44 SkM44::ColMajor ( const SkScalar  c[16])
inlinestatic

◆ Cols()

static SkM44 SkM44::Cols ( const SkV4 c0,
const SkV4 c1,
const SkV4 c2,
const SkV4 c3 
)
inlinestatic

◆ dump()

void SkM44::dump ( ) const

◆ getColMajor()

void SkM44::getColMajor ( SkScalar  v[]) const
inline

◆ getRowMajor()

void SkM44::getRowMajor ( SkScalar  v[]) const

◆ invert()

bool SkM44::invert ( SkM44 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 unchanged.

◆ isFinite()

bool SkM44::isFinite ( ) const
inline

Returns true if all elements of the matrix are finite.

Returns false if any element is infinity, or NaN.

Returns
true if matrix has only finite elements

◆ LookAt()

static SkM44 SkM44::LookAt ( const SkV3 eye,
const SkV3 center,
const SkV3 up 
)
static

◆ map()

SkV4 SkM44::map ( float  x,
float  y,
float  z,
float  w 
) const

◆ normalizePerspective()

void SkM44::normalizePerspective ( )

A matrix is categorized as 'perspective' if the bottom row is not [0, 0, 0, 1].

For most uses, a bottom row of [0, 0, 0, X] behaves like a non-perspective matrix, though it will be categorized as perspective. Calling normalizePerspective() will change the matrix such that, if its bottom row was [0, 0, 0, X], it will be changed to [0, 0, 0, 1] by scaling the rest of the matrix by 1/X.

| A B C D | | A/X B/X C/X D/X | | E F G H | -> | E/X F/X G/X H/X | for X != 0 | I J K L | | I/X J/X K/X L/X | | 0 0 0 X | | 0 0 0 1 |

◆ operator!=()

bool SkM44::operator!= ( const SkM44 other) const
inline

◆ operator*() [1/2]

SkV4 SkM44::operator* ( const SkV4 v) const
inline

◆ operator*() [2/2]

SkV3 SkM44::operator* ( SkV3  v) const
inline

◆ operator=()

SkM44& SkM44::operator= ( const SkM44 src)
default

◆ operator==()

bool SkM44::operator== ( const SkM44 other) const

◆ Perspective()

static SkM44 SkM44::Perspective ( float  near,
float  far,
float  angle 
)
static

◆ postConcat()

SkM44& SkM44::postConcat ( const SkM44 m)
inline

◆ postTranslate()

SkM44& SkM44::postTranslate ( SkScalar  x,
SkScalar  y,
SkScalar  z = 0 
)

◆ preConcat() [1/2]

SkM44& SkM44::preConcat ( const SkM44 m)
inline

◆ preConcat() [2/2]

SkM44& SkM44::preConcat ( const SkMatrix )

◆ preScale() [1/2]

SkM44& SkM44::preScale ( SkScalar  x,
SkScalar  y 
)

◆ preScale() [2/2]

SkM44& SkM44::preScale ( SkScalar  x,
SkScalar  y,
SkScalar  z 
)

◆ preTranslate()

SkM44& SkM44::preTranslate ( SkScalar  x,
SkScalar  y,
SkScalar  z = 0 
)

◆ rc()

SkScalar SkM44::rc ( int  r,
int  c 
) const
inline

◆ RectToRect()

static SkM44 SkM44::RectToRect ( const SkRect src,
const SkRect dst 
)
static

◆ Rotate()

static SkM44 SkM44::Rotate ( SkV3  axis,
SkScalar  radians 
)
inlinestatic

◆ row()

SkV4 SkM44::row ( int  i) const
inline

◆ RowMajor()

static SkM44 SkM44::RowMajor ( const SkScalar  r[16])
inlinestatic

◆ Rows()

static SkM44 SkM44::Rows ( const SkV4 r0,
const SkV4 r1,
const SkV4 r2,
const SkV4 r3 
)
inlinestatic

◆ Scale()

static SkM44 SkM44::Scale ( SkScalar  x,
SkScalar  y,
SkScalar  z = 1 
)
inlinestatic

◆ setCol()

void SkM44::setCol ( int  i,
const SkV4 v 
)
inline

◆ setConcat()

SkM44& SkM44::setConcat ( const SkM44 a,
const SkM44 b 
)

◆ setIdentity()

SkM44& SkM44::setIdentity ( )
inline

◆ setRC()

void SkM44::setRC ( int  r,
int  c,
SkScalar  value 
)
inline

◆ setRotate()

SkM44& SkM44::setRotate ( SkV3  axis,
SkScalar  radians 
)

Set this matrix to rotate about the specified axis vector, by an angle specified in radians.

Note: axis is not assumed to be unit-length, so it will be normalized internally. If axis is already unit-length, call setRotateAboutUnitRadians() instead.

◆ setRotateUnit()

SkM44& SkM44::setRotateUnit ( SkV3  axis,
SkScalar  radians 
)
inline

Set this matrix to rotate about the specified unit-length axis vector, by an angle specified in radians.

This does not attempt to verify that axis.length() == 1.

◆ setRotateUnitSinCos()

SkM44& 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 sin() and cos().

This does not attempt to verify that axis.length() == 1 or that the sin,cos values are correct.

◆ setRow()

void SkM44::setRow ( int  i,
const SkV4 v 
)
inline

◆ setScale()

SkM44& SkM44::setScale ( SkScalar  x,
SkScalar  y,
SkScalar  z = 1 
)
inline

◆ setTranslate()

SkM44& SkM44::setTranslate ( SkScalar  x,
SkScalar  y,
SkScalar  z = 0 
)
inline

◆ Translate()

static SkM44 SkM44::Translate ( SkScalar  x,
SkScalar  y,
SkScalar  z = 0 
)
inlinestatic

◆ transpose()

SkM44 SkM44::transpose ( ) const

Friends And Related Function Documentation

◆ operator*

SkM44 operator* ( const SkM44 a,
const SkM44 b 
)
friend

◆ SkMatrixPriv

friend class SkMatrixPriv
friend

The documentation for this class was generated from the following file: