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

Unified Diff: tests/ResourceCacheTest.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 | « tests/PathTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ResourceCacheTest.cpp
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index b795b01b24899135ec153c77b33174490e3320cb..43f087004fc42b0dc31b77767dde4abaf247dfb5 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -845,6 +845,21 @@ static void test_duplicate_unique_key(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
+
+ {
+ GrUniqueKey key2;
+ make_unique_key<0>(&key2, 0);
+ SkAutoTUnref<TestResource> d(SkNEW_ARGS(TestResource, (context->getGpu())));
+ int foo = 4132;
+ SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
+ key2.setCustomData(data.get());
+ d->resourcePriv().setUniqueKey(key2);
+ }
+
+ GrUniqueKey key3;
+ make_unique_key<0>(&key3, 0);
+ SkAutoTUnref<GrGpuResource> d2(cache->findAndRefUniqueResource(key3));
+ REPORTER_ASSERT(reporter, *(int*) d2->getUniqueKey().getCustomData()->data() == 4132);
}
static void test_purge_invalidated(skiatest::Reporter* reporter) {
@@ -1223,6 +1238,21 @@ static void test_large_resource_count(skiatest::Reporter* reporter) {
}
}
+static void test_custom_data(skiatest::Reporter* reporter) {
+ GrUniqueKey key1, key2;
+ make_unique_key<0>(&key1, 1);
+ make_unique_key<0>(&key2, 2);
+ int foo = 4132;
+ SkAutoTUnref<SkData> data(SkData::NewWithCopy(&foo, sizeof(foo)));
+ key1.setCustomData(data.get());
+ REPORTER_ASSERT(reporter, *(int*) key1.getCustomData()->data() == 4132);
+ REPORTER_ASSERT(reporter, key2.getCustomData() == nullptr);
+
+ // Test that copying a key also takes a ref on its custom data.
+ GrUniqueKey key3 = key1;
+ REPORTER_ASSERT(reporter, *(int*) key3.getCustomData()->data() == 4132);
+}
+
////////////////////////////////////////////////////////////////////////////////
DEF_GPUTEST(ResourceCache, reporter, factory) {
for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
@@ -1262,6 +1292,7 @@ DEF_GPUTEST(ResourceCache, reporter, factory) {
test_timestamp_wrap(reporter);
test_flush(reporter);
test_large_resource_count(reporter);
+ test_custom_data(reporter);
}
#endif
« no previous file with comments | « tests/PathTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698