aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/GpuLayerCacheTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-07-22 10:18:06 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-22 10:18:06 -0700
commitd771f6bc273457bc7aa95938ac326dfbbf876e1a (patch)
tree9a88b85ac2a0c044c9a160a0f960b5d7f761267f /tests/GpuLayerCacheTest.cpp
parent17f0b6df7248b9bbdaddacc3a6c9c6efe4ae278e (diff)
Add auto purging for SkPicture-related Ganesh resources (esp. layers)
This is intended to lower the bookkeeping burden for the Layer Caching feature. Cached layers are now automatically purged when a picture is deleted. R=bsalomon@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/408923002
Diffstat (limited to 'tests/GpuLayerCacheTest.cpp')
-rw-r--r--tests/GpuLayerCacheTest.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp
index 8da2b9ea8d..eb7d92c8e2 100644
--- a/tests/GpuLayerCacheTest.cpp
+++ b/tests/GpuLayerCacheTest.cpp
@@ -15,11 +15,14 @@
static const int kNumLayers = 5;
-class GetNumLayers {
+class TestingAccess {
public:
static int NumLayers(GrLayerCache* cache) {
return cache->numLayers();
}
+ static void Purge(GrLayerCache* cache, uint32_t pictureID) {
+ cache->purge(pictureID);
+ }
};
// Add several layers to the cache
@@ -34,7 +37,7 @@ static void create_layers(skiatest::Reporter* reporter,
GrCachedLayer* layer = cache->findLayer(&picture, i);
REPORTER_ASSERT(reporter, layer == layers[i]);
- REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(cache) == i+1);
+ REPORTER_ASSERT(reporter, TestingAccess::NumLayers(cache) == i + 1);
REPORTER_ASSERT(reporter, picture.uniqueID() == layers[i]->pictureID());
REPORTER_ASSERT(reporter, layers[i]->layerID() == i);
@@ -42,6 +45,7 @@ static void create_layers(skiatest::Reporter* reporter,
REPORTER_ASSERT(reporter, !layers[i]->isAtlased());
}
+ cache->trackPicture(&picture);
}
// This test case exercises the public API of the GrLayerCache class.
@@ -126,22 +130,36 @@ DEF_GPUTEST(GpuLayerCache, reporter, factory) {
#endif
}
+ //--------------------------------------------------------------------
// Free them all SkGpuDevice-style. This will not free up the
// atlas' texture but will eliminate all the layers.
- cache.purge(picture);
+ TestingAccess::Purge(&cache, picture->uniqueID());
- REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
+ REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
// TODO: add VRAM/resource cache check here
-#if 0
+
+ //--------------------------------------------------------------------
+ // Test out the GrContext-style purge. This should remove all the layers
+ // and the atlas.
// Re-create the layers
- create_layers(reporter, &cache, picture);
+ create_layers(reporter, &cache, *picture);
// Free them again GrContext-style. This should free up everything.
cache.freeAll();
- REPORTER_ASSERT(reporter, GetNumLayers::NumLayers(&cache) == 0);
+ REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
+ // TODO: add VRAM/resource cache check here
+
+ //--------------------------------------------------------------------
+ // Test out the MessageBus-style purge. This will not free the atlas
+ // but should eliminate the free-floating layers.
+ create_layers(reporter, &cache, *picture);
+
+ picture.reset(NULL);
+ cache.processDeletedPictures();
+
+ REPORTER_ASSERT(reporter, TestingAccess::NumLayers(&cache) == 0);
// TODO: add VRAM/resource cache check here
-#endif
}
}