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

Side by Side Diff: tests/PathTest.cpp

Issue 1114353004: Implement vertex buffer caching in the tessellated path renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Integrated cache invalidation based on SkPath GenID change Created 5 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
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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkParse.h" 10 #include "SkParse.h"
(...skipping 3681 matching lines...) Expand 10 before | Expand all | Expand 10 after
3692 q.conicTo(8, 7, 6, 5, 0.5f); 3692 q.conicTo(8, 7, 6, 5, 0.5f);
3693 q.quadTo(6, 7, 8, 6); 3693 q.quadTo(6, 7, 8, 6);
3694 q.cubicTo(5, 6, 7, 8, 7, 5); 3694 q.cubicTo(5, 6, 7, 8, 7, 5);
3695 q.close(); 3695 q.close();
3696 p.reversePathTo(q); 3696 p.reversePathTo(q);
3697 SkRect reverseExpected = {-4, -4, 8, 8}; 3697 SkRect reverseExpected = {-4, -4, 8, 8};
3698 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); 3698 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
3699 } 3699 }
3700 }; 3700 };
3701 3701
3702 namespace {
3703
3704 class ChangeListener : public SkPathRef::GenIDChangeListener {
3705 public:
3706 ChangeListener(bool *changed) : fChanged(changed) { *fChanged = false; }
3707 virtual ~ChangeListener() {}
3708 void onChange() override {
3709 *fChanged = true;
3710 }
3711 private:
3712 bool* fChanged;
3713 };
3714
3715 }
3716
3717 static void test_pathref_listeners(skiatest::Reporter* reporter) {
3718 SkPath p;
3719
3720 bool changed = false;
3721 p.moveTo(0, 0);
3722
3723 // Check that listener is notified on moveTo().
3724 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3725 REPORTER_ASSERT(reporter, !changed);
3726 p.moveTo(10, 0);
3727 REPORTER_ASSERT(reporter, changed);
3728
3729 // Check that listener is notified on lineTo().
3730 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3731 REPORTER_ASSERT(reporter, !changed);
3732 p.lineTo(20, 0);
3733 REPORTER_ASSERT(reporter, changed);
3734
3735 // Check that listener is notified on reset().
3736 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3737 REPORTER_ASSERT(reporter, !changed);
3738 p.reset();
3739 REPORTER_ASSERT(reporter, changed);
3740
3741 p.moveTo(0, 0);
3742
3743 // Check that listener is notified on rewind().
3744 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3745 REPORTER_ASSERT(reporter, !changed);
3746 p.rewind();
3747 REPORTER_ASSERT(reporter, changed);
3748
3749 // Check that listener is notified when pathref is deleted.
3750 {
3751 SkPath q;
3752 q.moveTo(10, 10);
3753 q.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3754 REPORTER_ASSERT(reporter, !changed);
3755 }
3756 // q went out of scope.
3757 REPORTER_ASSERT(reporter, changed);
3758 }
3759
3702 DEF_TEST(Paths, reporter) { 3760 DEF_TEST(Paths, reporter) {
3703 test_path_crbug364224(); 3761 test_path_crbug364224();
3704 3762
3705 SkTSize<SkScalar>::Make(3,4); 3763 SkTSize<SkScalar>::Make(3,4);
3706 3764
3707 SkPath p, empty; 3765 SkPath p, empty;
3708 SkRect bounds, bounds2; 3766 SkRect bounds, bounds2;
3709 test_empty(reporter, p); 3767 test_empty(reporter, p);
3710 3768
3711 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); 3769 REPORTER_ASSERT(reporter, p.getBounds().isEmpty());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 test_conicTo_special_case(reporter); 3899 test_conicTo_special_case(reporter);
3842 test_get_point(reporter); 3900 test_get_point(reporter);
3843 test_contains(reporter); 3901 test_contains(reporter);
3844 PathTest_Private::TestPathTo(reporter); 3902 PathTest_Private::TestPathTo(reporter);
3845 PathRefTest_Private::TestPathRef(reporter); 3903 PathRefTest_Private::TestPathRef(reporter);
3846 test_dump(reporter); 3904 test_dump(reporter);
3847 test_path_crbug389050(reporter); 3905 test_path_crbug389050(reporter);
3848 test_path_crbugskia2820(reporter); 3906 test_path_crbugskia2820(reporter);
3849 test_skbug_3469(reporter); 3907 test_skbug_3469(reporter);
3850 test_skbug_3239(reporter); 3908 test_skbug_3239(reporter);
3909 test_pathref_listeners(reporter);
3851 } 3910 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698