| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/debug/trace_event_argument.h" |
| 12 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
| 16 #include "cc/debug/frame_viewer_instrumentation.h" | 17 #include "cc/debug/frame_viewer_instrumentation.h" |
| 17 #include "cc/debug/traced_value.h" | 18 #include "cc/debug/traced_value.h" |
| 18 #include "cc/layers/picture_layer_impl.h" | 19 #include "cc/layers/picture_layer_impl.h" |
| 19 #include "cc/resources/raster_worker_pool.h" | 20 #include "cc/resources/raster_worker_pool.h" |
| 20 #include "cc/resources/tile.h" | 21 #include "cc/resources/tile.h" |
| 21 #include "skia/ext/paint_simplifier.h" | 22 #include "skia/ext/paint_simplifier.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 return NEVER_BIN; | 330 return NEVER_BIN; |
| 330 | 331 |
| 331 return EVENTUALLY_BIN; | 332 return EVENTUALLY_BIN; |
| 332 } | 333 } |
| 333 | 334 |
| 334 } // namespace | 335 } // namespace |
| 335 | 336 |
| 336 RasterTaskCompletionStats::RasterTaskCompletionStats() | 337 RasterTaskCompletionStats::RasterTaskCompletionStats() |
| 337 : completed_count(0u), canceled_count(0u) {} | 338 : completed_count(0u), canceled_count(0u) {} |
| 338 | 339 |
| 339 scoped_ptr<base::Value> RasterTaskCompletionStatsAsValue( | 340 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 340 const RasterTaskCompletionStats& stats) { | 341 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats) { |
| 341 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 342 scoped_refptr<base::debug::TracedValue> state = |
| 343 new base::debug::TracedValue(); |
| 342 state->SetInteger("completed_count", stats.completed_count); | 344 state->SetInteger("completed_count", stats.completed_count); |
| 343 state->SetInteger("canceled_count", stats.canceled_count); | 345 state->SetInteger("canceled_count", stats.canceled_count); |
| 344 return state.PassAs<base::Value>(); | 346 return state; |
| 345 } | 347 } |
| 346 | 348 |
| 347 // static | 349 // static |
| 348 scoped_ptr<TileManager> TileManager::Create( | 350 scoped_ptr<TileManager> TileManager::Create( |
| 349 TileManagerClient* client, | 351 TileManagerClient* client, |
| 350 base::SequencedTaskRunner* task_runner, | 352 base::SequencedTaskRunner* task_runner, |
| 351 ResourcePool* resource_pool, | 353 ResourcePool* resource_pool, |
| 352 Rasterizer* rasterizer, | 354 Rasterizer* rasterizer, |
| 353 RenderingStatsInstrumentation* rendering_stats_instrumentation) { | 355 RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
| 354 return make_scoped_ptr(new TileManager(client, | 356 return make_scoped_ptr(new TileManager(client, |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 AssignGpuMemoryToTiles(&prioritized_tiles_, | 662 AssignGpuMemoryToTiles(&prioritized_tiles_, |
| 661 &tiles_that_need_to_be_rasterized); | 663 &tiles_that_need_to_be_rasterized); |
| 662 | 664 |
| 663 // Finally, schedule rasterizer tasks. | 665 // Finally, schedule rasterizer tasks. |
| 664 ScheduleTasks(tiles_that_need_to_be_rasterized); | 666 ScheduleTasks(tiles_that_need_to_be_rasterized); |
| 665 | 667 |
| 666 TRACE_EVENT_INSTANT1("cc", | 668 TRACE_EVENT_INSTANT1("cc", |
| 667 "DidManage", | 669 "DidManage", |
| 668 TRACE_EVENT_SCOPE_THREAD, | 670 TRACE_EVENT_SCOPE_THREAD, |
| 669 "state", | 671 "state", |
| 670 TracedValue::FromValue(BasicStateAsValue().release())); | 672 BasicStateAsValue()); |
| 671 | 673 |
| 672 TRACE_COUNTER_ID1("cc", | 674 TRACE_COUNTER_ID1("cc", |
| 673 "unused_memory_bytes", | 675 "unused_memory_bytes", |
| 674 this, | 676 this, |
| 675 resource_pool_->total_memory_usage_bytes() - | 677 resource_pool_->total_memory_usage_bytes() - |
| 676 resource_pool_->acquired_memory_usage_bytes()); | 678 resource_pool_->acquired_memory_usage_bytes()); |
| 677 } | 679 } |
| 678 | 680 |
| 679 bool TileManager::UpdateVisibleTiles() { | 681 bool TileManager::UpdateVisibleTiles() { |
| 680 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); | 682 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); |
| 681 | 683 |
| 682 rasterizer_->CheckForCompletedTasks(); | 684 rasterizer_->CheckForCompletedTasks(); |
| 683 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 685 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 684 | 686 |
| 685 TRACE_EVENT_INSTANT1( | 687 TRACE_EVENT_INSTANT1( |
| 686 "cc", | 688 "cc", |
| 687 "DidUpdateVisibleTiles", | 689 "DidUpdateVisibleTiles", |
| 688 TRACE_EVENT_SCOPE_THREAD, | 690 TRACE_EVENT_SCOPE_THREAD, |
| 689 "stats", | 691 "stats", |
| 690 TracedValue::FromValue(RasterTaskCompletionStatsAsValue( | 692 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); |
| 691 update_visible_tiles_stats_).release())); | |
| 692 update_visible_tiles_stats_ = RasterTaskCompletionStats(); | 693 update_visible_tiles_stats_ = RasterTaskCompletionStats(); |
| 693 | 694 |
| 694 bool did_initialize_visible_tile = did_initialize_visible_tile_; | 695 bool did_initialize_visible_tile = did_initialize_visible_tile_; |
| 695 did_initialize_visible_tile_ = false; | 696 did_initialize_visible_tile_ = false; |
| 696 return did_initialize_visible_tile; | 697 return did_initialize_visible_tile; |
| 697 } | 698 } |
| 698 | 699 |
| 699 scoped_ptr<base::Value> TileManager::BasicStateAsValue() const { | 700 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 700 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 701 TileManager::BasicStateAsValue() const { |
| 701 state->SetInteger("tile_count", tiles_.size()); | 702 scoped_refptr<base::debug::TracedValue> value = |
| 702 state->Set("global_state", global_state_.AsValue().release()); | 703 new base::debug::TracedValue(); |
| 703 return state.PassAs<base::Value>(); | 704 BasicStateAsValueInto(value.get()); |
| 705 return value; |
| 704 } | 706 } |
| 705 | 707 |
| 706 scoped_ptr<base::Value> TileManager::AllTilesAsValue() const { | 708 void TileManager::BasicStateAsValueInto(base::debug::TracedValue* state) const { |
| 707 scoped_ptr<base::ListValue> state(new base::ListValue()); | 709 state->SetInteger("tile_count", tiles_.size()); |
| 708 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 710 state->BeginDictionary("global_state"); |
| 709 state->Append(it->second->AsValue().release()); | 711 global_state_.AsValueInto(state); |
| 712 state->EndDictionary(); |
| 713 } |
| 710 | 714 |
| 711 return state.PassAs<base::Value>(); | 715 void TileManager::AllTilesAsValueInto(base::debug::TracedValue* state) const { |
| 716 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 717 state->BeginDictionary(); |
| 718 it->second->AsValueInto(state); |
| 719 state->EndDictionary(); |
| 720 } |
| 712 } | 721 } |
| 713 | 722 |
| 714 void TileManager::AssignGpuMemoryToTiles( | 723 void TileManager::AssignGpuMemoryToTiles( |
| 715 PrioritizedTileSet* tiles, | 724 PrioritizedTileSet* tiles, |
| 716 TileVector* tiles_that_need_to_be_rasterized) { | 725 TileVector* tiles_that_need_to_be_rasterized) { |
| 717 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); | 726 TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles"); |
| 718 | 727 |
| 719 // Maintain the list of released resources that can potentially be re-used | 728 // Maintain the list of released resources that can potentially be re-used |
| 720 // or deleted. | 729 // or deleted. |
| 721 // If this operation becomes expensive too, only do this after some | 730 // If this operation becomes expensive too, only do this after some |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 1167 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 1159 | 1168 |
| 1160 rasterizer_->CheckForCompletedTasks(); | 1169 rasterizer_->CheckForCompletedTasks(); |
| 1161 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1170 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 1162 | 1171 |
| 1163 if (IsReadyToActivate()) | 1172 if (IsReadyToActivate()) |
| 1164 client_->NotifyReadyToActivate(); | 1173 client_->NotifyReadyToActivate(); |
| 1165 } | 1174 } |
| 1166 | 1175 |
| 1167 } // namespace cc | 1176 } // namespace cc |
| OLD | NEW |