| 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 3559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3570 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f)); | 3570 REPORTER_ASSERT(reporter, p.contains(5.5f, 5.5f)); |
| 3571 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f)); | 3571 REPORTER_ASSERT(reporter, !p.contains(4.5f, 5.5f)); |
| 3572 } | 3572 } |
| 3573 } | 3573 } |
| 3574 | 3574 |
| 3575 class PathRefTest_Private { | 3575 class PathRefTest_Private { |
| 3576 public: | 3576 public: |
| 3577 static void TestPathRef(skiatest::Reporter* reporter) { | 3577 static void TestPathRef(skiatest::Reporter* reporter) { |
| 3578 static const int kRepeatCnt = 10; | 3578 static const int kRepeatCnt = 10; |
| 3579 | 3579 |
| 3580 SkAutoTUnref<SkPathRef> pathRef(SkNEW(SkPathRef)); | 3580 SkAutoTUnref<SkPathRef> pathRef(new SkPathRef); |
| 3581 | 3581 |
| 3582 SkPathRef::Editor ed(&pathRef); | 3582 SkPathRef::Editor ed(&pathRef); |
| 3583 | 3583 |
| 3584 { | 3584 { |
| 3585 ed.growForRepeatedVerb(SkPath::kMove_Verb, kRepeatCnt); | 3585 ed.growForRepeatedVerb(SkPath::kMove_Verb, kRepeatCnt); |
| 3586 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs()); | 3586 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countVerbs()); |
| 3587 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints()); | 3587 REPORTER_ASSERT(reporter, kRepeatCnt == pathRef->countPoints()); |
| 3588 REPORTER_ASSERT(reporter, 0 == pathRef->getSegmentMasks()); | 3588 REPORTER_ASSERT(reporter, 0 == pathRef->getSegmentMasks()); |
| 3589 for (int i = 0; i < kRepeatCnt; ++i) { | 3589 for (int i = 0; i < kRepeatCnt; ++i) { |
| 3590 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef->atVerb(
i)); | 3590 REPORTER_ASSERT(reporter, SkPath::kMove_Verb == pathRef->atVerb(
i)); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3751 } | 3751 } |
| 3752 | 3752 |
| 3753 static void TestPathrefListeners(skiatest::Reporter* reporter) { | 3753 static void TestPathrefListeners(skiatest::Reporter* reporter) { |
| 3754 SkPath p; | 3754 SkPath p; |
| 3755 | 3755 |
| 3756 bool changed = false; | 3756 bool changed = false; |
| 3757 p.moveTo(0, 0); | 3757 p.moveTo(0, 0); |
| 3758 | 3758 |
| 3759 // Check that listener is notified on moveTo(). | 3759 // Check that listener is notified on moveTo(). |
| 3760 | 3760 |
| 3761 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed))); | 3761 SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed)); |
| 3762 REPORTER_ASSERT(reporter, !changed); | 3762 REPORTER_ASSERT(reporter, !changed); |
| 3763 p.moveTo(10, 0); | 3763 p.moveTo(10, 0); |
| 3764 REPORTER_ASSERT(reporter, changed); | 3764 REPORTER_ASSERT(reporter, changed); |
| 3765 | 3765 |
| 3766 // Check that listener is notified on lineTo(). | 3766 // Check that listener is notified on lineTo(). |
| 3767 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed))); | 3767 SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed)); |
| 3768 REPORTER_ASSERT(reporter, !changed); | 3768 REPORTER_ASSERT(reporter, !changed); |
| 3769 p.lineTo(20, 0); | 3769 p.lineTo(20, 0); |
| 3770 REPORTER_ASSERT(reporter, changed); | 3770 REPORTER_ASSERT(reporter, changed); |
| 3771 | 3771 |
| 3772 // Check that listener is notified on reset(). | 3772 // Check that listener is notified on reset(). |
| 3773 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed))); | 3773 SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed)); |
| 3774 REPORTER_ASSERT(reporter, !changed); | 3774 REPORTER_ASSERT(reporter, !changed); |
| 3775 p.reset(); | 3775 p.reset(); |
| 3776 REPORTER_ASSERT(reporter, changed); | 3776 REPORTER_ASSERT(reporter, changed); |
| 3777 | 3777 |
| 3778 p.moveTo(0, 0); | 3778 p.moveTo(0, 0); |
| 3779 | 3779 |
| 3780 // Check that listener is notified on rewind(). | 3780 // Check that listener is notified on rewind(). |
| 3781 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed))); | 3781 SkPathPriv::AddGenIDChangeListener(p, new ChangeListener(&changed)); |
| 3782 REPORTER_ASSERT(reporter, !changed); | 3782 REPORTER_ASSERT(reporter, !changed); |
| 3783 p.rewind(); | 3783 p.rewind(); |
| 3784 REPORTER_ASSERT(reporter, changed); | 3784 REPORTER_ASSERT(reporter, changed); |
| 3785 | 3785 |
| 3786 // Check that listener is notified when pathref is deleted. | 3786 // Check that listener is notified when pathref is deleted. |
| 3787 { | 3787 { |
| 3788 SkPath q; | 3788 SkPath q; |
| 3789 q.moveTo(10, 10); | 3789 q.moveTo(10, 10); |
| 3790 SkPathPriv::AddGenIDChangeListener(q, SkNEW(ChangeListener(&changed)
)); | 3790 SkPathPriv::AddGenIDChangeListener(q, new ChangeListener(&changed)); |
| 3791 REPORTER_ASSERT(reporter, !changed); | 3791 REPORTER_ASSERT(reporter, !changed); |
| 3792 } | 3792 } |
| 3793 // q went out of scope. | 3793 // q went out of scope. |
| 3794 REPORTER_ASSERT(reporter, changed); | 3794 REPORTER_ASSERT(reporter, changed); |
| 3795 } | 3795 } |
| 3796 }; | 3796 }; |
| 3797 | 3797 |
| 3798 DEF_TEST(Paths, reporter) { | 3798 DEF_TEST(Paths, reporter) { |
| 3799 test_path_crbug364224(); | 3799 test_path_crbug364224(); |
| 3800 | 3800 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3940 PathTest_Private::TestPathTo(reporter); | 3940 PathTest_Private::TestPathTo(reporter); |
| 3941 PathRefTest_Private::TestPathRef(reporter); | 3941 PathRefTest_Private::TestPathRef(reporter); |
| 3942 PathTest_Private::TestPathrefListeners(reporter); | 3942 PathTest_Private::TestPathrefListeners(reporter); |
| 3943 test_dump(reporter); | 3943 test_dump(reporter); |
| 3944 test_path_crbug389050(reporter); | 3944 test_path_crbug389050(reporter); |
| 3945 test_path_crbugskia2820(reporter); | 3945 test_path_crbugskia2820(reporter); |
| 3946 test_skbug_3469(reporter); | 3946 test_skbug_3469(reporter); |
| 3947 test_skbug_3239(reporter); | 3947 test_skbug_3239(reporter); |
| 3948 test_bounds_crbug_513799(reporter); | 3948 test_bounds_crbug_513799(reporter); |
| 3949 } | 3949 } |
| OLD | NEW |