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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 Rasterizer* rasterizer, | 232 Rasterizer* rasterizer, |
233 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 233 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
234 size_t scheduled_raster_task_limit) | 234 size_t scheduled_raster_task_limit) |
235 : client_(client), | 235 : client_(client), |
236 task_runner_(task_runner), | 236 task_runner_(task_runner), |
237 resource_pool_(resource_pool), | 237 resource_pool_(resource_pool), |
238 rasterizer_(rasterizer), | 238 rasterizer_(rasterizer), |
239 scheduled_raster_task_limit_(scheduled_raster_task_limit), | 239 scheduled_raster_task_limit_(scheduled_raster_task_limit), |
240 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), | 240 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), |
241 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 241 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
242 did_initialize_visible_tile_(false), | |
243 did_check_for_completed_tasks_since_last_schedule_tasks_(true), | 242 did_check_for_completed_tasks_since_last_schedule_tasks_(true), |
244 did_oom_on_last_assign_(false), | 243 did_oom_on_last_assign_(false), |
244 has_active_visible_tile_scheduled_(false), | |
245 ready_to_activate_check_notifier_( | 245 ready_to_activate_check_notifier_( |
246 task_runner_.get(), | 246 task_runner_.get(), |
247 base::Bind(&TileManager::CheckIfReadyToActivate, | 247 base::Bind(&TileManager::CheckIfReadyToActivate, |
248 base::Unretained(this))) { | 248 base::Unretained(this))) { |
249 rasterizer_->SetClient(this); | 249 rasterizer_->SetClient(this); |
250 } | 250 } |
251 | 251 |
252 TileManager::~TileManager() { | 252 TileManager::~TileManager() { |
253 // Reset global state and manage. This should cause | 253 // Reset global state and manage. This should cause |
254 // our memory usage to drop to zero. | 254 // our memory usage to drop to zero. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 | 311 |
312 delete tile; | 312 delete tile; |
313 it = released_tiles_.erase(it); | 313 it = released_tiles_.erase(it); |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 void TileManager::DidFinishRunningTasks(TaskSet task_set) { | 317 void TileManager::DidFinishRunningTasks(TaskSet task_set) { |
318 if (task_set == ALL) { | 318 if (task_set == ALL) { |
319 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTasks", "task_set", "ALL"); | 319 TRACE_EVENT1("cc", "TileManager::DidFinishRunningTasks", "task_set", "ALL"); |
320 | 320 |
321 UpdateVisibleTiles(); | |
reveman
2014/10/30 16:58:17
UpdateVisibleTiles() is part of the public TileMan
danakj
2014/10/30 16:59:53
OK. It seems like we're just duplicating that func
| |
322 | |
321 bool memory_usage_above_limit = resource_pool_->total_memory_usage_bytes() > | 323 bool memory_usage_above_limit = resource_pool_->total_memory_usage_bytes() > |
322 global_state_.soft_memory_limit_in_bytes; | 324 global_state_.soft_memory_limit_in_bytes; |
323 | 325 |
324 // When OOM, keep re-assigning memory until we reach a steady state | 326 // When OOM, keep re-assigning memory until we reach a steady state |
325 // where top-priority tiles are initialized. | 327 // where top-priority tiles are initialized. |
326 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && | 328 if (all_tiles_that_need_to_be_rasterized_are_scheduled_ && |
327 !memory_usage_above_limit) | 329 !memory_usage_above_limit) |
328 return; | 330 return; |
329 | 331 |
330 rasterizer_->CheckForCompletedTasks(); | |
331 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | |
332 | |
333 TileVector tiles_that_need_to_be_rasterized; | 332 TileVector tiles_that_need_to_be_rasterized; |
334 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); | 333 AssignGpuMemoryToTiles(&tiles_that_need_to_be_rasterized); |
335 | 334 |
336 // |tiles_that_need_to_be_rasterized| will be empty when we reach a | 335 // |tiles_that_need_to_be_rasterized| will be empty when we reach a |
337 // steady memory state. Keep scheduling tasks until we reach this state. | 336 // steady memory state. Keep scheduling tasks until we reach this state. |
338 if (!tiles_that_need_to_be_rasterized.empty()) { | 337 if (!tiles_that_need_to_be_rasterized.empty()) { |
339 ScheduleTasks(tiles_that_need_to_be_rasterized); | 338 ScheduleTasks(tiles_that_need_to_be_rasterized); |
340 return; | 339 return; |
341 } | 340 } |
342 | 341 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 "state", | 422 "state", |
424 BasicStateAsValue()); | 423 BasicStateAsValue()); |
425 | 424 |
426 TRACE_COUNTER_ID1("cc", | 425 TRACE_COUNTER_ID1("cc", |
427 "unused_memory_bytes", | 426 "unused_memory_bytes", |
428 this, | 427 this, |
429 resource_pool_->total_memory_usage_bytes() - | 428 resource_pool_->total_memory_usage_bytes() - |
430 resource_pool_->acquired_memory_usage_bytes()); | 429 resource_pool_->acquired_memory_usage_bytes()); |
431 } | 430 } |
432 | 431 |
433 bool TileManager::UpdateVisibleTiles() { | 432 void TileManager::UpdateVisibleTiles() { |
434 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); | 433 TRACE_EVENT0("cc", "TileManager::UpdateVisibleTiles"); |
435 | 434 |
436 rasterizer_->CheckForCompletedTasks(); | 435 rasterizer_->CheckForCompletedTasks(); |
437 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 436 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
438 | 437 |
439 TRACE_EVENT_INSTANT1( | 438 TRACE_EVENT_INSTANT1( |
440 "cc", | 439 "cc", |
441 "DidUpdateVisibleTiles", | 440 "DidUpdateVisibleTiles", |
442 TRACE_EVENT_SCOPE_THREAD, | 441 TRACE_EVENT_SCOPE_THREAD, |
443 "stats", | 442 "stats", |
444 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); | 443 RasterTaskCompletionStatsAsValue(update_visible_tiles_stats_)); |
445 update_visible_tiles_stats_ = RasterTaskCompletionStats(); | 444 update_visible_tiles_stats_ = RasterTaskCompletionStats(); |
446 | |
447 bool did_initialize_visible_tile = did_initialize_visible_tile_; | |
448 did_initialize_visible_tile_ = false; | |
449 return did_initialize_visible_tile; | |
450 } | 445 } |
451 | 446 |
452 scoped_refptr<base::debug::ConvertableToTraceFormat> | 447 scoped_refptr<base::debug::ConvertableToTraceFormat> |
453 TileManager::BasicStateAsValue() const { | 448 TileManager::BasicStateAsValue() const { |
454 scoped_refptr<base::debug::TracedValue> value = | 449 scoped_refptr<base::debug::TracedValue> value = |
455 new base::debug::TracedValue(); | 450 new base::debug::TracedValue(); |
456 BasicStateAsValueInto(value.get()); | 451 BasicStateAsValueInto(value.get()); |
457 return value; | 452 return value; |
458 } | 453 } |
459 | 454 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 const TileVector& tiles_that_need_to_be_rasterized) { | 661 const TileVector& tiles_that_need_to_be_rasterized) { |
667 TRACE_EVENT1("cc", | 662 TRACE_EVENT1("cc", |
668 "TileManager::ScheduleTasks", | 663 "TileManager::ScheduleTasks", |
669 "count", | 664 "count", |
670 tiles_that_need_to_be_rasterized.size()); | 665 tiles_that_need_to_be_rasterized.size()); |
671 | 666 |
672 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); | 667 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); |
673 | 668 |
674 raster_queue_.Reset(); | 669 raster_queue_.Reset(); |
675 | 670 |
671 has_active_visible_tile_scheduled_ = false; | |
672 | |
676 // Build a new task queue containing all task currently needed. Tasks | 673 // Build a new task queue containing all task currently needed. Tasks |
677 // are added in order of priority, highest priority task first. | 674 // are added in order of priority, highest priority task first. |
678 for (TileVector::const_iterator it = tiles_that_need_to_be_rasterized.begin(); | 675 for (TileVector::const_iterator it = tiles_that_need_to_be_rasterized.begin(); |
679 it != tiles_that_need_to_be_rasterized.end(); | 676 it != tiles_that_need_to_be_rasterized.end(); |
680 ++it) { | 677 ++it) { |
681 Tile* tile = *it; | 678 Tile* tile = *it; |
682 ManagedTileState& mts = tile->managed_state(); | 679 ManagedTileState& mts = tile->managed_state(); |
683 | 680 |
681 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) { | |
682 has_active_visible_tile_scheduled_ = true; | |
683 } | |
684 | |
684 DCHECK(mts.draw_info.requires_resource()); | 685 DCHECK(mts.draw_info.requires_resource()); |
685 DCHECK(!mts.draw_info.resource_); | 686 DCHECK(!mts.draw_info.resource_); |
686 | 687 |
687 if (!mts.raster_task.get()) | 688 if (!mts.raster_task.get()) |
688 mts.raster_task = CreateRasterTask(tile); | 689 mts.raster_task = CreateRasterTask(tile); |
689 | 690 |
690 TaskSetCollection task_sets; | 691 TaskSetCollection task_sets; |
691 if (tile->required_for_activation()) | 692 if (tile->required_for_activation()) |
692 task_sets.set(REQUIRED_FOR_ACTIVATION); | 693 task_sets.set(REQUIRED_FOR_ACTIVATION); |
693 task_sets.set(ALL); | 694 task_sets.set(ALL); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
815 ++update_visible_tiles_stats_.completed_count; | 816 ++update_visible_tiles_stats_.completed_count; |
816 | 817 |
817 if (analysis.is_solid_color) { | 818 if (analysis.is_solid_color) { |
818 mts.draw_info.set_solid_color(analysis.solid_color); | 819 mts.draw_info.set_solid_color(analysis.solid_color); |
819 resource_pool_->ReleaseResource(resource.Pass()); | 820 resource_pool_->ReleaseResource(resource.Pass()); |
820 } else { | 821 } else { |
821 mts.draw_info.set_use_resource(); | 822 mts.draw_info.set_use_resource(); |
822 mts.draw_info.resource_ = resource.Pass(); | 823 mts.draw_info.resource_ = resource.Pass(); |
823 } | 824 } |
824 | 825 |
825 if (tile->priority(ACTIVE_TREE).distance_to_visible == 0.f) | |
826 did_initialize_visible_tile_ = true; | |
827 | |
828 client_->NotifyTileStateChanged(tile); | 826 client_->NotifyTileStateChanged(tile); |
829 } | 827 } |
830 | 828 |
831 scoped_refptr<Tile> TileManager::CreateTile(RasterSource* raster_source, | 829 scoped_refptr<Tile> TileManager::CreateTile(RasterSource* raster_source, |
832 const gfx::Size& tile_size, | 830 const gfx::Size& tile_size, |
833 const gfx::Rect& content_rect, | 831 const gfx::Rect& content_rect, |
834 float contents_scale, | 832 float contents_scale, |
835 int layer_id, | 833 int layer_id, |
836 int source_frame_number, | 834 int source_frame_number, |
837 int flags) { | 835 int flags) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 result -= other; | 920 result -= other; |
923 return result; | 921 return result; |
924 } | 922 } |
925 | 923 |
926 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { | 924 bool TileManager::MemoryUsage::Exceeds(const MemoryUsage& limit) const { |
927 return memory_bytes_ > limit.memory_bytes_ || | 925 return memory_bytes_ > limit.memory_bytes_ || |
928 resource_count_ > limit.resource_count_; | 926 resource_count_ > limit.resource_count_; |
929 } | 927 } |
930 | 928 |
931 } // namespace cc | 929 } // namespace cc |
OLD | NEW |