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> | |
9 | 8 |
10 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
11 #include "cc/resources/rasterizer.h" | 10 #include "cc/resources/rasterizer.h" |
12 | 11 |
13 namespace cc { | 12 namespace cc { |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 class FakeRasterizerImpl : public Rasterizer, public RasterizerTaskClient { | 16 class FakeRasterizerImpl : public Rasterizer, public RasterizerTaskClient { |
18 public: | 17 public: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 base::LazyInstance<FakeRasterizerImpl> g_fake_rasterizer = | 59 base::LazyInstance<FakeRasterizerImpl> g_fake_rasterizer = |
61 LAZY_INSTANCE_INITIALIZER; | 60 LAZY_INSTANCE_INITIALIZER; |
62 | 61 |
63 } // namespace | 62 } // namespace |
64 | 63 |
65 FakeTileManager::FakeTileManager(TileManagerClient* client) | 64 FakeTileManager::FakeTileManager(TileManagerClient* client) |
66 : TileManager(client, | 65 : TileManager(client, |
67 NULL, | 66 NULL, |
68 g_fake_rasterizer.Pointer(), | 67 g_fake_rasterizer.Pointer(), |
69 g_fake_rasterizer.Pointer(), | 68 g_fake_rasterizer.Pointer(), |
70 std::numeric_limits<unsigned>::max(), | |
71 true, | 69 true, |
72 NULL) {} | 70 NULL) {} |
73 | 71 |
74 FakeTileManager::FakeTileManager(TileManagerClient* client, | 72 FakeTileManager::FakeTileManager(TileManagerClient* client, |
75 ResourcePool* resource_pool) | 73 ResourcePool* resource_pool) |
76 : TileManager(client, | 74 : TileManager(client, |
77 resource_pool, | 75 resource_pool, |
78 g_fake_rasterizer.Pointer(), | 76 g_fake_rasterizer.Pointer(), |
79 g_fake_rasterizer.Pointer(), | 77 g_fake_rasterizer.Pointer(), |
80 std::numeric_limits<unsigned>::max(), | |
81 true, | 78 true, |
82 NULL) {} | 79 NULL) {} |
83 | 80 |
84 FakeTileManager::FakeTileManager(TileManagerClient* client, | 81 FakeTileManager::FakeTileManager(TileManagerClient* client, |
85 ResourcePool* resource_pool, | 82 ResourcePool* resource_pool, |
86 bool allow_on_demand_raster) | 83 bool allow_on_demand_raster) |
87 : TileManager(client, | 84 : TileManager(client, |
88 resource_pool, | 85 resource_pool, |
89 g_fake_rasterizer.Pointer(), | 86 g_fake_rasterizer.Pointer(), |
90 g_fake_rasterizer.Pointer(), | 87 g_fake_rasterizer.Pointer(), |
91 std::numeric_limits<unsigned>::max(), | |
92 allow_on_demand_raster, | 88 allow_on_demand_raster, |
93 NULL) {} | 89 NULL) {} |
94 | 90 |
95 FakeTileManager::FakeTileManager(TileManagerClient* client, | |
96 ResourcePool* resource_pool, | |
97 size_t raster_task_limit_bytes) | |
98 : TileManager(client, | |
99 resource_pool, | |
100 g_fake_rasterizer.Pointer(), | |
101 g_fake_rasterizer.Pointer(), | |
102 raster_task_limit_bytes, | |
103 true, | |
104 NULL) {} | |
105 | |
106 FakeTileManager::~FakeTileManager() {} | 91 FakeTileManager::~FakeTileManager() {} |
107 | 92 |
108 void FakeTileManager::AssignMemoryToTiles( | 93 void FakeTileManager::AssignMemoryToTiles( |
109 const GlobalStateThatImpactsTilePriority& state) { | 94 const GlobalStateThatImpactsTilePriority& state) { |
110 tiles_for_raster.clear(); | 95 tiles_for_raster.clear(); |
111 all_tiles.Clear(); | 96 all_tiles.Clear(); |
112 | 97 |
113 SetGlobalStateForTesting(state); | 98 SetGlobalStateForTesting(state); |
114 GetTilesWithAssignedBins(&all_tiles); | 99 GetTilesWithAssignedBins(&all_tiles); |
115 AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster); | 100 AssignGpuMemoryToTiles(&all_tiles, &tiles_for_raster); |
116 } | 101 } |
117 | 102 |
118 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) { | 103 bool FakeTileManager::HasBeenAssignedMemory(Tile* tile) { |
119 return std::find(tiles_for_raster.begin(), | 104 return std::find(tiles_for_raster.begin(), |
120 tiles_for_raster.end(), | 105 tiles_for_raster.end(), |
121 tile) != tiles_for_raster.end(); | 106 tile) != tiles_for_raster.end(); |
122 } | 107 } |
123 | 108 |
124 void FakeTileManager::DidFinishRunningTasksForTesting() { | 109 void FakeTileManager::DidFinishRunningTasksForTesting() { |
125 DidFinishRunningTasks(); | 110 DidFinishRunningTasks(); |
126 } | 111 } |
127 | 112 |
128 void FakeTileManager::Release(Tile* tile) { | 113 void FakeTileManager::Release(Tile* tile) { |
129 TileManager::Release(tile); | 114 TileManager::Release(tile); |
130 CleanUpReleasedTiles(); | 115 CleanUpReleasedTiles(); |
131 } | 116 } |
132 | 117 |
133 } // namespace cc | 118 } // namespace cc |
OLD | NEW |