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

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: update 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
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 d46fa18a461bf426c8d5d5195800bbe5ca2c6a23..1bedc63ad86fc0dac2c26048f0c0f35274b6f4a5 100644
--- a/cc/tiles/gpu_image_decode_cache_unittest.cc
+++ b/cc/tiles/gpu_image_decode_cache_unittest.cc
@@ -1714,5 +1714,42 @@ TEST(GpuImageDecodeCacheTest, GetTaskForImageDifferentColorSpace) {
cache.UnrefImage(third_draw_image);
}
+TEST(GpuImageDecodeCacheTest, RemoveUnusedImage) {
ericrk 2017/06/19 17:09:30 Not needed right now, but I wonder if we should mo
sohan 2017/06/20 13:31:39 If we remove this test for future, we are essentia
ericrk 2017/06/20 16:06:05 SGTM, thanks
+ auto context_provider = TestContextProvider::Create();
+ context_provider->BindToCurrentThread();
+ TestGpuImageDecodeCache cache(context_provider.get());
+ 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));
+ }
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698