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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 resource_pool_(resource_pool), | 236 resource_pool_(resource_pool), |
| 237 rasterizer_(rasterizer), | 237 rasterizer_(rasterizer), |
| 238 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 238 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
| 239 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 239 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 240 did_initialize_visible_tile_(false), | 240 did_initialize_visible_tile_(false), |
| 241 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 241 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
| 242 did_oom_on_last_assign_(false), | 242 did_oom_on_last_assign_(false), |
| 243 ready_to_activate_check_notifier_( | 243 ready_to_activate_check_notifier_( |
| 244 task_runner_.get(), | 244 task_runner_.get(), |
| 245 base::Bind(&TileManager::CheckIfReadyToActivate, | 245 base::Bind(&TileManager::CheckIfReadyToActivate, |
| 246 base::Unretained(this))) { | 246 base::Unretained(this))), |
| 247 ready_to_draw_check_notifier_(task_runner_.get(), | |
| 248 base::Bind(&TileManager::CheckIfReadyToDraw, | |
| 249 base::Unretained(this))) { | |
| 247 rasterizer_->SetClient(this); | 250 rasterizer_->SetClient(this); |
| 248 } | 251 } |
| 249 | 252 |
| 250 TileManager::~TileManager() { | 253 TileManager::~TileManager() { |
| 251 // Reset global state and manage. This should cause | 254 // Reset global state and manage. This should cause |
| 252 // our memory usage to drop to zero. | 255 // our memory usage to drop to zero. |
| 253 global_state_ = GlobalStateThatImpactsTilePriority(); | 256 global_state_ = GlobalStateThatImpactsTilePriority(); |
| 254 | 257 |
| 255 RasterTaskQueue empty; | 258 RasterTaskQueue empty; |
| 256 rasterizer_->ScheduleTasks(&empty); | 259 rasterizer_->ScheduleTasks(&empty); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 } | 381 } |
| 379 | 382 |
| 380 if (ready_to_activate) { | 383 if (ready_to_activate) { |
| 381 DCHECK(IsReadyToActivate()); | 384 DCHECK(IsReadyToActivate()); |
| 382 ready_to_activate_check_notifier_.Schedule(); | 385 ready_to_activate_check_notifier_.Schedule(); |
| 383 } | 386 } |
| 384 raster_priority_queue_.Reset(); | 387 raster_priority_queue_.Reset(); |
| 385 return; | 388 return; |
| 386 } | 389 } |
| 387 | 390 |
| 391 if (task_set == REQUIRED_FOR_DRAW) { | |
|
brianderson
2014/10/24 01:34:04
Can a task_set be both required for draw and requi
ernstm
2014/10/24 04:54:20
We get separate DidFinishRunningTasks notification
| |
| 392 TRACE_EVENT1("cc", | |
| 393 "TileManager::DidFinishRunningTasks", | |
| 394 "task_set", | |
| 395 "REQUIRED_FOR_DRAW"); | |
| 396 ready_to_draw_check_notifier_.Schedule(); | |
| 397 return; | |
| 398 } | |
| 399 | |
| 388 if (task_set == REQUIRED_FOR_ACTIVATION) { | 400 if (task_set == REQUIRED_FOR_ACTIVATION) { |
| 389 TRACE_EVENT1("cc", | 401 TRACE_EVENT1("cc", |
| 390 "TileManager::DidFinishRunningTasks", | 402 "TileManager::DidFinishRunningTasks", |
| 391 "task_set", | 403 "task_set", |
| 392 "REQUIRED_FOR_ACTIVATION"); | 404 "REQUIRED_FOR_ACTIVATION"); |
| 393 ready_to_activate_check_notifier_.Schedule(); | 405 ready_to_activate_check_notifier_.Schedule(); |
| 394 } | 406 } |
| 395 } | 407 } |
| 396 | 408 |
| 397 void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { | 409 void TileManager::ManageTiles(const GlobalStateThatImpactsTilePriority& state) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 | 693 |
| 682 DCHECK(mts.draw_info.requires_resource()); | 694 DCHECK(mts.draw_info.requires_resource()); |
| 683 DCHECK(!mts.draw_info.resource_); | 695 DCHECK(!mts.draw_info.resource_); |
| 684 | 696 |
| 685 if (!mts.raster_task.get()) | 697 if (!mts.raster_task.get()) |
| 686 mts.raster_task = CreateRasterTask(tile); | 698 mts.raster_task = CreateRasterTask(tile); |
| 687 | 699 |
| 688 TaskSetCollection task_sets; | 700 TaskSetCollection task_sets; |
| 689 if (tile->required_for_activation()) | 701 if (tile->required_for_activation()) |
| 690 task_sets.set(REQUIRED_FOR_ACTIVATION); | 702 task_sets.set(REQUIRED_FOR_ACTIVATION); |
| 703 if (tile->required_for_draw()) | |
| 704 task_sets.set(REQUIRED_FOR_DRAW); | |
| 691 task_sets.set(ALL); | 705 task_sets.set(ALL); |
| 692 raster_queue_.items.push_back( | 706 raster_queue_.items.push_back( |
| 693 RasterTaskQueue::Item(mts.raster_task.get(), task_sets)); | 707 RasterTaskQueue::Item(mts.raster_task.get(), task_sets)); |
| 694 } | 708 } |
| 695 | 709 |
| 696 // We must reduce the amount of unused resoruces before calling | 710 // We must reduce the amount of unused resoruces before calling |
| 697 // ScheduleTasks to prevent usage from rising above limits. | 711 // ScheduleTasks to prevent usage from rising above limits. |
| 698 resource_pool_->ReduceResourceUsage(); | 712 resource_pool_->ReduceResourceUsage(); |
| 699 | 713 |
| 700 // Schedule running of |raster_queue_|. This replaces any previously | 714 // Schedule running of |raster_queue_|. This replaces any previously |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); | 874 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); |
| 861 it != layers.end(); | 875 it != layers.end(); |
| 862 ++it) { | 876 ++it) { |
| 863 if (!(*it)->AllTilesRequiredForActivationAreReadyToDraw()) | 877 if (!(*it)->AllTilesRequiredForActivationAreReadyToDraw()) |
| 864 return false; | 878 return false; |
| 865 } | 879 } |
| 866 | 880 |
| 867 return true; | 881 return true; |
| 868 } | 882 } |
| 869 | 883 |
| 884 bool TileManager::IsReadyToDraw() const { | |
| 885 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | |
| 886 | |
| 887 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); | |
| 888 it != layers.end(); | |
| 889 ++it) { | |
| 890 if (!(*it)->AllTilesRequiredForDrawAreReadyToDraw()) | |
| 891 return false; | |
| 892 } | |
| 893 | |
| 894 return true; | |
| 895 } | |
| 896 | |
| 870 void TileManager::CheckIfReadyToActivate() { | 897 void TileManager::CheckIfReadyToActivate() { |
| 871 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 898 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 872 | 899 |
| 873 rasterizer_->CheckForCompletedTasks(); | 900 rasterizer_->CheckForCompletedTasks(); |
| 874 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 901 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 875 | 902 |
| 876 if (IsReadyToActivate()) | 903 if (IsReadyToActivate()) |
| 877 client_->NotifyReadyToActivate(); | 904 client_->NotifyReadyToActivate(); |
| 878 } | 905 } |
| 879 | 906 |
| 907 void TileManager::CheckIfReadyToDraw() { | |
| 908 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToDraw"); | |
| 909 | |
| 910 rasterizer_->CheckForCompletedTasks(); | |
| 911 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | |
| 912 | |
| 913 if (IsReadyToDraw()) | |
| 914 client_->NotifyReadyToDraw(); | |
| 915 } | |
| 916 | |
| 880 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { | 917 TileManager::MemoryUsage::MemoryUsage() : memory_bytes_(0), resource_count_(0) { |
| 881 } | 918 } |
| 882 | 919 |
| 883 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) | 920 TileManager::MemoryUsage::MemoryUsage(int64 memory_bytes, int resource_count) |
| 884 : memory_bytes_(memory_bytes), resource_count_(resource_count) { | 921 : memory_bytes_(memory_bytes), resource_count_(resource_count) { |
| 885 } | 922 } |
| 886 | 923 |
| 887 // static | 924 // static |
| 888 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( | 925 TileManager::MemoryUsage TileManager::MemoryUsage::FromConfig( |
| 889 const gfx::Size& size, | 926 const gfx::Size& size, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 result -= other; | 958 result -= other; |
| 922 return result; | 959 return result; |
| 923 } | 960 } |
| 924 | 961 |
| 925 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 962 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 926 return memory_bytes_ > limit.memory_bytes_ || | 963 return memory_bytes_ > limit.memory_bytes_ || |
| 927 resource_count_ > limit.resource_count_; | 964 resource_count_ > limit.resource_count_; |
| 928 } | 965 } |
| 929 | 966 |
| 930 } // namespace cc | 967 } // namespace cc |
| OLD | NEW |