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

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: Update to ToT; remove GrContext and use GrResourceProvider directly 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 3697 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 compare_dump(reporter, p, false, true, 3708 compare_dump(reporter, p, false, true,
3709 "path.moveTo(SkBits2Float(0x3f800000), SkBits2Float(0x40000000) ); // 1, 2\n" 3709 "path.moveTo(SkBits2Float(0x3f800000), SkBits2Float(0x40000000) ); // 1, 2\n"
3710 "path.lineTo(SkBits2Float(0x40400000), SkBits2Float(0x40800000) ); // 3, 4\n"); 3710 "path.lineTo(SkBits2Float(0x40400000), SkBits2Float(0x40800000) ); // 3, 4\n");
3711 p.reset(); 3711 p.reset();
3712 p.moveTo(SkBits2Float(0x3f800000), SkBits2Float(0x40000000)); 3712 p.moveTo(SkBits2Float(0x3f800000), SkBits2Float(0x40000000));
3713 p.lineTo(SkBits2Float(0x40400000), SkBits2Float(0x40800000)); 3713 p.lineTo(SkBits2Float(0x40400000), SkBits2Float(0x40800000));
3714 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" 3714 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n"
3715 "path.lineTo(3, 4);\n"); 3715 "path.lineTo(3, 4);\n");
3716 } 3716 }
3717 3717
3718 namespace {
3719
3720 class ChangeListener : public SkPathRef::GenIDChangeListener {
3721 public:
3722 ChangeListener(bool *changed) : fChanged(changed) { *fChanged = false; }
3723 virtual ~ChangeListener() {}
3724 void onChange() override {
3725 *fChanged = true;
3726 }
3727 private:
3728 bool* fChanged;
3729 };
3730
3731 }
3732
3718 class PathTest_Private { 3733 class PathTest_Private {
3719 public: 3734 public:
3720 static void TestPathTo(skiatest::Reporter* reporter) { 3735 static void TestPathTo(skiatest::Reporter* reporter) {
3721 SkPath p, q; 3736 SkPath p, q;
3722 p.lineTo(4, 4); 3737 p.lineTo(4, 4);
3723 p.reversePathTo(q); 3738 p.reversePathTo(q);
3724 check_path_is_line(reporter, &p, 4, 4); 3739 check_path_is_line(reporter, &p, 4, 4);
3725 q.moveTo(-4, -4); 3740 q.moveTo(-4, -4);
3726 p.reversePathTo(q); 3741 p.reversePathTo(q);
3727 check_path_is_line(reporter, &p, 4, 4); 3742 check_path_is_line(reporter, &p, 4, 4);
3728 q.lineTo(7, 8); 3743 q.lineTo(7, 8);
3729 q.conicTo(8, 7, 6, 5, 0.5f); 3744 q.conicTo(8, 7, 6, 5, 0.5f);
3730 q.quadTo(6, 7, 8, 6); 3745 q.quadTo(6, 7, 8, 6);
3731 q.cubicTo(5, 6, 7, 8, 7, 5); 3746 q.cubicTo(5, 6, 7, 8, 7, 5);
3732 q.close(); 3747 q.close();
3733 p.reversePathTo(q); 3748 p.reversePathTo(q);
3734 SkRect reverseExpected = {-4, -4, 8, 8}; 3749 SkRect reverseExpected = {-4, -4, 8, 8};
3735 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); 3750 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
3736 } 3751 }
3752
3753 static void TestPathrefListeners(skiatest::Reporter* reporter) {
3754 SkPath p;
3755
3756 bool changed = false;
3757 p.moveTo(0, 0);
3758
3759 // Check that listener is notified on moveTo().
3760 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3761 REPORTER_ASSERT(reporter, !changed);
3762 p.moveTo(10, 0);
3763 REPORTER_ASSERT(reporter, changed);
3764
3765 // Check that listener is notified on lineTo().
3766 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3767 REPORTER_ASSERT(reporter, !changed);
3768 p.lineTo(20, 0);
3769 REPORTER_ASSERT(reporter, changed);
3770
3771 // Check that listener is notified on reset().
3772 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3773 REPORTER_ASSERT(reporter, !changed);
3774 p.reset();
3775 REPORTER_ASSERT(reporter, changed);
3776
3777 p.moveTo(0, 0);
3778
3779 // Check that listener is notified on rewind().
3780 p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
3781 REPORTER_ASSERT(reporter, !changed);
3782 p.rewind();
3783 REPORTER_ASSERT(reporter, changed);
3784
3785 // Check that listener is notified when pathref is deleted.
3786 {
3787 SkPath q;
3788 q.moveTo(10, 10);
3789 q.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed))) ;
3790 REPORTER_ASSERT(reporter, !changed);
3791 }
3792 // q went out of scope.
3793 REPORTER_ASSERT(reporter, changed);
3794 }
3737 }; 3795 };
3738 3796
3739 DEF_TEST(Paths, reporter) { 3797 DEF_TEST(Paths, reporter) {
3740 test_path_crbug364224(); 3798 test_path_crbug364224();
3741 3799
3742 SkTSize<SkScalar>::Make(3,4); 3800 SkTSize<SkScalar>::Make(3,4);
3743 3801
3744 SkPath p, empty; 3802 SkPath p, empty;
3745 SkRect bounds, bounds2; 3803 SkRect bounds, bounds2;
3746 test_empty(reporter, p); 3804 test_empty(reporter, p);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 test_addPathMode(reporter, false, true); 3931 test_addPathMode(reporter, false, true);
3874 test_addPathMode(reporter, true, true); 3932 test_addPathMode(reporter, true, true);
3875 test_extendClosedPath(reporter); 3933 test_extendClosedPath(reporter);
3876 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); 3934 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
3877 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); 3935 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
3878 test_conicTo_special_case(reporter); 3936 test_conicTo_special_case(reporter);
3879 test_get_point(reporter); 3937 test_get_point(reporter);
3880 test_contains(reporter); 3938 test_contains(reporter);
3881 PathTest_Private::TestPathTo(reporter); 3939 PathTest_Private::TestPathTo(reporter);
3882 PathRefTest_Private::TestPathRef(reporter); 3940 PathRefTest_Private::TestPathRef(reporter);
3941 PathTest_Private::TestPathrefListeners(reporter);
3883 test_dump(reporter); 3942 test_dump(reporter);
3884 test_path_crbug389050(reporter); 3943 test_path_crbug389050(reporter);
3885 test_path_crbugskia2820(reporter); 3944 test_path_crbugskia2820(reporter);
3886 test_skbug_3469(reporter); 3945 test_skbug_3469(reporter);
3887 test_skbug_3239(reporter); 3946 test_skbug_3239(reporter);
3888 test_bounds_crbug_513799(reporter); 3947 test_bounds_crbug_513799(reporter);
3889 } 3948 }
OLDNEW
« src/gpu/GrTessellatingPathRenderer.cpp ('K') | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698