| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 Rasterizer* rasterizer, | 212 Rasterizer* rasterizer, |
| 213 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 213 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 214 size_t scheduled_raster_task_limit) | 214 size_t scheduled_raster_task_limit) |
| 215 : client_(client), | 215 : client_(client), |
| 216 task_runner_(task_runner), | 216 task_runner_(task_runner), |
| 217 resource_pool_(resource_pool), | 217 resource_pool_(resource_pool), |
| 218 rasterizer_(rasterizer), | 218 rasterizer_(rasterizer), |
| 219 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 219 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
| 220 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 220 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
| 221 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 221 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 222 did_initialize_visible_tile_(false), | |
| 223 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 222 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
| 224 did_oom_on_last_assign_(false), | 223 did_oom_on_last_assign_(false), |
| 225 ready_to_activate_check_notifier_( | 224 ready_to_activate_check_notifier_( |
| 226 task_runner_.get(), | 225 task_runner_.get(), |
| 227 base::Bind(&TileManager::CheckIfReadyToActivate, | 226 base::Bind(&TileManager::CheckIfReadyToActivate, |
| 228 base::Unretained(this))), | 227 base::Unretained(this))), |
| 229 ready_to_draw_check_notifier_(task_runner_.get(), | 228 ready_to_draw_check_notifier_(task_runner_.get(), |
| 230 base::Bind(&TileManager::CheckIfReadyToDraw, | 229 base::Bind(&TileManager::CheckIfReadyToDraw, |
| 231 base::Unretained(this))) { | 230 base::Unretained(this))) { |
| 232 rasterizer_->SetClient(this); | 231 rasterizer_->SetClient(this); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 363 |
| 365 if (ready_to_activate) { | 364 if (ready_to_activate) { |
| 366 DCHECK(IsReadyToActivate()); | 365 DCHECK(IsReadyToActivate()); |
| 367 ready_to_activate_check_notifier_.Schedule(); | 366 ready_to_activate_check_notifier_.Schedule(); |
| 368 } | 367 } |
| 369 raster_priority_queue_.Reset(); | 368 raster_priority_queue_.Reset(); |
| 370 return; | 369 return; |
| 371 } | 370 } |
| 372 | 371 |
| 373 if (task_set == REQUIRED_FOR_DRAW) { | 372 if (task_set == REQUIRED_FOR_DRAW) { |
| 374 TRACE_EVENT1("cc", | 373 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTasks", "task_set", |
| 375 "TileManager::DidFinishRunningTasks", | |
| 376 "task_set", | |
| 377 "REQUIRED_FOR_DRAW"); | 374 "REQUIRED_FOR_DRAW"); |
| 378 ready_to_draw_check_notifier_.Schedule(); | 375 ready_to_draw_check_notifier_.Schedule(); |
| 379 return; | 376 return; |
| 380 } | 377 } |
| 381 | 378 |
| 382 if (task_set == REQUIRED_FOR_ACTIVATION) { | 379 if (task_set == REQUIRED_FOR_ACTIVATION) { |
| 383 TRACE_EVENT1("cc", | 380 TRACE_EVENT1("cc", |
| 384 "TileManager::DidFinishRunningTasks", | 381 "TileManager::DidFinishRunningTasks", |
| 385 "task_set", | 382 "task_set", |
| 386 "REQUIRED_FOR_ACTIVATION"); | 383 "REQUIRED_FOR_ACTIVATION"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 415 "state", | 412 "state", |
| 416 BasicStateAsValue()); | 413 BasicStateAsValue()); |
| 417 | 414 |
| 418 TRACE_COUNTER_ID1("cc", | 415 TRACE_COUNTER_ID1("cc", |
| 419 "unused_memory_bytes", | 416 "unused_memory_bytes", |
| 420 this, | 417 this, |
| 421 resource_pool_->total_memory_usage_bytes() - | 418 resource_pool_->total_memory_usage_bytes() - |
| 422 resource_pool_->acquired_memory_usage_bytes()); | 419 resource_pool_->acquired_memory_usage_bytes()); |
| 423 } | 420 } |
| 424 | 421 |
| 425 bool TileManager::UpdateVisibleTiles() { | 422 void TileManager::UpdateVisibleTiles() { |
| 426 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); | 423 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); |
| 427 | 424 |
| 428 rasterizer_->CheckForCompletedTasks(); | 425 rasterizer_->CheckForCompletedTasks(); |
| 429 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 426 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
| 430 | 427 |
| 431 TRACE_EVENT_INSTANT1( | 428 TRACE_EVENT_INSTANT1( |
| 432 "cc", | 429 "cc", |
| 433 "DidUpdateVisibleTiles", | 430 "DidUpdateVisibleTiles", |
| 434 TRACE_EVENT_SCOPE_THREAD, | 431 TRACE_EVENT_SCOPE_THREAD, |
| 435 "stats", | 432 "stats", |
| 436 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); | 433 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); |
| 437 update_visible_tiles_stats_ = RasterTaskCompletionStats(); | 434 update_visible_tiles_stats_ = RasterTaskCompletionStats(); |
| 438 | |
| 439 bool did_initialize_visible_tile = did_initialize_visible_tile_; | |
| 440 did_initialize_visible_tile_ = false; | |
| 441 return did_initialize_visible_tile; | |
| 442 } | 435 } |
| 443 | 436 |
| 444 scoped_refptr<base::debug::ConvertableToTraceFormat> | 437 scoped_refptr<base::debug::ConvertableToTraceFormat> |
| 445 TileManager::BasicStateAsValue() const { | 438 TileManager::BasicStateAsValue() const { |
| 446 scoped_refptr<base::debug::TracedValue> value = | 439 scoped_refptr<base::debug::TracedValue> value = |
| 447 new base::debug::TracedValue(); | 440 new base::debug::TracedValue(); |
| 448 BasicStateAsValueInto(value.get()); | 441 BasicStateAsValueInto(value.get()); |
| 449 return value; | 442 return value; |
| 450 } | 443 } |
| 451 | 444 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 ++update_visible_tiles_stats_.completed_count; | 803 ++update_visible_tiles_stats_.completed_count; |
| 811 | 804 |
| 812 if (analysis.is_solid_color) { | 805 if (analysis.is_solid_color) { |
| 813 mts.draw_info.set_solid_color(analysis.solid_color); | 806 mts.draw_info.set_solid_color(analysis.solid_color); |
| 814 resource_pool_->ReleaseResource(resource.Pass()); | 807 resource_pool_->ReleaseResource(resource.Pass()); |
| 815 } else { | 808 } else { |
| 816 mts.draw_info.set_use_resource(); | 809 mts.draw_info.set_use_resource(); |
| 817 mts.draw_info.resource_ = resource.Pass(); | 810 mts.draw_info.resource_ = resource.Pass(); |
| 818 } | 811 } |
| 819 | 812 |
| 820 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) | |
| 821 did_initialize_visible_tile_ = true; | |
| 822 | |
| 823 client_->NotifyTileStateChanged(tile); | 813 client_->NotifyTileStateChanged(tile); |
| 824 } | 814 } |
| 825 | 815 |
| 826 scoped_refptr<Tile> TileManager::CreateTile(RasterSource* raster_source, | 816 scoped_refptr<Tile> TileManager::CreateTile(RasterSource* raster_source, |
| 827 const gfx::Size& tile_size, | 817 const gfx::Size& tile_size, |
| 828 const gfx::Rect& content_rect, | 818 const gfx::Rect& content_rect, |
| 829 float contents_scale, | 819 float contents_scale, |
| 830 int layer_id, | 820 int layer_id, |
| 831 int source_frame_number, | 821 int source_frame_number, |
| 832 int flags) { | 822 int flags) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 861 return false; | 851 return false; |
| 862 } | 852 } |
| 863 | 853 |
| 864 return true; | 854 return true; |
| 865 } | 855 } |
| 866 | 856 |
| 867 bool TileManager::IsReadyToDraw() const { | 857 bool TileManager::IsReadyToDraw() const { |
| 868 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); | 858 const std::vector<PictureLayerImpl*>& layers = client_->GetPictureLayers(); |
| 869 | 859 |
| 870 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); | 860 for (std::vector<PictureLayerImpl*>::const_iterator it = layers.begin(); |
| 871 it != layers.end(); | 861 it != layers.end(); ++it) { |
| 872 ++it) { | |
| 873 if (!(*it)->AllTilesRequiredForDrawAreReadyToDraw()) | 862 if (!(*it)->AllTilesRequiredForDrawAreReadyToDraw()) |
| 874 return false; | 863 return false; |
| 875 } | 864 } |
| 876 | 865 |
| 877 return true; | 866 return true; |
| 878 } | 867 } |
| 879 | 868 |
| 880 void TileManager::CheckIfReadyToActivate() { | 869 void TileManager::CheckIfReadyToActivate() { |
| 881 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); | 870 TRACE_EVENT0("cc", "TileManager::CheckIfReadyToActivate"); |
| 882 | 871 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 result -= other; | 930 result -= other; |
| 942 return result; | 931 return result; |
| 943 } | 932 } |
| 944 | 933 |
| 945 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 934 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
| 946 return memory_bytes_ > limit.memory_bytes_ || | 935 return memory_bytes_ > limit.memory_bytes_ || |
| 947 resource_count_ > limit.resource_count_; | 936 resource_count_ > limit.resource_count_; |
| 948 } | 937 } |
| 949 | 938 |
| 950 } // namespace cc | 939 } // namespace cc |
| OLD | NEW |