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

Unified Diff: cc/tiles/gpu_image_decode_cache_unittest.cc

Issue 2945813002: cc: Interface to evict images from cc image decode cache. (Closed)
Patch Set: rebase Created 3 years, 6 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 | « cc/tiles/gpu_image_decode_cache.cc ('k') | cc/tiles/image_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/gpu_image_decode_cache_unittest.cc
diff --git a/cc/tiles/gpu_image_decode_cache_unittest.cc b/cc/tiles/gpu_image_decode_cache_unittest.cc
index a5ae673022df1c86349a802e5198fc9c8086124c..0257717af0099b83c04e4a8a1dee81b28ddc11b3 100644
--- a/cc/tiles/gpu_image_decode_cache_unittest.cc
+++ b/cc/tiles/gpu_image_decode_cache_unittest.cc
@@ -1774,6 +1774,43 @@ TEST_P(GpuImageDecodeCacheTest, GetTaskForImageDifferentColorSpace) {
cache.UnrefImage(third_draw_image);
}
+TEST_P(GpuImageDecodeCacheTest, RemoveUnusedImage) {
+ auto context_provider = TestContextProvider::Create();
+ context_provider->BindToCurrentThread();
+ TestGpuImageDecodeCache cache(context_provider.get(), GetParam());
+ bool is_decomposable = true;
+ SkFilterQuality quality = kHigh_SkFilterQuality;
+ std::vector<uint32_t> unique_ids(10);
+
+ for (int i = 0; i < 10; ++i) {
+ sk_sp<SkImage> image = CreateImage(100, 100);
+ unique_ids[i] = image->uniqueID();
+ DrawImage draw_image(
+ CreatePaintImage(image),
+ SkIRect::MakeWH(image->width(), image->height()), quality,
+ CreateMatrix(SkSize::Make(1.0f, 1.0f), is_decomposable),
+ DefaultColorSpace());
+ scoped_refptr<TileTask> task;
+ bool need_unref = cache.GetTaskForImageAndRef(
+ draw_image, ImageDecodeCache::TracingInfo(), &task);
+ EXPECT_TRUE(need_unref);
+ EXPECT_TRUE(task);
+ TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
+ TestTileTaskRunner::ProcessTask(task.get());
+ cache.UnrefImage(draw_image);
+ }
+
+ // We should now have data image in our cache.
+ EXPECT_GT(cache.GetBytesUsedForTesting(), 0u);
+ EXPECT_EQ(cache.GetNumCacheEntriesForTesting(), 10u);
+
+ // Remove unused ids.
+ for (uint32_t i = 0; i < 10; ++i) {
+ cache.NotifyImageUnused(unique_ids[i]);
+ EXPECT_EQ(cache.GetNumCacheEntriesForTesting(), (10 - i - 1));
+ }
+}
+
INSTANTIATE_TEST_CASE_P(GpuImageDecodeCacheTests,
GpuImageDecodeCacheTest,
::testing::Values(ResourceFormat::RGBA_8888,
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.cc ('k') | cc/tiles/image_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698