22 for (
int i = 0;
i < 16; ++
i) {
41 m.setTranslate(3, 4, 2);
47 const float f[] = { 1, 0, 0, 2, 3, 1, 2, 5, 0, 5, 3, 0, 0, 1, 0, 2 };
50 f[1],
f[5],
f[ 9],
f[13],
51 f[2],
f[6],
f[10],
f[14],
52 f[3],
f[7],
f[11],
f[15]) ==
m);
64 f[ 4],
f[ 5],
f[ 6],
f[ 7],
65 f[ 8],
f[ 9],
f[10],
f[14],
66 f[12],
f[13],
f[14],
f[15]) ==
m);
96 SkV4 d =
m.map(4, 3, 2, 1);
131 SkV4 v = {1, 2, 3, 4};
133 SkV4 v2 = c0 * v.
x + c1 * v.
y + c2 * v.
z + c3 * v.
w;
142 const SkV3 x = {1, 0, 0},
153 SkV3 expectedX, expectedY, expectedZ;
160 { 0,-1,
y, -
x,
y,-z},
161 { 0,-1, z, -
x,-
y, z},
166 { 1, 0,
y, -z,
y,
x},
171 {-1, 0, z, -
y,
x, z},
174 for (
const auto& r : recs) {
176 m.setRotateUnitSinCos(r.aboutAxis, r.sinAngle, r.cosAngle);
209 SkV4 mapped =
m.map(
p.x,
p.y, 0.f, 1.f);
212 return SkV2{mapped.
x, mapped.
y};
214 auto assertNearlyEqual = [&](
float actual,
float expected) {
216 "Expected %g == %g", actual, expected);
218 auto assertEdges = [&](
float actualLow,
float actualHigh,
219 float expectedLow,
float expectedHigh) {
220 SkASSERT(expectedLow < expectedHigh);
222 "Expected %g < %g", actualLow, actualHigh);
224 assertNearlyEqual(actualLow, expectedLow);
225 assertNearlyEqual(actualHigh, expectedHigh);
229 for (
const auto& r : dstScales) {
243 assertNearlyEqual(
center.x,
dst.centerX());
244 assertNearlyEqual(
center.y,
dst.centerY());
252 assertEdges(tl.
x, tr.x,
dst.fLeft,
dst.fRight);
253 assertEdges(bl.x, br.x,
dst.fLeft,
dst.fRight);
254 assertEdges(tl.
y, bl.y,
dst.fTop,
dst.fBottom);
255 assertEdges(tr.y, br.y,
dst.fTop,
dst.fBottom);
260 auto assertRectsNearlyEqual = [&](
const SkRect& actual,
const SkRect& expected,
263 "Expected %g == %g", actual.
fLeft, expected.fLeft);
265 "Expected %g == %g", actual.
fTop, expected.fTop);
267 "Expected %g == %g", actual.
fRight, expected.fRight);
269 "Expected %g == %g", actual.
fBottom, expected.fBottom);
272 SkRect epsilon = {1e-5f, 1e-5f, 1e-5f, 1e-5f};
278 assertRectsNearlyEqual(actual, *expected, epsilon);
281 SkV4 corners[4] = {{
src.fLeft,
src.fTop, 0.f, 1.f},
282 {
src.fRight,
src.fTop, 0.f, 1.f},
283 {
src.fRight,
src.fBottom, 0.f, 1.f},
284 {
src.fLeft,
src.fBottom, 0.f, 1.f}};
285 bool leftFound =
false;
286 bool topFound =
false;
287 bool rightFound =
false;
288 bool bottomFound =
false;
289 bool clipped =
false;
290 for (
int i = 0;
i < 4; ++
i) {
291 SkV4 mapped =
m * corners[
i];
292 if (mapped.
w > 0.f) {
294 float x = mapped.
x / mapped.
w;
295 float y = mapped.
y / mapped.
w;
299 "Expected %g contained in [%g, %g]",
302 "Expected %g contained in [%g, %g]",
326 if (!leftFound) { epsilon.
fLeft = .01f * actual.
fLeft; }
327 if (!topFound) { epsilon.
fTop = .01f * actual.
fTop; }
328 if (!rightFound) { epsilon.
fRight = .01f * actual.
fRight; }
337 assertRectsNearlyEqual(actual,
path.getBounds(), epsilon);
347 10.f + 2.f *
src.fRight, 8.f + 4.f *
src.fBottom);
348 assertMapRect(
SkM44::Scale(2.f, 4.f).postTranslate(10.f, 8.f),
src, &st);
351 .preTranslate(-
src.centerX(), -
src.centerY())
357 p.preTranslate(0.f, 5.f, -0.1f);
359 assertMapRect(
p,
src,
nullptr);
363 p.setRow(3, {-.2f, -.6f, 0.f, 8.f});
364 assertMapRect(
p,
src,
nullptr);
375 -1.75697533e-05f, 0.000157153074f, -1.10847975e-06f,
376 -6.00415362e-08f, 0.00000000f, 0.000169880834f));
static bool eq(const SkM44 &a, const SkM44 &b, float tol)
@ kYes
Do pre-clip the geometry before applying the (perspective) matrix.
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
#define REPORTER_ASSERT(r, cond,...)
static SkScalar center(float pos0, float pos1)
static SkM44 Rows(const SkV4 &r0, const SkV4 &r1, const SkV4 &r2, const SkV4 &r3)
static SkM44 RowMajor(const SkScalar r[16])
SkM44 & postTranslate(SkScalar x, SkScalar y, SkScalar z=0)
static SkM44 ColMajor(const SkScalar c[16])
SkScalar rc(int r, int c) const
static SkM44 Rotate(SkV3 axis, SkScalar radians)
static SkM44 RectToRect(const SkRect &src, const SkRect &dst)
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)
static SkRect MapRect(const SkM44 &m, const SkRect &r)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
float nextRangeF(float min, float max)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
sk_sp< SkBlender > blender SkRect rect
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
SkScalar fBottom
larger y-axis bounds
SkScalar fLeft
smaller x-axis bounds
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkScalar fRight
larger x-axis bounds
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
SkScalar fTop
smaller y-axis bounds