Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: cc/tiles/tile_manager.h

Issue 2006973004: Revert of cc: Cleanup tile manager a bit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cc/tiles/tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_TILES_TILE_MANAGER_H_ 5 #ifndef CC_TILES_TILE_MANAGER_H_
6 #define CC_TILES_TILE_MANAGER_H_ 6 #define CC_TILES_TILE_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 }; 88 };
89 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 89 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
90 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); 90 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats);
91 91
92 // This class manages tiles, deciding which should get rasterized and which 92 // This class manages tiles, deciding which should get rasterized and which
93 // should no longer have any memory assigned to them. Tile objects are "owned" 93 // should no longer have any memory assigned to them. Tile objects are "owned"
94 // by layers; they automatically register with the manager when they are 94 // by layers; they automatically register with the manager when they are
95 // created, and unregister from the manager when they are deleted. 95 // created, and unregister from the manager when they are deleted.
96 class CC_EXPORT TileManager { 96 class CC_EXPORT TileManager {
97 public: 97 public:
98 TileManager(TileManagerClient* client, 98 static std::unique_ptr<TileManager> Create(
99 scoped_refptr<base::SequencedTaskRunner> task_runner, 99 TileManagerClient* client,
100 size_t scheduled_raster_task_limit, 100 base::SequencedTaskRunner* task_runner,
101 bool use_partial_raster); 101 size_t scheduled_raster_task_limit,
102 bool use_partial_raster);
102 virtual ~TileManager(); 103 virtual ~TileManager();
103 104
104 // Assigns tile memory and schedules work to prepare tiles for drawing. 105 // Assigns tile memory and schedules work to prepare tiles for drawing.
105 // - Runs client_->NotifyReadyToActivate() when all tiles required for 106 // - Runs client_->NotifyReadyToActivate() when all tiles required for
106 // activation are prepared, or failed to prepare due to OOM. 107 // activation are prepared, or failed to prepare due to OOM.
107 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are 108 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are
108 // prepared, or failed to prepare due to OOM. 109 // prepared, or failed to prepare due to OOM.
109 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state); 110 bool PrepareTiles(const GlobalStateThatImpactsTilePriority& state);
110 111
111 // Synchronously finish any in progress work, cancel the rest, and clean up as 112 // Synchronously finish any in progress work, cancel the rest, and clean up as
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 167
167 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager); 168 void SetTileTaskManagerForTesting(TileTaskManager* tile_task_manager);
168 169
169 void FreeResourcesAndCleanUpReleasedTilesForTesting() { 170 void FreeResourcesAndCleanUpReleasedTilesForTesting() {
170 FreeResourcesForReleasedTiles(); 171 FreeResourcesForReleasedTiles();
171 CleanUpReleasedTiles(); 172 CleanUpReleasedTiles();
172 } 173 }
173 174
174 std::vector<Tile*> AllTilesForTesting() const { 175 std::vector<Tile*> AllTilesForTesting() const {
175 std::vector<Tile*> tiles; 176 std::vector<Tile*> tiles;
176 for (auto& tile_pair : tiles_) 177 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end();
177 tiles.push_back(tile_pair.second); 178 ++it) {
179 tiles.push_back(it->second);
180 }
178 return tiles; 181 return tiles;
179 } 182 }
180 183
181 void SetScheduledRasterTaskLimitForTesting(size_t limit) { 184 void SetScheduledRasterTaskLimitForTesting(size_t limit) {
182 scheduled_raster_task_limit_ = limit; 185 scheduled_raster_task_limit_ = limit;
183 } 186 }
184 187
185 void CheckIfMoreTilesNeedToBePreparedForTesting() { 188 void CheckIfMoreTilesNeedToBePreparedForTesting() {
186 CheckIfMoreTilesNeedToBePrepared(); 189 CheckIfMoreTilesNeedToBePrepared();
187 } 190 }
188 191
189 void SetMoreTilesNeedToBeRasterizedForTesting() { 192 void SetMoreTilesNeedToBeRasterizedForTesting() {
190 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; 193 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false;
191 } 194 }
192 195
193 bool HasScheduledTileTasksForTesting() const { 196 bool HasScheduledTileTasksForTesting() const {
194 return has_scheduled_tile_tasks_; 197 return has_scheduled_tile_tasks_;
195 } 198 }
196 199
197 protected: 200 protected:
201 TileManager(TileManagerClient* client,
202 scoped_refptr<base::SequencedTaskRunner> task_runner,
203 size_t scheduled_raster_task_limit,
204 bool use_partial_raster);
205
198 void FreeResourcesForReleasedTiles(); 206 void FreeResourcesForReleasedTiles();
199 void CleanUpReleasedTiles(); 207 void CleanUpReleasedTiles();
200 208
201 friend class Tile; 209 friend class Tile;
202 // Virtual for testing. 210 // Virtual for testing.
203 virtual void Release(Tile* tile); 211 virtual void Release(Tile* tile);
204 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } 212 Tile::Id GetUniqueTileId() { return ++next_tile_id_; }
205 213
214 typedef std::vector<PrioritizedTile> PrioritizedTileVector;
215 typedef std::set<Tile*> TileSet;
216
206 // Virtual for test 217 // Virtual for test
207 virtual void ScheduleTasks( 218 virtual void ScheduleTasks(
208 const std::vector<PrioritizedTile>& tiles_that_need_to_be_rasterized); 219 const PrioritizedTileVector& tiles_that_need_to_be_rasterized);
220
221 void AssignGpuMemoryToTiles(
222 RasterTilePriorityQueue* raster_priority_queue,
223 size_t scheduled_raser_task_limit,
224 PrioritizedTileVector* tiles_that_need_to_be_rasterized);
209 225
210 private: 226 private:
211 class MemoryUsage { 227 class MemoryUsage {
212 public: 228 public:
213 MemoryUsage(); 229 MemoryUsage();
214 MemoryUsage(size_t memory_bytes, size_t resource_count); 230 MemoryUsage(size_t memory_bytes, size_t resource_count);
215 231
216 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); 232 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format);
217 static MemoryUsage FromTile(const Tile* tile); 233 static MemoryUsage FromTile(const Tile* tile);
218 234
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 274
259 ResourceFormat DetermineResourceFormat(const Tile* tile) const; 275 ResourceFormat DetermineResourceFormat(const Tile* tile) const;
260 bool DetermineResourceRequiresSwizzle(const Tile* tile) const; 276 bool DetermineResourceRequiresSwizzle(const Tile* tile) const;
261 277
262 void DidFinishRunningTileTasksRequiredForActivation(); 278 void DidFinishRunningTileTasksRequiredForActivation();
263 void DidFinishRunningTileTasksRequiredForDraw(); 279 void DidFinishRunningTileTasksRequiredForDraw();
264 void DidFinishRunningAllTileTasks(); 280 void DidFinishRunningAllTileTasks();
265 281
266 scoped_refptr<TileTask> CreateTaskSetFinishedTask( 282 scoped_refptr<TileTask> CreateTaskSetFinishedTask(
267 void (TileManager::*callback)()); 283 void (TileManager::*callback)());
268 std::vector<PrioritizedTile> AssignGpuMemoryToTiles();
269 284
270 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 285 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
271 ScheduledTasksStateAsValue() const; 286 ScheduledTasksStateAsValue() const;
272 287
273 TileManagerClient* client_; 288 TileManagerClient* client_;
274 scoped_refptr<base::SequencedTaskRunner> task_runner_; 289 scoped_refptr<base::SequencedTaskRunner> task_runner_;
275 ResourcePool* resource_pool_; 290 ResourcePool* resource_pool_;
276 TileTaskManager* tile_task_manager_; 291 TileTaskManager* tile_task_manager_;
277 GlobalStateThatImpactsTilePriority global_state_; 292 GlobalStateThatImpactsTilePriority global_state_;
278 size_t scheduled_raster_task_limit_; 293 size_t scheduled_raster_task_limit_;
279 const bool use_partial_raster_; 294 const bool use_partial_raster_;
280 bool use_gpu_rasterization_; 295 bool use_gpu_rasterization_;
281 296
282 std::unordered_map<Tile::Id, Tile*> tiles_; 297 using TileMap = std::unordered_map<Tile::Id, Tile*>;
298 TileMap tiles_;
283 299
284 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; 300 bool all_tiles_that_need_to_be_rasterized_are_scheduled_;
285 MemoryHistory::Entry memory_stats_from_last_assign_; 301 MemoryHistory::Entry memory_stats_from_last_assign_;
286 302
287 bool did_check_for_completed_tasks_since_last_schedule_tasks_; 303 bool did_check_for_completed_tasks_since_last_schedule_tasks_;
288 bool did_oom_on_last_assign_; 304 bool did_oom_on_last_assign_;
289 305
290 ImageDecodeController* image_decode_controller_; 306 ImageDecodeController* image_decode_controller_;
291 307
292 RasterTaskCompletionStats flush_stats_; 308 RasterTaskCompletionStats flush_stats_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; 341 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_;
326 342
327 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; 343 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_;
328 344
329 DISALLOW_COPY_AND_ASSIGN(TileManager); 345 DISALLOW_COPY_AND_ASSIGN(TileManager);
330 }; 346 };
331 347
332 } // namespace cc 348 } // namespace cc
333 349
334 #endif // CC_TILES_TILE_MANAGER_H_ 350 #endif // CC_TILES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698