OLD | NEW |
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 "SkCanvas.h" | 8 #include "SkCanvas.h" |
9 #include "SkPaint.h" | 9 #include "SkPaint.h" |
10 #include "SkParse.h" | 10 #include "SkParse.h" |
(...skipping 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3412 REPORTER_ASSERT(reporter, a == b); | 3412 REPORTER_ASSERT(reporter, a == b); |
3413 a.lineTo(1, 1); | 3413 a.lineTo(1, 1); |
3414 b.lineTo(1, 2); | 3414 b.lineTo(1, 2); |
3415 REPORTER_ASSERT(reporter, a != b); | 3415 REPORTER_ASSERT(reporter, a != b); |
3416 a.reset(); | 3416 a.reset(); |
3417 a.lineTo(1, 2); | 3417 a.lineTo(1, 2); |
3418 REPORTER_ASSERT(reporter, a == b); | 3418 REPORTER_ASSERT(reporter, a == b); |
3419 } | 3419 } |
3420 | 3420 |
3421 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool
force, | 3421 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool
force, |
3422 const char* str) { | 3422 bool dumpAsHex, const char* str) { |
3423 SkDynamicMemoryWStream wStream; | 3423 SkDynamicMemoryWStream wStream; |
3424 path.dump(&wStream, force); | 3424 path.dump(&wStream, force, dumpAsHex); |
3425 SkAutoDataUnref data(wStream.copyToData()); | 3425 SkAutoDataUnref data(wStream.copyToData()); |
3426 REPORTER_ASSERT(reporter, data->size() == strlen(str)); | 3426 REPORTER_ASSERT(reporter, data->size() == strlen(str)); |
3427 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str))); | 3427 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str))); |
3428 } | 3428 } |
3429 | 3429 |
3430 static void test_dump(skiatest::Reporter* reporter) { | 3430 static void test_dump(skiatest::Reporter* reporter) { |
3431 SkPath p; | 3431 SkPath p; |
3432 compare_dump(reporter, p, false, ""); | 3432 compare_dump(reporter, p, false, false, ""); |
3433 compare_dump(reporter, p, true, ""); | 3433 compare_dump(reporter, p, true, false, ""); |
3434 p.moveTo(1, 2); | 3434 p.moveTo(1, 2); |
3435 p.lineTo(3, 4); | 3435 p.lineTo(3, 4); |
3436 compare_dump(reporter, p, false, "path.moveTo(1, 2);\n" | 3436 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" |
3437 "path.lineTo(3, 4);\n"); | 3437 "path.lineTo(3, 4);\n"); |
3438 compare_dump(reporter, p, true, "path.moveTo(1, 2);\n" | 3438 compare_dump(reporter, p, true, false, "path.moveTo(1, 2);\n" |
3439 "path.lineTo(3, 4);\n" | 3439 "path.lineTo(3, 4);\n" |
3440 "path.lineTo(1, 2);\n" | 3440 "path.lineTo(1, 2);\n" |
3441 "path.close();\n"); | 3441 "path.close();\n"); |
3442 p.reset(); | 3442 p.reset(); |
3443 p.moveTo(1, 2); | 3443 p.moveTo(1, 2); |
3444 p.quadTo(3, 4, 5, 6); | 3444 p.quadTo(3, 4, 5, 6); |
3445 compare_dump(reporter, p, false, "path.moveTo(1, 2);\n" | 3445 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" |
3446 "path.quadTo(3, 4, 5, 6);\n"); | 3446 "path.quadTo(3, 4, 5, 6);\n"); |
3447 p.reset(); | 3447 p.reset(); |
3448 p.moveTo(1, 2); | 3448 p.moveTo(1, 2); |
3449 p.conicTo(3, 4, 5, 6, 0.5f); | 3449 p.conicTo(3, 4, 5, 6, 0.5f); |
3450 compare_dump(reporter, p, false, "path.moveTo(1, 2);\n" | 3450 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" |
3451 "path.conicTo(3, 4, 5, 6, 0.5f);\n"); | 3451 "path.conicTo(3, 4, 5, 6, 0.5f);\n")
; |
3452 p.reset(); | 3452 p.reset(); |
3453 p.moveTo(1, 2); | 3453 p.moveTo(1, 2); |
3454 p.cubicTo(3, 4, 5, 6, 7, 8); | 3454 p.cubicTo(3, 4, 5, 6, 7, 8); |
3455 compare_dump(reporter, p, false, "path.moveTo(1, 2);\n" | 3455 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" |
3456 "path.cubicTo(3, 4, 5, 6, 7, 8);\n"); | 3456 "path.cubicTo(3, 4, 5, 6, 7, 8);\n")
; |
| 3457 p.reset(); |
| 3458 p.moveTo(1, 2); |
| 3459 p.lineTo(3, 4); |
| 3460 compare_dump(reporter, p, false, true, "path.moveTo(SkBits2Float(0x3f800000
), SkBits2Float(0x40000000));\n" |
| 3461 "path.lineTo(SkBits2Float(0x40400000
), SkBits2Float(0x40800000));\n"); |
| 3462 p.reset(); |
| 3463 p.moveTo(SkBits2Float(0x3f800000), SkBits2Float(0x40000000)); |
| 3464 p.lineTo(SkBits2Float(0x40400000), SkBits2Float(0x40800000)); |
| 3465 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" |
| 3466 "path.lineTo(3, 4);\n"); |
3457 } | 3467 } |
3458 | 3468 |
3459 class PathTest_Private { | 3469 class PathTest_Private { |
3460 public: | 3470 public: |
3461 static void TestPathTo(skiatest::Reporter* reporter) { | 3471 static void TestPathTo(skiatest::Reporter* reporter) { |
3462 SkPath p, q; | 3472 SkPath p, q; |
3463 p.lineTo(4, 4); | 3473 p.lineTo(4, 4); |
3464 p.reversePathTo(q); | 3474 p.reversePathTo(q); |
3465 check_path_is_line(reporter, &p, 4, 4); | 3475 check_path_is_line(reporter, &p, 4, 4); |
3466 q.moveTo(-4, -4); | 3476 q.moveTo(-4, -4); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3601 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); | 3611 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); |
3602 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); | 3612 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); |
3603 test_conicTo_special_case(reporter); | 3613 test_conicTo_special_case(reporter); |
3604 test_get_point(reporter); | 3614 test_get_point(reporter); |
3605 test_contains(reporter); | 3615 test_contains(reporter); |
3606 PathTest_Private::TestPathTo(reporter); | 3616 PathTest_Private::TestPathTo(reporter); |
3607 PathRefTest_Private::TestPathRef(reporter); | 3617 PathRefTest_Private::TestPathRef(reporter); |
3608 test_dump(reporter); | 3618 test_dump(reporter); |
3609 test_path_crbugskia2820(reporter); | 3619 test_path_crbugskia2820(reporter); |
3610 } | 3620 } |
OLD | NEW |