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_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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 BasicStateAsValue() const; | 157 BasicStateAsValue() const; |
158 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 158 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
159 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 159 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
160 return memory_stats_from_last_assign_; | 160 return memory_stats_from_last_assign_; |
161 } | 161 } |
162 | 162 |
163 // Public methods for testing. | 163 // Public methods for testing. |
164 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { | 164 void InitializeTilesWithResourcesForTesting(const std::vector<Tile*>& tiles) { |
165 for (size_t i = 0; i < tiles.size(); ++i) { | 165 for (size_t i = 0; i < tiles.size(); ++i) { |
166 TileDrawInfo& draw_info = tiles[i]->draw_info(); | 166 TileDrawInfo& draw_info = tiles[i]->draw_info(); |
167 draw_info.set_resource(resource_pool_->AcquireResource( | 167 draw_info.set_resource( |
168 tiles[i]->desired_texture_size(), | 168 resource_pool_->AcquireResource( |
169 raster_buffer_provider_->GetResourceFormat(false), | 169 tiles[i]->desired_texture_size(), |
170 client_->GetRasterColorSpace())); | 170 raster_buffer_provider_->GetResourceFormat(false), |
| 171 client_->GetRasterColorSpace()), |
| 172 false); |
171 draw_info.set_resource_ready_for_draw(); | 173 draw_info.set_resource_ready_for_draw(); |
172 } | 174 } |
173 } | 175 } |
174 | 176 |
175 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { | 177 void ReleaseTileResourcesForTesting(const std::vector<Tile*>& tiles) { |
176 for (size_t i = 0; i < tiles.size(); ++i) { | 178 for (size_t i = 0; i < tiles.size(); ++i) { |
177 Tile* tile = tiles[i]; | 179 Tile* tile = tiles[i]; |
178 FreeResourcesForTile(tile); | 180 FreeResourcesForTile(tile); |
179 } | 181 } |
180 } | 182 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 230 |
229 // CheckerImageTrackerClient implementation. | 231 // CheckerImageTrackerClient implementation. |
230 void NeedsInvalidationForCheckerImagedTiles() override; | 232 void NeedsInvalidationForCheckerImagedTiles() override; |
231 | 233 |
232 // This method can only be used for debugging information, since it performs a | 234 // This method can only be used for debugging information, since it performs a |
233 // non trivial amount of work. | 235 // non trivial amount of work. |
234 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 236 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
235 ActivationStateAsValue(); | 237 ActivationStateAsValue(); |
236 | 238 |
237 void ActivationStateAsValueInto(base::trace_event::TracedValue* state); | 239 void ActivationStateAsValueInto(base::trace_event::TracedValue* state); |
| 240 int num_of_tiles_with_checker_images() const { |
| 241 return num_of_tiles_with_checker_images_; |
| 242 } |
238 | 243 |
239 protected: | 244 protected: |
240 friend class Tile; | 245 friend class Tile; |
241 // Must be called by tile during destruction. | 246 // Must be called by tile during destruction. |
242 void Release(Tile* tile); | 247 void Release(Tile* tile); |
243 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } | 248 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } |
244 | 249 |
245 private: | 250 private: |
246 class MemoryUsage { | 251 class MemoryUsage { |
247 public: | 252 public: |
(...skipping 28 matching lines...) Expand all Loading... |
276 bool did_notify_all_tile_tasks_completed; | 281 bool did_notify_all_tile_tasks_completed; |
277 }; | 282 }; |
278 | 283 |
279 struct PrioritizedWorkToSchedule { | 284 struct PrioritizedWorkToSchedule { |
280 PrioritizedWorkToSchedule(); | 285 PrioritizedWorkToSchedule(); |
281 PrioritizedWorkToSchedule(PrioritizedWorkToSchedule&& other); | 286 PrioritizedWorkToSchedule(PrioritizedWorkToSchedule&& other); |
282 ~PrioritizedWorkToSchedule(); | 287 ~PrioritizedWorkToSchedule(); |
283 | 288 |
284 std::vector<PrioritizedTile> tiles_to_raster; | 289 std::vector<PrioritizedTile> tiles_to_raster; |
285 std::vector<PrioritizedTile> tiles_to_process_for_images; | 290 std::vector<PrioritizedTile> tiles_to_process_for_images; |
| 291 CheckerImageTracker::ImageDecodeQueue checker_image_decode_queue; |
286 }; | 292 }; |
287 | 293 |
288 void FreeResourcesForTile(Tile* tile); | 294 void FreeResourcesForTile(Tile* tile); |
289 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); | 295 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile); |
290 scoped_refptr<TileTask> CreateRasterTask( | 296 scoped_refptr<TileTask> CreateRasterTask( |
291 const PrioritizedTile& prioritized_tile, | 297 const PrioritizedTile& prioritized_tile, |
292 const gfx::ColorSpace& color_space); | 298 const gfx::ColorSpace& color_space, |
| 299 CheckerImageTracker::ImageDecodeQueue* checker_image_decode_queue); |
293 | 300 |
294 std::unique_ptr<EvictionTilePriorityQueue> | 301 std::unique_ptr<EvictionTilePriorityQueue> |
295 FreeTileResourcesUntilUsageIsWithinLimit( | 302 FreeTileResourcesUntilUsageIsWithinLimit( |
296 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, | 303 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
297 const MemoryUsage& limit, | 304 const MemoryUsage& limit, |
298 MemoryUsage* usage); | 305 MemoryUsage* usage); |
299 std::unique_ptr<EvictionTilePriorityQueue> | 306 std::unique_ptr<EvictionTilePriorityQueue> |
300 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 307 FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
301 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, | 308 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
302 const MemoryUsage& limit, | 309 const MemoryUsage& limit, |
(...skipping 11 matching lines...) Expand all Loading... |
314 | 321 |
315 void DidFinishRunningTileTasksRequiredForActivation(); | 322 void DidFinishRunningTileTasksRequiredForActivation(); |
316 void DidFinishRunningTileTasksRequiredForDraw(); | 323 void DidFinishRunningTileTasksRequiredForDraw(); |
317 void DidFinishRunningAllTileTasks(); | 324 void DidFinishRunningAllTileTasks(); |
318 | 325 |
319 scoped_refptr<TileTask> CreateTaskSetFinishedTask( | 326 scoped_refptr<TileTask> CreateTaskSetFinishedTask( |
320 void (TileManager::*callback)()); | 327 void (TileManager::*callback)()); |
321 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); | 328 PrioritizedWorkToSchedule AssignGpuMemoryToTiles(); |
322 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); | 329 void ScheduleTasks(const PrioritizedWorkToSchedule& work_to_schedule); |
323 | 330 |
| 331 void PartitionImagesForCheckering( |
| 332 const PrioritizedTile& prioritized_tile, |
| 333 const gfx::ColorSpace& raster_color_space, |
| 334 std::vector<DrawImage>* sync_decoded_images, |
| 335 std::vector<sk_sp<const SkImage>>* checkered_images); |
| 336 void AddCheckeredImagesToDecodeQueue( |
| 337 const PrioritizedTile& prioritized_tile, |
| 338 const gfx::ColorSpace& raster_color_space, |
| 339 CheckerImageTracker::ImageDecodeQueue* image_decode_queue); |
| 340 |
324 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 341 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
325 ScheduledTasksStateAsValue() const; | 342 ScheduledTasksStateAsValue() const; |
326 | 343 |
327 bool UsePartialRaster() const; | 344 bool UsePartialRaster() const; |
328 | 345 |
329 void CheckPendingGpuWorkTiles(bool issue_signals); | 346 void CheckPendingGpuWorkTiles(bool issue_signals); |
330 | 347 |
331 TileManagerClient* client_; | 348 TileManagerClient* client_; |
332 base::SequencedTaskRunner* task_runner_; | 349 base::SequencedTaskRunner* task_runner_; |
333 ResourcePool* resource_pool_; | 350 ResourcePool* resource_pool_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 std::unordered_set<Tile*> pending_gpu_work_tiles_; | 385 std::unordered_set<Tile*> pending_gpu_work_tiles_; |
369 uint64_t pending_required_for_activation_callback_id_ = 0; | 386 uint64_t pending_required_for_activation_callback_id_ = 0; |
370 uint64_t pending_required_for_draw_callback_id_ = 0; | 387 uint64_t pending_required_for_draw_callback_id_ = 0; |
371 // If true, we should re-compute tile requirements in | 388 // If true, we should re-compute tile requirements in |
372 // CheckPendingGpuWorkTiles. | 389 // CheckPendingGpuWorkTiles. |
373 bool pending_tile_requirements_dirty_ = false; | 390 bool pending_tile_requirements_dirty_ = false; |
374 | 391 |
375 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 392 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
376 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; | 393 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; |
377 | 394 |
| 395 // Number of tiles with a checker-imaged resource or active raster tasks which |
| 396 // will create a checker-imaged resource. |
| 397 int num_of_tiles_with_checker_images_ = 0; |
| 398 |
378 // We need two WeakPtrFactory objects as the invalidation pattern of each is | 399 // We need two WeakPtrFactory objects as the invalidation pattern of each is |
379 // different. The |task_set_finished_weak_ptr_factory_| is invalidated any | 400 // different. The |task_set_finished_weak_ptr_factory_| is invalidated any |
380 // time new tasks are scheduled, preventing a race when the callback has | 401 // time new tasks are scheduled, preventing a race when the callback has |
381 // been scheduled but not yet executed. | 402 // been scheduled but not yet executed. |
382 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 403 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
383 // The |ready_to_draw_callback_weak_ptr_factory_| is never invalidated. | 404 // The |ready_to_draw_callback_weak_ptr_factory_| is never invalidated. |
384 base::WeakPtrFactory<TileManager> ready_to_draw_callback_weak_ptr_factory_; | 405 base::WeakPtrFactory<TileManager> ready_to_draw_callback_weak_ptr_factory_; |
385 | 406 |
386 DISALLOW_COPY_AND_ASSIGN(TileManager); | 407 DISALLOW_COPY_AND_ASSIGN(TileManager); |
387 }; | 408 }; |
388 | 409 |
389 } // namespace cc | 410 } // namespace cc |
390 | 411 |
391 #endif // CC_TILES_TILE_MANAGER_H_ | 412 #endif // CC_TILES_TILE_MANAGER_H_ |
OLD | NEW |