| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/test/fake_tile_manager.h" | 5 #include "cc/test/fake_tile_manager.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "cc/resources/raster_worker_pool.h" | 10 #include "cc/resources/raster_worker_pool.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 FakeTileManager::FakeTileManager(TileManagerClient* client) | 52 FakeTileManager::FakeTileManager(TileManagerClient* client) |
| 53 : TileManager(client, | 53 : TileManager(client, |
| 54 NULL, | 54 NULL, |
| 55 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), | 55 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), |
| 56 1, | 56 1, |
| 57 std::numeric_limits<unsigned>::max(), | 57 std::numeric_limits<unsigned>::max(), |
| 58 NULL), | 58 NULL) {} |
| 59 in_bundle_cleanup_(false) {} | |
| 60 | 59 |
| 61 FakeTileManager::FakeTileManager(TileManagerClient* client, | 60 FakeTileManager::FakeTileManager(TileManagerClient* client, |
| 62 ResourceProvider* resource_provider) | 61 ResourceProvider* resource_provider) |
| 63 : TileManager(client, | 62 : TileManager(client, |
| 64 resource_provider, | 63 resource_provider, |
| 65 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), | 64 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), |
| 66 1, | 65 1, |
| 67 std::numeric_limits<unsigned>::max(), | 66 std::numeric_limits<unsigned>::max(), |
| 68 NULL), | 67 NULL) {} |
| 69 in_bundle_cleanup_(false) {} | |
| 70 | 68 |
| 71 FakeTileManager::FakeTileManager(TileManagerClient* client, | 69 FakeTileManager::FakeTileManager(TileManagerClient* client, |
| 72 ResourceProvider* resource_provider, | 70 ResourceProvider* resource_provider, |
| 73 size_t raster_task_limit_bytes) | 71 size_t raster_task_limit_bytes) |
| 74 : TileManager(client, | 72 : TileManager(client, |
| 75 resource_provider, | 73 resource_provider, |
| 76 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), | 74 make_scoped_ptr<RasterWorkerPool>(new FakeRasterWorkerPool), |
| 77 1, | 75 1, |
| 78 raster_task_limit_bytes, | 76 raster_task_limit_bytes, |
| 79 NULL), | 77 NULL) {} |
| 80 in_bundle_cleanup_(false) {} | |
| 81 | 78 |
| 82 FakeTileManager::~FakeTileManager() {} | 79 FakeTileManager::~FakeTileManager() {} |
| 83 | 80 |
| 84 void FakeTileManager::AssignMemoryToTiles( | 81 void FakeTileManager::AssignMemoryToTiles( |
| 85 const GlobalStateThatImpactsTilePriority& state) { | 82 const GlobalStateThatImpactsTilePriority& state) { |
| 86 tiles_for_raster.clear(); | 83 tiles_for_raster.clear(); |
| 87 all_tiles.Clear(); | 84 all_tiles.Clear(); |
| 88 | 85 |
| 89 SetGlobalStateForTesting(state); | 86 SetGlobalStateForTesting(state); |
| 90 GetTilesWithAssignedBins(&all_tiles); | 87 GetTilesWithAssignedBins(&all_tiles); |
| 91 AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster); | 88 AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster); |
| 92 } | 89 } |
| 93 | 90 |
| 94 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) { | 91 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) { |
| 95 return std::find(tiles_for_raster.begin(), | 92 return std::find(tiles_for_raster.begin(), |
| 96 tiles_for_raster.end(), | 93 tiles_for_raster.end(), |
| 97 tile) != tiles_for_raster.end(); | 94 tile) != tiles_for_raster.end(); |
| 98 } | 95 } |
| 99 | 96 |
| 100 void FakeTileManager::CheckForCompletedTasks() { | 97 void FakeTileManager::CheckForCompletedTasks() { |
| 101 RasterWorkerPoolForTesting()->CheckForCompletedTasks(); | 98 RasterWorkerPoolForTesting()->CheckForCompletedTasks(); |
| 102 } | 99 } |
| 103 | 100 |
| 104 void FakeTileManager::Release(Tile* tile) { | 101 void FakeTileManager::Release(Tile* tile) { |
| 105 TileManager::Release(tile); | 102 TileManager::Release(tile); |
| 106 if (!in_bundle_cleanup_) | |
| 107 CleanUpReleasedTiles(); | |
| 108 } | |
| 109 | |
| 110 void FakeTileManager::Release(TileBundle* bundle) { | |
| 111 TileManager::Release(bundle); | |
| 112 in_bundle_cleanup_ = true; | |
| 113 CleanUpReleasedTiles(); | 103 CleanUpReleasedTiles(); |
| 114 in_bundle_cleanup_ = false; | |
| 115 } | 104 } |
| 116 | 105 |
| 117 } // namespace cc | 106 } // namespace cc |
| OLD | NEW |