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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 used_layer_counts_[tile->layer_id()]++; | 858 used_layer_counts_[tile->layer_id()]++; |
859 return tile; | 859 return tile; |
860 } | 860 } |
861 | 861 |
862 void TileManager::SetTileTaskRunnerForTesting( | 862 void TileManager::SetTileTaskRunnerForTesting( |
863 TileTaskRunner* tile_task_runner) { | 863 TileTaskRunner* tile_task_runner) { |
864 tile_task_runner_ = tile_task_runner; | 864 tile_task_runner_ = tile_task_runner; |
865 tile_task_runner_->SetClient(this); | 865 tile_task_runner_->SetClient(this); |
866 } | 866 } |
867 | 867 |
| 868 bool TileManager::AreRequiredTilesReadyToDraw( |
| 869 RasterTilePriorityQueue::Type type) const { |
| 870 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 871 client_->BuildRasterQueue(global_state_.tree_priority, type)); |
| 872 // It is insufficient to check whether the raster queue we constructed is |
| 873 // empty. The reason for this is that there are situations (rasterize on |
| 874 // demand) when the tile both needs raster and it's ready to draw. Hence, we |
| 875 // have to iterate the queue to check whether the required tiles are ready to |
| 876 // draw. |
| 877 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| 878 if (!raster_priority_queue->Top()->IsReadyToDraw()) |
| 879 return false; |
| 880 } |
| 881 return true; |
| 882 } |
868 bool TileManager::IsReadyToActivate() const { | 883 bool TileManager::IsReadyToActivate() const { |
869 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); | 884 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
870 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 885 return AreRequiredTilesReadyToDraw( |
871 | 886 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
872 // TODO(vmpstr): Replace this with building a REQUIRED_TO_ACTIVATE raster | |
873 // queue and checking if the tiles it contains are all ready to draw. | |
874 for (const auto& layer : layers) { | |
875 if (!layer->AllTilesRequiredForActivationAreReadyToDraw()) | |
876 return false; | |
877 } | |
878 | |
879 return true; | |
880 } | 887 } |
881 | 888 |
882 bool TileManager::IsReadyToDraw() const { | 889 bool TileManager::IsReadyToDraw() const { |
883 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 890 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); |
884 | 891 return AreRequiredTilesReadyToDraw( |
885 // TODO(vmpstr): Replace this with building a REQUIRED_TO_DRAW raster queue | 892 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
886 // and checking if the tiles it contains are all ready to draw. | |
887 for (const auto& layer : layers) { | |
888 if (!layer->AllTilesRequiredForDrawAreReadyToDraw()) | |
889 return false; | |
890 } | |
891 | |
892 return true; | |
893 } | 893 } |
894 | 894 |
895 void TileManager::NotifyReadyToActivate() { | 895 void TileManager::NotifyReadyToActivate() { |
896 TRACE_EVENT0("cc", "TileManager::NotifyReadyToActivate"); | 896 TRACE_EVENT0("cc", "TileManager::NotifyReadyToActivate"); |
897 if (did_notify_ready_to_activate_) | 897 if (did_notify_ready_to_activate_) |
898 return; | 898 return; |
899 client_->NotifyReadyToActivate(); | 899 client_->NotifyReadyToActivate(); |
900 did_notify_ready_to_activate_ = true; | 900 did_notify_ready_to_activate_ = true; |
901 } | 901 } |
902 | 902 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 result -= other; | 1043 result -= other; |
1044 return result; | 1044 return result; |
1045 } | 1045 } |
1046 | 1046 |
1047 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1047 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
1048 return memory_bytes_ > limit.memory_bytes_ || | 1048 return memory_bytes_ > limit.memory_bytes_ || |
1049 resource_count_ > limit.resource_count_; | 1049 resource_count_ > limit.resource_count_; |
1050 } | 1050 } |
1051 | 1051 |
1052 } // namespace cc | 1052 } // namespace cc |
OLD | NEW |