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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 419 |
420 scoped_ptr<RasterTilePriorityQueue> required_for_draw_queue( | 420 scoped_ptr<RasterTilePriorityQueue> required_for_draw_queue( |
421 client_->BuildRasterQueue( | 421 client_->BuildRasterQueue( |
422 global_state_.tree_priority, | 422 global_state_.tree_priority, |
423 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); | 423 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW)); |
424 TileVector tiles_that_need_to_be_rasterized; | 424 TileVector tiles_that_need_to_be_rasterized; |
425 AssignGpuMemoryToTiles(required_for_draw_queue.get(), | 425 AssignGpuMemoryToTiles(required_for_draw_queue.get(), |
426 std::numeric_limits<size_t>::max(), | 426 std::numeric_limits<size_t>::max(), |
427 &tiles_that_need_to_be_rasterized); | 427 &tiles_that_need_to_be_rasterized); |
428 | 428 |
| 429 // Since we are synchronously rasterizing all tiles, we don't require further |
| 430 // draws for that. Set the flag to false so that we can clear it if it was set |
| 431 // earlier by PrepareTiles. |
| 432 client_->SetIsLikelyToRequireADraw(false); |
| 433 |
429 // We must reduce the amount of unused resources before calling | 434 // We must reduce the amount of unused resources before calling |
430 // RunTasks to prevent usage from rising above limits. | 435 // RunTasks to prevent usage from rising above limits. |
431 resource_pool_->ReduceResourceUsage(); | 436 resource_pool_->ReduceResourceUsage(); |
432 | 437 |
433 // Run and complete all raster task synchronously. | 438 // Run and complete all raster task synchronously. |
434 rasterizer_->RasterizeTiles( | 439 rasterizer_->RasterizeTiles( |
435 tiles_that_need_to_be_rasterized, resource_pool_, | 440 tiles_that_need_to_be_rasterized, resource_pool_, |
436 tile_task_runner_->GetResourceFormat(), | 441 tile_task_runner_->GetResourceFormat(), |
437 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); | 442 base::Bind(&TileManager::UpdateTileDrawInfo, base::Unretained(this))); |
438 | 443 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 // When OOM, keep re-assigning memory until we reach a steady state | 959 // When OOM, keep re-assigning memory until we reach a steady state |
955 // where top-priority tiles are initialized. | 960 // where top-priority tiles are initialized. |
956 TileVector tiles_that_need_to_be_rasterized; | 961 TileVector tiles_that_need_to_be_rasterized; |
957 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 962 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
958 client_->BuildRasterQueue(global_state_.tree_priority, | 963 client_->BuildRasterQueue(global_state_.tree_priority, |
959 RasterTilePriorityQueue::Type::ALL)); | 964 RasterTilePriorityQueue::Type::ALL)); |
960 AssignGpuMemoryToTiles(raster_priority_queue.get(), | 965 AssignGpuMemoryToTiles(raster_priority_queue.get(), |
961 scheduled_raster_task_limit_, | 966 scheduled_raster_task_limit_, |
962 &tiles_that_need_to_be_rasterized); | 967 &tiles_that_need_to_be_rasterized); |
963 | 968 |
| 969 // Inform the client that will likely require a draw if the highest priority |
| 970 // tile that will be rasterized is required for draw. |
| 971 client_->SetIsLikelyToRequireADraw( |
| 972 !tiles_that_need_to_be_rasterized.empty() && |
| 973 (*tiles_that_need_to_be_rasterized.begin())->required_for_draw()); |
| 974 |
964 // |tiles_that_need_to_be_rasterized| will be empty when we reach a | 975 // |tiles_that_need_to_be_rasterized| will be empty when we reach a |
965 // steady memory state. Keep scheduling tasks until we reach this state. | 976 // steady memory state. Keep scheduling tasks until we reach this state. |
966 if (!tiles_that_need_to_be_rasterized.empty()) { | 977 if (!tiles_that_need_to_be_rasterized.empty()) { |
967 ScheduleTasks(tiles_that_need_to_be_rasterized); | 978 ScheduleTasks(tiles_that_need_to_be_rasterized); |
968 return; | 979 return; |
969 } | 980 } |
970 | 981 |
971 FreeResourcesForReleasedTiles(); | 982 FreeResourcesForReleasedTiles(); |
972 | 983 |
973 resource_pool_->ReduceResourceUsage(); | 984 resource_pool_->ReduceResourceUsage(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 result -= other; | 1064 result -= other; |
1054 return result; | 1065 return result; |
1055 } | 1066 } |
1056 | 1067 |
1057 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 1068 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
1058 return memory_bytes_ > limit.memory_bytes_ || | 1069 return memory_bytes_ > limit.memory_bytes_ || |
1059 resource_count_ > limit.resource_count_; | 1070 resource_count_ > limit.resource_count_; |
1060 } | 1071 } |
1061 | 1072 |
1062 } // namespace cc | 1073 } // namespace cc |
OLD | NEW |