Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: tests/Matrix44Test.cpp

Issue 22904003: Make SkMatrix44::invert() check for finite 1/det instead of magic value (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Shrink range of one matrix test to pass is_identity() check on i386-linux Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/utils/SkMatrix44.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "Test.h" 8 #include "Test.h"
9 #include "SkMatrix44.h" 9 #include "SkMatrix44.h"
10 10
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 mat.setScale(3, 3, 3); 396 mat.setScale(3, 3, 3);
397 rot.setRotateDegreesAbout(0, 0, -1, 90); 397 rot.setRotateDegreesAbout(0, 0, -1, 90);
398 mat.postConcat(rot); 398 mat.postConcat(rot);
399 REPORTER_ASSERT(reporter, mat.invert(NULL)); 399 REPORTER_ASSERT(reporter, mat.invert(NULL));
400 mat.invert(&inverse); 400 mat.invert(&inverse);
401 iden1.setConcat(mat, inverse); 401 iden1.setConcat(mat, inverse);
402 REPORTER_ASSERT(reporter, is_identity(iden1)); 402 REPORTER_ASSERT(reporter, is_identity(iden1));
403 iden2.setConcat(inverse, mat); 403 iden2.setConcat(inverse, mat);
404 REPORTER_ASSERT(reporter, is_identity(iden2)); 404 REPORTER_ASSERT(reporter, is_identity(iden2));
405 405
406 // test tiny-valued matrix inverse
407 mat.reset();
408 mat.setScale(1.0e-12, 1.0e-12, 1.0e-12);
409 rot.setRotateDegreesAbout(0, 0, -1, 90);
410 mat.postConcat(rot);
411 mat.postTranslate(1.0e-12, 1.0e-12, 1.0e-12);
412 REPORTER_ASSERT(reporter, mat.invert(NULL));
413 mat.invert(&inverse);
414 iden1.setConcat(mat, inverse);
415 REPORTER_ASSERT(reporter, is_identity(iden1));
416
417 // test mixed-valued matrix inverse
418 mat.reset();
419 mat.setScale(1.0e-11, 3.0, 1.0e+11);
420 rot.setRotateDegreesAbout(0, 0, -1, 90);
421 mat.postConcat(rot);
422 mat.postTranslate(1.0e+11, 3.0, 1.0e-11);
423 REPORTER_ASSERT(reporter, mat.invert(NULL));
424 mat.invert(&inverse);
425 iden1.setConcat(mat, inverse);
426 REPORTER_ASSERT(reporter, is_identity(iden1));
427
428 // test degenerate matrix
429 mat.reset();
430 mat.set3x3(1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0);
431 REPORTER_ASSERT(reporter, !mat.invert(NULL));
432
406 // test rol/col Major getters 433 // test rol/col Major getters
407 { 434 {
408 mat.setTranslate(2, 3, 4); 435 mat.setTranslate(2, 3, 4);
409 float dataf[16]; 436 float dataf[16];
410 double datad[16]; 437 double datad[16];
411 438
412 mat.asColMajorf(dataf); 439 mat.asColMajorf(dataf);
413 assert16<float>(reporter, dataf, 440 assert16<float>(reporter, dataf,
414 1, 0, 0, 0, 441 1, 0, 0, 0,
415 0, 1, 0, 0, 442 0, 1, 0, 0,
(...skipping 28 matching lines...) Expand all
444 test_transpose(reporter); 471 test_transpose(reporter);
445 test_get_set_double(reporter); 472 test_get_set_double(reporter);
446 test_set_row_col_major(reporter); 473 test_set_row_col_major(reporter);
447 test_translate(reporter); 474 test_translate(reporter);
448 test_scale(reporter); 475 test_scale(reporter);
449 test_map2(reporter); 476 test_map2(reporter);
450 } 477 }
451 478
452 #include "TestClassDef.h" 479 #include "TestClassDef.h"
453 DEFINE_TESTCLASS("Matrix44", Matrix44TestClass, TestMatrix44) 480 DEFINE_TESTCLASS("Matrix44", Matrix44TestClass, TestMatrix44)
OLDNEW
« no previous file with comments | « src/utils/SkMatrix44.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698