| 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> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" |
| 18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 19 #include "base/numerics/safe_conversions.h" | 20 #include "base/numerics/safe_conversions.h" |
| 20 #include "base/trace_event/trace_event_argument.h" | 21 #include "base/trace_event/trace_event_argument.h" |
| 21 #include "cc/base/histograms.h" | 22 #include "cc/base/histograms.h" |
| 22 #include "cc/debug/devtools_instrumentation.h" | 23 #include "cc/debug/devtools_instrumentation.h" |
| 23 #include "cc/debug/frame_viewer_instrumentation.h" | 24 #include "cc/debug/frame_viewer_instrumentation.h" |
| 24 #include "cc/debug/traced_value.h" | 25 #include "cc/debug/traced_value.h" |
| 25 #include "cc/layers/picture_layer_impl.h" | 26 #include "cc/layers/picture_layer_impl.h" |
| 26 #include "cc/raster/raster_buffer.h" | 27 #include "cc/raster/raster_buffer.h" |
| 27 #include "cc/raster/task_category.h" | 28 #include "cc/raster/task_category.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 RasterSource::PlaybackSettings playback_settings_; | 120 RasterSource::PlaybackSettings playback_settings_; |
| 120 TileResolution tile_resolution_; | 121 TileResolution tile_resolution_; |
| 121 int layer_id_; | 122 int layer_id_; |
| 122 uint64_t source_prepare_tiles_id_; | 123 uint64_t source_prepare_tiles_id_; |
| 123 const void* tile_; | 124 const void* tile_; |
| 124 uint64_t new_content_id_; | 125 uint64_t new_content_id_; |
| 125 uint64_t previous_content_id_; | 126 uint64_t previous_content_id_; |
| 126 uint64_t resource_content_id_; | 127 uint64_t resource_content_id_; |
| 127 int source_frame_number_; | 128 int source_frame_number_; |
| 128 const base::Callback<void(bool)> reply_; | 129 const base::Callback<void(bool)> reply_; |
| 129 scoped_ptr<RasterBuffer> raster_buffer_; | 130 std::unique_ptr<RasterBuffer> raster_buffer_; |
| 130 | 131 |
| 131 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 132 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
| 132 }; | 133 }; |
| 133 | 134 |
| 134 // Task priorities that make sure that the task set done tasks run before any | 135 // Task priorities that make sure that the task set done tasks run before any |
| 135 // other remaining tasks. | 136 // other remaining tasks. |
| 136 const size_t kRequiredForActivationDoneTaskPriority = 1u; | 137 const size_t kRequiredForActivationDoneTaskPriority = 1u; |
| 137 const size_t kRequiredForDrawDoneTaskPriority = 2u; | 138 const size_t kRequiredForDrawDoneTaskPriority = 2u; |
| 138 const size_t kAllDoneTaskPriority = 3u; | 139 const size_t kAllDoneTaskPriority = 3u; |
| 139 | 140 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 const base::Closure on_task_set_finished_callback_; | 249 const base::Closure on_task_set_finished_callback_; |
| 249 | 250 |
| 250 DISALLOW_COPY_AND_ASSIGN(TaskSetFinishedTaskImpl); | 251 DISALLOW_COPY_AND_ASSIGN(TaskSetFinishedTaskImpl); |
| 251 }; | 252 }; |
| 252 | 253 |
| 253 } // namespace | 254 } // namespace |
| 254 | 255 |
| 255 RasterTaskCompletionStats::RasterTaskCompletionStats() | 256 RasterTaskCompletionStats::RasterTaskCompletionStats() |
| 256 : completed_count(0u), canceled_count(0u) {} | 257 : completed_count(0u), canceled_count(0u) {} |
| 257 | 258 |
| 258 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 259 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 259 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) { | 260 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) { |
| 260 scoped_ptr<base::trace_event::TracedValue> state( | 261 std::unique_ptr<base::trace_event::TracedValue> state( |
| 261 new base::trace_event::TracedValue()); | 262 new base::trace_event::TracedValue()); |
| 262 state->SetInteger("completed_count", | 263 state->SetInteger("completed_count", |
| 263 base::saturated_cast<int>(stats.completed_count)); | 264 base::saturated_cast<int>(stats.completed_count)); |
| 264 state->SetInteger("canceled_count", | 265 state->SetInteger("canceled_count", |
| 265 base::saturated_cast<int>(stats.canceled_count)); | 266 base::saturated_cast<int>(stats.canceled_count)); |
| 266 return std::move(state); | 267 return std::move(state); |
| 267 } | 268 } |
| 268 | 269 |
| 269 // static | 270 // static |
| 270 scoped_ptr<TileManager> TileManager::Create( | 271 std::unique_ptr<TileManager> TileManager::Create( |
| 271 TileManagerClient* client, | 272 TileManagerClient* client, |
| 272 base::SequencedTaskRunner* task_runner, | 273 base::SequencedTaskRunner* task_runner, |
| 273 size_t scheduled_raster_task_limit, | 274 size_t scheduled_raster_task_limit, |
| 274 bool use_partial_raster) { | 275 bool use_partial_raster) { |
| 275 // TODO(vmpstr): |task_runner| is a raw pointer that is implicitly converted | 276 // TODO(vmpstr): |task_runner| is a raw pointer that is implicitly converted |
| 276 // into a scoped_refptr. Figure out whether to plumb a ref pointer or whether | 277 // into a scoped_refptr. Figure out whether to plumb a ref pointer or whether |
| 277 // tile manager can have a non-owning pointer and fix. | 278 // tile manager can have a non-owning pointer and fix. |
| 278 return make_scoped_ptr(new TileManager( | 279 return base::WrapUnique(new TileManager( |
| 279 client, task_runner, scheduled_raster_task_limit, use_partial_raster)); | 280 client, task_runner, scheduled_raster_task_limit, use_partial_raster)); |
| 280 } | 281 } |
| 281 | 282 |
| 282 TileManager::TileManager(TileManagerClient* client, | 283 TileManager::TileManager(TileManagerClient* client, |
| 283 scoped_refptr<base::SequencedTaskRunner> task_runner, | 284 scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 284 size_t scheduled_raster_task_limit, | 285 size_t scheduled_raster_task_limit, |
| 285 bool use_partial_raster) | 286 bool use_partial_raster) |
| 286 : client_(client), | 287 : client_(client), |
| 287 task_runner_(std::move(task_runner)), | 288 task_runner_(std::move(task_runner)), |
| 288 resource_pool_(nullptr), | 289 resource_pool_(nullptr), |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // to ScheduleTasks() to prevent canceled tasks from being scheduled. | 438 // to ScheduleTasks() to prevent canceled tasks from being scheduled. |
| 438 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { | 439 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { |
| 439 tile_task_runner_->CheckForCompletedTasks(); | 440 tile_task_runner_->CheckForCompletedTasks(); |
| 440 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 441 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 441 } | 442 } |
| 442 | 443 |
| 443 FreeResourcesForReleasedTiles(); | 444 FreeResourcesForReleasedTiles(); |
| 444 CleanUpReleasedTiles(); | 445 CleanUpReleasedTiles(); |
| 445 | 446 |
| 446 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 447 PrioritizedTileVector tiles_that_need_to_be_rasterized; |
| 447 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 448 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 448 client_->BuildRasterQueue(global_state_.tree_priority, | 449 client_->BuildRasterQueue(global_state_.tree_priority, |
| 449 RasterTilePriorityQueue::Type::ALL)); | 450 RasterTilePriorityQueue::Type::ALL)); |
| 450 AssignGpuMemoryToTiles(raster_priority_queue.get(), | 451 AssignGpuMemoryToTiles(raster_priority_queue.get(), |
| 451 scheduled_raster_task_limit_, | 452 scheduled_raster_task_limit_, |
| 452 &tiles_that_need_to_be_rasterized); | 453 &tiles_that_need_to_be_rasterized); |
| 453 | 454 |
| 454 // Inform the client that will likely require a draw if the highest priority | 455 // Inform the client that will likely require a draw if the highest priority |
| 455 // tile that will be rasterized is required for draw. | 456 // tile that will be rasterized is required for draw. |
| 456 client_->SetIsLikelyToRequireADraw( | 457 client_->SetIsLikelyToRequireADraw( |
| 457 !tiles_that_need_to_be_rasterized.empty() && | 458 !tiles_that_need_to_be_rasterized.empty() && |
| (...skipping 17 matching lines...) Expand all Loading... |
| 475 | 476 |
| 476 tile_task_runner_->CheckForCompletedTasks(); | 477 tile_task_runner_->CheckForCompletedTasks(); |
| 477 | 478 |
| 478 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 479 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 479 | 480 |
| 480 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", | 481 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", |
| 481 RasterTaskCompletionStatsAsValue(flush_stats_)); | 482 RasterTaskCompletionStatsAsValue(flush_stats_)); |
| 482 flush_stats_ = RasterTaskCompletionStats(); | 483 flush_stats_ = RasterTaskCompletionStats(); |
| 483 } | 484 } |
| 484 | 485 |
| 485 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 486 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 486 TileManager::BasicStateAsValue() const { | 487 TileManager::BasicStateAsValue() const { |
| 487 scoped_ptr<base::trace_event::TracedValue> value( | 488 std::unique_ptr<base::trace_event::TracedValue> value( |
| 488 new base::trace_event::TracedValue()); | 489 new base::trace_event::TracedValue()); |
| 489 BasicStateAsValueInto(value.get()); | 490 BasicStateAsValueInto(value.get()); |
| 490 return std::move(value); | 491 return std::move(value); |
| 491 } | 492 } |
| 492 | 493 |
| 493 void TileManager::BasicStateAsValueInto( | 494 void TileManager::BasicStateAsValueInto( |
| 494 base::trace_event::TracedValue* state) const { | 495 base::trace_event::TracedValue* state) const { |
| 495 state->SetInteger("tile_count", base::saturated_cast<int>(tiles_.size())); | 496 state->SetInteger("tile_count", base::saturated_cast<int>(tiles_.size())); |
| 496 state->SetBoolean("did_oom_on_last_assign", did_oom_on_last_assign_); | 497 state->SetBoolean("did_oom_on_last_assign", did_oom_on_last_assign_); |
| 497 state->BeginDictionary("global_state"); | 498 state->BeginDictionary("global_state"); |
| 498 global_state_.AsValueInto(state); | 499 global_state_.AsValueInto(state); |
| 499 state->EndDictionary(); | 500 state->EndDictionary(); |
| 500 } | 501 } |
| 501 | 502 |
| 502 scoped_ptr<EvictionTilePriorityQueue> | 503 std::unique_ptr<EvictionTilePriorityQueue> |
| 503 TileManager::FreeTileResourcesUntilUsageIsWithinLimit( | 504 TileManager::FreeTileResourcesUntilUsageIsWithinLimit( |
| 504 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue, | 505 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
| 505 const MemoryUsage& limit, | 506 const MemoryUsage& limit, |
| 506 MemoryUsage* usage) { | 507 MemoryUsage* usage) { |
| 507 while (usage->Exceeds(limit)) { | 508 while (usage->Exceeds(limit)) { |
| 508 if (!eviction_priority_queue) { | 509 if (!eviction_priority_queue) { |
| 509 eviction_priority_queue = | 510 eviction_priority_queue = |
| 510 client_->BuildEvictionQueue(global_state_.tree_priority); | 511 client_->BuildEvictionQueue(global_state_.tree_priority); |
| 511 } | 512 } |
| 512 if (eviction_priority_queue->IsEmpty()) | 513 if (eviction_priority_queue->IsEmpty()) |
| 513 break; | 514 break; |
| 514 | 515 |
| 515 Tile* tile = eviction_priority_queue->Top().tile(); | 516 Tile* tile = eviction_priority_queue->Top().tile(); |
| 516 *usage -= MemoryUsage::FromTile(tile); | 517 *usage -= MemoryUsage::FromTile(tile); |
| 517 FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); | 518 FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(tile); |
| 518 eviction_priority_queue->Pop(); | 519 eviction_priority_queue->Pop(); |
| 519 } | 520 } |
| 520 return eviction_priority_queue; | 521 return eviction_priority_queue; |
| 521 } | 522 } |
| 522 | 523 |
| 523 scoped_ptr<EvictionTilePriorityQueue> | 524 std::unique_ptr<EvictionTilePriorityQueue> |
| 524 TileManager::FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( | 525 TileManager::FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
| 525 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue, | 526 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue, |
| 526 const MemoryUsage& limit, | 527 const MemoryUsage& limit, |
| 527 const TilePriority& other_priority, | 528 const TilePriority& other_priority, |
| 528 MemoryUsage* usage) { | 529 MemoryUsage* usage) { |
| 529 while (usage->Exceeds(limit)) { | 530 while (usage->Exceeds(limit)) { |
| 530 if (!eviction_priority_queue) { | 531 if (!eviction_priority_queue) { |
| 531 eviction_priority_queue = | 532 eviction_priority_queue = |
| 532 client_->BuildEvictionQueue(global_state_.tree_priority); | 533 client_->BuildEvictionQueue(global_state_.tree_priority); |
| 533 } | 534 } |
| 534 if (eviction_priority_queue->IsEmpty()) | 535 if (eviction_priority_queue->IsEmpty()) |
| 535 break; | 536 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; | 585 all_tiles_that_need_to_be_rasterized_are_scheduled_ = true; |
| 585 bool had_enough_memory_to_schedule_tiles_needed_now = true; | 586 bool had_enough_memory_to_schedule_tiles_needed_now = true; |
| 586 | 587 |
| 587 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, | 588 MemoryUsage hard_memory_limit(global_state_.hard_memory_limit_in_bytes, |
| 588 global_state_.num_resources_limit); | 589 global_state_.num_resources_limit); |
| 589 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, | 590 MemoryUsage soft_memory_limit(global_state_.soft_memory_limit_in_bytes, |
| 590 global_state_.num_resources_limit); | 591 global_state_.num_resources_limit); |
| 591 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), | 592 MemoryUsage memory_usage(resource_pool_->memory_usage_bytes(), |
| 592 resource_pool_->resource_count()); | 593 resource_pool_->resource_count()); |
| 593 | 594 |
| 594 scoped_ptr<EvictionTilePriorityQueue> eviction_priority_queue; | 595 std::unique_ptr<EvictionTilePriorityQueue> eviction_priority_queue; |
| 595 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { | 596 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| 596 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); | 597 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); |
| 597 Tile* tile = prioritized_tile.tile(); | 598 Tile* tile = prioritized_tile.tile(); |
| 598 TilePriority priority = prioritized_tile.priority(); | 599 TilePriority priority = prioritized_tile.priority(); |
| 599 | 600 |
| 600 if (TilePriorityViolatesMemoryPolicy(priority)) { | 601 if (TilePriorityViolatesMemoryPolicy(priority)) { |
| 601 TRACE_EVENT_INSTANT0( | 602 TRACE_EVENT_INSTANT0( |
| 602 "cc", "TileManager::AssignGpuMemory tile violates memory policy", | 603 "cc", "TileManager::AssignGpuMemory tile violates memory policy", |
| 603 TRACE_EVENT_SCOPE_THREAD); | 604 TRACE_EVENT_SCOPE_THREAD); |
| 604 break; | 605 break; |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 return tile; | 947 return tile; |
| 947 } | 948 } |
| 948 | 949 |
| 949 void TileManager::SetTileTaskRunnerForTesting( | 950 void TileManager::SetTileTaskRunnerForTesting( |
| 950 TileTaskRunner* tile_task_runner) { | 951 TileTaskRunner* tile_task_runner) { |
| 951 tile_task_runner_ = tile_task_runner; | 952 tile_task_runner_ = tile_task_runner; |
| 952 } | 953 } |
| 953 | 954 |
| 954 bool TileManager::AreRequiredTilesReadyToDraw( | 955 bool TileManager::AreRequiredTilesReadyToDraw( |
| 955 RasterTilePriorityQueue::Type type) const { | 956 RasterTilePriorityQueue::Type type) const { |
| 956 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 957 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 957 client_->BuildRasterQueue(global_state_.tree_priority, type)); | 958 client_->BuildRasterQueue(global_state_.tree_priority, type)); |
| 958 // It is insufficient to check whether the raster queue we constructed is | 959 // It is insufficient to check whether the raster queue we constructed is |
| 959 // empty. The reason for this is that there are situations (rasterize on | 960 // empty. The reason for this is that there are situations (rasterize on |
| 960 // demand) when the tile both needs raster and it's ready to draw. Hence, we | 961 // demand) when the tile both needs raster and it's ready to draw. Hence, we |
| 961 // have to iterate the queue to check whether the required tiles are ready to | 962 // have to iterate the queue to check whether the required tiles are ready to |
| 962 // draw. | 963 // draw. |
| 963 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { | 964 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { |
| 964 if (!raster_priority_queue->Top().tile()->draw_info().IsReadyToDraw()) | 965 if (!raster_priority_queue->Top().tile()->draw_info().IsReadyToDraw()) |
| 965 return false; | 966 return false; |
| 966 } | 967 } |
| 967 | 968 |
| 968 #if DCHECK_IS_ON() | 969 #if DCHECK_IS_ON() |
| 969 scoped_ptr<RasterTilePriorityQueue> all_queue( | 970 std::unique_ptr<RasterTilePriorityQueue> all_queue( |
| 970 client_->BuildRasterQueue(global_state_.tree_priority, type)); | 971 client_->BuildRasterQueue(global_state_.tree_priority, type)); |
| 971 for (; !all_queue->IsEmpty(); all_queue->Pop()) { | 972 for (; !all_queue->IsEmpty(); all_queue->Pop()) { |
| 972 Tile* tile = all_queue->Top().tile(); | 973 Tile* tile = all_queue->Top().tile(); |
| 973 DCHECK(!tile->required_for_activation() || | 974 DCHECK(!tile->required_for_activation() || |
| 974 tile->draw_info().IsReadyToDraw()); | 975 tile->draw_info().IsReadyToDraw()); |
| 975 } | 976 } |
| 976 #endif | 977 #endif |
| 977 return true; | 978 return true; |
| 978 } | 979 } |
| 979 | 980 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 } | 1031 } |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 void TileManager::CheckIfMoreTilesNeedToBePrepared() { | 1034 void TileManager::CheckIfMoreTilesNeedToBePrepared() { |
| 1034 tile_task_runner_->CheckForCompletedTasks(); | 1035 tile_task_runner_->CheckForCompletedTasks(); |
| 1035 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1036 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1036 | 1037 |
| 1037 // When OOM, keep re-assigning memory until we reach a steady state | 1038 // When OOM, keep re-assigning memory until we reach a steady state |
| 1038 // where top-priority tiles are initialized. | 1039 // where top-priority tiles are initialized. |
| 1039 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 1040 PrioritizedTileVector tiles_that_need_to_be_rasterized; |
| 1040 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 1041 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( |
| 1041 client_->BuildRasterQueue(global_state_.tree_priority, | 1042 client_->BuildRasterQueue(global_state_.tree_priority, |
| 1042 RasterTilePriorityQueue::Type::ALL)); | 1043 RasterTilePriorityQueue::Type::ALL)); |
| 1043 AssignGpuMemoryToTiles(raster_priority_queue.get(), | 1044 AssignGpuMemoryToTiles(raster_priority_queue.get(), |
| 1044 scheduled_raster_task_limit_, | 1045 scheduled_raster_task_limit_, |
| 1045 &tiles_that_need_to_be_rasterized); | 1046 &tiles_that_need_to_be_rasterized); |
| 1046 | 1047 |
| 1047 // Inform the client that will likely require a draw if the highest priority | 1048 // Inform the client that will likely require a draw if the highest priority |
| 1048 // tile that will be rasterized is required for draw. | 1049 // tile that will be rasterized is required for draw. |
| 1049 client_->SetIsLikelyToRequireADraw( | 1050 client_->SetIsLikelyToRequireADraw( |
| 1050 !tiles_that_need_to_be_rasterized.empty() && | 1051 !tiles_that_need_to_be_rasterized.empty() && |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 DCHECK(IsReadyToActivate()); | 1096 DCHECK(IsReadyToActivate()); |
| 1096 DCHECK(IsReadyToDraw()); | 1097 DCHECK(IsReadyToDraw()); |
| 1097 signals_.ready_to_activate = need_to_signal_activate; | 1098 signals_.ready_to_activate = need_to_signal_activate; |
| 1098 signals_.ready_to_draw = need_to_signal_draw; | 1099 signals_.ready_to_draw = need_to_signal_draw; |
| 1099 // TODO(ericrk): Investigate why we need to schedule this (not just call it | 1100 // TODO(ericrk): Investigate why we need to schedule this (not just call it |
| 1100 // inline). http://crbug.com/498439 | 1101 // inline). http://crbug.com/498439 |
| 1101 signals_check_notifier_.Schedule(); | 1102 signals_check_notifier_.Schedule(); |
| 1102 } | 1103 } |
| 1103 | 1104 |
| 1104 bool TileManager::MarkTilesOutOfMemory( | 1105 bool TileManager::MarkTilesOutOfMemory( |
| 1105 scoped_ptr<RasterTilePriorityQueue> queue) const { | 1106 std::unique_ptr<RasterTilePriorityQueue> queue) const { |
| 1106 // Mark required tiles as OOM so that we can activate/draw without them. | 1107 // Mark required tiles as OOM so that we can activate/draw without them. |
| 1107 if (queue->IsEmpty()) | 1108 if (queue->IsEmpty()) |
| 1108 return false; | 1109 return false; |
| 1109 | 1110 |
| 1110 for (; !queue->IsEmpty(); queue->Pop()) { | 1111 for (; !queue->IsEmpty(); queue->Pop()) { |
| 1111 Tile* tile = queue->Top().tile(); | 1112 Tile* tile = queue->Top().tile(); |
| 1112 if (tile->draw_info().IsReadyToDraw()) | 1113 if (tile->draw_info().IsReadyToDraw()) |
| 1113 continue; | 1114 continue; |
| 1114 tile->draw_info().set_oom(); | 1115 tile->draw_info().set_oom(); |
| 1115 client_->NotifyTileStateChanged(tile); | 1116 client_->NotifyTileStateChanged(tile); |
| 1116 } | 1117 } |
| 1117 return true; | 1118 return true; |
| 1118 } | 1119 } |
| 1119 | 1120 |
| 1120 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { | 1121 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { |
| 1121 return tile_task_runner_->GetResourceFormat(!tile->is_opaque()); | 1122 return tile_task_runner_->GetResourceFormat(!tile->is_opaque()); |
| 1122 } | 1123 } |
| 1123 | 1124 |
| 1124 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { | 1125 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { |
| 1125 return tile_task_runner_->GetResourceRequiresSwizzle(!tile->is_opaque()); | 1126 return tile_task_runner_->GetResourceRequiresSwizzle(!tile->is_opaque()); |
| 1126 } | 1127 } |
| 1127 | 1128 |
| 1128 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 1129 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 1129 TileManager::ScheduledTasksStateAsValue() const { | 1130 TileManager::ScheduledTasksStateAsValue() const { |
| 1130 scoped_ptr<base::trace_event::TracedValue> state( | 1131 std::unique_ptr<base::trace_event::TracedValue> state( |
| 1131 new base::trace_event::TracedValue()); | 1132 new base::trace_event::TracedValue()); |
| 1132 state->BeginDictionary("tasks_pending"); | 1133 state->BeginDictionary("tasks_pending"); |
| 1133 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); | 1134 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); |
| 1134 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 1135 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); |
| 1135 state->SetBoolean("all_tile_tasks_completed", | 1136 state->SetBoolean("all_tile_tasks_completed", |
| 1136 signals_.all_tile_tasks_completed); | 1137 signals_.all_tile_tasks_completed); |
| 1137 state->EndDictionary(); | 1138 state->EndDictionary(); |
| 1138 return std::move(state); | 1139 return std::move(state); |
| 1139 } | 1140 } |
| 1140 | 1141 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 void TileManager::Signals::reset() { | 1218 void TileManager::Signals::reset() { |
| 1218 ready_to_activate = false; | 1219 ready_to_activate = false; |
| 1219 did_notify_ready_to_activate = false; | 1220 did_notify_ready_to_activate = false; |
| 1220 ready_to_draw = false; | 1221 ready_to_draw = false; |
| 1221 did_notify_ready_to_draw = false; | 1222 did_notify_ready_to_draw = false; |
| 1222 all_tile_tasks_completed = false; | 1223 all_tile_tasks_completed = false; |
| 1223 did_notify_all_tile_tasks_completed = false; | 1224 did_notify_all_tile_tasks_completed = false; |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 } // namespace cc | 1227 } // namespace cc |
| OLD | NEW |