Lines Matching refs:SkMatrix

32 /** \class SkMatrix
33 SkMatrix holds a 3x3 matrix for transforming coordinates. This allows mapping
37 SkMatrix elements are in row major order.
38 SkMatrix constexpr default constructs to identity.
40 SkMatrix includes a hidden variable that classifies the type of matrix to
41 improve performance. SkMatrix is not thread safe unless getType() is called first.
46 class SK_API SkMatrix {
49 /** Creates an identity SkMatrix:
55 constexpr SkMatrix() : SkMatrix(1,0,0, 0,1,0, 0,0,1, kIdentity_Mask | kRectStaysRect_Mask) {}
57 /** Sets SkMatrix to scale by (sx, sy). Returned matrix is:
65 @return SkMatrix with scale
67 static SkMatrix SK_WARN_UNUSED_RESULT Scale(SkScalar sx, SkScalar sy) {
68 SkMatrix m;
73 /** Sets SkMatrix to translate by (dx, dy). Returned matrix is:
81 @return SkMatrix with translation
83 static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkScalar dx, SkScalar dy) {
84 SkMatrix m;
88 static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkVector t) { return Translate(t.x(), t.y()); }
89 static SkMatrix SK_WARN_UNUSED_RESULT Translate(SkIVector t) { return Translate(t.x(), t.y()); }
91 /** Sets SkMatrix to rotate by |deg| about a pivot point at (0, 0).
94 @return SkMatrix with rotation
96 static SkMatrix SK_WARN_UNUSED_RESULT RotateDeg(SkScalar deg) {
97 SkMatrix m;
101 static SkMatrix SK_WARN_UNUSED_RESULT RotateDeg(SkScalar deg, SkPoint pt) {
102 SkMatrix m;
106 static SkMatrix SK_WARN_UNUSED_RESULT RotateRad(SkScalar rad) {
110 /** Sets SkMatrix to skew by (kx, ky) about pivot point (0, 0).
114 @return SkMatrix with skew
116 static SkMatrix SK_WARN_UNUSED_RESULT Skew(SkScalar kx, SkScalar ky) {
117 SkMatrix m;
122 /** \enum SkMatrix::ScaleToFit
123 ScaleToFit describes how SkMatrix is constructed to map one SkRect to another.
124 ScaleToFit may allow SkMatrix to have unequal horizontal and vertical scaling,
125 or may restrict SkMatrix to square scaling. If restricted, ScaleToFit specifies
126 how SkMatrix maps to the side or center of the destination SkRect.
135 /** Returns SkMatrix set to scale and translate src to dst. ScaleToFit selects
137 align src within dst. Returns the identity SkMatrix if src is empty. If dst is
138 empty, returns SkMatrix set to:
147 @return SkMatrix mapping src to dst
149 static SkMatrix SK_WARN_UNUSED_RESULT RectToRect(const SkRect& src, const SkRect& dst,
154 /** Sets SkMatrix to:
169 @return SkMatrix constructed from parameters
171 static SkMatrix SK_WARN_UNUSED_RESULT MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX,
174 SkMatrix m;
179 /** \enum SkMatrix::TypeMask
181 Used to identify the complexity of SkMatrix, to optimize performance.
184 kIdentity_Mask = 0, //!< identity SkMatrix; all bits clear
185 kTranslate_Mask = 0x01, //!< translation SkMatrix
186 kScale_Mask = 0x02, //!< scale SkMatrix
187 kAffine_Mask = 0x04, //!< skew or rotate SkMatrix
188 kPerspective_Mask = 0x08, //!< perspective SkMatrix
207 /** Returns true if SkMatrix is identity. Identity matrix is:
213 @return true if SkMatrix has no effect
219 /** Returns true if SkMatrix at most scales and translates. SkMatrix may be identity,
220 contain only scale elements, only translate elements, or both. SkMatrix form is:
226 @return true if SkMatrix is identity; or scales, translates, or both
232 /** Returns true if SkMatrix is identity, or translates. SkMatrix form is:
238 @return true if SkMatrix is identity, or translates
242 /** Returns true SkMatrix maps SkRect to another SkRect. If true, SkMatrix is identity,
244 cases, SkMatrix may also have translation. SkMatrix form is either:
261 @return true if SkMatrix maps one SkRect into another
270 /** Returns true SkMatrix maps SkRect to another SkRect. If true, SkMatrix is identity,
272 cases, SkMatrix may also have translation. SkMatrix form is either:
289 @return true if SkMatrix maps one SkRect into another
293 /** Returns true if the matrix contains perspective elements. SkMatrix form is:
302 @return true if SkMatrix is in most general form
309 /** Returns true if SkMatrix contains only translation, rotation, reflection, and
311 Returns false if SkMatrix contains different scales, skewing, perspective, or
314 Describes that the SkMatrix makes rendering with and without the matrix are
321 @return true if SkMatrix only rotates, uniformly scales, translates
327 /** Returns true if SkMatrix contains only translation, rotation, reflection, and
329 Returns false if SkMatrix skewing, perspective, or degenerate forms that collapse
336 @return true if SkMatrix only rotates, scales, translates
342 /** SkMatrix organizes its values in row-major order. These members correspond to
343 each value in SkMatrix.
458 /** Returns writable SkMatrix value. Asserts if index is out of range and SK_DEBUG is
459 defined. Clears internal cache anticipating that caller will change SkMatrix value.
461 Next call to read SkMatrix state may recompute cache; subsequent writes to SkMatrix
474 /** Sets SkMatrix value. Asserts if index is out of range and SK_DEBUG is
479 @param value scalar to store in SkMatrix
481 SkMatrix& set(int index, SkScalar value) {
492 SkMatrix& setScaleX(SkScalar v) { return this->set(kMScaleX, v); }
498 SkMatrix& setScaleY(SkScalar v) { return this->set(kMScaleY, v); }
504 SkMatrix& setSkewY(SkScalar v) { return this->set(kMSkewY, v); }
510 SkMatrix& setSkewX(SkScalar v) { return this->set(kMSkewX, v); }
516 SkMatrix& setTranslateX(SkScalar v) { return this->set(kMTransX, v); }
522 SkMatrix& setTranslateY(SkScalar v) { return this->set(kMTransY, v); }
529 SkMatrix& setPerspX(SkScalar v) { return this->set(kMPersp0, v); }
536 SkMatrix& setPerspY(SkScalar v) { return this->set(kMPersp1, v); }
554 SkMatrix& setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX,
570 /** Copies nine scalar values contained by SkMatrix into buffer, in member value
580 /** Sets SkMatrix to nine scalar values in buffer, in member value ascending order:
590 In the future, set9 followed by get9 may not return the same values. Since SkMatrix
596 SkMatrix& set9(const SkScalar buffer[9]);
598 /** Sets SkMatrix to identity; which has no effect on mapped SkPoint. Sets SkMatrix to:
607 SkMatrix& reset();
609 /** Sets SkMatrix to identity; which has no effect on mapped SkPoint. Sets SkMatrix to:
618 SkMatrix& setIdentity() { return this->reset(); }
620 /** Sets SkMatrix to translate by (dx, dy).
625 SkMatrix& setTranslate(SkScalar dx, SkScalar dy);
627 /** Sets SkMatrix to translate by (v.fX, v.fY).
631 SkMatrix& setTranslate(const SkVector& v) { return this->setTranslate(v.fX, v.fY); }
633 /** Sets SkMatrix to scale by sx and sy, about a pivot point at (px, py).
634 The pivot point is unchanged when mapped with SkMatrix.
641 SkMatrix& setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
643 /** Sets SkMatrix to scale by sx and sy about at pivot point at (0, 0).
648 SkMatrix& setScale(SkScalar sx, SkScalar sy);
650 /** Sets SkMatrix to rotate by degrees about a pivot point at (px, py).
651 The pivot point is unchanged when mapped with SkMatrix.
659 SkMatrix& setRotate(SkScalar degrees, SkScalar px, SkScalar py);
661 /** Sets SkMatrix to rotate by degrees about a pivot point at (0, 0).
666 SkMatrix& setRotate(SkScalar degrees);
668 /** Sets SkMatrix to rotate by sinValue and cosValue, about a pivot point at (px, py).
669 The pivot point is unchanged when mapped with SkMatrix.
679 SkMatrix& setSinCos(SkScalar sinValue, SkScalar cosValue,
682 /** Sets SkMatrix to rotate by sinValue and cosValue, about a pivot point at (0, 0).
690 SkMatrix& setSinCos(SkScalar sinValue, SkScalar cosValue);
692 /** Sets SkMatrix to rotate, scale, and translate using a compressed matrix form.
699 @return reference to SkMatrix
703 SkMatrix& setRSXform(const SkRSXform& rsxForm);
705 /** Sets SkMatrix to skew by kx and ky, about a pivot point at (px, py).
706 The pivot point is unchanged when mapped with SkMatrix.
713 SkMatrix& setSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
715 /** Sets SkMatrix to skew by kx and ky, about a pivot point at (0, 0).
720 SkMatrix& setSkew(SkScalar kx, SkScalar ky);
722 /** Sets SkMatrix to SkMatrix a multiplied by SkMatrix b. Either a or b may be this.
730 sets SkMatrix to:
736 @param a SkMatrix on left side of multiply expression
737 @param b SkMatrix on right side of multiply expression
739 SkMatrix& setConcat(const SkMatrix& a, const SkMatrix& b);
741 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from translation (dx, dy).
742 This can be thought of as moving the point to be mapped before applying SkMatrix.
750 sets SkMatrix to:
756 @param dx x-axis translation before applying SkMatrix
757 @param dy y-axis translation before applying SkMatrix
759 SkMatrix& preTranslate(SkScalar dx, SkScalar dy);
761 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from scaling by (sx, sy)
763 This can be thought of as scaling about a pivot point before applying SkMatrix.
776 sets SkMatrix to:
787 SkMatrix& preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
789 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from scaling by (sx, sy)
791 This can be thought of as scaling about the origin before applying SkMatrix.
799 sets SkMatrix to:
808 SkMatrix& preScale(SkScalar sx, SkScalar sy);
810 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from rotating by degrees
812 This can be thought of as rotating about a pivot point before applying SkMatrix.
829 sets SkMatrix to:
839 SkMatrix& preRotate(SkScalar degrees, SkScalar px, SkScalar py);
841 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from rotating by degrees
843 This can be thought of as rotating about the origin before applying SkMatrix.
858 sets SkMatrix to:
866 SkMatrix& preRotate(SkScalar degrees);
868 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from skewing by (kx, ky)
870 This can be thought of as skewing about a pivot point before applying SkMatrix.
883 sets SkMatrix to:
894 SkMatrix& preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
896 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix constructed from skewing by (kx, ky)
898 This can be thought of as skewing about the origin before applying SkMatrix.
906 sets SkMatrix to:
915 SkMatrix& preSkew(SkScalar kx, SkScalar ky);
917 /** Sets SkMatrix to SkMatrix multiplied by SkMatrix other.
918 This can be thought of mapping by other before applying SkMatrix.
926 sets SkMatrix to:
932 @param other SkMatrix on right side of multiply expression
934 SkMatrix& preConcat(const SkMatrix& other);
936 /** Sets SkMatrix to SkMatrix constructed from translation (dx, dy) multiplied by SkMatrix.
937 This can be thought of as moving the point to be mapped after applying SkMatrix.
945 sets SkMatrix to:
951 @param dx x-axis translation after applying SkMatrix
952 @param dy y-axis translation after applying SkMatrix
954 SkMatrix& postTranslate(SkScalar dx, SkScalar dy);
956 /** Sets SkMatrix to SkMatrix constructed from scaling by (sx, sy) about pivot point
957 (px, py), multiplied by SkMatrix.
958 This can be thought of as scaling about a pivot point after applying SkMatrix.
971 sets SkMatrix to:
982 SkMatrix& postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py);
984 /** Sets SkMatrix to SkMatrix constructed from scaling by (sx, sy) about pivot point
985 (0, 0), multiplied by SkMatrix.
986 This can be thought of as scaling about the origin after applying SkMatrix.
994 sets SkMatrix to:
1003 SkMatrix& postScale(SkScalar sx, SkScalar sy);
1005 /** Sets SkMatrix to SkMatrix constructed from rotating by degrees about pivot point
1006 (px, py), multiplied by SkMatrix.
1007 This can be thought of as rotating about a pivot point after applying SkMatrix.
1024 sets SkMatrix to:
1034 SkMatrix& postRotate(SkScalar degrees, SkScalar px, SkScalar py);
1036 /** Sets SkMatrix to SkMatrix constructed from rotating by degrees about pivot point
1037 (0, 0), multiplied by SkMatrix.
1038 This can be thought of as rotating about the origin after applying SkMatrix.
1053 sets SkMatrix to:
1061 SkMatrix& postRotate(SkScalar degrees);
1063 /** Sets SkMatrix to SkMatrix constructed from skewing by (kx, ky) about pivot point
1064 (px, py), multiplied by SkMatrix.
1065 This can be thought of as skewing about a pivot point after applying SkMatrix.
1078 sets SkMatrix to:
1089 SkMatrix& postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py);
1091 /** Sets SkMatrix to SkMatrix constructed from skewing by (kx, ky) about pivot point
1092 (0, 0), multiplied by SkMatrix.
1093 This can be thought of as skewing about the origin after applying SkMatrix.
1101 sets SkMatrix to:
1110 SkMatrix& postSkew(SkScalar kx, SkScalar ky);
1112 /** Sets SkMatrix to SkMatrix other multiplied by SkMatrix.
1113 This can be thought of mapping by other after applying SkMatrix.
1121 sets SkMatrix to:
1127 @param other SkMatrix on left side of multiply expression
1129 SkMatrix& postConcat(const SkMatrix& other);
1134 /** Sets SkMatrix to scale and translate src SkRect to dst SkRect. stf selects whether
1136 src within dst. Returns false if src is empty, and sets SkMatrix to identity.
1137 Returns true if dst is empty, and sets SkMatrix to:
1145 @return true if SkMatrix can represent SkRect mapping
1151 /** Returns SkMatrix set to scale and translate src SkRect to dst SkRect. stf selects
1153 align src within dst. Returns the identity SkMatrix if src is empty. If dst is
1154 empty, returns SkMatrix set to:
1162 @return SkMatrix mapping src to dst
1164 static SkMatrix MakeRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf) {
1165 SkMatrix m;
1173 /** Sets SkMatrix to map src to dst. count must be zero or greater, and four or less.
1175 If count is zero, sets SkMatrix to identity and returns true.
1176 If count is one, sets SkMatrix to translate and returns true.
1177 If count is two or more, sets SkMatrix to map SkPoint if possible; returns false
1178 if SkMatrix cannot be constructed. If count is four, SkMatrix may include
1184 @return true if SkMatrix was constructed successfully
1190 /** Sets inverse to reciprocal matrix, returning true if SkMatrix can be inverted.
1191 Geometrically, if SkMatrix maps from source to destination, inverse SkMatrix
1192 maps from destination to source. If SkMatrix can not be inverted, inverse is
1195 @param inverse storage for inverted SkMatrix; may be nullptr
1196 @return true if SkMatrix can be inverted
1198 bool SK_WARN_UNUSED_RESULT invert(SkMatrix* inverse) const {
1228 If SkMatrix contains perspective, returns false and leaves affine unchanged.
1231 @return true if SkMatrix does not contain perspective
1235 /** Sets SkMatrix to affine values, passed in column major order. Given affine,
1241 SkMatrix is set, row, then column, to:
1249 SkMatrix& setAffine(const SkScalar affine[6]);
1269 length. SkPoint are mapped by multiplying each SkPoint by SkMatrix. Given:
1299 each SkPoint by SkMatrix. Given:
1326 greater. SkPoint3 array is mapped by multiplying each SkPoint3 by SkMatrix. Given:
1351 /** Returns SkPoint pt multiplied by SkMatrix. Given:
1372 /** Maps SkPoint (x, y) to result. SkPoint is mapped by multiplying by SkMatrix. Given:
1392 /** Returns SkPoint (x, y) multiplied by SkMatrix. Given:
1415 /** Returns (0, 0) multiplied by SkMatrix. Given:
1442 length. Vectors are mapped by multiplying each vector by SkMatrix, treating
1443 SkMatrix translation as zero. Given:
1473 SkMatrix, treating SkMatrix translation as zero. Given:
1499 /** Maps vector (dx, dy) to result. Vector is mapped by multiplying by SkMatrix,
1500 treating SkMatrix translation as zero. Given:
1521 /** Returns vector (dx, dy) multiplied by SkMatrix, treating SkMatrix translation as zero.
1544 /** Sets dst to bounds of src corners mapped by SkMatrix.
1559 /** Sets rect to bounds of rect corners mapped by SkMatrix.
1572 /** Returns bounds of src corners mapped by SkMatrix.
1585 rect corner by SkMatrix. rect corner is processed in this order:
1618 /** Sets dst to bounds of src corners mapped by SkMatrix. If matrix contains
1630 size radius, and mapping constructed circle with SkMatrix. The result squared is
1632 Result is not meaningful if SkMatrix contains perspective elements.
1642 even if sign of zero values are different. Returns false if either SkMatrix
1643 contains NaN, even if the other SkMatrix also contains NaN.
1645 @param a SkMatrix to compare
1646 @param b SkMatrix to compare
1647 @return true if SkMatrix a and SkMatrix b are numerically equal
1649 friend SK_API bool operator==(const SkMatrix& a, const SkMatrix& b);
1652 even if sign of zero values are different. Returns true if either SkMatrix
1653 contains NaN, even if the other SkMatrix also contains NaN.
1655 @param a SkMatrix to compare
1656 @param b SkMatrix to compare
1657 @return true if SkMatrix a and SkMatrix b are numerically not equal
1659 friend SK_API bool operator!=(const SkMatrix& a, const SkMatrix& b) {
1663 /** Writes text representation of SkMatrix to standard output. Floating point values
1665 original SkMatrix from output.
1671 /** Writes text representation of SkMatrix to string.
1678 /** Returns the minimum scaling factor of SkMatrix by decomposing the scaling and
1680 Returns -1 if scale factor overflows or SkMatrix contains perspective.
1688 /** Returns the maximum scaling factor of SkMatrix by decomposing the scaling and
1690 Returns -1 if scale factor overflows or SkMatrix contains perspective.
1700 the SkMatrix scaling and skewing elements.
1710 /** Decomposes SkMatrix into scale components and whatever remains. Returns false if
1711 SkMatrix could not be decomposed.
1713 Sets scale to portion of SkMatrix that scale axes. Sets remaining to SkMatrix
1715 to determine if SkMatrix can be decomposed without computing remainder.
1718 unchanged if SkMatrix contains perspective; scale factors are not finite, or
1724 @param remaining SkMatrix without scaling; may be nullptr
1729 bool decomposeScale(SkSize* scale, SkMatrix* remaining = nullptr) const;
1731 /** Returns reference to const identity SkMatrix. Returned SkMatrix is set to:
1737 @return const identity SkMatrix
1741 static const SkMatrix& I();
1743 /** Returns reference to a const SkMatrix with invalid values. Returned SkMatrix is set
1750 @return const invalid SkMatrix
1754 static const SkMatrix& InvalidMatrix();
1756 /** Returns SkMatrix a multiplied by SkMatrix b.
1764 sets SkMatrix to:
1770 @param a SkMatrix on left side of multiply expression
1771 @param b SkMatrix on right side of multiply expression
1772 @return SkMatrix computed from a times b
1774 static SkMatrix Concat(const SkMatrix& a, const SkMatrix& b) {
1775 SkMatrix result;
1780 friend SkMatrix operator*(const SkMatrix& a, const SkMatrix& b) {
1785 modifications to SkMatrix element reference returned by operator[](int index).
1791 /** Initializes SkMatrix with scale and translate elements.
1862 constexpr SkMatrix(SkScalar sx, SkScalar kx, SkScalar tx,
1920 typedef void (*MapXYProc)(const SkMatrix& mat, SkScalar x, SkScalar y,
1932 typedef void (*MapPtsProc)(const SkMatrix& mat, SkPoint dst[],
1944 bool SK_WARN_UNUSED_RESULT invertNonIdentity(SkMatrix* inverse) const;
1946 static bool Poly2Proc(const SkPoint[], SkMatrix*);
1947 static bool Poly3Proc(const SkPoint[], SkMatrix*);
1948 static bool Poly4Proc(const SkPoint[], SkMatrix*);
1950 static void Identity_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1951 static void Trans_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1952 static void Scale_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1953 static void ScaleTrans_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1954 static void Rot_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1955 static void RotTrans_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1956 static void Persp_xy(const SkMatrix&, SkScalar, SkScalar, SkPoint*);
1960 static void Identity_pts(const SkMatrix&, SkPoint[], const SkPoint[], int);
1961 static void Trans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);
1962 static void Scale_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);
1963 static void ScaleTrans_pts(const SkMatrix&, SkPoint dst[], const SkPoint[],
1965 static void Persp_pts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);
1967 static void Affine_vpts(const SkMatrix&, SkPoint dst[], const SkPoint[], int);