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