Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkMatrix Class Reference

The SkMatrix class holds a 3x3 matrix for transforming coordinates. More...

#include <SkMatrix.h>

Public Types

enum  TypeMask {
  kIdentity_Mask = 0, kTranslate_Mask = 0x01, kScale_Mask = 0x02, kAffine_Mask = 0x04,
  kPerspective_Mask = 0x08
}
 Enum of bit fields for the mask return by getType(). More...
 
enum  {
  kMScaleX, kMSkewX, kMTransX, kMSkewY,
  kMScaleY, kMTransY, kMPersp0, kMPersp1,
  kMPersp2
}
 
enum  {
  kAScaleX, kASkewY, kASkewX, kAScaleY,
  kATransX, kATransY
}
 Affine arrays are in column major order because that's how PDF and XPS like it.
 
enum  ScaleToFit { kFill_ScaleToFit, kStart_ScaleToFit, kCenter_ScaleToFit, kEnd_ScaleToFit }
 
enum  { kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t) }
 
typedef void(* MapXYProc )(const SkMatrix &mat, SkScalar x, SkScalar y, SkPoint *result)
 
typedef void(* MapPtsProc )(const SkMatrix &mat, SkPoint dst[], const SkPoint src[], int count)
 

Public Member Functions

TypeMask getType () const
 Returns a bitfield describing the transformations the matrix may perform. More...
 
bool isIdentity () const
 Returns true if the matrix is identity.
 
bool isScaleTranslate () const
 
bool rectStaysRect () const
 Returns true if will map a rectangle to another rectangle. More...
 
bool preservesAxisAlignment () const
 
bool hasPerspective () const
 Returns true if the matrix contains perspective elements.
 
bool isSimilarity (SkScalar tol=SK_ScalarNearlyZero) const
 Returns true if the matrix contains only translation, rotation/reflection or uniform scale Returns false if other transformation types are included or is degenerate.
 
bool preservesRightAngles (SkScalar tol=SK_ScalarNearlyZero) const
 Returns true if the matrix contains only translation, rotation/reflection or scale (non-uniform scale is allowed). More...
 
SkScalar operator[] (int index) const
 
SkScalar get (int index) const
 
SkScalar getScaleX () const
 
SkScalar getScaleY () const
 
SkScalar getSkewY () const
 
SkScalar getSkewX () const
 
SkScalar getTranslateX () const
 
SkScalar getTranslateY () const
 
SkScalar getPerspX () const
 
SkScalar getPerspY () const
 
SkScalar & operator[] (int index)
 
void set (int index, SkScalar value)
 
void setScaleX (SkScalar v)
 
void setScaleY (SkScalar v)
 
void setSkewY (SkScalar v)
 
void setSkewX (SkScalar v)
 
void setTranslateX (SkScalar v)
 
void setTranslateY (SkScalar v)
 
void setPerspX (SkScalar v)
 
void setPerspY (SkScalar v)
 
void setAll (SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2)
 
void get9 (SkScalar buffer[9]) const
 Copy the 9 scalars for this matrix into buffer, in the same order as the kMScaleX enum... More...
 
void set9 (const SkScalar buffer[9])
 Set this matrix to the 9 scalars from the buffer, in the same order as the kMScaleX enum... More...
 
void reset ()
 Set the matrix to identity.
 
void setIdentity ()
 
void setTranslate (SkScalar dx, SkScalar dy)
 Set the matrix to translate by (dx, dy).
 
void setTranslate (const SkVector &v)
 
void setScale (SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 Set the matrix to scale by sx and sy, with a pivot point at (px, py). More...
 
void setScale (SkScalar sx, SkScalar sy)
 Set the matrix to scale by sx and sy.
 
bool setIDiv (int divx, int divy)
 Set the matrix to scale by 1/divx and 1/divy. More...
 
void setRotate (SkScalar degrees, SkScalar px, SkScalar py)
 Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py). More...
 
void setRotate (SkScalar degrees)
 Set the matrix to rotate about (0,0) by the specified number of degrees.
 
void setSinCos (SkScalar sinValue, SkScalar cosValue, SkScalar px, SkScalar py)
 Set the matrix to rotate by the specified sine and cosine values, with a pivot point at (px, py). More...
 
