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

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

Issue 2668873002: cc: Add checker-imaging support to TileManager. (Closed)
Patch Set: remove include 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
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_settings.h » ('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 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 732
732 // Debugging to check that remaining tiles in the priority queue are not in 733 // Debugging to check that remaining tiles in the priority queue are not in
733 // the NOW bin and are required for neither activation nor draw. 734 // the NOW bin and are required for neither activation nor draw.
734 // This runs if the following conditions hold: 735 // This runs if the following conditions hold:
735 // - check_tile_priority_inversion has been enabled. 736 // - check_tile_priority_inversion has been enabled.
736 // - the loop above has processed all tiles that would be needed for any 737 // - the loop above has processed all tiles that would be needed for any
737 // signals to fire (that is, 738 // signals to fire (that is,
738 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true) 739 // all_tiles_that_need_to_be_rasterized_are_scheduled_ is true)
739 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's 740 // - Memory limit policy allows for any tiles to be scheduled at all (ie it's
740 // not ALLOW_NOTHING). 741 // not ALLOW_NOTHING).
741 if (check_tile_priority_inversion_ && 742 if (tile_manager_settings_.check_tile_priority_inversion &&
742 all_tiles_that_need_to_be_rasterized_are_scheduled_ && 743 all_tiles_that_need_to_be_rasterized_are_scheduled_ &&
743 global_state_.memory_limit_policy != ALLOW_NOTHING) { 744 global_state_.memory_limit_policy != ALLOW_NOTHING) {
744 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW; 745 TilePriority::PriorityBin highest_bin_found = TilePriority::NOW;
745 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { 746 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
746 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top(); 747 const PrioritizedTile& prioritized_tile = raster_priority_queue->Top();
747 Tile* tile = prioritized_tile.tile(); 748 Tile* tile = prioritized_tile.tile();
748 TilePriority priority = prioritized_tile.priority(); 749 TilePriority priority = prioritized_tile.priority();
749 750
750 if (priority.priority_bin > highest_bin_found) 751 if (priority.priority_bin > highest_bin_found)
751 highest_bin_found = priority.priority_bin; 752 highest_bin_found = priority.priority_bin;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, 889 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++,
889 use_foreground_category); 890 use_foreground_category);
890 } 891 }
891 892
892 const std::vector<PrioritizedTile>& tiles_to_process_for_images = 893 const std::vector<PrioritizedTile>& tiles_to_process_for_images =
893 work_to_schedule.tiles_to_process_for_images; 894 work_to_schedule.tiles_to_process_for_images;
894 std::vector<DrawImage> new_locked_images; 895 std::vector<DrawImage> new_locked_images;
895 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) { 896 for (const PrioritizedTile& prioritized_tile : tiles_to_process_for_images) {
896 Tile* tile = prioritized_tile.tile(); 897 Tile* tile = prioritized_tile.tile();
897 898
899 // TODO(khushalsagar): Send these images to the ImageDecodeService, through
900 // the CheckerImageTracker as well. See crbug.com/691087.
898 std::vector<DrawImage> images; 901 std::vector<DrawImage> images;
899 prioritized_tile.raster_source()->GetDiscardableImagesInRect( 902 prioritized_tile.raster_source()->GetDiscardableImagesInRect(
900 tile->enclosing_layer_rect(), tile->contents_scale(), &images); 903 tile->enclosing_layer_rect(), tile->contents_scale(), &images);
901 new_locked_images.insert(new_locked_images.end(), images.begin(), 904 new_locked_images.insert(new_locked_images.end(), images.begin(),
902 images.end()); 905 images.end());
903 } 906 }
904 907
905 // TODO(vmpstr): SOON is misleading here, but these images can come from 908 // TODO(vmpstr): SOON is misleading here, but these images can come from
906 // several diffent tiles. Rethink what we actually want to trace here. Note 909 // several diffent tiles. Rethink what we actually want to trace here. Note
907 // that I'm using SOON, since it can't be NOW (these are prepaint). 910 // 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
990 } 993 }
991 994
992 // For LOW_RESOLUTION tiles, we don't draw or predecode images. 995 // For LOW_RESOLUTION tiles, we don't draw or predecode images.
993 RasterSource::PlaybackSettings playback_settings; 996 RasterSource::PlaybackSettings playback_settings;
994 playback_settings.skip_images = 997 playback_settings.skip_images =
995 prioritized_tile.priority().resolution == LOW_RESOLUTION; 998 prioritized_tile.priority().resolution == LOW_RESOLUTION;
996 999
997 // Create and queue all image decode tasks that this tile depends on. 1000 // Create and queue all image decode tasks that this tile depends on.
998 TileTask::Vector decode_tasks; 1001 TileTask::Vector decode_tasks;
999 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; 1002 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()];
1003 ImageIdFlatSet images_to_skip;
1000 images.clear(); 1004 images.clear();
1001 if (!playback_settings.skip_images) { 1005 if (!playback_settings.skip_images) {
1002 prioritized_tile.raster_source()->GetDiscardableImagesInRect( 1006 prioritized_tile.raster_source()->GetDiscardableImagesInRect(
1003 tile->enclosing_layer_rect(), tile->contents_scale(), &images); 1007 tile->enclosing_layer_rect(), tile->contents_scale(), &images);
1008 checker_image_tracker_.FilterImagesForCheckeringForTile(
1009 &images, &images_to_skip, prioritized_tile.tile()->tiling()->tree());
1004 } 1010 }
1005 1011
1006 // We can skip the image hijack canvas if we have no images. 1012 // We can skip the image hijack canvas if we have no images, or no images to
1007 playback_settings.use_image_hijack_canvas = !images.empty(); 1013 // skip during raster.
1014 playback_settings.use_image_hijack_canvas =
1015 !images.empty() || !images_to_skip.empty();
1016 playback_settings.images_to_skip = std::move(images_to_skip);
1008 1017
1009 // Get the tasks for the required images. 1018 // Get the tasks for the required images.
1010 ImageDecodeCache::TracingInfo tracing_info( 1019 ImageDecodeCache::TracingInfo tracing_info(
1011 prepare_tiles_count_, prioritized_tile.priority().priority_bin); 1020 prepare_tiles_count_, prioritized_tile.priority().priority_bin);
1012 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks, 1021 image_controller_.GetTasksForImagesAndRef(&images, &decode_tasks,
1013 tracing_info); 1022 tracing_info);
1014 1023
1015 std::unique_ptr<RasterBuffer> raster_buffer = 1024 std::unique_ptr<RasterBuffer> raster_buffer =
1016 raster_buffer_provider_->AcquireBufferForRaster( 1025 raster_buffer_provider_->AcquireBufferForRaster(
1017 resource, resource_content_id, tile->invalidated_id()); 1026 resource, resource_content_id, tile->invalidated_id());
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 // Mark required tiles as OOM so that we can activate/draw without them. 1273 // Mark required tiles as OOM so that we can activate/draw without them.
1265 for (; !queue->IsEmpty(); queue->Pop()) { 1274 for (; !queue->IsEmpty(); queue->Pop()) {
1266 Tile* tile = queue->Top().tile(); 1275 Tile* tile = queue->Top().tile();
1267 if (tile->draw_info().IsReadyToDraw()) 1276 if (tile->draw_info().IsReadyToDraw())
1268 continue; 1277 continue;
1269 tile->draw_info().set_oom(); 1278 tile->draw_info().set_oom();
1270 client_->NotifyTileStateChanged(tile); 1279 client_->NotifyTileStateChanged(tile);
1271 } 1280 }
1272 } 1281 }
1273 1282
1283 const ImageIdFlatSet& 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
1274 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { 1295 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const {
1275 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); 1296 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque());
1276 } 1297 }
1277 1298
1278 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { 1299 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const {
1279 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque()); 1300 return raster_buffer_provider_->IsResourceSwizzleRequired(!tile->is_opaque());
1280 } 1301 }
1281 1302
1282 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1303 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1283 TileManager::ScheduledTasksStateAsValue() const { 1304 TileManager::ScheduledTasksStateAsValue() const {
1284 std::unique_ptr<base::trace_event::TracedValue> state( 1305 std::unique_ptr<base::trace_event::TracedValue> state(
1285 new base::trace_event::TracedValue()); 1306 new base::trace_event::TracedValue());
1286 state->BeginDictionary("tasks_pending"); 1307 state->BeginDictionary("tasks_pending");
1287 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); 1308 state->SetBoolean("ready_to_activate", signals_.ready_to_activate);
1288 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); 1309 state->SetBoolean("ready_to_draw", signals_.ready_to_draw);
1289 state->SetBoolean("all_tile_tasks_completed", 1310 state->SetBoolean("all_tile_tasks_completed",
1290 signals_.all_tile_tasks_completed); 1311 signals_.all_tile_tasks_completed);
1291 state->EndDictionary(); 1312 state->EndDictionary();
1292 return std::move(state); 1313 return std::move(state);
1293 } 1314 }
1294 1315
1295 bool TileManager::UsePartialRaster() const { 1316 bool TileManager::UsePartialRaster() const {
1296 return use_partial_raster_ && 1317 return tile_manager_settings_.use_partial_raster &&
1297 raster_buffer_provider_->CanPartialRasterIntoProvidedResource(); 1318 raster_buffer_provider_->CanPartialRasterIntoProvidedResource();
1298 } 1319 }
1299 1320
1300 void TileManager::CheckPendingGpuWorkTiles(bool issue_signals) { 1321 void TileManager::CheckPendingGpuWorkTiles(bool issue_signals) {
1301 ResourceProvider::ResourceIdArray required_for_activation_ids; 1322 ResourceProvider::ResourceIdArray required_for_activation_ids;
1302 ResourceProvider::ResourceIdArray required_for_draw_ids; 1323 ResourceProvider::ResourceIdArray required_for_draw_ids;
1303 1324
1304 for (auto it = pending_gpu_work_tiles_.begin(); 1325 for (auto it = pending_gpu_work_tiles_.begin();
1305 it != pending_gpu_work_tiles_.end();) { 1326 it != pending_gpu_work_tiles_.end();) {
1306 Tile* tile = *it; 1327 Tile* tile = *it;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 all_tile_tasks_completed = false; 1469 all_tile_tasks_completed = false;
1449 did_notify_all_tile_tasks_completed = false; 1470 did_notify_all_tile_tasks_completed = false;
1450 } 1471 }
1451 1472
1452 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default; 1473 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule() = default;
1453 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule( 1474 TileManager::PrioritizedWorkToSchedule::PrioritizedWorkToSchedule(
1454 PrioritizedWorkToSchedule&& other) = default; 1475 PrioritizedWorkToSchedule&& other) = default;
1455 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default; 1476 TileManager::PrioritizedWorkToSchedule::~PrioritizedWorkToSchedule() = default;
1456 1477
1457 } // namespace cc 1478 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698