Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: cc/tiles/tile_manager.cc

Issue 2612123002: cc: Add a flag to check for tile priority inversion in AssignGpuMemory. (Closed)
Patch Set: master: compile_fix Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 state->SetInteger("completed_count", 338 state->SetInteger("completed_count",
339 base::saturated_cast<int>(stats.completed_count)); 339 base::saturated_cast<int>(stats.completed_count));
340 state->SetInteger("canceled_count", 340 state->SetInteger("canceled_count",
341 base::saturated_cast<int>(stats.canceled_count)); 341 base::saturated_cast<int>(stats.canceled_count));
342 return std::move(state); 342 return std::move(state);
343 } 343 }
344 344
345 TileManager::TileManager(TileManagerClient* client, 345 TileManager::TileManager(TileManagerClient* client,
346 base::SequencedTaskRunner* task_runner, 346 base::SequencedTaskRunner* task_runner,
347 size_t scheduled_raster_task_limit, 347 size_t scheduled_raster_task_limit,
348 bool use_partial_raster) 348 bool use_partial_raster,
349 bool check_tile_priority_inversion)
349 : client_(client), 350 : client_(client),
350 task_runner_(task_runner), 351 task_runner_(task_runner),
351 resource_pool_(nullptr), 352 resource_pool_(nullptr),
352 tile_task_manager_(nullptr), 353 tile_task_manager_(nullptr),
353 scheduled_raster_task_limit_(scheduled_raster_task_limit), 354 scheduled_raster_task_limit_(scheduled_raster_task_limit),
354 use_partial_raster_(use_partial_raster), 355 use_partial_raster_(use_partial_raster),
355 use_gpu_rasterization_(false), 356 use_gpu_rasterization_(false),
356 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 357 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
357 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 358 did_check_for_completed_tasks_since_last_schedule_tasks_(true),
358 did_oom_on_last_assign_(false), 359 did_oom_on_last_assign_(false),
359 more_tiles_need_prepare_check_notifier_( 360 more_tiles_need_prepare_check_notifier_(
360 task_runner_, 361 task_runner_,
361 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, 362 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared,
362 base::Unretained(this))), 363 base::Unretained(this))),
363 signals_check_notifier_(task_runner_, 364 signals_check_notifier_(task_runner_,
364 base::Bind(&TileManager::CheckAndIssueSignals, 365 base::Bind(&TileManager::CheckAndIssueSignals,
365 base::Unretained(this))), 366 base::Unretained(this))),
366 has_scheduled_tile_tasks_(false), 367 has_scheduled_tile_tasks_(false),
367 prepare_tiles_count_(0u), 368 prepare_tiles_count_(0u),
368 next_tile_id_(0u), 369 next_tile_id_(0u),
370 check_tile_priority_inversion_(check_tile_priority_inversion),
369 task_set_finished_weak_ptr_factory_(this) {} 371 task_set_finished_weak_ptr_factory_(this) {}
370 372
371 TileManager::~TileManager() { 373 TileManager::~TileManager() {
372 FinishTasksAndCleanUp(); 374 FinishTasksAndCleanUp();
373 } 375 }
374 376
375 void TileManager::FinishTasksAndCleanUp() { 377 void TileManager::FinishTasksAndCleanUp() {
376 if (!tile_task_manager_) 378 if (!tile_task_manager_)
377 return; 379 return;
378 380
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 work_to_schedule.tiles_to_raster.push_back(prioritized_tile); 748 work_to_schedule.tiles_to_raster.push_back(prioritized_tile);
747 749
748 // Since we scheduled the tile, set whether it was a prepaint or not 750 // Since we scheduled the tile, set whether it was a prepaint or not
749 // assuming that the tile will successfully finish running. We don't have 751 // assuming that the tile will successfully finish running. We don't have
750 // priority information at the time the tile completes, so it should be done 752 // priority information at the time the tile completes, so it should be done
751 // here. 753 // here.
752 if (!tile_is_needed_now) 754 if (!tile_is_needed_now)
753 tile->draw_info().set_was_a_prepaint_tile(); 755 tile->draw_info().set_was_a_prepaint_tile();
754 } 756 }
755 757
758 // Debugging to check that remaining tiles in the priority queue are not in
759 // the NOW bin and are required for neither activation nor draw.
760 // This runs if the following conditions hold:
761 // - check_tile_priority_inversion has been enabled.
762 // - the loop above has processed all tiles that would be needed for any
763 // signals to fire (that is,
764 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true)
765 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's
766 // not ALLOW_NOTHING).
767 if (check_tile_priority_inversion_ &&
768 all_tiles_that_need_to_be_rasterized_are_scheduled_ &&
769 global_state_.memory_limit_policy != ALLOW_NOTHING) {
770 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW;
771 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
772 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top();
773 Tile* tile = prioritized_tile.tile();
774 TilePriority priority = prioritized_tile.priority();
775
776 if (priority.priority_bin > highest_bin_found)
777 highest_bin_found = priority.priority_bin;
778
779 CHECK_NE(TilePriority::NOW, priority.priority_bin)
780 << "mode: " << global_state_.tree_priority
781 << " highest bin: " << highest_bin_found;
782 CHECK(!tile->required_for_activation())
783 << "mode: " << global_state_.tree_priority
784 << " bin: " << priority.priority_bin
785 << " highest bin: " << highest_bin_found;
786 CHECK(!tile->required_for_draw())
787 << "mode: " << global_state_.tree_priority
788 << " bin: " << priority.priority_bin
789 << " highest bin: " << highest_bin_found;
790 }
791 }
792
756 // Note that we should try and further reduce memory in case the above loop 793 // Note that we should try and further reduce memory in case the above loop
757 // didn't reduce memory. This ensures that we always release as many resources 794 // didn't reduce memory. This ensures that we always release as many resources
758 // as possible to stay within the memory limit. 795 // as possible to stay within the memory limit.
759 eviction_priority_queue = FreeTileResourcesUntilUsageIsWithinLimit( 796 eviction_priority_queue = FreeTileResourcesUntilUsageIsWithinLimit(
760 std::move(eviction_priority_queue), hard_memory_limit, &memory_usage); 797 std::move(eviction_priority_queue), hard_memory_limit, &memory_usage);
761 798
762 UMA_HISTOGRAM_BOOLEAN("TileManager.ExceededMemoryBudget", 799 UMA_HISTOGRAM_BOOLEAN("TileManager.ExceededMemoryBudget",
763 !had_enough_memory_to_schedule_tiles_needed_now); 800 !had_enough_memory_to_schedule_tiles_needed_now);
764 did_oom_on_last_assign_ = !had_enough_memory_to_schedule_tiles_needed_now; 801 did_oom_on_last_assign_ = !had_enough_memory_to_schedule_tiles_needed_now;
765 802
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 all_tile_tasks_completed = false; 1382 all_tile_tasks_completed = false;
1346 did_notify_all_tile_tasks_completed = false; 1383 did_notify_all_tile_tasks_completed = false;
1347 } 1384 }
1348 1385
1349 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; 1386 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default;
1350 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( 1387 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule(
1351 PrioritizedWorkToSchedule&& other) = default; 1388 PrioritizedWorkToSchedule&& other) = default;
1352 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; 1389 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default;
1353 1390
1354 } // namespace cc 1391 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698