33 auto eq = (a0 == b0) & (a1 == b1) & (a2 == b2) & (a3 == b3);
34 return (
eq[0] &
eq[1] &
eq[2] &
eq[3]) == ~0;
55 return c0*r[0] + (c1*r[1] + (c2*r[2] + c3*r[3]));
75 auto compute = [&](
float r0,
float r1,
float r3) {
76 return (c0*r0 + (c1*r1 + c3*r3));
79 auto m0 = compute(
b[0],
b[3],
b[6]);
80 auto m1 = compute(
b[1],
b[4],
b[7]);
81 auto m3 = compute(
b[2],
b[5],
b[8]);
96 (c0*
x + (c1*
y + (c2*z + c3))).
store(fMat + 12);
125 (c2 * z).
store(fMat + 8);
136 (c0*
x + (c1*
y + (c2*z + c3*
w))).
store(&v.
x);
153 auto minMax = c3 + flip *
min(
min(c0 *
src.fLeft + c1 *
src.fTop,
154 c0 *
src.fRight + c1 *
src.fTop),
156 c0 *
src.fRight + c1 *
src.fBottom));
173 auto tl = c0 *
src.fLeft + c1 *
src.fTop + c3;
174 auto tr = c0 *
src.fRight + c1 *
src.fTop + c3;
175 auto bl = c0 *
src.fLeft + c1 *
src.fBottom + c3;
176 auto br = c0 *
src.fRight + c1 *
src.fBottom + c3;
185 return flip * skvx::shuffle<0,1,0,1>(p0) / w0;
191 auto c = (t * skvx::shuffle<0,1>(
p) + (1.f - t) * skvx::shuffle<0,1>(p0)) /
194 return flip * skvx::shuffle<0,1,0,1>(c);
208 auto minMax = flip *
min(
min(project(tl, tr, bl), project(tr, br, tl)),
209 min(project(br, bl, tr), project(bl, tl, br)));
217 const bool hasPerspective =
218 m.fMat[3] != 0 ||
m.fMat[7] != 0 ||
m.fMat[11] != 0 ||
m.fMat[15] != 1;
219 if (hasPerspective) {
231 if (fMat[15] != 1 && fMat[15] != 0 && fMat[3] == 0 && fMat[7] == 0 && fMat[11] == 0) {
232 double inv = 1.0 / fMat[15];
252 memcpy(inverse->fMat, tmp,
sizeof(tmp));
272 *
this = { t*
x*
x + c, t*
x*
y -
s*z, t*
x*z +
s*
y, 0,
273 t*
x*
y +
s*z, t*
y*
y + c, t*
y*z -
s*
x, 0,
274 t*
x*z -
s*
y, t*
y*z +
s*
x, t*z*z + c, 0,
296 fMat[0], fMat[4], fMat[8], fMat[12],
297 fMat[1], fMat[5], fMat[9], fMat[13],
298 fMat[2], fMat[6], fMat[10], fMat[14],
299 fMat[3], fMat[7], fMat[11], fMat[15]);
307 }
else if (
dst.isEmpty()) {
311 float sx =
dst.width() /
src.width();
312 float sy =
dst.height() /
src.height();
314 float tx =
dst.fLeft - sx *
src.fLeft;
315 float ty =
dst.fTop - sy *
src.fTop;
317 return SkM44{sx, 0.f, 0.f, tx,
324 const auto vlen = v.
length();
347 float halfAngle = angle * 0.5f;
354 m.setRC(2, 2, (far + near) * denomInv);
355 m.setRC(2, 3, 2 * far * near * denomInv);
static SkM44 inv(const SkM44 &m)
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static bool SkIsFinite(T x, Pack... values)
static constexpr float sk_ieee_float_divide(float numer, float denom)
static SkRect map_rect_affine(const SkRect &src, const float mat[16])
static void transpose_arrays(SkScalar dst[], const SkScalar src[])
static SkV3 normalize(SkV3 v)
static SkV4 v4(SkV3 v, SkScalar w)
static SkRect map_rect_perspective(const SkRect &src, const float mat[16])
SkScalar SkInvert4x4Matrix(const SkScalar inMatrix[16], SkScalar outMatrix[16])
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
#define SK_ScalarInfinity
static SkScalar center(float pos0, float pos1)
SkV4 map(float x, float y, float z, float w) const
SkM44 & preScale(SkScalar x, SkScalar y)
void getRowMajor(SkScalar v[]) const
static SkM44 LookAt(const SkV3 &eye, const SkV3 ¢er, const SkV3 &up)
SkM44 & postTranslate(SkScalar x, SkScalar y, SkScalar z=0)
SkM44 & setRotate(SkV3 axis, SkScalar radians)
void normalizePerspective()
@ kUninitialized_Constructor
SkM44 & preConcat(const SkM44 &m)
static SkM44 RectToRect(const SkRect &src, const SkRect &dst)
SkM44 & setRotateUnitSinCos(SkV3 axis, SkScalar sinAngle, SkScalar cosAngle)
bool operator==(const SkM44 &other) const
bool invert(SkM44 *inverse) const
SkM44 & setRotateUnit(SkV3 axis, SkScalar radians)
static SkM44 Perspective(float near, float far, float angle)
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
static SkM44 Cols(const SkV4 &c0, const SkV4 &c1, const SkV4 &c2, const SkV4 &c3)
SkM44 & preTranslate(SkScalar x, SkScalar y, SkScalar z=0)
SkM44 & setConcat(const SkM44 &a, const SkM44 &b)
static SkRect MapRect(const SkM44 &m, const SkRect &r)
static constexpr SkScalar kW0PlaneDistance
static float min(float r, float g, float b)
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)