| 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/tiles/tile_manager.h" | 5 #include "cc/tiles/tile_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 FreeResourcesForReleasedTiles(); | 389 FreeResourcesForReleasedTiles(); |
| 390 CleanUpReleasedTiles(); | 390 CleanUpReleasedTiles(); |
| 391 | 391 |
| 392 tile_task_manager_ = nullptr; | 392 tile_task_manager_ = nullptr; |
| 393 resource_pool_ = nullptr; | 393 resource_pool_ = nullptr; |
| 394 more_tiles_need_prepare_check_notifier_.Cancel(); | 394 more_tiles_need_prepare_check_notifier_.Cancel(); |
| 395 signals_check_notifier_.Cancel(); | 395 signals_check_notifier_.Cancel(); |
| 396 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 396 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
| 397 | 397 |
| 398 image_manager_.SetImageDecodeController(nullptr); | 398 image_manager_.SetImageDecodeCache(nullptr); |
| 399 locked_image_tasks_.clear(); | 399 locked_image_tasks_.clear(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void TileManager::SetResources(ResourcePool* resource_pool, | 402 void TileManager::SetResources(ResourcePool* resource_pool, |
| 403 ImageDecodeController* image_decode_controller, | 403 ImageDecodeCache* image_decode_cache, |
| 404 TaskGraphRunner* task_graph_runner, | 404 TaskGraphRunner* task_graph_runner, |
| 405 RasterBufferProvider* raster_buffer_provider, | 405 RasterBufferProvider* raster_buffer_provider, |
| 406 size_t scheduled_raster_task_limit, | 406 size_t scheduled_raster_task_limit, |
| 407 bool use_gpu_rasterization) { | 407 bool use_gpu_rasterization) { |
| 408 DCHECK(!tile_task_manager_); | 408 DCHECK(!tile_task_manager_); |
| 409 DCHECK(task_graph_runner); | 409 DCHECK(task_graph_runner); |
| 410 | 410 |
| 411 use_gpu_rasterization_ = use_gpu_rasterization; | 411 use_gpu_rasterization_ = use_gpu_rasterization; |
| 412 scheduled_raster_task_limit_ = scheduled_raster_task_limit; | 412 scheduled_raster_task_limit_ = scheduled_raster_task_limit; |
| 413 resource_pool_ = resource_pool; | 413 resource_pool_ = resource_pool; |
| 414 image_manager_.SetImageDecodeController(image_decode_controller); | 414 image_manager_.SetImageDecodeCache(image_decode_cache); |
| 415 tile_task_manager_ = TileTaskManagerImpl::Create(task_graph_runner); | 415 tile_task_manager_ = TileTaskManagerImpl::Create(task_graph_runner); |
| 416 raster_buffer_provider_ = raster_buffer_provider; | 416 raster_buffer_provider_ = raster_buffer_provider; |
| 417 } | 417 } |
| 418 | 418 |
| 419 void TileManager::Release(Tile* tile) { | 419 void TileManager::Release(Tile* tile) { |
| 420 released_tiles_.push_back(tile); | 420 released_tiles_.push_back(tile); |
| 421 } | 421 } |
| 422 | 422 |
| 423 void TileManager::FreeResourcesForReleasedTiles() { | 423 void TileManager::FreeResourcesForReleasedTiles() { |
| 424 for (auto* tile : released_tiles_) | 424 for (auto* tile : released_tiles_) |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 std::vector<DrawImage> images; | 885 std::vector<DrawImage> images; |
| 886 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 886 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 887 tile->enclosing_layer_rect(), tile->raster_scales(), &images); | 887 tile->enclosing_layer_rect(), tile->raster_scales(), &images); |
| 888 new_locked_images.insert(new_locked_images.end(), images.begin(), | 888 new_locked_images.insert(new_locked_images.end(), images.begin(), |
| 889 images.end()); | 889 images.end()); |
| 890 } | 890 } |
| 891 | 891 |
| 892 // TODO(vmpstr): SOON is misleading here, but these images can come from | 892 // TODO(vmpstr): SOON is misleading here, but these images can come from |
| 893 // several diffent tiles. Rethink what we actually want to trace here. Note | 893 // several diffent tiles. Rethink what we actually want to trace here. Note |
| 894 // that I'm using SOON, since it can't be NOW (these are prepaint). | 894 // that I'm using SOON, since it can't be NOW (these are prepaint). |
| 895 ImageDecodeController::TracingInfo tracing_info(prepare_tiles_count_, | 895 ImageDecodeCache::TracingInfo tracing_info(prepare_tiles_count_, |
| 896 TilePriority::SOON); | 896 TilePriority::SOON); |
| 897 std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = | 897 std::vector<scoped_refptr<TileTask>> new_locked_image_tasks = |
| 898 image_manager_.SetPredecodeImages(std::move(new_locked_images), | 898 image_manager_.SetPredecodeImages(std::move(new_locked_images), |
| 899 tracing_info); | 899 tracing_info); |
| 900 | 900 |
| 901 for (auto& task : new_locked_image_tasks) { | 901 for (auto& task : new_locked_image_tasks) { |
| 902 auto decode_it = std::find_if(graph_.nodes.begin(), graph_.nodes.end(), | 902 auto decode_it = std::find_if(graph_.nodes.begin(), graph_.nodes.end(), |
| 903 [&task](const TaskGraph::Node& node) { | 903 [&task](const TaskGraph::Node& node) { |
| 904 return node.task == task.get(); | 904 return node.task == task.get(); |
| 905 }); | 905 }); |
| 906 // If this task is already in the graph, then we don't have to insert it. | 906 // If this task is already in the graph, then we don't have to insert it. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 images.clear(); | 987 images.clear(); |
| 988 if (!playback_settings.skip_images) { | 988 if (!playback_settings.skip_images) { |
| 989 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 989 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
| 990 tile->enclosing_layer_rect(), tile->raster_scales(), &images); | 990 tile->enclosing_layer_rect(), tile->raster_scales(), &images); |
| 991 } | 991 } |
| 992 | 992 |
| 993 // We can skip the image hijack canvas if we have no images. | 993 // We can skip the image hijack canvas if we have no images. |
| 994 playback_settings.use_image_hijack_canvas = !images.empty(); | 994 playback_settings.use_image_hijack_canvas = !images.empty(); |
| 995 | 995 |
| 996 // Get the tasks for the required images. | 996 // Get the tasks for the required images. |
| 997 ImageDecodeController::TracingInfo tracing_info( | 997 ImageDecodeCache::TracingInfo tracing_info( |
| 998 prepare_tiles_count_, prioritized_tile.priority().priority_bin); | 998 prepare_tiles_count_, prioritized_tile.priority().priority_bin); |
| 999 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); | 999 image_manager_.GetTasksForImagesAndRef(&images, &decode_tasks, tracing_info); |
| 1000 | 1000 |
| 1001 std::unique_ptr<RasterBuffer> raster_buffer = | 1001 std::unique_ptr<RasterBuffer> raster_buffer = |
| 1002 raster_buffer_provider_->AcquireBufferForRaster( | 1002 raster_buffer_provider_->AcquireBufferForRaster( |
| 1003 resource, resource_content_id, tile->invalidated_id()); | 1003 resource, resource_content_id, tile->invalidated_id()); |
| 1004 return make_scoped_refptr(new RasterTaskImpl( | 1004 return make_scoped_refptr(new RasterTaskImpl( |
| 1005 this, tile, resource, prioritized_tile.raster_source(), playback_settings, | 1005 this, tile, resource, prioritized_tile.raster_source(), playback_settings, |
| 1006 prioritized_tile.priority().resolution, invalidated_rect, | 1006 prioritized_tile.priority().resolution, invalidated_rect, |
| 1007 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, | 1007 prepare_tiles_count_, std::move(raster_buffer), &decode_tasks, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 // steady memory state. Keep scheduling tasks until we reach this state. | 1157 // steady memory state. Keep scheduling tasks until we reach this state. |
| 1158 if (!work_to_schedule.tiles_to_raster.empty()) { | 1158 if (!work_to_schedule.tiles_to_raster.empty()) { |
| 1159 ScheduleTasks(work_to_schedule); | 1159 ScheduleTasks(work_to_schedule); |
| 1160 return; | 1160 return; |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 // If we're not in SMOOTHNESS_TAKES_PRIORITY mode, we should unlock all | 1163 // If we're not in SMOOTHNESS_TAKES_PRIORITY mode, we should unlock all |
| 1164 // images since we're technically going idle here at least for this frame. | 1164 // images since we're technically going idle here at least for this frame. |
| 1165 if (global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY) { | 1165 if (global_state_.tree_priority != SMOOTHNESS_TAKES_PRIORITY) { |
| 1166 image_manager_.SetPredecodeImages(std::vector<DrawImage>(), | 1166 image_manager_.SetPredecodeImages(std::vector<DrawImage>(), |
| 1167 ImageDecodeController::TracingInfo()); | 1167 ImageDecodeCache::TracingInfo()); |
| 1168 locked_image_tasks_.clear(); | 1168 locked_image_tasks_.clear(); |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 FreeResourcesForReleasedTiles(); | 1171 FreeResourcesForReleasedTiles(); |
| 1172 | 1172 |
| 1173 resource_pool_->ReduceResourceUsage(); | 1173 resource_pool_->ReduceResourceUsage(); |
| 1174 image_manager_.ReduceMemoryUsage(); | 1174 image_manager_.ReduceMemoryUsage(); |
| 1175 | 1175 |
| 1176 // TODO(vmpstr): Temporary check to debug crbug.com/642927. | 1176 // TODO(vmpstr): Temporary check to debug crbug.com/642927. |
| 1177 CHECK(tile_task_manager_); | 1177 CHECK(tile_task_manager_); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 all_tile_tasks_completed = false; | 1340 all_tile_tasks_completed = false; |
| 1341 did_notify_all_tile_tasks_completed = false; | 1341 did_notify_all_tile_tasks_completed = false; |
| 1342 } | 1342 } |
| 1343 | 1343 |
| 1344 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; | 1344 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; |
| 1345 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( | 1345 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( |
| 1346 PrioritizedWorkToSchedule&& other) = default; | 1346 PrioritizedWorkToSchedule&& other) = default; |
| 1347 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; | 1347 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; |
| 1348 | 1348 |
| 1349 } // namespace cc | 1349 } // namespace cc |
| OLD | NEW |