void setSinCos (SkScalar sinValue, SkScalar cosValue)
 Set the matrix to rotate by the specified sine and cosine values.
 
SkMatrixsetRSXform (const SkRSXform &)
 
void setSkew (SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)
 Set the matrix to skew by sx and sy, with a pivot point at (px, py). More...
 
void setSkew (SkScalar kx, SkScalar ky)
 Set the matrix to skew by sx and sy.
 
void setConcat (const SkMatrix &a, const SkMatrix &b)
 Set the matrix to the concatenation of the two specified matrices. More...
 
void preTranslate (SkScalar dx, SkScalar dy)
 Preconcats the matrix with the specified translation. More...
 
void preScale (SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 Preconcats the matrix with the specified scale. More...
 
void preScale (SkScalar sx, SkScalar sy)
 Preconcats the matrix with the specified scale. More...
 
void preRotate (SkScalar degrees, SkScalar px, SkScalar py)
 Preconcats the matrix with the specified rotation. More...
 
void preRotate (SkScalar degrees)
 Preconcats the matrix with the specified rotation. More...
 
void preSkew (SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)
 Preconcats the matrix with the specified skew. More...
 
void preSkew (SkScalar kx, SkScalar ky)
 Preconcats the matrix with the specified skew. More...
 
void preConcat (const SkMatrix &other)
 Preconcats the matrix with the specified matrix. More...
 
void postTranslate (SkScalar dx, SkScalar dy)
 Postconcats the matrix with the specified translation. More...
 
void postScale (SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
 Postconcats the matrix with the specified scale. More...
 
void postScale (SkScalar sx, SkScalar sy)
 Postconcats the matrix with the specified scale. More...
 
bool postIDiv (int divx, int divy)
 Postconcats the matrix by dividing it by the specified integers. More...
 
void postRotate (SkScalar degrees, SkScalar px, SkScalar py)
 Postconcats the matrix with the specified rotation. More...
 
void postRotate (SkScalar degrees)
 Postconcats the matrix with the specified rotation. More...
 
void postSkew (SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)
 Postconcats the matrix with the specified skew. More...
 
void postSkew (SkScalar kx, SkScalar ky)
 Postconcats the matrix with the specified skew. More...
 
void postConcat (const SkMatrix &other)
 Postconcats the matrix with the specified matrix. More...
 
bool setRectToRect (const SkRect &src, const SkRect &dst, ScaleToFit stf)
 Set the matrix to the scale and translate values that map the source rectangle to the destination rectangle, returning true if the the result can be represented. More...
 
bool setPolyToPoly (const SkPoint src[], const SkPoint dst[], int count)
 Set the matrix such that the specified src points would map to the specified dst points. More...
 
bool SK_WARN_UNUSED_RESULT invert (SkMatrix *inverse) const
 If this matrix can be inverted, return true and if inverse is not null, set inverse to be the inverse of this matrix. More...
 
bool SK_WARN_UNUSED_RESULT asAffine (SkScalar affine[6]) const
 Fills the passed array with the affine values in column major order. More...
 
void setAffine (const SkScalar affine[6])
 Set the matrix to the specified affine values. More...
 
void mapPoints (SkPoint dst[], const SkPoint src[], int count) const
 Apply this matrix to the array of points specified by src, and write the transformed points into the array of points specified by dst. More...
 
void mapPoints (SkPoint pts[], int count) const
 Apply this matrix to the array of points, overwriting it with the transformed values. More...
 
void mapPointsWithStride (SkPoint pts[], size_t stride, int count) const
 Like mapPoints but with custom byte stride between the points. More...
 
void mapPointsWithStride (SkPoint dst[], SkPoint src[], size_t stride, int count) const
 Like mapPoints but with custom byte stride between the points.
 
void mapHomogeneousPoints (SkScalar dst[], const SkScalar src[], int count) const
 Apply this matrix to the array of homogeneous points, specified by src, where a homogeneous point is defined by 3 contiguous scalar values, and write the transformed points into the array of scalars specified by dst. More...
 
void mapXY (SkScalar x, SkScalar y, SkPoint *result) const
 
SkPoint mapXY (SkScalar x, SkScalar y) const
 
void mapVectors (SkVector dst[], const SkVector src[], int count) const
 Apply this matrix to the array of vectors specified by src, and write the transformed vectors into the array of vectors specified by dst. More...
 
void mapVectors (SkVector vecs[], int count) const
 Apply this matrix to the array of vectors specified by src, and write the transformed vectors into the array of vectors specified by dst. More...
 
void mapVector (SkScalar dx, SkScalar dy, SkVector *result) const
 
SkVector mapVector (SkScalar dx, SkScalar dy) const
 
bool mapRect (SkRect *dst, const SkRect &src) const
 Apply this matrix to the src rectangle, and write the transformed rectangle into dst. More...
 
bool mapRect (SkRect *rect) const
 Apply this matrix to the rectangle, and write the transformed rectangle back into it. More...
 
void mapRectToQuad (SkPoint dst[4], const SkRect &rect) const
 Apply this matrix to the src rectangle, and write the four transformed points into dst. More...
 
void mapRectScaleTranslate (SkRect *dst, const SkRect &src) const
 Maps a rect to another rect, asserting (in debug mode) that the matrix only contains scale and translate elements. More...
 
SkScalar mapRadius (SkScalar radius) const
 Return the mean radius of a circle after it has been mapped by this matrix. More...
 
MapXYProc getMapXYProc () const
 
MapPtsProc getMapPtsProc () const
 
bool isFixedStepInX () const
 Returns true if the matrix can be stepped in X (not complex perspective).
 
SkVector fixedStepInX (SkScalar y) const
 If the matrix can be stepped in X (not complex perspective) then return the step value. More...
 
bool cheapEqualTo (const SkMatrix &m) const
 Efficient comparison of two matrices. More...
 
size_t writeToMemory (void *buffer) const
 
size_t readFromMemory (const void *buffer, size_t length)
 Reads data from the buffer parameter. More...
 
void dump () const
 
void toString (SkString *) const
 
SkScalar getMinScale () const
 Calculates the minimum scaling factor of the matrix as computed from the SVD of the upper left 2x2. More...
 
SkScalar getMaxScale () const
 Calculates the maximum scaling factor of the matrix as computed from the SVD of the upper left 2x2. More...
 
bool SK_WARN_UNUSED_RESULT getMinMaxScales (SkScalar scaleFactors[2]) const
 Gets both the min and max scale factors. More...
 
bool decomposeScale (SkSize *scale, SkMatrix *remaining=NULL) const
 Attempt to decompose this matrix into a scale-only component and whatever remains, where the scale component is to be applied first. More...
 
void dirtyMatrixTypeCache ()
 Testing routine; the matrix's type cache should never need to be manually invalidated during normal use.
 
void setScaleTranslate (SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty)
 Initialize the matrix to be scale + post-translate.
 

Static Public Member Functions

static SkMatrix
SK_WARN_UNUSED_RESULT 
MakeScale (SkScalar sx, SkScalar sy)
 
static SkMatrix
SK_WARN_UNUSED_RESULT 
MakeScale (SkScalar scale)
 
static SkMatrix
SK_WARN_UNUSED_RESULT 
MakeTrans (SkScalar dx, SkScalar dy)
 
static SkMatrix MakeRectToRect (const SkRect &src, const SkRect &dst, ScaleToFit stf)
 
static void SetAffineIdentity (SkScalar affine[6])
 Fills the passed array with affine identity values in column major order. More...
 
static MapXYProc GetMapXYProc (TypeMask mask)
 
static MapPtsProc GetMapPtsProc (TypeMask mask)
 
static const SkMatrixI ()
 Return a reference to a const identity matrix.
 
static const SkMatrixInvalidMatrix ()
 Return a reference to a const matrix that is "invalid", one that could never be used.
 
static SkMatrix Concat (const SkMatrix &a, const SkMatrix &b)
 Return the concatenation of two matrices, a * b.
 

Private Types

enum  {
  kRectStaysRect_Mask = 0x10, kOnlyPerspectiveValid_Mask = 0x40, kUnknown_Mask = 0x80, kORableMasks,
  kAllMasks
}
 

Private Member Functions

bool isFinite () const
 Are all elements of the matrix finite?
 
uint8_t computeTypeMask () const
 
uint8_t computePerspectiveTypeMask () const
 
void setTypeMask (int mask)
 
void orTypeMask (int mask)
 
void clearTypeMask (int mask)
 
TypeMask getPerspectiveTypeMaskOnly () const
 
bool isTriviallyIdentity () const
 Returns true if we already know that the matrix is identity; false otherwise.
 
bool SK_WARN_UNUSED_RESULT invertNonIdentity (SkMatrix *inverse) const
 

Static Private Member Functions

static void ComputeInv (SkScalar dst[9], const SkScalar src[9], double invDet, bool isPersp)
 
static bool Poly2Proc (const SkPoint[], SkMatrix *, const SkPoint &scale)
 
static bool Poly3Proc (const SkPoint[], SkMatrix *, const SkPoint &scale)
 
static bool Poly4Proc (const SkPoint[], SkMatrix *, const SkPoint &scale)
 
static void Identity_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void Trans_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void Scale_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void ScaleTrans_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void Rot_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void RotTrans_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void Persp_xy (const SkMatrix &, SkScalar, SkScalar, SkPoint *)
 
static void Identity_pts (const SkMatrix &, SkPoint[], const SkPoint[], int)
 
static void Trans_pts (const SkMatrix &, SkPoint dst[], const SkPoint[], int)
 
static void Scale_pts (const SkMatrix &, SkPoint dst[], const SkPoint[], int)
 
static void ScaleTrans_pts (const SkMatrix &, SkPoint dst[], const SkPoint[], int count)
 
static void Persp_pts (const SkMatrix &, SkPoint dst[], const SkPoint[], int)
 
static void Affine_vpts (const SkMatrix &, SkPoint dst[], const SkPoint[], int)
 

Private Attributes

SkScalar fMat [9]
 
uint32_t fTypeMask
 

Static Private Attributes

static const MapXYProc gMapXYProcs []
 
static const MapPtsProc gMapPtsProcs []
 

Friends

class SkPerspIter
 
class SkMatrixPriv
 
SK_API bool operator== (const SkMatrix &a, const SkMatrix &b)
 
SK_API bool operator!= (const SkMatrix &a, const SkMatrix &b)
 

Detailed Description

The SkMatrix class holds a 3x3 matrix for transforming coordinates.

SkMatrix does not have a constructor, so it must be explicitly initialized using either reset() - to construct an identity matrix, or one of the set functions (e.g. setTranslate, setRotate, etc.).

Member Enumeration Documentation

anonymous enum
private
Enumerator
kRectStaysRect_Mask 

Set if the matrix will map a rectangle to another rectangle.

This can be true if the matrix is scale-only, or rotates a multiple of 90 degrees.

This bit will be set on identity matrices

kOnlyPerspectiveValid_Mask 

Set if the perspective bit is valid even though the rest of the matrix is Unknown.

Enumerator
kFill_ScaleToFit 

Scale in X and Y independently, so that src matches dst exactly.

This may change the aspect ratio of the src.

kStart_ScaleToFit 

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst.

At least one axis (X or Y) will fit exactly. kStart aligns the result to the left and top edges of dst.

kCenter_ScaleToFit 

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst.

At least one axis (X or Y) will fit exactly. The result is centered inside dst.

kEnd_ScaleToFit 

Compute a scale that will maintain the original src aspect ratio, but will also ensure that src fits entirely inside dst.

At least one axis (X or Y) will fit exactly. kEnd aligns the result to the right and bottom edges of dst.

Enum of bit fields for the mask return by getType().

Use this to identify the complexity of the matrix.

Enumerator
kTranslate_Mask 

set if the matrix has translation

kScale_Mask 

set if the matrix has X or Y scale

kAffine_Mask 

set if the matrix skews or rotates

kPerspective_Mask 

set if the matrix is in perspective

Member Function Documentation

bool SK_WARN_UNUSED_RESULT SkMatrix::asAffine ( SkScalar  affine[6]) const

Fills the passed array with the affine values in column major order.

If the matrix is a perspective transform, returns false and does not change the passed array.

Parameters
affineThe array to fill with affine values. Ignored if NULL.
bool SkMatrix::cheapEqualTo ( const SkMatrix m) const
inline

Efficient comparison of two matrices.

It distinguishes between zero and negative zero. It will return false when the sign of zero values is the only difference between the two matrices. It considers NaN values to be equal to themselves. So a matrix full of NaNs is "cheap equal" to another matrix full of NaNs iff the NaN values are bitwise identical while according to strict the strict == test a matrix with a NaN value is equal to nothing, including itself.

bool SkMatrix::decomposeScale ( SkSize scale,
SkMatrix remaining = NULL 
) const

Attempt to decompose this matrix into a scale-only component and whatever remains, where the scale component is to be applied first.

M -> Remaining * Scale

On success, return true and assign the scale and remaining components (assuming their respective parameters are not null). On failure return false and ignore the parameters.

Possible reasons to fail: perspective, one or more scale factors are zero.

SkVector SkMatrix::fixedStepInX ( SkScalar  y) const

If the matrix can be stepped in X (not complex perspective) then return the step value.

If it cannot, behavior is undefined.

void SkMatrix::get9 ( SkScalar  buffer[9]) const
inline

Copy the 9 scalars for this matrix into buffer, in the same order as the kMScaleX enum...

scalex, skewx, transx, skewy, scaley, transy, persp0, persp1, persp2

SkScalar SkMatrix::getMaxScale ( ) const

Calculates the maximum scaling factor of the matrix as computed from the SVD of the upper left 2x2.

If the max scale factor cannot be computed (for example overflow or perspective) -1 is returned.

Returns
maximum scale factor
bool SK_WARN_UNUSED_RESULT SkMatrix::getMinMaxScales ( SkScalar  scaleFactors[2]) const

Gets both the min and max scale factors.

The min scale factor is scaleFactors[0] and the max is scaleFactors[1]. If the min/max scale factors cannot be computed false is returned and the values of scaleFactors[] are undefined.

SkScalar SkMatrix::getMinScale ( ) const

Calculates the minimum scaling factor of the matrix as computed from the SVD of the upper left 2x2.

If the max scale factor cannot be computed (for example overflow or perspective) -1 is returned.

Returns
minimum scale factor
TypeMask SkMatrix::getType ( ) const
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 SK_WARN_UNUSED_RESULT SkMatrix::invert ( SkMatrix inverse) const
inline

If this matrix can be inverted, return true and if inverse is not null, set inverse to be the inverse of this matrix.

If this matrix cannot be inverted, ignore inverse and return false

void SkMatrix::mapHomogeneousPoints ( SkScalar  dst[],
const SkScalar  src[],
int  count 
) const

Apply this matrix to the array of homogeneous points, specified by src, where a homogeneous point is defined by 3 contiguous scalar values, and write the transformed points into the array of scalars specified by dst.

dst[] = M * src[]

Parameters
dstWhere the transformed coordinates are written. It must contain at least 3 * count entries
srcThe original coordinates that are to be transformed. It must contain at least 3 * count entries
countThe number of triples (homogeneous points) in src to read, and then transform into dst.
void SkMatrix::mapPoints ( SkPoint  dst[],
const SkPoint  src[],
int  count 
) const
inline

Apply this matrix to the array of points specified by src, and write the transformed points into the array of points specified by dst.

dst[] = M * src[]

Parameters
dstWhere the transformed coordinates are written. It must contain at least count entries
srcThe original coordinates that are to be transformed. It must contain at least count entries
countThe number of points in src to read, and then transform into dst.
void SkMatrix::mapPoints ( SkPoint  pts[],
int  count 
) const
inline

Apply this matrix to the array of points, overwriting it with the transformed values.

dst[] = M * pts[]

Parameters
ptsThe points to be transformed. It must contain at least count entries
countThe number of points in pts.
void SkMatrix::mapPointsWithStride ( SkPoint  pts[],
size_t  stride,
int  count 
) const
inline

Like mapPoints but with custom byte stride between the points.

Stride should be a multiple of sizeof(SkScalar).

SkScalar SkMatrix::mapRadius ( SkScalar  radius) const

Return the mean radius of a circle after it has been mapped by this matrix.

NOTE: in perspective this value assumes the circle has its center at the origin.

bool SkMatrix::mapRect ( SkRect dst,
const SkRect src 
) const

Apply this matrix to the src rectangle, and write the transformed rectangle into dst.

This is accomplished by transforming the 4 corners of src, and then setting dst to the bounds of those points.

Parameters
dstWhere the transformed rectangle is written.
srcThe original rectangle to be transformed.
Returns
the result of calling rectStaysRect()
bool SkMatrix::mapRect ( SkRect rect) const
inline

Apply this matrix to the rectangle, and write the transformed rectangle back into it.

This is accomplished by transforming the 4 corners of rect, and then setting it to the bounds of those points

Parameters
rectThe rectangle to transform.
Returns
the result of calling rectStaysRect()
void SkMatrix::mapRectScaleTranslate ( SkRect dst,
const SkRect src 
) const

Maps a rect to another rect, asserting (in debug mode) that the matrix only contains scale and translate elements.

If it contains other elements, the results are undefined.

void SkMatrix::mapRectToQuad ( SkPoint  dst[4],
const SkRect rect 
) const
inline

Apply this matrix to the src rectangle, and write the four transformed points into dst.

The points written to dst will be the original top-left, top-right, bottom-right, and bottom-left points transformed by the matrix.

Parameters
dstWhere the transformed quad is written.
rectThe original rectangle to be transformed.
void SkMatrix::mapVectors ( SkVector  dst[],
const SkVector  src[],
int  count 
) const

Apply this matrix to the array of vectors specified by src, and write the transformed vectors into the array of vectors specified by dst.

This is similar to mapPoints, but ignores any translation in the matrix.

Parameters
dstWhere the transformed coordinates are written. It must contain at least count entries
srcThe original coordinates that are to be transformed. It must contain at least count entries
countThe number of vectors in src to read, and then transform into dst.
void SkMatrix::mapVectors ( SkVector  vecs[],
int  count 
) const
inline

Apply this matrix to the array of vectors specified by src, and write the transformed vectors into the array of vectors specified by dst.

This is similar to mapPoints, but ignores any translation in the matrix.

Parameters
vecsThe vectors to be transformed. It must contain at least count entries
countThe number of vectors in vecs.
void SkMatrix::postConcat ( const SkMatrix other)

Postconcats the matrix with the specified matrix.

M' = other * M

bool SkMatrix::postIDiv ( int  divx,
int  divy 
)

Postconcats the matrix by dividing it by the specified integers.

M' = S(1/divx, 1/divy, 0, 0) * M

void SkMatrix::postRotate ( SkScalar  degrees,
SkScalar  px,
SkScalar  py 
)

Postconcats the matrix with the specified rotation.

M' = R(degrees, px, py) * M

void SkMatrix::postRotate ( SkScalar  degrees)

Postconcats the matrix with the specified rotation.

M' = R(degrees) * M

void SkMatrix::postScale ( SkScalar  sx,
SkScalar  sy,
SkScalar  px,
SkScalar  py 
)

Postconcats the matrix with the specified scale.

M' = S(sx, sy, px, py) * M

void SkMatrix::postScale ( SkScalar  sx,
SkScalar  sy 
)

Postconcats the matrix with the specified scale.

M' = S(sx, sy) * M

void SkMatrix::postSkew ( SkScalar  kx,
SkScalar  ky,
SkScalar  px,
SkScalar  py 
)

Postconcats the matrix with the specified skew.

M' = K(kx, ky, px, py) * M

void SkMatrix::postSkew ( SkScalar  kx,
SkScalar  ky 
)

Postconcats the matrix with the specified skew.

M' = K(kx, ky) * M

void SkMatrix::postTranslate ( SkScalar  dx,
SkScalar  dy 
)

Postconcats the matrix with the specified translation.

M' = T(dx, dy) * M

void SkMatrix::preConcat ( const SkMatrix other)

Preconcats the matrix with the specified matrix.

M' = M * other

void SkMatrix::preRotate ( SkScalar  degrees,
SkScalar  px,
SkScalar  py 
)

Preconcats the matrix with the specified rotation.

M' = M * R(degrees, px, py)

void SkMatrix::preRotate ( SkScalar  degrees)

Preconcats the matrix with the specified rotation.

M' = M * R(degrees)

void SkMatrix::preScale ( SkScalar  sx,
SkScalar  sy,
SkScalar  px,
SkScalar  py 
)

Preconcats the matrix with the specified scale.

M' = M * S(sx, sy, px, py)

void SkMatrix::preScale ( SkScalar  sx,
SkScalar  sy 
)

Preconcats the matrix with the specified scale.

M' = M * S(sx, sy)

bool SkMatrix::preservesRightAngles ( SkScalar  tol = SK_ScalarNearlyZero) const

Returns true if the matrix contains only translation, rotation/reflection or scale (non-uniform scale is allowed).

Returns false if other transformation types are included or is degenerate

void SkMatrix::preSkew ( SkScalar  kx,
SkScalar  ky,
SkScalar  px,
SkScalar  py 
)

Preconcats the matrix with the specified skew.

M' = M * K(kx, ky, px, py)

void SkMatrix::preSkew ( SkScalar  kx,
SkScalar  ky 
)

Preconcats the matrix with the specified skew.

M' = M * K(kx, ky)

void SkMatrix::preTranslate ( SkScalar  dx,
SkScalar  dy 
)

Preconcats the matrix with the specified translation.

M' = M * T(dx, dy)

size_t SkMatrix::readFromMemory ( const void *  buffer,
size_t  length 
)

Reads data from the buffer parameter.

Parameters
bufferMemory to read from
lengthAmount of memory available in the buffer
Returns
number of bytes read (must be a multiple of 4) or 0 if there was not enough memory available
bool SkMatrix::rectStaysRect ( ) const
inline

Returns true if will map a rectangle to another rectangle.

This can be true if the matrix is identity, scale-only, or rotates a multiple of 90 degrees, or mirrors in x or y.

void SkMatrix::set9 ( const SkScalar  buffer[9])

Set this matrix to the 9 scalars from the buffer, in the same order as the kMScaleX enum...

scalex, skewx, transx, skewy, scaley, transy, persp0, persp1, persp2

Note: calling set9 followed by get9 may not return the exact same values. Since the matrix is used to map non-homogeneous coordinates, it is free to rescale the 9 values as needed.

void SkMatrix::setAffine ( const SkScalar  affine[6])

Set the matrix to the specified affine values.

Note: these are passed in column major order.

static void SkMatrix::SetAffineIdentity ( SkScalar  affine[6])
static

Fills the passed array with affine identity values in column major order.

Parameters
affineThe array to fill with affine identity values. Must not be NULL.
void SkMatrix::setConcat ( const SkMatrix a,
const SkMatrix b 
)

Set the matrix to the concatenation of the two specified matrices.

Either of the two matrices may also be the target matrix. this = a * b;

bool SkMatrix::setIDiv ( int  divx,
int  divy 
)

Set the matrix to scale by 1/divx and 1/divy.

Returns false and doesn't touch the matrix if either divx or divy is zero.

bool SkMatrix::setPolyToPoly ( const SkPoint  src[],
const SkPoint  dst[],
int  count 
)

Set the matrix such that the specified src points would map to the specified dst points.

count must be within [0..4].

Parameters
srcThe array of src points
dstThe array of dst points
countThe number of points to use for the transformation
Returns
true if the matrix was set to the specified transformation
bool SkMatrix::setRectToRect ( const SkRect src,
const SkRect dst,
ScaleToFit  stf 
)

Set the matrix to the scale and translate values that map the source rectangle to the destination rectangle, returning true if the the result can be represented.

Parameters
srcthe source rectangle to map from.
dstthe destination rectangle to map to.
stfthe ScaleToFit option
Returns
true if the matrix can be represented by the rectangle mapping.
void SkMatrix::setRotate ( SkScalar  degrees,
SkScalar  px,
SkScalar  py 
)

Set the matrix to rotate by the specified number of degrees, with a pivot point at (px, py).

The pivot point is the coordinate that should remain unchanged by the specified transformation.

void SkMatrix::setScale ( SkScalar  sx,
SkScalar  sy,
SkScalar  px,
SkScalar  py 
)

Set the matrix to scale by sx and sy, with a pivot point at (px, py).

The pivot point is the coordinate that should remain unchanged by the specified transformation.

void SkMatrix::setSinCos ( SkScalar  sinValue,
SkScalar  cosValue,
SkScalar  px,
SkScalar  py 
)

Set the matrix to rotate by the specified sine and cosine values, with a pivot point at (px, py).

The pivot point is the coordinate that should remain unchanged by the specified transformation.

void SkMatrix::setSkew ( SkScalar  kx,
SkScalar  ky,
SkScalar  px,
SkScalar  py 
)

Set the matrix to skew by sx and sy, with a pivot point at (px, py).

The pivot point is the coordinate that should remain unchanged by the specified transformation.


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