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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrTessellatingPathRenderer.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PathTest.cpp
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 8272692167d5de54ee35f00b759c0389485cb2a6..b0bd66726d4eb719a7361970743c8bc1f3992556 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -3715,6 +3715,21 @@ static void test_dump(skiatest::Reporter* reporter) {
"path.lineTo(3, 4);\n");
}
+namespace {
+
+class ChangeListener : public SkPathRef::GenIDChangeListener {
+public:
+ ChangeListener(bool *changed) : fChanged(changed) { *fChanged = false; }
+ virtual ~ChangeListener() {}
+ void onChange() override {
+ *fChanged = true;
+ }
+private:
+ bool* fChanged;
+};
+
+}
+
class PathTest_Private {
public:
static void TestPathTo(skiatest::Reporter* reporter) {
@@ -3734,6 +3749,50 @@ public:
SkRect reverseExpected = {-4, -4, 8, 8};
REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected);
}
+
+ static void TestPathrefListeners(skiatest::Reporter* reporter) {
+ SkPath p;
+
+ bool changed = false;
+ p.moveTo(0, 0);
+
+ // Check that listener is notified on moveTo().
+
+ SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.moveTo(10, 0);
+ REPORTER_ASSERT(reporter, changed);
+
+ // Check that listener is notified on lineTo().
+ SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.lineTo(20, 0);
+ REPORTER_ASSERT(reporter, changed);
+
+ // Check that listener is notified on reset().
+ SkPathPriv::AddGenIDChangeListener(p, SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ p.reset();
+ REPORTER_ASSERT(reporter, changed);
+
+ p.moveTo(0, 0);
+
+ // Check that listener is notified on rewind().
+ SkPathPriv::AddGenIDChangeListener(p, 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);
+ SkPathPriv::AddGenIDChangeListener(q, SkNEW(ChangeListener(&changed)));
+ REPORTER_ASSERT(reporter, !changed);
+ }
+ // q went out of scope.
+ REPORTER_ASSERT(reporter, changed);
+ }
};
DEF_TEST(Paths, reporter) {
@@ -3880,6 +3939,7 @@ DEF_TEST(Paths, reporter) {
test_contains(reporter);
PathTest_Private::TestPathTo(reporter);
PathRefTest_Private::TestPathRef(reporter);
+ PathTest_Private::TestPathrefListeners(reporter);
test_dump(reporter);
test_path_crbug389050(reporter);
test_path_crbugskia2820(reporter);
« 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