| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 path.rLineTo(0, 100); | 218 path.rLineTo(0, 100); |
| 219 path.rLineTo(100, 0); | 219 path.rLineTo(100, 0); |
| 220 path.close(); | 220 path.close(); |
| 221 path.rCubicTo(50, 50, 85, 85, 95, 95); | 221 path.rCubicTo(50, 50, 85, 85, 95, 95); |
| 222 | 222 |
| 223 path.getLastPt(&last); | 223 path.getLastPt(&last); |
| 224 REPORTER_ASSERT(reporter, 95 == last.fX); | 224 REPORTER_ASSERT(reporter, 95 == last.fX); |
| 225 REPORTER_ASSERT(reporter, 95 == last.fY); | 225 REPORTER_ASSERT(reporter, 95 == last.fY); |
| 226 } | 226 } |
| 227 | 227 |
| 228 static void test_android_specific_behavior(skiatest::Reporter* reporter) { | |
| 229 #ifdef SK_BUILD_FOR_ANDROID | |
| 230 // Make sure we treat fGenerationID and fSourcePath correctly for each of | |
| 231 // copy, assign, rewind, reset, and swap. | |
| 232 SkPath original, source, anotherSource; | |
| 233 original.setSourcePath(&source); | |
| 234 original.moveTo(0, 0); | |
| 235 original.lineTo(1, 1); | |
| 236 REPORTER_ASSERT(reporter, original.getSourcePath() == &source); | |
| 237 | |
| 238 uint32_t copyID, assignID; | |
| 239 | |
| 240 // Test copy constructor. Copy generation ID, copy source path. | |
| 241 SkPath copy(original); | |
| 242 REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID
()); | |
| 243 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | |
| 244 | |
| 245 // Test assigment operator. Change generation ID, copy source path. | |
| 246 SkPath assign; | |
| 247 assignID = assign.getGenerationID(); | |
| 248 assign = original; | |
| 249 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); | |
| 250 REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath()
); | |
| 251 | |
| 252 // Test rewind. Change generation ID, don't touch source path. | |
| 253 copyID = copy.getGenerationID(); | |
| 254 copy.rewind(); | |
| 255 REPORTER_ASSERT(reporter, copy.getGenerationID() != copyID); | |
| 256 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | |
| 257 | |
| 258 // Test reset. Change generation ID, don't touch source path. | |
| 259 assignID = assign.getGenerationID(); | |
| 260 assign.reset(); | |
| 261 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); | |
| 262 REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath()
); | |
| 263 | |
| 264 // Test swap. Swap the generation IDs, swap source paths. | |
| 265 copy.reset(); | |
| 266 copy.moveTo(2, 2); | |
| 267 copy.setSourcePath(&anotherSource); | |
| 268 copyID = copy.getGenerationID(); | |
| 269 assign.moveTo(3, 3); | |
| 270 assignID = assign.getGenerationID(); | |
| 271 copy.swap(assign); | |
| 272 REPORTER_ASSERT(reporter, copy.getGenerationID() != copyID); | |
| 273 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); | |
| 274 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | |
| 275 REPORTER_ASSERT(reporter, assign.getSourcePath() == &anotherSource); | |
| 276 #endif | |
| 277 } | |
| 278 | |
| 279 static void test_gen_id(skiatest::Reporter* reporter) { | 228 static void test_gen_id(skiatest::Reporter* reporter) { |
| 280 SkPath a, b; | 229 SkPath a, b; |
| 281 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID()); | 230 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID()); |
| 282 | 231 |
| 283 a.moveTo(0, 0); | 232 a.moveTo(0, 0); |
| 284 const uint32_t z = a.getGenerationID(); | 233 const uint32_t z = a.getGenerationID(); |
| 285 REPORTER_ASSERT(reporter, z != b.getGenerationID()); | 234 REPORTER_ASSERT(reporter, z != b.getGenerationID()); |
| 286 | 235 |
| 287 a.reset(); | 236 a.reset(); |
| 288 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID()); | 237 REPORTER_ASSERT(reporter, a.getGenerationID() == b.getGenerationID()); |
| (...skipping 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3741 test_isfinite_after_transform(reporter); | 3690 test_isfinite_after_transform(reporter); |
| 3742 test_arb_round_rect_is_convex(reporter); | 3691 test_arb_round_rect_is_convex(reporter); |
| 3743 test_arb_zero_rad_round_rect_is_rect(reporter); | 3692 test_arb_zero_rad_round_rect_is_rect(reporter); |
| 3744 test_addrect(reporter); | 3693 test_addrect(reporter); |
| 3745 test_addrect_isfinite(reporter); | 3694 test_addrect_isfinite(reporter); |
| 3746 test_tricky_cubic(); | 3695 test_tricky_cubic(); |
| 3747 test_clipped_cubic(); | 3696 test_clipped_cubic(); |
| 3748 test_crbug_170666(); | 3697 test_crbug_170666(); |
| 3749 test_bad_cubic_crbug229478(); | 3698 test_bad_cubic_crbug229478(); |
| 3750 test_bad_cubic_crbug234190(); | 3699 test_bad_cubic_crbug234190(); |
| 3751 test_android_specific_behavior(reporter); | |
| 3752 test_gen_id(reporter); | 3700 test_gen_id(reporter); |
| 3753 test_path_close_issue1474(reporter); | 3701 test_path_close_issue1474(reporter); |
| 3754 test_path_to_region(reporter); | 3702 test_path_to_region(reporter); |
| 3755 test_rrect(reporter); | 3703 test_rrect(reporter); |
| 3756 test_arc(reporter); | 3704 test_arc(reporter); |
| 3757 test_arcTo(reporter); | 3705 test_arcTo(reporter); |
| 3758 test_addPath(reporter); | 3706 test_addPath(reporter); |
| 3759 test_addPathMode(reporter, false, false); | 3707 test_addPathMode(reporter, false, false); |
| 3760 test_addPathMode(reporter, true, false); | 3708 test_addPathMode(reporter, true, false); |
| 3761 test_addPathMode(reporter, false, true); | 3709 test_addPathMode(reporter, false, true); |
| 3762 test_addPathMode(reporter, true, true); | 3710 test_addPathMode(reporter, true, true); |
| 3763 test_extendClosedPath(reporter); | 3711 test_extendClosedPath(reporter); |
| 3764 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); | 3712 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); |
| 3765 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); | 3713 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); |
| 3766 test_conicTo_special_case(reporter); | 3714 test_conicTo_special_case(reporter); |
| 3767 test_get_point(reporter); | 3715 test_get_point(reporter); |
| 3768 test_contains(reporter); | 3716 test_contains(reporter); |
| 3769 PathTest_Private::TestPathTo(reporter); | 3717 PathTest_Private::TestPathTo(reporter); |
| 3770 PathRefTest_Private::TestPathRef(reporter); | 3718 PathRefTest_Private::TestPathRef(reporter); |
| 3771 test_dump(reporter); | 3719 test_dump(reporter); |
| 3772 test_path_crbugskia2820(reporter); | 3720 test_path_crbugskia2820(reporter); |
| 3773 test_skbug_3239(reporter); | 3721 test_skbug_3239(reporter); |
| 3774 } | 3722 } |
| OLD | NEW |