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

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

Issue 2668873002: cc: Add checker-imaging support to TileManager. (Closed)
Patch Set: all tests Created 3 years, 10 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
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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 345 TileManager::TileManager(
346 TileManagerClient* client, 346 TileManagerClient* client,
347 base::SequencedTaskRunner* origin_task_runner, 347 base::SequencedTaskRunner* origin_task_runner,
348 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner, 348 scoped_refptr<base::SequencedTaskRunner> image_worker_task_runner,
349 size_t scheduled_raster_task_limit, 349 size_t scheduled_raster_task_limit,
350 bool use_partial_raster, 350 const TileManagerSettings& tile_manager_settings)
351 bool check_tile_priority_inversion)
352 : client_(client), 351 : client_(client),
353 task_runner_(origin_task_runner), 352 task_runner_(origin_task_runner),
354 resource_pool_(nullptr), 353 resource_pool_(nullptr),
355 tile_task_manager_(nullptr), 354 tile_task_manager_(nullptr),
356 scheduled_raster_task_limit_(scheduled_raster_task_limit), 355 scheduled_raster_task_limit_(scheduled_raster_task_limit),
357 use_partial_raster_(use_partial_raster), 356 tile_manager_settings_(tile_manager_settings),
358 use_gpu_rasterization_(false), 357 use_gpu_rasterization_(false),
359 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 358 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
360 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 359 did_check_for_completed_tasks_since_last_schedule_tasks_(true),
361 did_oom_on_last_assign_(false), 360 did_oom_on_last_assign_(false),
362 image_controller_(origin_task_runner, 361 image_controller_(origin_task_runner,
363 std::move(image_worker_task_runner)), 362 std::move(image_worker_task_runner)),
363 checker_image_tracker_(&image_controller_,
364 this,
365 tile_manager_settings_.enable_checker_imaging),
364 more_tiles_need_prepare_check_notifier_( 366 more_tiles_need_prepare_check_notifier_(
365 task_runner_, 367 task_runner_,
366 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, 368 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared,
367 base::Unretained(this))), 369 base::Unretained(this))),
368 signals_check_notifier_(task_runner_, 370 signals_check_notifier_(task_runner_,
369 base::Bind(&TileManager::CheckAndIssueSignals, 371 base::Bind(&TileManager::CheckAndIssueSignals,
370 base::Unretained(this))), 372 base::Unretained(this))),
371 has_scheduled_tile_tasks_(false), 373 has_scheduled_tile_tasks_(false),
372 prepare_tiles_count_(0u), 374 prepare_tiles_count_(0u),
373 next_tile_id_(0u), 375 next_tile_id_(0u),
374 check_tile_priority_inversion_(check_tile_priority_inversion),
375 task_set_finished_weak_ptr_factory_(this), 376 task_set_finished_weak_ptr_factory_(this),
376 ready_to_draw_callback_weak_ptr_factory_(this) {} 377 ready_to_draw_callback_weak_ptr_factory_(this) {}
377 378
378 TileManager::~TileManager() { 379 TileManager::~TileManager() {
379 FinishTasksAndCleanUp(); 380 FinishTasksAndCleanUp();
380 } 381 }
381 382
382 void TileManager::FinishTasksAndCleanUp() { 383 void TileManager::FinishTasksAndCleanUp() {
383 if (!tile_task_manager_) 384 if (!tile_task_manager_)
384 return; 385 return;
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 733
733 // Debugging to check that remaining tiles in the priority queue are not in 734 // Debugging to check that remaining tiles in the priority queue are not in
734 // the NOW bin and are required for neither activation nor draw. 735 // the NOW bin and are required for neither activation nor draw.
735 // This runs if the following conditions hold: 736 // This runs if the following conditions hold:
736 // - check_tile_priority_inversion has been enabled. 737 // - check_tile_priority_inversion has been enabled.
737 // - the loop above has processed all tiles that would be needed for any 738 // - the loop above has processed all tiles that would be needed for any
738 // signals to fire (that is, 739 // signals to fire (that is,
739 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true) 740 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true)
740 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's 741 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's
741 // not ALLOW_NOTHING). 742 // not ALLOW_NOTHING).
742 if (check_tile_priority_inversion_ && 743 if (tile_manager_settings_.check_tile_priority_inversion &&
743 all_tiles_that_need_to_be_rasterized_are_scheduled_ && 744 all_tiles_that_need_to_be_rasterized_are_scheduled_ &&
744 global_state_.memory_limit_policy != ALLOW_NOTHING) { 745 global_state_.memory_limit_policy != ALLOW_NOTHING) {
745 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW; 746 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW;
746 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { 747 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
747 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); 748 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top();
748 Tile* tile = prioritized_tile.tile(); 749 Tile* tile = prioritized_tile.tile();
749 TilePriority priority = prioritized_tile.priority(); 750 TilePriority priority = prioritized_tile.priority();
750 751
751 if (priority.priority_bin > highest_bin_found) 752 if (priority.priority_bin > highest_bin_found)
752 highest_bin_found = priority.priority_bin; 753 highest_bin_found = priority.priority_bin;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, 888 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++,
888 use_foreground_category); 889 use_foreground_category);
889 } 890 }
890 891
891 const std::vector<PrioritizedTile>& tiles_to_process_for_images = 892 const std::vector<PrioritizedTile>& tiles_to_process_for_images =
892 work_to_schedule.tiles_to_process_for_images; 893 work_to_schedule.tiles_to_process_for_images;
893 std::vector<DrawImage> new_locked_images; 894 std::vector<DrawImage> new_locked_images;
894 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { 895 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) {
895 Tile* tile = prioritized_tile.tile(); 896 Tile* tile = prioritized_tile.tile();
896 897
898 // TODO(khushalsagar): Send these images to the ImageDecodeService, through
899 // the CheckerImageTracker as well. See crbug.com/691087.
897 std::vector<DrawImage> images; 900 std::vector<DrawImage> images;
898 prioritized_tile.raster_source()->GetDiscardableImagesInRect( 901 prioritized_tile.raster_source()->GetDiscardableImagesInRect(
899 tile->enclosing_layer_rect(), tile->contents_scale(), &images); 902 tile->enclosing_layer_rect(), tile->contents_scale(), &images);
900 new_locked_images.insert(new_locked_images.end(), images.begin(), 903 new_locked_images.insert(new_locked_images.end(), images.begin(),
901 images.end()); 904 images.end());
902 } 905 }
903 906
904 // TODO(vmpstr): SOON is misleading here, but these images can come from 907 // TODO(vmpstr): SOON is misleading here, but these images can come from
905 // several diffent tiles. Rethink what we actually want to trace here. Note 908 // several diffent tiles. Rethink what we actually want to trace here. Note
906 // that I'm using SOON, since it can't be NOW (these are prepaint). 909 // that I'm using SOON, since it can't be NOW (these are prepaint).
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 } 992 }
990 993
991 // For LOW_RESOLUTION tiles, we don't draw or predecode images. 994 // For LOW_RESOLUTION tiles, we don't draw or predecode images.
992 RasterSource::PlaybackSettings playback_settings; 995 RasterSource::PlaybackSettings playback_settings;
993 playback_settings.skip_images = 996 playback_settings.skip_images =
994 prioritized_tile.priority().resolution == LOW_RESOLUTION; 997 prioritized_tile.priority().resolution == LOW_RESOLUTION;
995 998
996 // Create and queue all image decode tasks that this tile depends on. 999 // Create and queue all image decode tasks that this tile depends on.
997 TileTask::Vector decode_tasks; 1000 TileTask::Vector decode_tasks;
998 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; 1001 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()];
1002 ImageIdFlatSet images_to_skip;
999 images.clear(); 1003 images.clear();
1000 if (!playback_settings.skip_images) { 1004 if (!playback_settings.skip_images) {
1001 prioritized_tile.raster_source()->GetDiscardableImagesInRect( 1005 prioritized_tile.raster_source()->GetDiscardableImagesInRect(
1002 tile->enclosing_layer_rect(), tile->contents_scale(), &images); 1006 tile->enclosing_layer_rect(), tile->contents_scale(), &images);
1007 checker_image_tracker_.FilterImagesForCheckeringForTile(
1008 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree());
1003 } 1009 }
1004 1010
1005 // We can skip the image hijack canvas if we have no images. 1011 // We can skip the image hijack canvas if we have no images, or no images to
1006 playback_settings.use_image_hijack_canvas = !images.empty(); 1012 // skip during raster.
1013 playback_settings.use_image_hijack_canvas =
1014 !images.empty() || !images_to_skip.empty();
1015 playback_settings.images_to_skip = std::move(images_to_skip);
1007 1016
1008 // Get the tasks for the required images. 1017 // Get the tasks for the required images.
1009 ImageDecodeCache::TracingInfo tracing_info( 1018 ImageDecodeCache::TracingInfo tracing_info(
1010 prepare_tiles_count_, prioritized_tile.priority().priority_bin); 1019 prepare_tiles_count_, prioritized_tile.priority().priority_bin);
1011 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, 1020 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks,
1012 tracing_info); 1021 tracing_info);
1013 1022
1014 std::unique_ptr<RasterBuffer> raster_buffer = 1023 std::unique_ptr<RasterBuffer> raster_buffer =
1015 raster_buffer_provider_->AcquireBufferForRaster( 1024 raster_buffer_provider_->AcquireBufferForRaster(
1016 resource, resource_content_id, tile->invalidated_id()); 1025 resource, resource_content_id, tile->invalidated_id());
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 // Mark required tiles as OOM so that we can activate/draw without them. 1272 // Mark required tiles as OOM so that we can activate/draw without them.
1264 for (; !queue->IsEmpty(); queue->Pop()) { 1273 for (; !queue->IsEmpty(); queue->Pop()) {
1265 Tile* tile = queue->Top().tile(); 1274 Tile* tile = queue->Top().tile();
1266 if (tile->draw_info().IsReadyToDraw()) 1275 if (tile->draw_info().IsReadyToDraw())
1267 continue; 1276 continue;
1268 tile->draw_info().set_oom(); 1277 tile->draw_info().set_oom();
1269 client_->NotifyTileStateChanged(tile); 1278 client_->NotifyTileStateChanged(tile);
1270 } 1279 }
1271 } 1280 }
1272 1281
1282 const std::unordered_set<ImageId>&
1283 TileManager::TakeImagesToInvalidateOnSyncTree() {
1284 return checker_image_tracker_.TakeImagesToInvalidateOnSyncTree();
1285 }
1286
1287 void TileManager::DidActivateSyncTree() {
1288 checker_image_tracker_.DidActivateSyncTree();
1289 }
1290
1291 void TileManager::NeedsInvalidationForCheckerImagedTiles() {
1292 client_->RequestImplSideInvalidation();
1293 }
1294
1273 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { 1295 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const {
1274 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); 1296 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque());
1275 } 1297 }
1276 1298
1277 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { 1299 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const {
1278 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); 1300 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque());
1279 } 1301 }
1280 1302
1281 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1303 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1282 TileManager::ScheduledTasksStateAsValue() const { 1304 TileManager::ScheduledTasksStateAsValue() const {
1283 std::unique_ptr<base::trace_event::TracedValue> state( 1305 std::unique_ptr<base::trace_event::TracedValue> state(
1284 new base::trace_event::TracedValue()); 1306 new base::trace_event::TracedValue());
1285 state->BeginDictionary("tasks_pending"); 1307 state->BeginDictionary("tasks_pending");
1286 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); 1308 state->SetBoolean("ready_to_activate", signals_.ready_to_activate);
1287 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); 1309 state->SetBoolean("ready_to_draw", signals_.ready_to_draw);
1288 state->SetBoolean("all_tile_tasks_completed", 1310 state->SetBoolean("all_tile_tasks_completed",
1289 signals_.all_tile_tasks_completed); 1311 signals_.all_tile_tasks_completed);
1290 state->EndDictionary(); 1312 state->EndDictionary();
1291 return std::move(state); 1313 return std::move(state);
1292 } 1314 }
1293 1315
1294 bool TileManager::UsePartialRaster() const { 1316 bool TileManager::UsePartialRaster() const {
1295 return use_partial_raster_ && 1317 return tile_manager_settings_.use_partial_raster &&
1296 raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); 1318 raster_buffer_provider_->CanPartialRasterIntoProvidedResource();
1297 } 1319 }
1298 1320
1299 void TileManager::CheckPendingGpuWorkTiles(bool issue_signals) { 1321 void TileManager::CheckPendingGpuWorkTiles(bool issue_signals) {
1300 ResourceProvider::ResourceIdArray required_for_activation_ids; 1322 ResourceProvider::ResourceIdArray required_for_activation_ids;
1301 ResourceProvider::ResourceIdArray required_for_draw_ids; 1323 ResourceProvider::ResourceIdArray required_for_draw_ids;
1302 1324
1303 for (auto it = pending_gpu_work_tiles_.begin(); 1325 for (auto it = pending_gpu_work_tiles_.begin();
1304 it != pending_gpu_work_tiles_.end();) { 1326 it != pending_gpu_work_tiles_.end();) {
1305 Tile* tile = *it; 1327 Tile* tile = *it;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 all_tile_tasks_completed = false; 1468 all_tile_tasks_completed = false;
1447 did_notify_all_tile_tasks_completed = false; 1469 did_notify_all_tile_tasks_completed = false;
1448 } 1470 }
1449 1471
1450 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; 1472 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default;
1451 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( 1473 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule(
1452 PrioritizedWorkToSchedule&& other) = default; 1474 PrioritizedWorkToSchedule&& other) = default;
1453 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; 1475 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default;
1454 1476
1455 } // namespace cc 1477 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698