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

Unified Diff: tests/GpuLayerCacheTest.cpp

Issue 408923002: Add auto purging for SkPicture-related Ganesh resources (esp. layers) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix comment Created 6 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
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tools/PictureBenchmark.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GpuLayerCacheTest.cpp
diff --git a/tests/GpuLayerCacheTest.cpp b/tests/GpuLayerCacheTest.cpp
index 8da2b9ea8d28b1a2182fd6d77e006dbe7a5d1f3d..eb7d92c8e20fbcf3eb01de8cf1103d37e6a30b2a 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
}
}
« no previous file with comments | « src/gpu/SkGpuDevice.cpp ('k') | tools/PictureBenchmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698