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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 313d84a142bc9c84a029c8968df0ef64d693b408..0453bdd9f70cda0f319e3810e8012afd31d45bdd 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -3699,6 +3699,64 @@ public:
}
};
+namespace {
+
+class ChangeListener : public SkPathRef::GenIDChangeListener {
+public:
+ ChangeListener(bool *changed) : fChanged(changed) { *fChanged = false; }
+ virtual ~ChangeListener() {}
+ void onChange() override {
+ *fChanged = true;
+ }
+private:
+ bool* fChanged;
+};
+
+}
+
+static void test_pathref_listeners(skiatest::Reporter* reporter) {
+ SkPath p;
+
+ bool changed = false;
+ p.moveTo(0, 0);
+
+ // Check that listener is notified on moveTo().
+ p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.moveTo(10, 0);
+ REPORTER_ASSERT(reporter, changed);
+
+ // Check that listener is notified on lineTo().
+ p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.lineTo(20, 0);
+ REPORTER_ASSERT(reporter, changed);
+
+ // Check that listener is notified on reset().
+ p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.reset();
+ REPORTER_ASSERT(reporter, changed);
+
+ p.moveTo(0, 0);
+
+ // Check that listener is notified on rewind().
+ p.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.rewind();
+ REPORTER_ASSERT(reporter, changed);
+
+ // Check that listener is notified when pathref is deleted.
+ {
+ SkPath q;
+ q.moveTo(10, 10);
+ q.pathRef()->addGenIDChangeListener(SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ }
+ // q went out of scope.
+ REPORTER_ASSERT(reporter, changed);
+}
+
DEF_TEST(Paths, reporter) {
test_path_crbug364224();
@@ -3848,4 +3906,5 @@ DEF_TEST(Paths, reporter) {
test_path_crbugskia2820(reporter);
test_skbug_3469(reporter);
test_skbug_3239(reporter);
+ test_pathref_listeners(reporter);
}

Powered by Google App Engine
This is Rietveld 408576698