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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/tiles/gpu_image_decode_cache.h" 5 #include "cc/tiles/gpu_image_decode_cache.h"
6 6
7 #include "cc/paint/draw_image.h" 7 #include "cc/paint/draw_image.h"
8 #include "cc/test/test_context_provider.h" 8 #include "cc/test/test_context_provider.h"
9 #include "cc/test/test_tile_task_runner.h" 9 #include "cc/test/test_tile_task_runner.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 TestTileTaskRunner::ProcessTask(first_task->dependencies()[0].get()); 1767 TestTileTaskRunner::ProcessTask(first_task->dependencies()[0].get());
1768 TestTileTaskRunner::ProcessTask(first_task.get()); 1768 TestTileTaskRunner::ProcessTask(first_task.get());
1769 TestTileTaskRunner::ProcessTask(second_task->dependencies()[0].get()); 1769 TestTileTaskRunner::ProcessTask(second_task->dependencies()[0].get());
1770 TestTileTaskRunner::ProcessTask(second_task.get()); 1770 TestTileTaskRunner::ProcessTask(second_task.get());
1771 1771
1772 cache.UnrefImage(first_draw_image); 1772 cache.UnrefImage(first_draw_image);
1773 cache.UnrefImage(second_draw_image); 1773 cache.UnrefImage(second_draw_image);
1774 cache.UnrefImage(third_draw_image); 1774 cache.UnrefImage(third_draw_image);
1775 } 1775 }
1776 1776
1777 TEST_P(GpuImageDecodeCacheTest, RemoveUnusedImage) {
1778 auto context_provider = TestContextProvider::Create();
1779 context_provider->BindToCurrentThread();
1780 TestGpuImageDecodeCache cache(context_provider.get(), GetParam());
1781 bool is_decomposable = true;
1782 SkFilterQuality quality = kHigh_SkFilterQuality;
1783 std::vector<uint32_t> unique_ids(10);
1784
1785 for (int i = 0; i < 10; ++i) {
1786 sk_sp<SkImage> image = CreateImage(100, 100);
1787 unique_ids[i] = image->uniqueID();
1788 DrawImage draw_image(
1789 CreatePaintImage(image),
1790 SkIRect::MakeWH(image->width(), image->height()), quality,
1791 CreateMatrix(SkSize::Make(1.0f, 1.0f), is_decomposable),
1792 DefaultColorSpace());
1793 scoped_refptr<TileTask> task;
1794 bool need_unref = cache.GetTaskForImageAndRef(
1795 draw_image, ImageDecodeCache::TracingInfo(), &task);
1796 EXPECT_TRUE(need_unref);
1797 EXPECT_TRUE(task);
1798 TestTileTaskRunner::ProcessTask(task->dependencies()[0].get());
1799 TestTileTaskRunner::ProcessTask(task.get());
1800 cache.UnrefImage(draw_image);
1801 }
1802
1803 // We should now have data image in our cache.
1804 EXPECT_GT(cache.GetBytesUsedForTesting(), 0u);
1805 EXPECT_EQ(cache.GetNumCacheEntriesForTesting(), 10u);
1806
1807 // Remove unused ids.
1808 for (uint32_t i = 0; i < 10; ++i) {
1809 cache.NotifyImageUnused(unique_ids[i]);
1810 EXPECT_EQ(cache.GetNumCacheEntriesForTesting(), (10 - i - 1));
1811 }
1812 }
1813
1777 INSTANTIATE_TEST_CASE_P(GpuImageDecodeCacheTests, 1814 INSTANTIATE_TEST_CASE_P(GpuImageDecodeCacheTests,
1778 GpuImageDecodeCacheTest, 1815 GpuImageDecodeCacheTest,
1779 ::testing::Values(ResourceFormat::RGBA_8888, 1816 ::testing::Values(ResourceFormat::RGBA_8888,
1780 ResourceFormat::RGBA_4444)); 1817 ResourceFormat::RGBA_4444));
1781 1818
1782 } // namespace 1819 } // namespace
1783 } // namespace cc 1820 } // namespace cc
OLDNEW
« 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