| 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 rasterizer_(rasterizer), | 232 rasterizer_(rasterizer), |
| 233 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 233 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
| 234 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 234 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
| 235 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 235 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 236 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 236 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
| 237 did_oom_on_last_assign_(false), | 237 did_oom_on_last_assign_(false), |
| 238 ready_to_activate_check_notifier_( | 238 ready_to_activate_check_notifier_( |
| 239 task_runner_.get(), | 239 task_runner_.get(), |
| 240 base::Bind(&TileManager::CheckIfReadyToActivate, | 240 base::Bind(&TileManager::CheckIfReadyToActivate, |
| 241 base::Unretained(this))), | 241 base::Unretained(this))), |
| 242 ready_to_draw_check_notifier_(task_runner_.get(), | 242 ready_to_draw_check_notifier_( |
| 243 base::Bind(&TileManager::CheckIfReadyToDraw, | 243 task_runner_.get(), |
| 244 base::Unretained(this))) { | 244 base::Bind(&TileManager::CheckIfReadyToDraw, base::Unretained(this))), |
| 245 did_notify_ready_to_activate_(false), |
| 246 did_notify_ready_to_draw_(false) { |
| 245 rasterizer_->SetClient(this); | 247 rasterizer_->SetClient(this); |
| 246 } | 248 } |
| 247 | 249 |
| 248 TileManager::~TileManager() { | 250 TileManager::~TileManager() { |
| 249 // Reset global state and manage. This should cause | 251 // Reset global state and manage. This should cause |
| 250 // our memory usage to drop to zero. | 252 // our memory usage to drop to zero. |
| 251 global_state_ = GlobalStateThatImpactsTilePriority(); | 253 global_state_ = GlobalStateThatImpactsTilePriority(); |
| 252 | 254 |
| 253 RasterTaskQueue empty; | 255 RasterTaskQueue empty; |
| 254 rasterizer_->ScheduleTasks(&empty); | 256 rasterizer_->ScheduleTasks(&empty); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 rasterizer_->CheckForCompletedTasks(); | 411 rasterizer_->CheckForCompletedTasks(); |
| 410 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 412 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 411 } | 413 } |
| 412 | 414 |
| 413 FreeResourcesForReleasedTiles(); | 415 FreeResourcesForReleasedTiles(); |
| 414 CleanUpReleasedTiles(); | 416 CleanUpReleasedTiles(); |
| 415 | 417 |
| 416 TileVector tiles_that_need_to_be_rasterized; | 418 TileVector tiles_that_need_to_be_rasterized; |
| 417 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); | 419 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); |
| 418 | 420 |
| 419 // Finally, schedule rasterizer tasks. | 421 // Schedule rasterizer tasks. |
| 420 ScheduleTasks(tiles_that_need_to_be_rasterized); | 422 ScheduleTasks(tiles_that_need_to_be_rasterized); |
| 421 | 423 |
| 424 did_notify_ready_to_activate_ = false; |
| 425 did_notify_ready_to_draw_ = false; |
| 426 |
| 422 TRACE_EVENT_INSTANT1("cc", | 427 TRACE_EVENT_INSTANT1("cc", |
| 423 "DidManage", | 428 "DidManage", |
| 424 TRACE_EVENT_SCOPE_THREAD, | 429 TRACE_EVENT_SCOPE_THREAD, |
| 425 "state", | 430 "state", |
| 426 BasicStateAsValue()); | 431 BasicStateAsValue()); |
| 427 | 432 |
| 428 TRACE_COUNTER_ID1("cc", | 433 TRACE_COUNTER_ID1("cc", |
| 429 "unused_memory_bytes", | 434 "unused_memory_bytes", |
| 430 this, | 435 this, |
| 431 resource_pool_->total_memory_usage_bytes() - | 436 resource_pool_->total_memory_usage_bytes() - |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 | 880 |
| 876 return true; | 881 return true; |
| 877 } | 882 } |
| 878 | 883 |
| 879 void TileManager::CheckIfReadyToActivate() { | 884 void TileManager::CheckIfReadyToActivate() { |
| 880 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 885 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 881 | 886 |
| 882 rasterizer_->CheckForCompletedTasks(); | 887 rasterizer_->CheckForCompletedTasks(); |
| 883 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 888 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 884 | 889 |
| 885 if (IsReadyToActivate()) | 890 if (did_notify_ready_to_activate_) |
| 886 client_->NotifyReadyToActivate(); | 891 return; |
| 892 if (!IsReadyToActivate()) |
| 893 return; |
| 894 |
| 895 client_->NotifyReadyToActivate(); |
| 896 did_notify_ready_to_activate_ = true; |
| 887 } | 897 } |
| 888 | 898 |
| 889 void TileManager::CheckIfReadyToDraw() { | 899 void TileManager::CheckIfReadyToDraw() { |
| 890 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToDraw"); | 900 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToDraw"); |
| 891 | 901 |
| 892 rasterizer_->CheckForCompletedTasks(); | 902 rasterizer_->CheckForCompletedTasks(); |
| 893 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 903 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 894 | 904 |
| 895 if (IsReadyToDraw()) | 905 if (did_notify_ready_to_draw_) |
| 896 client_->NotifyReadyToDraw(); | 906 return; |
| 907 if (!IsReadyToDraw()) |
| 908 return; |
| 909 |
| 910 client_->NotifyReadyToDraw(); |
| 911 did_notify_ready_to_draw_ = true; |
| 897 } | 912 } |
| 898 | 913 |
| 899 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { | 914 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { |
| 900 } | 915 } |
| 901 | 916 |
| 902 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) | 917 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) |
| 903 : memory_bytes_(memory_bytes), resource_count_(resource_count) { | 918 : memory_bytes_(memory_bytes), resource_count_(resource_count) { |
| 904 } | 919 } |
| 905 | 920 |
| 906 // static | 921 // static |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 result -= other; | 955 result -= other; |
| 941 return result; | 956 return result; |
| 942 } | 957 } |
| 943 | 958 |
| 944 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 959 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 945 return memory_bytes_ > limit.memory_bytes_ || | 960 return memory_bytes_ > limit.memory_bytes_ || |
| 946 resource_count_ > limit.resource_count_; | 961 resource_count_ > limit.resource_count_; |
| 947 } | 962 } |
| 948 | 963 |
| 949 } // namespace cc | 964 } // namespace cc |
| OLD | NEW |