8#ifndef SkMatrix_DEFINED
9#define SkMatrix_DEFINED
27#define SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
63 constexpr SkMatrix() :
SkMatrix(1,0,0, 0,1,0, 0,0,1, kIdentity_Mask | kRectStaysRect_Mask) {}
93 m.setTranslate(
dx, dy);
111 m.setRotate(deg, pt.
x(), pt.
y());
183 m.setAll(scaleX, skewX, transX, skewY, scaleY, transY, pers0, pers1, pers2);
193 kTranslate_Mask = 0x01,
196 kPerspective_Mask = 0x08,
208 if (fTypeMask & kUnknown_Mask) {
209 fTypeMask = this->computeTypeMask();
224 return this->getType() == 0;
237 return !(this->getType() & ~(kScale_Mask | kTranslate_Mask));
248 bool isTranslate()
const {
return !(this->getType() & ~(kTranslate_Mask)); }
272 if (fTypeMask & kUnknown_Mask) {
273 fTypeMask = this->computeTypeMask();
275 return (fTypeMask & kRectStaysRect_Mask) != 0;
313 return SkToBool(this->getPerspectiveTypeMaskOnly() &
353 static constexpr int kMScaleX = 0;
354 static constexpr int kMSkewX = 1;
355 static constexpr int kMTransX = 2;
356 static constexpr int kMSkewY = 3;
357 static constexpr int kMScaleY = 4;
358 static constexpr int kMTransY = 5;
359 static constexpr int kMPersp0 = 6;
360 static constexpr int kMPersp1 = 7;
361 static constexpr int kMPersp2 = 8;
366 static constexpr int kAScaleX = 0;
367 static constexpr int kASkewY = 1;
368 static constexpr int kASkewX = 2;
369 static constexpr int kAScaleY = 3;
370 static constexpr int kATransX = 4;
371 static constexpr int kATransY = 5;
407 return fMat[r*3 + c];
478 this->setTypeMask(kUnknown_Mask);
492 this->setTypeMask(kUnknown_Mask);
565 fMat[kMScaleX] = scaleX;
566 fMat[kMSkewX] = skewX;
567 fMat[kMTransX] = transX;
568 fMat[kMSkewY] = skewY;
569 fMat[kMScaleY] = scaleY;
570 fMat[kMTransY] = transY;
571 fMat[kMPersp0] = persp0;
572 fMat[kMPersp1] = persp1;
573 fMat[kMPersp2] = persp2;
574 this->setTypeMask(kUnknown_Mask);
1139#ifndef SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
1174 m.setRectToRect(
src,
dst, stf);
1177#ifndef SK_SUPPORT_LEGACY_MATRIX_RECTTORECT
1208 if (this->isIdentity()) {
1214 return this->invertNonIdentity(inverse);
1229 static void SetAffineIdentity(
SkScalar affine[6]);
1241 [[nodiscard]]
bool asAffine(
SkScalar affine[6])
const;
1272 this->doNormalizePerspective();
1330 this->mapPoints(pts, pts,
count);
1376 this->mapXY(pt.
x(), pt.
y(), &
result);
1439 y = this->getTranslateY();
1440 if (this->hasPerspective()) {
1442 if (
w) {
w = 1 /
w; }
1504 this->mapVectors(vecs, vecs,
count);
1526 this->mapVectors(
result, &vec, 1);
1548 this->mapVectors(&vec, &vec, 1);
1577 return this->mapRect(
rect, *
rect, pc);
1588 (void)this->mapRect(&
dst,
src, pc);
1623 this->mapPoints(
dst, 4);
1709 [[nodiscard]]
bool getMinMaxScales(
SkScalar scaleFactors[2])
const;
1755 static const SkMatrix& InvalidMatrix();
1789 this->setTypeMask(kUnknown_Mask);
1804 fMat[kMScaleX] = sx;
1806 fMat[kMTransX] = tx;
1809 fMat[kMScaleY] = sy;
1810 fMat[kMTransY] = ty;
1817 if (sx != 1 || sy != 1) {
1818 mask |= kScale_Mask;
1820 if (tx != 0.0f || ty != 0.0f) {
1821 mask |= kTranslate_Mask;
1823 if (sx != 0 && sy != 0) {
1824 mask |= kRectStaysRect_Mask;
1826 this->setTypeMask(mask);
1843 static constexpr int kRectStaysRect_Mask = 0x10;
1848 static constexpr int kOnlyPerspectiveValid_Mask = 0x40;
1850 static constexpr int kUnknown_Mask = 0x80;
1852 static constexpr int kORableMasks = kTranslate_Mask |
1857 static constexpr int kAllMasks = kTranslate_Mask |
1861 kRectStaysRect_Mask;
1864 mutable int32_t fTypeMask;
1872 , fTypeMask(typeMask) {}
1876 uint8_t computeTypeMask()
const;
1877 uint8_t computePerspectiveTypeMask()
const;
1879 void setTypeMask(
int mask) {
1881 SkASSERT(kUnknown_Mask == mask || (mask & kAllMasks) == mask ||
1882 ((kUnknown_Mask | kOnlyPerspectiveValid_Mask) & mask)
1883 == (kUnknown_Mask | kOnlyPerspectiveValid_Mask));
1887 void orTypeMask(
int mask) {
1888 SkASSERT((mask & kORableMasks) == mask);
1892 void clearTypeMask(
int mask) {
1894 SkASSERT((mask & kAllMasks) == mask);
1898 TypeMask getPerspectiveTypeMaskOnly()
const {
1899 if ((fTypeMask & kUnknown_Mask) &&
1900 !(fTypeMask & kOnlyPerspectiveValid_Mask)) {
1901 fTypeMask = this->computePerspectiveTypeMask();
1903 return (TypeMask)(fTypeMask & 0xF);
1909 bool isTriviallyIdentity()
const {
1910 if (fTypeMask & kUnknown_Mask) {
1913 return ((fTypeMask & 0xF) == 0);
1916 inline void updateTranslateMask() {
1917 if ((fMat[kMTransX] != 0) | (fMat[kMTransY] != 0)) {
1918 fTypeMask |= kTranslate_Mask;
1920 fTypeMask &= ~kTranslate_Mask;
1927 static MapXYProc GetMapXYProc(TypeMask mask) {
1928 SkASSERT((mask & ~kAllMasks) == 0);
1929 return gMapXYProcs[mask & kAllMasks];
1932 MapXYProc getMapXYProc()
const {
1933 return GetMapXYProc(this->getType());
1939 static MapPtsProc GetMapPtsProc(TypeMask mask) {
1940 SkASSERT((mask & ~kAllMasks) == 0);
1941 return gMapPtsProcs[mask & kAllMasks];
1944 MapPtsProc getMapPtsProc()
const {
1945 return GetMapPtsProc(this->getType());
1948 [[nodiscard]]
bool invertNonIdentity(
SkMatrix* inverse)
const;
1962 static const MapXYProc gMapXYProcs[];
1973 static const MapPtsProc gMapPtsProcs[];
1976 size_t writeToMemory(
void*
buffer)
const;
1985 size_t readFromMemory(
const void*
buffer,
size_t length);
1988 bool postIDiv(
int divx,
int divy);
1989 void doNormalizePerspective();
1991 friend class SkPerspIter;
static bool SkIsFinite(T x, Pack... values)
#define SK_BEGIN_REQUIRE_DENSE
#define SK_END_REQUIRE_DENSE
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
@ kNo
Don't pre-clip the geometry before applying the (perspective) matrix.
#define SK_ScalarNearlyZero
#define SkRadiansToDegrees(radians)
static constexpr bool SkToBool(const T &x)
static void dump(const float m[20], SkYUVColorSpace cs, bool rgb2yuv)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
SkMatrix & setTranslateY(SkScalar v)
SkScalar getPerspY() const
SkScalar & operator[](int index)
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
static SkMatrix RotateDeg(SkScalar deg)
SkScalar getSkewY() const
SkMatrix & setTranslate(const SkVector &v)
static SkMatrix RotateRad(SkScalar rad)
static SkMatrix Translate(SkIVector t)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
void mapVectors(SkVector vecs[], int count) const
SkMatrix & setSkewX(SkScalar v)
SkMatrix & setPerspX(SkScalar v)
SkMatrix & setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2)
SkScalar getTranslateY() const
@ kStart_ScaleToFit
scales and aligns to left and top
@ kEnd_ScaleToFit
scales and aligns to right and bottom
@ kCenter_ScaleToFit
scales and aligns to center
@ kFill_ScaleToFit
scales in x and y to fill destination SkRect
SkMatrix & set(int index, SkScalar value)
SkScalar rc(int r, int c) const
void setScaleTranslate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty)
SkPoint mapPoint(SkPoint pt) const
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
void mapPoints(SkPoint pts[], int count) const
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
friend SK_API bool operator!=(const SkMatrix &a, const SkMatrix &b)
SkScalar getSkewX() const
bool invert(SkMatrix *inverse) const
bool rectStaysRect() const
bool mapRect(SkRect *rect, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static SkMatrix RotateDeg(SkScalar deg, SkPoint pt)
SkScalar getScaleX() const
SkMatrix & setPerspY(SkScalar v)
SkMatrix & setTranslateX(SkScalar v)
void get9(SkScalar buffer[9]) const
SkRect mapRect(const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
SkScalar getScaleY() const
SkPoint mapOrigin() const
static SkMatrix MakeRectToRect(const SkRect &src, const SkRect &dst, ScaleToFit stf)
bool isScaleTranslate() const
SkScalar operator[](int index) const
void normalizePerspective()
SkVector mapVector(SkScalar dx, SkScalar dy) const
bool hasPerspective() const
SkPoint mapXY(SkScalar x, SkScalar y) const
SkMatrix & setScaleY(SkScalar v)
friend SkMatrix operator*(const SkMatrix &a, const SkMatrix &b)
SkScalar get(int index) const
bool preservesAxisAlignment() const
SkScalar getPerspX() const
static SkMatrix Skew(SkScalar kx, SkScalar ky)
SkMatrix & setSkewY(SkScalar v)
static SkMatrix Translate(SkVector t)
SkMatrix & setScaleX(SkScalar v)
SkScalar getTranslateX() const
void mapVector(SkScalar dx, SkScalar dy, SkVector *result) const
void dirtyMatrixTypeCache()
void mapRectToQuad(SkPoint dst[4], const SkRect &rect) const
sk_sp< SkBlender > blender SkRect rect
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
static const char * Concat(const char *a, const char *b)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not set
bool operator==(C p1, const scoped_nsprotocol< C > &p2)
constexpr int32_t y() const
constexpr int32_t x() const
constexpr float y() const
constexpr float x() const