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 #ifndef CC_RESOURCES_TILE_MANAGER_H_ | 5 #ifndef CC_RESOURCES_TILE_MANAGER_H_ |
6 #define CC_RESOURCES_TILE_MANAGER_H_ | 6 #define CC_RESOURCES_TILE_MANAGER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 scoped_ptr<base::Value> AllTilesAsValue() const; | 80 scoped_ptr<base::Value> AllTilesAsValue() const; |
81 void GetMemoryStats(size_t* memory_required_bytes, | 81 void GetMemoryStats(size_t* memory_required_bytes, |
82 size_t* memory_nice_to_have_bytes, | 82 size_t* memory_nice_to_have_bytes, |
83 size_t* memory_used_bytes) const; | 83 size_t* memory_used_bytes) const; |
84 | 84 |
85 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 85 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
86 return memory_stats_from_last_assign_; | 86 return memory_stats_from_last_assign_; |
87 } | 87 } |
88 | 88 |
89 bool AreTilesRequiredForActivationReady() const { | 89 bool AreTilesRequiredForActivationReady() const { |
90 return tiles_that_need_to_be_initialized_for_activation_.empty(); | 90 return tiles_that_need_to_be_initialized_for_activation_.empty() && |
| 91 oom_tiles_that_need_to_be_initialized_for_activation_.empty(); |
91 } | 92 } |
92 | 93 |
93 protected: | 94 protected: |
94 TileManager(TileManagerClient* client, | 95 TileManager(TileManagerClient* client, |
95 ResourceProvider* resource_provider, | 96 ResourceProvider* resource_provider, |
96 scoped_ptr<RasterWorkerPool> raster_worker_pool, | 97 scoped_ptr<RasterWorkerPool> raster_worker_pool, |
97 size_t num_raster_threads, | 98 size_t num_raster_threads, |
98 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 99 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
99 GLenum texture_format); | 100 GLenum texture_format); |
100 | 101 |
101 // Methods called by Tile | 102 // Methods called by Tile |
102 friend class Tile; | 103 friend class Tile; |
103 void RegisterTile(Tile* tile); | 104 void RegisterTile(Tile* tile); |
104 void UnregisterTile(Tile* tile); | 105 void UnregisterTile(Tile* tile); |
105 | 106 |
106 // Overriden from RasterWorkerPoolClient: | 107 // Overriden from RasterWorkerPoolClient: |
107 virtual bool ShouldForceTasksRequiredForActivationToComplete() const | 108 virtual bool ShouldForceTasksRequiredForActivationToComplete() const |
108 OVERRIDE; | 109 OVERRIDE; |
| 110 virtual void DidFinishedRunningTasks() OVERRIDE; |
| 111 virtual void DidFinishedRunningTasksRequiredForActivation() OVERRIDE; |
109 | 112 |
110 // Virtual for test | 113 // Virtual for test |
111 virtual void ScheduleTasks(); | 114 virtual void ScheduleTasks(); |
112 | 115 |
| 116 const std::vector<Tile*>& tiles_that_need_to_be_rasterized() const { |
| 117 return tiles_that_need_to_be_rasterized_; |
| 118 } |
| 119 |
| 120 void ReassignGpuMemoryToOOMTilesRequiredForActivation(); |
| 121 |
113 private: | 122 private: |
114 void OnImageDecodeTaskCompleted( | 123 void OnImageDecodeTaskCompleted( |
115 int layer_id, | 124 int layer_id, |
116 skia::LazyPixelRef* pixel_ref, | 125 skia::LazyPixelRef* pixel_ref, |
117 bool was_canceled); | 126 bool was_canceled); |
118 void OnRasterTaskCompleted( | 127 void OnRasterTaskCompleted( |
119 scoped_refptr<Tile> tile, | 128 scoped_refptr<Tile> tile, |
120 scoped_ptr<ResourcePool::Resource> resource, | 129 scoped_ptr<ResourcePool::Resource> resource, |
121 RasterMode raster_mode, | 130 RasterMode raster_mode, |
122 const PicturePileImpl::Analysis& analysis, | 131 const PicturePileImpl::Analysis& analysis, |
(...skipping 21 matching lines...) Expand all Loading... |
144 TileManagerClient* client_; | 153 TileManagerClient* client_; |
145 scoped_ptr<ResourcePool> resource_pool_; | 154 scoped_ptr<ResourcePool> resource_pool_; |
146 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 155 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
147 GlobalStateThatImpactsTilePriority global_state_; | 156 GlobalStateThatImpactsTilePriority global_state_; |
148 | 157 |
149 typedef std::vector<Tile*> TileVector; | 158 typedef std::vector<Tile*> TileVector; |
150 TileVector tiles_; | 159 TileVector tiles_; |
151 TileVector tiles_that_need_to_be_rasterized_; | 160 TileVector tiles_that_need_to_be_rasterized_; |
152 typedef std::set<Tile*> TileSet; | 161 typedef std::set<Tile*> TileSet; |
153 TileSet tiles_that_need_to_be_initialized_for_activation_; | 162 TileSet tiles_that_need_to_be_initialized_for_activation_; |
| 163 TileSet oom_tiles_that_need_to_be_initialized_for_activation_; |
154 | 164 |
155 bool ever_exceeded_memory_budget_; | 165 bool ever_exceeded_memory_budget_; |
156 MemoryHistory::Entry memory_stats_from_last_assign_; | 166 MemoryHistory::Entry memory_stats_from_last_assign_; |
157 | 167 |
158 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 168 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
159 | 169 |
160 bool did_initialize_visible_tile_; | 170 bool did_initialize_visible_tile_; |
161 | 171 |
162 GLenum texture_format_; | 172 GLenum texture_format_; |
163 | 173 |
164 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; | 174 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefTaskMap; |
165 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; | 175 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; |
166 LayerPixelRefTaskMap image_decode_tasks_; | 176 LayerPixelRefTaskMap image_decode_tasks_; |
167 | 177 |
168 DISALLOW_COPY_AND_ASSIGN(TileManager); | 178 DISALLOW_COPY_AND_ASSIGN(TileManager); |
169 }; | 179 }; |
170 | 180 |
171 } // namespace cc | 181 } // namespace cc |
172 | 182 |
173 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 183 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |