Chromium Code Reviews| 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/resources/tile_manager.h" | 5 #include "cc/resources/tile_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 | 318 |
| 319 bool memory_usage_above_limit = resource_pool_->total_memory_usage_bytes() > | 319 bool memory_usage_above_limit = resource_pool_->total_memory_usage_bytes() > |
| 320 global_state_.soft_memory_limit_in_bytes; | 320 global_state_.soft_memory_limit_in_bytes; |
| 321 | 321 |
| 322 // When OOM, keep re-assigning memory until we reach a steady state | 322 // When OOM, keep re-assigning memory until we reach a steady state |
| 323 // where top-priority tiles are initialized. | 323 // where top-priority tiles are initialized. |
| 324 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && | 324 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && |
| 325 !memory_usage_above_limit) | 325 !memory_usage_above_limit) |
| 326 return; | 326 return; |
| 327 | 327 |
| 328 rasterizer_->CheckForCompletedTasks(); | 328 rasterizer_->CheckForCompletedTasks(); |
|
vmpstr
2014/10/28 01:35:34
This would normally check completed tasks, but not
danakj
2014/10/31 20:02:01
Right, I ended up not moving this anymore. Now ins
| |
| 329 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 329 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 330 | 330 |
| 331 TileVector tiles_that_need_to_be_rasterized; | 331 TileVector tiles_that_need_to_be_rasterized; |
| 332 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); | 332 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); |
| 333 | 333 |
| 334 // |tiles_that_need_to_be_rasterized| will be empty when we reach a | 334 // |tiles_that_need_to_be_rasterized| will be empty when we reach a |
| 335 // steady memory state. Keep scheduling tasks until we reach this state. | 335 // steady memory state. Keep scheduling tasks until we reach this state. |
| 336 if (!tiles_that_need_to_be_rasterized.empty()) { | 336 if (!tiles_that_need_to_be_rasterized.empty()) { |
| 337 ScheduleTasks(tiles_that_need_to_be_rasterized); | 337 ScheduleTasks(tiles_that_need_to_be_rasterized); |
| 338 return; | 338 return; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 365 ManagedTileState& mts = tile->managed_state(); | 365 ManagedTileState& mts = tile->managed_state(); |
| 366 | 366 |
| 367 if (tile->required_for_activation() && !mts.draw_info.IsReadyToDraw()) { | 367 if (tile->required_for_activation() && !mts.draw_info.IsReadyToDraw()) { |
| 368 // If we can't raster on demand, give up early (and don't activate). | 368 // If we can't raster on demand, give up early (and don't activate). |
| 369 if (!allow_rasterize_on_demand) { | 369 if (!allow_rasterize_on_demand) { |
| 370 ready_to_activate = false; | 370 ready_to_activate = false; |
| 371 break; | 371 break; |
| 372 } | 372 } |
| 373 | 373 |
| 374 mts.draw_info.set_rasterize_on_demand(); | 374 mts.draw_info.set_rasterize_on_demand(); |
| 375 client_->NotifyTileStateChanged(tile); | 375 bool visible_tile = |
| 376 tile->priority(ACTIVE_TREE).distance_to_visible == 0.f; | |
| 377 client_->NotifyTileStateChanged(tile, visible_tile); | |
| 376 } | 378 } |
| 377 raster_priority_queue_.Pop(); | 379 raster_priority_queue_.Pop(); |
| 378 } | 380 } |
| 379 | 381 |
| 380 if (ready_to_activate) { | 382 if (ready_to_activate) { |
| 381 DCHECK(IsReadyToActivate()); | 383 DCHECK(IsReadyToActivate()); |
| 382 ready_to_activate_check_notifier_.Schedule(); | 384 ready_to_activate_check_notifier_.Schedule(); |
| 383 } | 385 } |
| 384 raster_priority_queue_.Reset(); | 386 raster_priority_queue_.Reset(); |
| 385 return; | 387 return; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 BasicStateAsValue()); | 424 BasicStateAsValue()); |
| 423 | 425 |
| 424 TRACE_COUNTER_ID1("cc", | 426 TRACE_COUNTER_ID1("cc", |
| 425 "unused_memory_bytes", | 427 "unused_memory_bytes", |
| 426 this, | 428 this, |
| 427 resource_pool_->total_memory_usage_bytes() - | 429 resource_pool_->total_memory_usage_bytes() - |
| 428 resource_pool_->acquired_memory_usage_bytes()); | 430 resource_pool_->acquired_memory_usage_bytes()); |
| 429 } | 431 } |
| 430 | 432 |
| 431 bool TileManager::UpdateVisibleTiles() { | 433 bool TileManager::UpdateVisibleTiles() { |
| 434 return false; | |
| 432 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); | 435 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); |
| 433 | 436 |
| 434 rasterizer_->CheckForCompletedTasks(); | 437 rasterizer_->CheckForCompletedTasks(); |
|
vmpstr
2014/10/28 01:35:34
We still need something to check for completed tas
enne (OOO)
2014/10/28 18:09:21
Yeah. If we're using async uploads, we need to ch
danakj
2014/10/31 20:02:01
Right, no longer changing this method.
| |
| 435 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 438 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 436 | 439 |
| 437 TRACE_EVENT_INSTANT1( | 440 TRACE_EVENT_INSTANT1( |
| 438 "cc", | 441 "cc", |
| 439 "DidUpdateVisibleTiles", | 442 "DidUpdateVisibleTiles", |
| 440 TRACE_EVENT_SCOPE_THREAD, | 443 TRACE_EVENT_SCOPE_THREAD, |
| 441 "stats", | 444 "stats", |
| 442 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); | 445 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); |
| 443 update_visible_tiles_stats_ = RasterTaskCompletionStats(); | 446 update_visible_tiles_stats_ = RasterTaskCompletionStats(); |
| 444 | 447 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 void TileManager::FreeResourcesForTile(Tile* tile) { | 652 void TileManager::FreeResourcesForTile(Tile* tile) { |
| 650 ManagedTileState& mts = tile->managed_state(); | 653 ManagedTileState& mts = tile->managed_state(); |
| 651 if (mts.draw_info.resource_) | 654 if (mts.draw_info.resource_) |
| 652 resource_pool_->ReleaseResource(mts.draw_info.resource_.Pass()); | 655 resource_pool_->ReleaseResource(mts.draw_info.resource_.Pass()); |
| 653 } | 656 } |
| 654 | 657 |
| 655 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( | 658 void TileManager::FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw( |
| 656 Tile* tile) { | 659 Tile* tile) { |
| 657 bool was_ready_to_draw = tile->IsReadyToDraw(); | 660 bool was_ready_to_draw = tile->IsReadyToDraw(); |
| 658 FreeResourcesForTile(tile); | 661 FreeResourcesForTile(tile); |
| 659 if (was_ready_to_draw) | 662 if (was_ready_to_draw) { |
| 660 client_->NotifyTileStateChanged(tile); | 663 bool visible_tile = tile->priority(ACTIVE_TREE).distance_to_visible == 0.f; |
| 664 client_->NotifyTileStateChanged(tile, visible_tile); | |
| 665 } | |
| 661 } | 666 } |
| 662 | 667 |
| 663 void TileManager::ScheduleTasks( | 668 void TileManager::ScheduleTasks( |
| 664 const TileVector& tiles_that_need_to_be_rasterized) { | 669 const TileVector& tiles_that_need_to_be_rasterized) { |
| 665 TRACE_EVENT1("cc", | 670 TRACE_EVENT1("cc", |
| 666 "TileManager::ScheduleTasks", | 671 "TileManager::ScheduleTasks", |
| 667 "count", | 672 "count", |
| 668 tiles_that_need_to_be_rasterized.size()); | 673 tiles_that_need_to_be_rasterized.size()); |
| 669 | 674 |
| 670 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); | 675 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 ++update_visible_tiles_stats_.completed_count; | 819 ++update_visible_tiles_stats_.completed_count; |
| 815 | 820 |
| 816 if (analysis.is_solid_color) { | 821 if (analysis.is_solid_color) { |
| 817 mts.draw_info.set_solid_color(analysis.solid_color); | 822 mts.draw_info.set_solid_color(analysis.solid_color); |
| 818 resource_pool_->ReleaseResource(resource.Pass()); | 823 resource_pool_->ReleaseResource(resource.Pass()); |
| 819 } else { | 824 } else { |
| 820 mts.draw_info.set_use_resource(); | 825 mts.draw_info.set_use_resource(); |
| 821 mts.draw_info.resource_ = resource.Pass(); | 826 mts.draw_info.resource_ = resource.Pass(); |
| 822 } | 827 } |
| 823 | 828 |
| 824 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) | 829 bool visible_tile = false; |
| 830 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) { | |
| 831 visible_tile = true; | |
| 825 did_initialize_visible_tile_ = true; | 832 did_initialize_visible_tile_ = true; |
| 833 } | |
| 826 | 834 |
| 827 client_->NotifyTileStateChanged(tile); | 835 client_->NotifyTileStateChanged(tile, visible_tile); |
| 828 } | 836 } |
| 829 | 837 |
| 830 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, | 838 scoped_refptr<Tile> TileManager::CreateTile(PicturePileImpl* picture_pile, |
| 831 const gfx::Size& tile_size, | 839 const gfx::Size& tile_size, |
| 832 const gfx::Rect& content_rect, | 840 const gfx::Rect& content_rect, |
| 833 float contents_scale, | 841 float contents_scale, |
| 834 int layer_id, | 842 int layer_id, |
| 835 int source_frame_number, | 843 int source_frame_number, |
| 836 int flags) { | 844 int flags) { |
| 837 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, | 845 scoped_refptr<Tile> tile = make_scoped_refptr(new Tile(this, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 result -= other; | 929 result -= other; |
| 922 return result; | 930 return result; |
| 923 } | 931 } |
| 924 | 932 |
| 925 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 933 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 926 return memory_bytes_ > limit.memory_bytes_ || | 934 return memory_bytes_ > limit.memory_bytes_ || |
| 927 resource_count_ > limit.resource_count_; | 935 resource_count_ > limit.resource_count_; |
| 928 } | 936 } |
| 929 | 937 |
| 930 } // namespace cc | 938 } // namespace cc |
| OLD | NEW |