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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 355 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
356 } | 356 } |
357 | 357 |
358 FreeResourcesForReleasedTiles(); | 358 FreeResourcesForReleasedTiles(); |
359 CleanUpReleasedTiles(); | 359 CleanUpReleasedTiles(); |
360 | 360 |
361 TileVector tiles_that_need_to_be_rasterized; | 361 TileVector tiles_that_need_to_be_rasterized; |
362 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 362 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
363 client_->BuildRasterQueue(global_state_.tree_priority, | 363 client_->BuildRasterQueue(global_state_.tree_priority, |
364 RasterTilePriorityQueue::Type::ALL)); | 364 RasterTilePriorityQueue::Type::ALL)); |
| 365 // Inform the client that will likely require a draw if the top tile is |
| 366 // required for draw. |
| 367 client_->SetIsLikelyToRequireADraw( |
| 368 !raster_priority_queue->IsEmpty() && |
| 369 raster_priority_queue->Top()->required_for_draw()); |
365 AssignGpuMemoryToTiles(raster_priority_queue.get(), | 370 AssignGpuMemoryToTiles(raster_priority_queue.get(), |
366 scheduled_raster_task_limit_, | 371 scheduled_raster_task_limit_, |
367 &tiles_that_need_to_be_rasterized); | 372 &tiles_that_need_to_be_rasterized); |
368 | 373 |
369 // Schedule tile tasks. | 374 // Schedule tile tasks. |
370 ScheduleTasks(tiles_that_need_to_be_rasterized); | 375 ScheduleTasks(tiles_that_need_to_be_rasterized); |
371 | 376 |
372 did_notify_ready_to_activate_ = false; | 377 did_notify_ready_to_activate_ = false; |
373 did_notify_ready_to_draw_ = false; | 378 did_notify_ready_to_draw_ = false; |
374 } else { | 379 } else { |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 void TileManager::UpdateTileDrawInfo( | 828 void TileManager::UpdateTileDrawInfo( |
824 Tile* tile, | 829 Tile* tile, |
825 scoped_ptr<ScopedResource> resource, | 830 scoped_ptr<ScopedResource> resource, |
826 const RasterSource::SolidColorAnalysis& analysis) { | 831 const RasterSource::SolidColorAnalysis& analysis) { |
827 TileDrawInfo& draw_info = tile->draw_info(); | 832 TileDrawInfo& draw_info = tile->draw_info(); |
828 | 833 |
829 ++update_visible_tiles_stats_.completed_count; | 834 ++update_visible_tiles_stats_.completed_count; |
830 | 835 |
831 if (analysis.is_solid_color) { | 836 if (analysis.is_solid_color) { |
832 draw_info.set_solid_color(analysis.solid_color); | 837 draw_info.set_solid_color(analysis.solid_color); |
833 resource_pool_->ReleaseResource(resource.Pass()); | 838 if (resource) |
| 839 resource_pool_->ReleaseResource(resource.Pass()); |
834 } else { | 840 } else { |
| 841 DCHECK(resource); |
835 draw_info.set_use_resource(); | 842 draw_info.set_use_resource(); |
836 draw_info.resource_ = resource.Pass(); | 843 draw_info.resource_ = resource.Pass(); |
837 } | 844 } |
838 | 845 |
839 client_->NotifyTileStateChanged(tile); | 846 client_->NotifyTileStateChanged(tile); |
840 } | 847 } |
841 | 848 |
842 scoped_refptr<Tile> TileManager::CreateTile( | 849 scoped_refptr<Tile> TileManager::CreateTile( |
843 RasterSource* raster_source, | 850 RasterSource* raster_source, |
844 const gfx::Size& desired_texture_size, | 851 const gfx::Size& desired_texture_size, |
(...skipping 11 matching lines...) Expand all Loading... |
856 used_layer_counts_[tile->layer_id()]++; | 863 used_layer_counts_[tile->layer_id()]++; |
857 return tile; | 864 return tile; |
858 } | 865 } |
859 | 866 |
860 void TileManager::SetTileTaskRunnerForTesting( | 867 void TileManager::SetTileTaskRunnerForTesting( |
861 TileTaskRunner* tile_task_runner) { | 868 TileTaskRunner* tile_task_runner) { |
862 tile_task_runner_ = tile_task_runner; | 869 tile_task_runner_ = tile_task_runner; |
863 tile_task_runner_->SetClient(this); | 870 tile_task_runner_->SetClient(this); |
864 } | 871 } |
865 | 872 |
| 873 bool TileManager::AreRequiredTilesReadyToDraw( |
| 874 RasterTilePriorityQueue::Type type) const { |
| 875 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 876 client_->BuildRasterQueue(global_state_.tree_priority, type)); |
| 877 // It is insufficient to check whether the raster queue we constructed is |
| 878 // empty. The reason for this is that there are situations (rasterize on |
| 879 // demand) when the tile both needs raster and it's ready to draw. Hence, we |
| 880 // have to iterate the queue to check whether the required tiles are ready to |
| 881 // draw. |
| 882 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| 883 if (!raster_priority_queue->Top()->IsReadyToDraw()) |
| 884 return false; |
| 885 } |
| 886 return true; |
| 887 } |
866 bool TileManager::IsReadyToActivate() const { | 888 bool TileManager::IsReadyToActivate() const { |
867 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); | 889 TRACE_EVENT0("cc", "TileManager::IsReadyToActivate"); |
868 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 890 return AreRequiredTilesReadyToDraw( |
869 | 891 RasterTilePriorityQueue::Type::REQUIRED_FOR_ACTIVATION); |
870 // TODO(vmpstr): Replace this with building a REQUIRED_TO_ACTIVATE raster | |
871 // queue and checking if the tiles it contains are all ready to draw. | |
872 for (const auto& layer : layers) { | |
873 if (!layer->AllTilesRequiredForActivationAreReadyToDraw()) | |
874 return false; | |
875 } | |
876 | |
877 return true; | |
878 } | 892 } |
879 | 893 |
880 bool TileManager::IsReadyToDraw() const { | 894 bool TileManager::IsReadyToDraw() const { |
881 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 895 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); |
882 | 896 return AreRequiredTilesReadyToDraw( |
883 // TODO(vmpstr): Replace this with building a REQUIRED_TO_DRAW raster queue | 897 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
884 // and checking if the tiles it contains are all ready to draw. | |
885 for (const auto& layer : layers) { | |
886 if (!layer->AllTilesRequiredForDrawAreReadyToDraw()) | |
887 return false; | |
888 } | |
889 | |
890 return true; | |
891 } | 898 } |
892 | 899 |
893 void TileManager::NotifyReadyToActivate() { | 900 void TileManager::NotifyReadyToActivate() { |
894 TRACE_EVENT0("cc", "TileManager::NotifyReadyToActivate"); | 901 TRACE_EVENT0("cc", "TileManager::NotifyReadyToActivate"); |
895 if (did_notify_ready_to_activate_) | 902 if (did_notify_ready_to_activate_) |
896 return; | 903 return; |
897 client_->NotifyReadyToActivate(); | 904 client_->NotifyReadyToActivate(); |
898 did_notify_ready_to_activate_ = true; | 905 did_notify_ready_to_activate_ = true; |
899 } | 906 } |
900 | 907 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 result -= other; | 1048 result -= other; |
1042 return result; | 1049 return result; |
1043 } | 1050 } |
1044 | 1051 |
1045 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1052 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
1046 return memory_bytes_ > limit.memory_bytes_ || | 1053 return memory_bytes_ > limit.memory_bytes_ || |
1047 resource_count_ > limit.resource_count_; | 1054 resource_count_ > limit.resource_count_; |
1048 } | 1055 } |
1049 | 1056 |
1050 } // namespace cc | 1057 } // namespace cc |
OLD | NEW |