| OLD | NEW |
| 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/playback/draw_image.h" | 7 #include "cc/playback/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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 DCHECK_GT(cache.GetBytesUsedForTesting(), 0u); | 1329 DCHECK_GT(cache.GetBytesUsedForTesting(), 0u); |
| 1330 DCHECK_EQ(cache.GetNumCacheEntriesForTesting(), 1u); | 1330 DCHECK_EQ(cache.GetNumCacheEntriesForTesting(), 1u); |
| 1331 | 1331 |
| 1332 // Set us to the not visible state (prerequisite for SUSPENDED). | 1332 // Set us to the not visible state (prerequisite for SUSPENDED). |
| 1333 cache.SetShouldAggressivelyFreeResources(true); | 1333 cache.SetShouldAggressivelyFreeResources(true); |
| 1334 | 1334 |
| 1335 // Image should be cached, but not using memory budget. | 1335 // Image should be cached, but not using memory budget. |
| 1336 DCHECK_EQ(cache.GetBytesUsedForTesting(), 0u); | 1336 DCHECK_EQ(cache.GetBytesUsedForTesting(), 0u); |
| 1337 DCHECK_EQ(cache.GetNumCacheEntriesForTesting(), 1u); | 1337 DCHECK_EQ(cache.GetNumCacheEntriesForTesting(), 1u); |
| 1338 | 1338 |
| 1339 // Set us to the SUSPENDED state. | 1339 // Set us to the SUSPENDED state with purging. |
| 1340 cache.OnPurgeMemory(); |
| 1340 cache.OnMemoryStateChange(base::MemoryState::SUSPENDED); | 1341 cache.OnMemoryStateChange(base::MemoryState::SUSPENDED); |
| 1341 | 1342 |
| 1342 // Nothing should be cached. | 1343 // Nothing should be cached. |
| 1343 DCHECK_EQ(cache.GetBytesUsedForTesting(), 0u); | 1344 DCHECK_EQ(cache.GetBytesUsedForTesting(), 0u); |
| 1344 DCHECK_EQ(cache.GetNumCacheEntriesForTesting(), 0u); | 1345 DCHECK_EQ(cache.GetNumCacheEntriesForTesting(), 0u); |
| 1345 | 1346 |
| 1346 // Attempts to get a task for the image should fail, as we have no space (at | 1347 // Attempts to get a task for the image should fail, as we have no space (at |
| 1347 // raster only). | 1348 // raster only). |
| 1348 need_unref = cache.GetTaskForImageAndRef( | 1349 need_unref = cache.GetTaskForImageAndRef( |
| 1349 draw_image, ImageDecodeCache::TracingInfo(), &task); | 1350 draw_image, ImageDecodeCache::TracingInfo(), &task); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 // Run the decode task. | 1387 // Run the decode task. |
| 1387 TestTileTaskRunner::ProcessTask(task.get()); | 1388 TestTileTaskRunner::ProcessTask(task.get()); |
| 1388 | 1389 |
| 1389 // The image should remain in the cache till we unref it. | 1390 // The image should remain in the cache till we unref it. |
| 1390 EXPECT_TRUE(cache.IsInInUseCacheForTesting(draw_image)); | 1391 EXPECT_TRUE(cache.IsInInUseCacheForTesting(draw_image)); |
| 1391 cache.UnrefImage(draw_image); | 1392 cache.UnrefImage(draw_image); |
| 1392 } | 1393 } |
| 1393 | 1394 |
| 1394 } // namespace | 1395 } // namespace |
| 1395 } // namespace cc | 1396 } // namespace cc |
| OLD | NEW |