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

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: Merge resource cache fix, leak fix, inverse winding fix 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
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
3761 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
3762 REPORTER_ASSERT(reporter, !changed);
3763 p.moveTo(10, 0);
3764 REPORTER_ASSERT(reporter, changed);
3765
3766 // Check that listener is notified on lineTo().
3767 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
3768 REPORTER_ASSERT(reporter, !changed);
3769 p.lineTo(20, 0);
3770 REPORTER_ASSERT(reporter, changed);
3771
3772 // Check that listener is notified on reset().
3773 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
3774 REPORTER_ASSERT(reporter, !changed);
3775 p.reset();
3776 REPORTER_ASSERT(reporter, changed);
3777
3778 p.moveTo(0, 0);
3779
3780 // Check that listener is notified on rewind().
3781 SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
3782 REPORTER_ASSERT(reporter, !changed);
3783 p.rewind();
3784 REPORTER_ASSERT(reporter, changed);
3785
3786 // Check that listener is notified when pathref is deleted.
3787 {
3788 SkPath q;
3789 q.moveTo(10, 10);
3790 SkPathPriv::AddGenIDChangeListener(q, SkNEW(ChangeListener(&changed) ));
3791 REPORTER_ASSERT(reporter, !changed);
3792 }
3793 // q went out of scope.
3794 REPORTER_ASSERT(reporter, changed);
3795 }
3737 }; 3796 };
3738 3797
3739 DEF_TEST(Paths, reporter) { 3798 DEF_TEST(Paths, reporter) {
3740 test_path_crbug364224(); 3799 test_path_crbug364224();
3741 3800
3742 SkTSize<SkScalar>::Make(3,4); 3801 SkTSize<SkScalar>::Make(3,4);
3743 3802
3744 SkPath p, empty; 3803 SkPath p, empty;
3745 SkRect bounds, bounds2; 3804 SkRect bounds, bounds2;
3746 test_empty(reporter, p); 3805 test_empty(reporter, p);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 test_addPathMode(reporter, false, true); 3932 test_addPathMode(reporter, false, true);
3874 test_addPathMode(reporter, true, true); 3933 test_addPathMode(reporter, true, true);
3875 test_extendClosedPath(reporter); 3934 test_extendClosedPath(reporter);
3876 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); 3935 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
3877 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); 3936 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
3878 test_conicTo_special_case(reporter); 3937 test_conicTo_special_case(reporter);
3879 test_get_point(reporter); 3938 test_get_point(reporter);
3880 test_contains(reporter); 3939 test_contains(reporter);
3881 PathTest_Private::TestPathTo(reporter); 3940 PathTest_Private::TestPathTo(reporter);
3882 PathRefTest_Private::TestPathRef(reporter); 3941 PathRefTest_Private::TestPathRef(reporter);
3942 PathTest_Private::TestPathrefListeners(reporter);
3883 test_dump(reporter); 3943 test_dump(reporter);
3884 test_path_crbug389050(reporter); 3944 test_path_crbug389050(reporter);
3885 test_path_crbugskia2820(reporter); 3945 test_path_crbugskia2820(reporter);
3886 test_skbug_3469(reporter); 3946 test_skbug_3469(reporter);
3887 test_skbug_3239(reporter); 3947 test_skbug_3239(reporter);
3888 test_bounds_crbug_513799(reporter); 3948 test_bounds_crbug_513799(reporter);
3889 } 3949 }
OLDNEW
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698