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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 // Run and complete all raster task synchronously. | 416 // Run and complete all raster task synchronously. |
417 rasterizer_->RasterizeTiles( | 417 rasterizer_->RasterizeTiles( |
418 tiles_that_need_to_be_rasterized, resource_pool_, | 418 tiles_that_need_to_be_rasterized, resource_pool_, |
419 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); | 419 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); |
420 | 420 |
421 // Use on-demand raster for any required-for-activation tiles that have not | 421 // Use on-demand raster for any required-for-activation tiles that have not |
422 // been been assigned memory after reaching a steady memory state. This | 422 // been been assigned memory after reaching a steady memory state. This |
423 // ensures that we activate even when OOM. Note that we have to rebuilt the | 423 // ensures that we activate even when OOM. Note that we have to rebuilt the |
424 // queue in case the last AssignGpuMemoryToTiles evicted some tiles that would | 424 // queue in case the last AssignGpuMemoryToTiles evicted some tiles that would |
425 // otherwise not be picked up by the old raster queue. | 425 // otherwise not be picked up by the old raster queue. |
426 // TODO(hendrikw): This doesn't seem to do anything, remove? | |
vmpstr
2015/01/08 21:06:08
hendrikw, FYI.
| |
426 client_->BuildRasterQueue(&raster_priority_queue_, | 427 client_->BuildRasterQueue(&raster_priority_queue_, |
427 global_state_.tree_priority); | 428 global_state_.tree_priority, |
429 RasterTilePriorityQueue::Type::ALL); | |
428 | 430 |
429 // Use on-demand raster for any tiles that have not been been assigned | 431 // Use on-demand raster for any tiles that have not been been assigned |
430 // memory. This ensures that we draw even when OOM. | 432 // memory. This ensures that we draw even when OOM. |
431 while (!raster_priority_queue_.IsEmpty()) { | 433 while (!raster_priority_queue_.IsEmpty()) { |
432 Tile* tile = raster_priority_queue_.Top(); | 434 Tile* tile = raster_priority_queue_.Top(); |
433 TileDrawInfo& draw_info = tile->draw_info(); | 435 TileDrawInfo& draw_info = tile->draw_info(); |
434 | 436 |
435 if (tile->required_for_draw() && !draw_info.IsReadyToDraw()) { | 437 if (tile->required_for_draw() && !draw_info.IsReadyToDraw()) { |
436 draw_info.set_rasterize_on_demand(); | 438 draw_info.set_rasterize_on_demand(); |
437 client_->NotifyTileStateChanged(tile); | 439 client_->NotifyTileStateChanged(tile); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 bool had_enough_memory_to_schedule_tiles_needed_now = true; | 575 bool had_enough_memory_to_schedule_tiles_needed_now = true; |
574 | 576 |
575 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, | 577 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, |
576 global_state_.num_resources_limit); | 578 global_state_.num_resources_limit); |
577 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, | 579 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, |
578 global_state_.num_resources_limit); | 580 global_state_.num_resources_limit); |
579 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), | 581 MemoryUsage memory_usage(resource_pool_->acquired_memory_usage_bytes(), |
580 resource_pool_->acquired_resource_count()); | 582 resource_pool_->acquired_resource_count()); |
581 | 583 |
582 eviction_priority_queue_is_up_to_date_ = false; | 584 eviction_priority_queue_is_up_to_date_ = false; |
585 // TODO(vmpstr): Take this as a parameter and have SynchronousRaster build a | |
586 // REQUIRED_FOR_DRAW queue. | |
583 client_->BuildRasterQueue(&raster_priority_queue_, | 587 client_->BuildRasterQueue(&raster_priority_queue_, |
584 global_state_.tree_priority); | 588 global_state_.tree_priority, |
589 RasterTilePriorityQueue::Type::ALL); | |
585 | 590 |
586 while (!raster_priority_queue_.IsEmpty()) { | 591 while (!raster_priority_queue_.IsEmpty()) { |
587 Tile* tile = raster_priority_queue_.Top(); | 592 Tile* tile = raster_priority_queue_.Top(); |
588 | 593 |
589 // TODO(vmpstr): Remove this when the iterator returns the correct tiles | 594 // TODO(vmpstr): Remove this when the iterator returns the correct tiles |
590 // to draw for GPU rasterization. | 595 // to draw for GPU rasterization. |
591 if (required_for_draw_only) { | 596 if (required_for_draw_only) { |
592 if (!tile->required_for_draw()) { | 597 if (!tile->required_for_draw()) { |
593 raster_priority_queue_.Pop(); | 598 raster_priority_queue_.Pop(); |
594 continue; | 599 continue; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
873 void TileManager::SetTileTaskRunnerForTesting( | 878 void TileManager::SetTileTaskRunnerForTesting( |
874 TileTaskRunner* tile_task_runner) { | 879 TileTaskRunner* tile_task_runner) { |
875 tile_task_runner_ = tile_task_runner; | 880 tile_task_runner_ = tile_task_runner; |
876 tile_task_runner_->SetClient(this); | 881 tile_task_runner_->SetClient(this); |
877 } | 882 } |
878 | 883 |
879 bool TileManager::IsReadyToActivate() const { | 884 bool TileManager::IsReadyToActivate() const { |
880 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); | 885 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
881 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 886 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); |
882 | 887 |
888 // TODO(vmpstr): Replace this with building a REQUIRED_TO_ACTIVATE raster | |
889 // queue and checking if it's empty. | |
883 for (const auto& layer : layers) { | 890 for (const auto& layer : layers) { |
884 if (!layer->AllTilesRequiredForActivationAreReadyToDraw()) | 891 if (!layer->AllTilesRequiredForActivationAreReadyToDraw()) |
885 return false; | 892 return false; |
886 } | 893 } |
887 | 894 |
888 return true; | 895 return true; |
889 } | 896 } |
890 | 897 |
891 bool TileManager::IsReadyToDraw() const { | 898 bool TileManager::IsReadyToDraw() const { |
892 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 899 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); |
893 | 900 |
901 // TODO(vmpstr): Replace this with building a REQUIRED_TO_DRAW raster queue | |
902 // and checking if it's empty. | |
894 for (const auto& layer : layers) { | 903 for (const auto& layer : layers) { |
895 if (!layer->AllTilesRequiredForDrawAreReadyToDraw()) | 904 if (!layer->AllTilesRequiredForDrawAreReadyToDraw()) |
896 return false; | 905 return false; |
897 } | 906 } |
898 | 907 |
899 return true; | 908 return true; |
900 } | 909 } |
901 | 910 |
902 void TileManager::NotifyReadyToActivate() { | 911 void TileManager::NotifyReadyToActivate() { |
903 TRACE_EVENT0("cc", "TileManager::NotifyReadyToActivate"); | 912 TRACE_EVENT0("cc", "TileManager::NotifyReadyToActivate"); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 // activate as activation can cause checkerboards. | 981 // activate as activation can cause checkerboards. |
973 bool allow_rasterize_on_demand = | 982 bool allow_rasterize_on_demand = |
974 global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY && | 983 global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY && |
975 global_state_.memory_limit_policy != ALLOW_NOTHING; | 984 global_state_.memory_limit_policy != ALLOW_NOTHING; |
976 | 985 |
977 // Use on-demand raster for any required-for-activation tiles that have | 986 // Use on-demand raster for any required-for-activation tiles that have |
978 // not been been assigned memory after reaching a steady memory state. This | 987 // not been been assigned memory after reaching a steady memory state. This |
979 // ensures that we activate even when OOM. Note that we have to rebuilt the | 988 // ensures that we activate even when OOM. Note that we have to rebuilt the |
980 // queue in case the last AssignGpuMemoryToTiles evicted some tiles that | 989 // queue in case the last AssignGpuMemoryToTiles evicted some tiles that |
981 // would otherwise not be picked up by the old raster queue. | 990 // would otherwise not be picked up by the old raster queue. |
991 // TODO(vmpstr): Make this use REQUIRED_FOR_ACTIVAITON queue. | |
vmpstr
2015/01/08 21:06:08
I could just make the change now, but I'd prefer t
danakj
2015/01/08 23:24:40
Yes sounds good. Then you can add a test to show t
vmpstr
2015/01/09 20:21:40
The change would just simply this code, but end up
| |
982 client_->BuildRasterQueue(&raster_priority_queue_, | 992 client_->BuildRasterQueue(&raster_priority_queue_, |
983 global_state_.tree_priority); | 993 global_state_.tree_priority, |
994 RasterTilePriorityQueue::Type::ALL); | |
984 bool ready_to_activate = true; | 995 bool ready_to_activate = true; |
985 while (!raster_priority_queue_.IsEmpty()) { | 996 while (!raster_priority_queue_.IsEmpty()) { |
986 Tile* tile = raster_priority_queue_.Top(); | 997 Tile* tile = raster_priority_queue_.Top(); |
987 TileDrawInfo& draw_info = tile->draw_info(); | 998 TileDrawInfo& draw_info = tile->draw_info(); |
988 | 999 |
989 if (tile->required_for_activation() && !draw_info.IsReadyToDraw()) { | 1000 if (tile->required_for_activation() && !draw_info.IsReadyToDraw()) { |
990 // If we can't raster on demand, give up early (and don't activate). | 1001 // If we can't raster on demand, give up early (and don't activate). |
991 if (!allow_rasterize_on_demand) { | 1002 if (!allow_rasterize_on_demand) { |
992 ready_to_activate = false; | 1003 ready_to_activate = false; |
993 break; | 1004 break; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 result -= other; | 1061 result -= other; |
1051 return result; | 1062 return result; |
1052 } | 1063 } |
1053 | 1064 |
1054 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1065 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
1055 return memory_bytes_ > limit.memory_bytes_ || | 1066 return memory_bytes_ > limit.memory_bytes_ || |
1056 resource_count_ > limit.resource_count_; | 1067 resource_count_ > limit.resource_count_; |
1057 } | 1068 } |
1058 | 1069 |
1059 } // namespace cc | 1070 } // namespace cc |
OLD | NEW |