Lines Matching refs:mat
261 SkMatrix mat;
262 mat.reset();
265 mat.postConcat(mats[x]);
268 SkScalar minScale = mat.getMinScale();
269 SkScalar maxScale = mat.getMaxScale();
271 REPORTER_ASSERT(reporter, (maxScale < 0) == mat.hasPerspective());
273 success = mat.getMinMaxScales(scales);
274 REPORTER_ASSERT(reporter, success == !mat.hasPerspective());
277 if (mat.hasPerspective()) {
296 mat.mapVectors(vectors, SK_ARRAY_COUNT(vectors));
314 SkMatrix mat;
317 mat.setIdentity();
318 REPORTER_ASSERT(reporter, mat.isSimilarity());
319 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
322 mat.setTranslate(100, 100);
323 REPORTER_ASSERT(reporter, mat.isSimilarity());
324 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
327 mat.setScale(15, 15);
328 REPORTER_ASSERT(reporter, mat.isSimilarity());
329 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
332 mat.setScale(-15, 15);
333 REPORTER_ASSERT(reporter, mat.isSimilarity());
334 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
337 mat.setScale(15, 20);
338 REPORTER_ASSERT(reporter, !mat.isSimilarity());
339 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
342 mat.setScale(15, 15, 2, 2);
343 REPORTER_ASSERT(reporter, mat.isSimilarity());
344 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
347 mat.setScale(15, 20, 2, 2);
348 REPORTER_ASSERT(reporter, !mat.isSimilarity());
349 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
352 mat.setSkew(15, 15);
353 REPORTER_ASSERT(reporter, !mat.isSimilarity());
354 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
357 mat.setSkew(15, 20);
358 REPORTER_ASSERT(reporter, !mat.isSimilarity());
359 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
362 mat.setSkew(15, 15, 2, 2);
363 REPORTER_ASSERT(reporter, !mat.isSimilarity());
364 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
367 mat.setSkew(15, 20, 2, 2);
368 REPORTER_ASSERT(reporter, !mat.isSimilarity());
369 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
372 mat.reset().setPerspX(SK_Scalar1 / 2);
373 REPORTER_ASSERT(reporter, !mat.isSimilarity());
374 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
377 mat.reset().setPerspY(SK_Scalar1 / 2);
378 REPORTER_ASSERT(reporter, !mat.isSimilarity());
379 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
383 mat.setRotate(SkIntToScalar(angle));
384 REPORTER_ASSERT(reporter, mat.isSimilarity());
385 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
389 mat.reset();
391 mat.postRotate(1);
393 REPORTER_ASSERT(reporter, mat.isSimilarity());
394 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
397 mat.setRotate(30).postTranslate(10, 20);
398 REPORTER_ASSERT(reporter, mat.isSimilarity());
399 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
402 mat.setRotate(30).postScale(2, 2);
403 REPORTER_ASSERT(reporter, mat.isSimilarity());
404 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
407 mat.setRotate(30).postScale(3, 2);
408 REPORTER_ASSERT(reporter, !mat.isSimilarity());
409 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
412 mat.setScale(3, 2).postRotate(30);
413 REPORTER_ASSERT(reporter, !mat.isSimilarity());
414 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
417 mat.setAll(0, 0, 0, 0, 0, 0, 0, 0, 0);
418 REPORTER_ASSERT(reporter, !mat.isSimilarity());
419 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
422 mat.setAll(0, 0, 0, 0, 0, 0, 0, 0, 1);
423 REPORTER_ASSERT(reporter, !mat.isSimilarity());
424 REPORTER_ASSERT(reporter, !mat.preservesRightAngles());
427 mat.setAll(0, 1, 0,
430 REPORTER_ASSERT(reporter, mat.isSimilarity());
431 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
434 mat.setAll(0, 1, 0,
437 REPORTER_ASSERT(reporter, mat.isSimilarity());
438 REPORTER_ASSERT(reporter, mat.preservesRightAngles());
463 static bool check_matrix_recomposition(const SkMatrix& mat,
475 bool result = scalar_nearly_equal_relative(mat[SkMatrix::kMScaleX],
477 scalar_nearly_equal_relative(mat[SkMatrix::kMSkewX],
479 scalar_nearly_equal_relative(mat[SkMatrix::kMSkewY],
481 scalar_nearly_equal_relative(mat[SkMatrix::kMScaleY],
487 SkMatrix mat;
496 mat.reset();
497 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
498 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
500 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, nullptr, nullptr, nullptr));
503 mat.setRotate(kRotation0);
504 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
505 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
508 mat.setScale(kScale0, kScale0);
509 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
510 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
513 mat.setScale(kScale1, kScale0);
514 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
515 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
518 mat.setRotate(kRotation1).postScale(kScale0, kScale0);
519 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
520 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
523 mat.setScale(kScale0, kScale0).postRotate(kRotation1);
524 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
525 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
528 mat.setRotate(kRotation0).postScale(kScale1, -kScale1);
529 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
530 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
533 mat.setScale(kScale0, -kScale0).postRotate(kRotation1);
534 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
535 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
538 mat.setRotate(kRotation1).postScale(kScale1, kScale0);
539 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
540 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
543 mat.setRotate(90).postScale(kScale1, kScale0);
544 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
545 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
548 mat.setScale(kScale1, kScale0).postRotate(kRotation0);
549 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
550 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
553 mat.setScale(kScale1, kScale0).postRotate(90);
554 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
555 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
558 mat.setRotate(kRotation1).postScale(kScale0, kScale0).postRotate(kRotation0);
559 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
560 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
563 mat.setRotate(kRotation0).postScale(kScale1, kScale0).postRotate(kRotation1);
564 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
565 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
568 mat.setRotate(kRotation0).postScale(-kScale1, kScale0).postRotate(kRotation1);
569 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
570 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
579 mat.setRotate(rot0).postScale(sx, sy).postRotate(rot1);
581 if (SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2)) {
582 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
585 SkScalar perpdot = mat[SkMatrix::kMScaleX]*mat[SkMatrix::kMScaleY] -
586 mat[SkMatrix::kMSkewX]*mat[SkMatrix::kMSkewY];
592 mat.postTranslate(-1000.f, 1000.f);
593 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
594 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
597 mat[SkMatrix::kMPersp0] = 12.f;
598 mat[SkMatrix::kMPersp1] = 4.f;
599 mat[SkMatrix::kMPersp2] = 1872.f;
600 REPORTER_ASSERT(reporter, SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
601 REPORTER_ASSERT(reporter, check_matrix_recomposition(mat, rotation1, scale, rotation2));
605 mat.reset();
606 mat[SkMatrix::kMScaleX] = 0.f;
607 REPORTER_ASSERT(reporter, !SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
608 mat.reset();
609 mat[SkMatrix::kMScaleY] = 0.f;
610 REPORTER_ASSERT(reporter, !SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
611 mat.reset();
613 mat[SkMatrix::kMScaleX] = 1.f;
614 mat[SkMatrix::kMSkewX] = 2.f;
615 mat[SkMatrix::kMSkewY] = 4.f;
616 mat[SkMatrix::kMScaleY] = 8.f;
617 REPORTER_ASSERT(reporter, !SkDecomposeUpper2x2(mat, &rotation1, &scale, &rotation2));
651 SkMatrix mat;
683 mat.reset();
685 mat.mapHomogeneousPoints(dst, randTriples, kTripleCount);
692 mat.setAll(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
694 mat.mapHomogeneousPoints(dst, randTriples, kTripleCount);
716 mat.setScale(kScale0, kScale0);
721 mat.mapHomogeneousPoints(&dst, &src, 1);
722 mat.mapPoints(&pnt, &pnt, 1);
730 mat.setRotate(kRotation0);
735 mat.mapHomogeneousPoints(&dst, &src, 1);
736 mat.mapPoints(&pnt, &pnt, 1);
744 mat.setRotate(kRotation1);
745 mat.postScale(kScale0, kScale0);
746 mat.postRotate(kRotation0);
751 mat.mapHomogeneousPoints(&dst, &src, 1);
752 mat.mapPoints(&pnt, &pnt, 1);
843 SkMatrix mat, inverse, iden1, iden2;
845 mat.reset();
846 mat.setTranslate(1, 1);
847 REPORTER_ASSERT(reporter, mat.invert(&inverse));
848 iden1.setConcat(mat, inverse);
851 mat.setScale(2, 4);
852 REPORTER_ASSERT(reporter, mat.invert(&inverse));
853 iden1.setConcat(mat, inverse);
855 test_flatten(reporter, mat);
857 mat.setScale(SK_Scalar1/2, 2);
858 REPORTER_ASSERT(reporter, mat.invert(&inverse));
859 iden1.setConcat(mat, inverse);
861 test_flatten(reporter, mat);
863 mat.setScale(3, 5, 20, 0).postRotate(25);
864 REPORTER_ASSERT(reporter, mat.invert(nullptr));
865 REPORTER_ASSERT(reporter, mat.invert(&inverse));
866 iden1.setConcat(mat, inverse);
868 iden2.setConcat(inverse, mat);
870 test_flatten(reporter, mat);
873 mat.setScale(0, 1);
874 REPORTER_ASSERT(reporter, !mat.invert(nullptr));
875 REPORTER_ASSERT(reporter, !mat.invert(&inverse));
876 mat.setScale(1, 0);
877 REPORTER_ASSERT(reporter, !mat.invert(nullptr));
878 REPORTER_ASSERT(reporter, !mat.invert(&inverse));
881 mat.setAll(0.0f, 1.0f, 2.0f,
884 REPORTER_ASSERT(reporter, !mat.invert(nullptr));
885 REPORTER_ASSERT(reporter, !mat.invert(&inverse));
925 mat.reset();
926 mat.set(SkMatrix::kMScaleX, 1)
933 REPORTER_ASSERT(reporter, mat.asAffine(affine));
935 #define affineEqual(e) affine[SkMatrix::kA##e] == mat.get(SkMatrix::kM##e)
944 mat.set(SkMatrix::kMPersp1, SK_Scalar1 / 2);
945 REPORTER_ASSERT(reporter, !mat.asAffine(affine));
949 mat.reset();
951 mat.set(SkMatrix::kMSkewX, -zero);
952 REPORTER_ASSERT(reporter, are_equal(reporter, mat, mat2));
955 mat.reset();
956 mat.set(SkMatrix::kMSkewX, SK_ScalarNaN);
958 REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2));
969 mat.setScaleTranslate(2, 3, 1, 4);
971 REPORTER_ASSERT(reporter, mat == mat2);
991 SkMatrix mat;
992 mat.setScale(2, 3).postTranslate(1, 4);
1002 mat.mapPoints((SkPoint*)&dst[0].fLeft, (SkPoint*)&src.fLeft, 2);
1004 mat.mapRect(&dst[1], src);
1005 mat.mapRectScaleTranslate(&dst[2], src);
1006 dst[3] = mat.mapRect(src);