class SkMatrixPriv {
public: enum { // writeTo/readFromMemory will never return a value larger than this
kMaxFlattenSize = 9 * sizeof(SkScalar) + sizeof(uint32_t),
};
/** *Attempttomaptherectthroughtheinverseofthematrix.Ifitisnotinvertible, *thenthisreturnsfalseanddstisunchanged.
*/
[[nodiscard]] staticbool InverseMapRect(const SkMatrix& mx, SkRect* dst, const SkRect& src) { if (mx.isScaleTranslate()) { // A scale-translate matrix with a 0 scale factor is not invertible. if (mx.getScaleX() == 0.f || mx.getScaleY() == 0.f) { returnfalse;
}
const SkScalar tx = mx.getTranslateX(); const SkScalar ty = mx.getTranslateY(); // mx maps coordinates as ((sx*x + tx), (sy*y + ty)) so the inverse is // ((x - tx)/sx), (y - ty)/sy). If sx or sy are negative, we have to swap the edge // values to maintain a sorted rect. auto inverted = skvx::float4::Load(&src.fLeft);
inverted -= skvx::float4(tx, ty, tx, ty);
staticbool PostIDiv(SkMatrix* matrix, int divx, int divy) { return matrix->postIDiv(divx, divy);
}
staticbool CheapEqual(const SkMatrix& a, const SkMatrix& b) { return &a == &b || 0 == memcmp(a.fMat, b.fMat, sizeof(a.fMat));
}
staticconst SkScalar* M44ColMajor(const SkM44& m) { return m.fMat; }
// This is legacy functionality that only checks the 3x3 portion. The matrix could have Z-based // shear, or other complex behavior. Only use this if you're planning to use the information // to accelerate some purely 2D operation. staticbool IsScaleTranslateAsM33(const SkM44& m) { return m.rc(1,0) == 0 && m.rc(3,0) == 0 &&
m.rc(0,1) == 0 && m.rc(3,1) == 0 &&
m.rc(3,3) == 1;
}
// Map the four corners of 'r' and return the bounding box of those points. The four corners of // 'r' are assumed to have z = 0 and w = 1. If the matrix has perspective, the returned // rectangle will be the bounding box of the projected points after being clipped to w > 0. static SkRect MapRect(const SkM44& m, const SkRect& r);
// Returns the differential area scale factor for a local point 'p' that will be transformed // by 'm' (which may have perspective). If 'm' does not have perspective, this scale factor is // constant regardless of 'p'; when it does have perspective, it is specific to that point. // // This can be crudely thought of as "device pixel area" / "local pixel area" at 'p'. // // Returns positive infinity if the transformed homogeneous point has w <= 0. static SkScalar DifferentialAreaScale(const SkMatrix& m, const SkPoint& p);
// Determines if the transformation m applied to the bounds can be approximated by // an affine transformation, i.e., the perspective part of the transformation has little // visible effect. staticbool NearlyAffine(const SkMatrix& m, const SkRect& bounds,
SkScalar tolerance = SK_ScalarNearlyZero);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.