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

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

Issue 2046033002: Revert of cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: Created 4 years, 6 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_unittest.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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 void TileManager::FinishTasksAndCleanUp() { 337 void TileManager::FinishTasksAndCleanUp() {
338 if (!tile_task_manager_) 338 if (!tile_task_manager_)
339 return; 339 return;
340 340
341 global_state_ = GlobalStateThatImpactsTilePriority(); 341 global_state_ = GlobalStateThatImpactsTilePriority();
342 342
343 // This cancels tasks if possible, finishes pending tasks, and release any 343 // This cancels tasks if possible, finishes pending tasks, and release any
344 // uninitialized resources. 344 // uninitialized resources.
345 tile_task_manager_->Shutdown(); 345 tile_task_manager_->Shutdown();
346 346
347 raster_buffer_provider_->Shutdown(); 347 // Now that all tasks have been finished, we can clear any
348 348 // |orphan_tasks_|.
349 // Now that all tasks have been finished, we can clear any |orphan_tasks_|.
350 orphan_tasks_.clear(); 349 orphan_tasks_.clear();
351 350
352 tile_task_manager_->CheckForCompletedTasks(); 351 tile_task_manager_->CheckForCompletedTasks();
353 352
354 FreeResourcesForReleasedTiles(); 353 FreeResourcesForReleasedTiles();
355 CleanUpReleasedTiles(); 354 CleanUpReleasedTiles();
356 355
357 tile_task_manager_ = nullptr; 356 tile_task_manager_ = nullptr;
358 resource_pool_ = nullptr; 357 resource_pool_ = nullptr;
359 more_tiles_need_prepare_check_notifier_.Cancel(); 358 more_tiles_need_prepare_check_notifier_.Cancel();
360 signals_check_notifier_.Cancel(); 359 signals_check_notifier_.Cancel();
361 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); 360 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs();
362 } 361 }
363 362
364 void TileManager::SetResources(ResourcePool* resource_pool, 363 void TileManager::SetResources(ResourcePool* resource_pool,
365 ImageDecodeController* image_decode_controller, 364 ImageDecodeController* image_decode_controller,
366 TileTaskManager* tile_task_manager, 365 TileTaskManager* tile_task_manager,
367 RasterBufferProvider* raster_buffer_provider,
368 size_t scheduled_raster_task_limit, 366 size_t scheduled_raster_task_limit,
369 bool use_gpu_rasterization) { 367 bool use_gpu_rasterization) {
370 DCHECK(!tile_task_manager_); 368 DCHECK(!tile_task_manager_);
371 DCHECK(tile_task_manager); 369 DCHECK(tile_task_manager);
372 370
373 use_gpu_rasterization_ = use_gpu_rasterization; 371 use_gpu_rasterization_ = use_gpu_rasterization;
374 scheduled_raster_task_limit_ = scheduled_raster_task_limit; 372 scheduled_raster_task_limit_ = scheduled_raster_task_limit;
375 resource_pool_ = resource_pool; 373 resource_pool_ = resource_pool;
376 image_decode_controller_ = image_decode_controller; 374 image_decode_controller_ = image_decode_controller;
377 tile_task_manager_ = tile_task_manager; 375 tile_task_manager_ = tile_task_manager;
378 raster_buffer_provider_ = raster_buffer_provider;
379 } 376 }
380 377
381 void TileManager::Release(Tile* tile) { 378 void TileManager::Release(Tile* tile) {
382 released_tiles_.push_back(tile); 379 released_tiles_.push_back(tile);
383 } 380 }
384 381
385 void TileManager::FreeResourcesForReleasedTiles() { 382 void TileManager::FreeResourcesForReleasedTiles() {
386 for (auto* tile : released_tiles_) 383 for (auto* tile : released_tiles_)
387 FreeResourcesForTile(tile); 384 FreeResourcesForTile(tile);
388 } 385 }
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 kRequiredForDrawDoneTaskPriority, required_for_draw_count); 828 kRequiredForDrawDoneTaskPriority, required_for_draw_count);
832 InsertNodeForTask(&graph_, all_done_task.get(), 829 InsertNodeForTask(&graph_, all_done_task.get(),
833 TASK_CATEGORY_NONCONCURRENT_FOREGROUND, 830 TASK_CATEGORY_NONCONCURRENT_FOREGROUND,
834 kAllDoneTaskPriority, all_count); 831 kAllDoneTaskPriority, all_count);
835 832
836 // We must reduce the amount of unused resoruces before calling 833 // We must reduce the amount of unused resoruces before calling
837 // ScheduleTasks to prevent usage from rising above limits. 834 // ScheduleTasks to prevent usage from rising above limits.
838 resource_pool_->ReduceResourceUsage(); 835 resource_pool_->ReduceResourceUsage();
839 image_decode_controller_->ReduceCacheUsage(); 836 image_decode_controller_->ReduceCacheUsage();
840 837
841 // Synchronize worker with compositor.
842 raster_buffer_provider_->OrderingBarrier();
843
844 // Schedule running of |raster_queue_|. This replaces any previously 838 // Schedule running of |raster_queue_|. This replaces any previously
845 // scheduled tasks and effectively cancels all tasks not present 839 // scheduled tasks and effectively cancels all tasks not present
846 // in |raster_queue_|. 840 // in |raster_queue_|.
847 tile_task_manager_->ScheduleTasks(&graph_); 841 tile_task_manager_->ScheduleTasks(&graph_);
848 842
849 // It's now safe to clean up orphan tasks as raster worker pool is not 843 // It's now safe to clean up orphan tasks as raster worker pool is not
850 // allowed to keep around unreferenced raster tasks after ScheduleTasks() has 844 // allowed to keep around unreferenced raster tasks after ScheduleTasks() has
851 // been called. 845 // been called.
852 orphan_tasks_.clear(); 846 orphan_tasks_.clear();
853 847
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 decode_tasks.push_back(task); 905 decode_tasks.push_back(task);
912 906
913 if (need_to_unref_when_finished) 907 if (need_to_unref_when_finished)
914 ++it; 908 ++it;
915 else 909 else
916 it = images.erase(it); 910 it = images.erase(it);
917 } 911 }
918 912
919 bool supports_concurrent_execution = !use_gpu_rasterization_; 913 bool supports_concurrent_execution = !use_gpu_rasterization_;
920 std::unique_ptr<RasterBuffer> raster_buffer = 914 std::unique_ptr<RasterBuffer> raster_buffer =
921 raster_buffer_provider_->AcquireBufferForRaster( 915 tile_task_manager_->GetRasterBufferProvider()->AcquireBufferForRaster(
922 resource, resource_content_id, tile->invalidated_id()); 916 resource, resource_content_id, tile->invalidated_id());
923 return make_scoped_refptr(new RasterTaskImpl( 917 return make_scoped_refptr(new RasterTaskImpl(
924 this, tile, resource, prioritized_tile.raster_source(), playback_settings, 918 this, tile, resource, prioritized_tile.raster_source(), playback_settings,
925 prioritized_tile.priority().resolution, prepare_tiles_count_, 919 prioritized_tile.priority().resolution, prepare_tiles_count_,
926 std::move(raster_buffer), &decode_tasks, supports_concurrent_execution)); 920 std::move(raster_buffer), &decode_tasks, supports_concurrent_execution));
927 } 921 }
928 922
929 void TileManager::OnRasterTaskCompleted( 923 void TileManager::OnRasterTaskCompleted(
930 std::unique_ptr<RasterBuffer> raster_buffer, 924 std::unique_ptr<RasterBuffer> raster_buffer,
931 Tile* tile, 925 Tile* tile,
932 Resource* resource, 926 Resource* resource,
933 bool was_canceled) { 927 bool was_canceled) {
934 DCHECK(tile); 928 DCHECK(tile);
935 DCHECK(tiles_.find(tile->id()) != tiles_.end()); 929 DCHECK(tiles_.find(tile->id()) != tiles_.end());
936 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer)); 930 tile_task_manager_->GetRasterBufferProvider()->ReleaseBufferForRaster(
931 std::move(raster_buffer));
937 932
938 TileDrawInfo& draw_info = tile->draw_info(); 933 TileDrawInfo& draw_info = tile->draw_info();
939 DCHECK(tile->raster_task_.get()); 934 DCHECK(tile->raster_task_.get());
940 orphan_tasks_.push_back(tile->raster_task_); 935 orphan_tasks_.push_back(tile->raster_task_);
941 tile->raster_task_ = nullptr; 936 tile->raster_task_ = nullptr;
942 937
943 // Unref all the images. 938 // Unref all the images.
944 auto images_it = scheduled_draw_images_.find(tile->id()); 939 auto images_it = scheduled_draw_images_.find(tile->id());
945 const std::vector<DrawImage>& images = images_it->second; 940 const std::vector<DrawImage>& images = images_it->second;
946 for (const auto& image : images) 941 for (const auto& image : images)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 977
983 tiles_[tile->id()] = tile.get(); 978 tiles_[tile->id()] = tile.get();
984 return tile; 979 return tile;
985 } 980 }
986 981
987 void TileManager::SetTileTaskManagerForTesting( 982 void TileManager::SetTileTaskManagerForTesting(
988 TileTaskManager* tile_task_manager) { 983 TileTaskManager* tile_task_manager) {
989 tile_task_manager_ = tile_task_manager; 984 tile_task_manager_ = tile_task_manager;
990 } 985 }
991 986
992 void TileManager::SetRasterBufferProviderForTesting(
993 RasterBufferProvider* raster_buffer_provider) {
994 raster_buffer_provider_ = raster_buffer_provider;
995 }
996
997 bool TileManager::AreRequiredTilesReadyToDraw( 987 bool TileManager::AreRequiredTilesReadyToDraw(
998 RasterTilePriorityQueue::Type type) const { 988 RasterTilePriorityQueue::Type type) const {
999 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 989 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
1000 client_->BuildRasterQueue(global_state_.tree_priority, type)); 990 client_->BuildRasterQueue(global_state_.tree_priority, type));
1001 // It is insufficient to check whether the raster queue we constructed is 991 // It is insufficient to check whether the raster queue we constructed is
1002 // empty. The reason for this is that there are situations (rasterize on 992 // empty. The reason for this is that there are situations (rasterize on
1003 // demand) when the tile both needs raster and it's ready to draw. Hence, we 993 // demand) when the tile both needs raster and it's ready to draw. Hence, we
1004 // have to iterate the queue to check whether the required tiles are ready to 994 // have to iterate the queue to check whether the required tiles are ready to
1005 // draw. 995 // draw.
1006 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) { 996 for (; !raster_priority_queue->IsEmpty(); raster_priority_queue->Pop()) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 Tile* tile = queue->Top().tile(); 1139 Tile* tile = queue->Top().tile();
1150 if (tile->draw_info().IsReadyToDraw()) 1140 if (tile->draw_info().IsReadyToDraw())
1151 continue; 1141 continue;
1152 tile->draw_info().set_oom(); 1142 tile->draw_info().set_oom();
1153 client_->NotifyTileStateChanged(tile); 1143 client_->NotifyTileStateChanged(tile);
1154 } 1144 }
1155 return true; 1145 return true;
1156 } 1146 }
1157 1147
1158 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const { 1148 ResourceFormat TileManager::DetermineResourceFormat(const Tile* tile) const {
1159 return raster_buffer_provider_->GetResourceFormat(!tile->is_opaque()); 1149 return tile_task_manager_->GetRasterBufferProvider()->GetResourceFormat(
1150 !tile->is_opaque());
1160 } 1151 }
1161 1152
1162 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const { 1153 bool TileManager::DetermineResourceRequiresSwizzle(const Tile* tile) const {
1163 return raster_buffer_provider_->GetResourceRequiresSwizzle( 1154 return tile_task_manager_->GetRasterBufferProvider()
1164 !tile->is_opaque()); 1155 ->GetResourceRequiresSwizzle(!tile->is_opaque());
1165 } 1156 }
1166 1157
1167 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 1158 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
1168 TileManager::ScheduledTasksStateAsValue() const { 1159 TileManager::ScheduledTasksStateAsValue() const {
1169 std::unique_ptr<base::trace_event::TracedValue> state( 1160 std::unique_ptr<base::trace_event::TracedValue> state(
1170 new base::trace_event::TracedValue()); 1161 new base::trace_event::TracedValue());
1171 state->BeginDictionary("tasks_pending"); 1162 state->BeginDictionary("tasks_pending");
1172 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); 1163 state->SetBoolean("ready_to_activate", signals_.ready_to_activate);
1173 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); 1164 state->SetBoolean("ready_to_draw", signals_.ready_to_draw);
1174 state->SetBoolean("all_tile_tasks_completed", 1165 state->SetBoolean("all_tile_tasks_completed",
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 void TileManager::Signals::reset() { 1247 void TileManager::Signals::reset() {
1257 ready_to_activate = false; 1248 ready_to_activate = false;
1258 did_notify_ready_to_activate = false; 1249 did_notify_ready_to_activate = false;
1259 ready_to_draw = false; 1250 ready_to_draw = false;
1260 did_notify_ready_to_draw = false; 1251 did_notify_ready_to_draw = false;
1261 all_tile_tasks_completed = false; 1252 all_tile_tasks_completed = false;
1262 did_notify_all_tile_tasks_completed = false; 1253 did_notify_all_tile_tasks_completed = false;
1263 } 1254 }
1264 1255
1265 } // namespace cc 1256 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/tile_manager.h ('k') | cc/tiles/tile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698