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

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

Issue 1866043006: cc: Remove ScheduleOnOriginThread() and CompleteOnOriginThread(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip - fixed few unit tests Created 4 years, 8 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 26 matching lines...) Expand all
37 // a tile is of solid color. 37 // a tile is of solid color.
38 const bool kUseColorEstimator = true; 38 const bool kUseColorEstimator = true;
39 39
40 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( 40 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER(
41 ScopedRasterTaskTimer, 41 ScopedRasterTaskTimer,
42 "Compositing.%s.RasterTask.RasterUs", 42 "Compositing.%s.RasterTask.RasterUs",
43 "Compositing.%s.RasterTask.RasterPixelsPerMs"); 43 "Compositing.%s.RasterTask.RasterPixelsPerMs");
44 44
45 class RasterTaskImpl : public RasterTask { 45 class RasterTaskImpl : public RasterTask {
46 public: 46 public:
47 RasterTaskImpl(const Resource* resource, 47 RasterTaskImpl(Resource* resource,
48 scoped_refptr<RasterSource> raster_source, 48 scoped_refptr<RasterSource> raster_source,
49 const gfx::Rect& content_rect, 49 const gfx::Rect& content_rect,
50 const gfx::Rect& invalid_content_rect, 50 const gfx::Rect& invalid_content_rect,
51 float contents_scale, 51 float contents_scale,
52 const RasterSource::PlaybackSettings& playback_settings, 52 const RasterSource::PlaybackSettings& playback_settings,
53 TileResolution tile_resolution, 53 TileResolution tile_resolution,
54 int layer_id, 54 int layer_id,
55 uint64_t source_prepare_tiles_id, 55 uint64_t source_prepare_tiles_id,
56 const void* tile, 56 Tile* tile,
57 uint64_t new_content_id, 57 uint64_t new_content_id,
58 uint64_t previous_content_id, 58 uint64_t previous_content_id,
59 uint64_t resource_content_id, 59 uint64_t resource_content_id,
60 int source_frame_number, 60 int source_frame_number,
61 const base::Callback<void(bool)>& reply, 61 std::unique_ptr<RasterBuffer> raster_buffer,
62 ImageDecodeTask::Vector* dependencies) 62 ImageDecodeTask::Vector* dependencies)
63 : RasterTask(dependencies), 63 : RasterTask(dependencies),
64 resource_(resource), 64 resource_(resource),
65 raster_source_(std::move(raster_source)), 65 raster_source_(std::move(raster_source)),
66 content_rect_(content_rect), 66 content_rect_(content_rect),
67 invalid_content_rect_(invalid_content_rect), 67 invalid_content_rect_(invalid_content_rect),
68 contents_scale_(contents_scale), 68 contents_scale_(contents_scale),
69 playback_settings_(playback_settings), 69 playback_settings_(playback_settings),
70 tile_resolution_(tile_resolution), 70 tile_resolution_(tile_resolution),
71 layer_id_(layer_id), 71 layer_id_(layer_id),
72 source_prepare_tiles_id_(source_prepare_tiles_id), 72 source_prepare_tiles_id_(source_prepare_tiles_id),
73 tile_(tile), 73 tile_(tile),
74 new_content_id_(new_content_id), 74 new_content_id_(new_content_id),
75 previous_content_id_(previous_content_id), 75 previous_content_id_(previous_content_id),
76 resource_content_id_(resource_content_id), 76 resource_content_id_(resource_content_id),
77 source_frame_number_(source_frame_number), 77 source_frame_number_(source_frame_number),
78 reply_(reply) {} 78 raster_buffer_(std::move(raster_buffer)) {
79 SetTaskTypeId(kRasterTaskTypeId);
80 }
79 81
80 // Overridden from Task: 82 // Overridden from Task:
81 void RunOnWorkerThread() override { 83 void RunOnWorkerThread() override {
82 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", 84 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread",
83 "source_prepare_tiles_id", source_prepare_tiles_id_); 85 "source_prepare_tiles_id", source_prepare_tiles_id_);
84 86
85 DCHECK(raster_source_.get()); 87 DCHECK(raster_source_.get());
86 DCHECK(raster_buffer_); 88 DCHECK(raster_buffer_);
87 89
88 frame_viewer_instrumentation::ScopedRasterTask raster_task( 90 frame_viewer_instrumentation::ScopedRasterTask raster_task(
89 tile_, tile_resolution_, source_frame_number_, layer_id_); 91 tile_, tile_resolution_, source_frame_number_, layer_id_);
90 ScopedRasterTaskTimer timer; 92 ScopedRasterTaskTimer timer;
91 timer.SetArea(content_rect_.size().GetArea()); 93 timer.SetArea(content_rect_.size().GetArea());
92 94
93 DCHECK(raster_source_); 95 DCHECK(raster_source_);
94 96
95 raster_buffer_->Playback(raster_source_.get(), content_rect_, 97 raster_buffer_->Playback(raster_source_.get(), content_rect_,
96 invalid_content_rect_, new_content_id_, 98 invalid_content_rect_, new_content_id_,
97 contents_scale_, playback_settings_); 99 contents_scale_, playback_settings_);
98 } 100 }
99 101
100 // Overridden from TileTask: 102 protected:
101 void ScheduleOnOriginThread(TileTaskClient* client) override { 103 ~RasterTaskImpl() override {}
102 DCHECK(!raster_buffer_);
103 raster_buffer_ = client->AcquireBufferForRaster(
104 resource_, resource_content_id_, previous_content_id_);
105 }
106 void CompleteOnOriginThread(TileTaskClient* client) override {
107 client->ReleaseBufferForRaster(std::move(raster_buffer_));
108 reply_.Run(!HasFinishedRunning());
109 }
110 104
111 protected: 105 public:
112 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } 106 Resource* resource_;
113
114 private:
115 const Resource* resource_;
116 scoped_refptr<RasterSource> raster_source_; 107 scoped_refptr<RasterSource> raster_source_;
117 gfx::Rect content_rect_; 108 gfx::Rect content_rect_;
118 gfx::Rect invalid_content_rect_; 109 gfx::Rect invalid_content_rect_;
119 float contents_scale_; 110 float contents_scale_;
120 RasterSource::PlaybackSettings playback_settings_; 111 RasterSource::PlaybackSettings playback_settings_;
121 TileResolution tile_resolution_; 112 TileResolution tile_resolution_;
122 int layer_id_; 113 int layer_id_;
123 uint64_t source_prepare_tiles_id_; 114 uint64_t source_prepare_tiles_id_;
124 const void* tile_; 115 Tile* tile_;
125 uint64_t new_content_id_; 116 uint64_t new_content_id_;
126 uint64_t previous_content_id_; 117 uint64_t previous_content_id_;
127 uint64_t resource_content_id_; 118 uint64_t resource_content_id_;
128 int source_frame_number_; 119 int source_frame_number_;
129 const base::Callback<void(bool)> reply_;
130 std::unique_ptr<RasterBuffer> raster_buffer_; 120 std::unique_ptr<RasterBuffer> raster_buffer_;
131 121
122 private:
132 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); 123 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl);
133 }; 124 };
134 125
135 // Task priorities that make sure that the task set done tasks run before any 126 // Task priorities that make sure that the task set done tasks run before any
136 // other remaining tasks. 127 // other remaining tasks.
137 const size_t kRequiredForActivationDoneTaskPriority = 1u; 128 const size_t kRequiredForActivationDoneTaskPriority = 1u;
138 const size_t kRequiredForDrawDoneTaskPriority = 2u; 129 const size_t kRequiredForDrawDoneTaskPriority = 2u;
139 const size_t kAllDoneTaskPriority = 3u; 130 const size_t kAllDoneTaskPriority = 3u;
140 131
141 // For correctness, |kTileTaskPriorityBase| must be greater than 132 // For correctness, |kTileTaskPriorityBase| must be greater than
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 const base::Closure& on_task_set_finished_callback) 217 const base::Closure& on_task_set_finished_callback)
227 : task_runner_(task_runner), 218 : task_runner_(task_runner),
228 on_task_set_finished_callback_(on_task_set_finished_callback) {} 219 on_task_set_finished_callback_(on_task_set_finished_callback) {}
229 220
230 // Overridden from Task: 221 // Overridden from Task:
231 void RunOnWorkerThread() override { 222 void RunOnWorkerThread() override {
232 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); 223 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread");
233 TaskSetFinished(); 224 TaskSetFinished();
234 } 225 }
235 226
236 // Overridden from TileTask:
237 void ScheduleOnOriginThread(TileTaskClient* client) override {}
238 void CompleteOnOriginThread(TileTaskClient* client) override {}
239
240 protected: 227 protected:
241 ~TaskSetFinishedTaskImpl() override {} 228 ~TaskSetFinishedTaskImpl() override {}
242 229
243 void TaskSetFinished() { 230 void TaskSetFinished() {
244 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); 231 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_);
245 } 232 }
246 233
247 private: 234 private:
248 scoped_refptr<base::SequencedTaskRunner> task_runner_; 235 scoped_refptr<base::SequencedTaskRunner> task_runner_;
249 const base::Closure on_task_set_finished_callback_; 236 const base::Closure on_task_set_finished_callback_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 size_t scheduled_raster_task_limit, 272 size_t scheduled_raster_task_limit,
286 bool use_partial_raster) 273 bool use_partial_raster)
287 : client_(client), 274 : client_(client),
288 task_runner_(std::move(task_runner)), 275 task_runner_(std::move(task_runner)),
289 resource_pool_(nullptr), 276 resource_pool_(nullptr),
290 tile_task_runner_(nullptr), 277 tile_task_runner_(nullptr),
291 scheduled_raster_task_limit_(scheduled_raster_task_limit), 278 scheduled_raster_task_limit_(scheduled_raster_task_limit),
292 use_partial_raster_(use_partial_raster), 279 use_partial_raster_(use_partial_raster),
293 use_gpu_rasterization_(false), 280 use_gpu_rasterization_(false),
294 all_tiles_that_need_to_be_rasterized_are_scheduled_(true), 281 all_tiles_that_need_to_be_rasterized_are_scheduled_(true),
295 did_check_for_completed_tasks_since_last_schedule_tasks_(true), 282 did_check_and_process_completed_tasks_since_last_schedule_tasks_(true),
296 did_oom_on_last_assign_(false), 283 did_oom_on_last_assign_(false),
297 more_tiles_need_prepare_check_notifier_( 284 more_tiles_need_prepare_check_notifier_(
298 task_runner_.get(), 285 task_runner_.get(),
299 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared, 286 base::Bind(&TileManager::CheckIfMoreTilesNeedToBePrepared,
300 base::Unretained(this))), 287 base::Unretained(this))),
301 signals_check_notifier_(task_runner_.get(), 288 signals_check_notifier_(task_runner_.get(),
302 base::Bind(&TileManager::CheckAndIssueSignals, 289 base::Bind(&TileManager::CheckAndIssueSignals,
303 base::Unretained(this))), 290 base::Unretained(this))),
304 has_scheduled_tile_tasks_(false), 291 has_scheduled_tile_tasks_(false),
305 prepare_tiles_count_(0u), 292 prepare_tiles_count_(0u),
(...skipping 11 matching lines...) Expand all
317 global_state_ = GlobalStateThatImpactsTilePriority(); 304 global_state_ = GlobalStateThatImpactsTilePriority();
318 305
319 // This cancels tasks if possible, finishes pending tasks, and release any 306 // This cancels tasks if possible, finishes pending tasks, and release any
320 // uninitialized resources. 307 // uninitialized resources.
321 tile_task_runner_->Shutdown(); 308 tile_task_runner_->Shutdown();
322 309
323 // Now that all tasks have been finished, we can clear any 310 // Now that all tasks have been finished, we can clear any
324 // |orphan_tasks_|. 311 // |orphan_tasks_|.
325 orphan_tasks_.clear(); 312 orphan_tasks_.clear();
326 313
327 tile_task_runner_->CheckForCompletedTasks(); 314 CheckAndProcessCompletedTasks();
328 315
329 FreeResourcesForReleasedTiles(); 316 FreeResourcesForReleasedTiles();
330 CleanUpReleasedTiles(); 317 CleanUpReleasedTiles();
331 318
332 tile_task_runner_ = nullptr; 319 tile_task_runner_ = nullptr;
333 resource_pool_ = nullptr; 320 resource_pool_ = nullptr;
334 more_tiles_need_prepare_check_notifier_.Cancel(); 321 more_tiles_need_prepare_check_notifier_.Cancel();
335 signals_check_notifier_.Cancel(); 322 signals_check_notifier_.Cancel();
336 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); 323 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs();
337 } 324 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 414
428 if (!tile_task_runner_) { 415 if (!tile_task_runner_) {
429 TRACE_EVENT_INSTANT0("cc", "PrepareTiles aborted", 416 TRACE_EVENT_INSTANT0("cc", "PrepareTiles aborted",
430 TRACE_EVENT_SCOPE_THREAD); 417 TRACE_EVENT_SCOPE_THREAD);
431 return false; 418 return false;
432 } 419 }
433 420
434 signals_.reset(); 421 signals_.reset();
435 global_state_ = state; 422 global_state_ = state;
436 423
437 // We need to call CheckForCompletedTasks() once in-between each call 424 // We need to call CheckAndProcessCompletedTasks() once in-between each call
438 // to ScheduleTasks() to prevent canceled tasks from being scheduled. 425 // to ScheduleTasks() to prevent canceled tasks from being scheduled.
439 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { 426 if (!did_check_and_process_completed_tasks_since_last_schedule_tasks_)
440 tile_task_runner_->CheckForCompletedTasks(); 427 CheckAndProcessCompletedTasks();
441 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
442 }
443 428
444 FreeResourcesForReleasedTiles(); 429 FreeResourcesForReleasedTiles();
445 CleanUpReleasedTiles(); 430 CleanUpReleasedTiles();
446 431
447 PrioritizedTileVector tiles_that_need_to_be_rasterized; 432 PrioritizedTileVector tiles_that_need_to_be_rasterized;
448 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 433 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
449 client_->BuildRasterQueue(global_state_.tree_priority, 434 client_->BuildRasterQueue(global_state_.tree_priority,
450 RasterTilePriorityQueue::Type::ALL)); 435 RasterTilePriorityQueue::Type::ALL));
451 AssignGpuMemoryToTiles(raster_priority_queue.get(), 436 AssignGpuMemoryToTiles(raster_priority_queue.get(),
452 scheduled_raster_task_limit_, 437 scheduled_raster_task_limit_,
(...skipping 14 matching lines...) Expand all
467 } 452 }
468 453
469 void TileManager::Flush() { 454 void TileManager::Flush() {
470 TRACE_EVENT0("cc", "TileManager::Flush"); 455 TRACE_EVENT0("cc", "TileManager::Flush");
471 456
472 if (!tile_task_runner_) { 457 if (!tile_task_runner_) {
473 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); 458 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD);
474 return; 459 return;
475 } 460 }
476 461
477 tile_task_runner_->CheckForCompletedTasks(); 462 CheckAndProcessCompletedTasks();
478
479 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
480 463
481 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", 464 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats",
482 RasterTaskCompletionStatsAsValue(flush_stats_)); 465 RasterTaskCompletionStatsAsValue(flush_stats_));
483 flush_stats_ = RasterTaskCompletionStats(); 466 flush_stats_ = RasterTaskCompletionStats();
484 } 467 }
485 468
486 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 469 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
487 TileManager::BasicStateAsValue() const { 470 TileManager::BasicStateAsValue() const {
488 std::unique_ptr<base::trace_event::TracedValue> value( 471 std::unique_ptr<base::trace_event::TracedValue> value(
489 new base::trace_event::TracedValue()); 472 new base::trace_event::TracedValue());
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 FreeResourcesForTile(tile); 694 FreeResourcesForTile(tile);
712 if (was_ready_to_draw) 695 if (was_ready_to_draw)
713 client_->NotifyTileStateChanged(tile); 696 client_->NotifyTileStateChanged(tile);
714 } 697 }
715 698
716 void TileManager::ScheduleTasks( 699 void TileManager::ScheduleTasks(
717 const PrioritizedTileVector& tiles_that_need_to_be_rasterized) { 700 const PrioritizedTileVector& tiles_that_need_to_be_rasterized) {
718 TRACE_EVENT1("cc", "TileManager::ScheduleTasks", "count", 701 TRACE_EVENT1("cc", "TileManager::ScheduleTasks", "count",
719 tiles_that_need_to_be_rasterized.size()); 702 tiles_that_need_to_be_rasterized.size());
720 703
721 DCHECK(did_check_for_completed_tasks_since_last_schedule_tasks_); 704 DCHECK(did_check_and_process_completed_tasks_since_last_schedule_tasks_);
722 705
723 if (!has_scheduled_tile_tasks_) { 706 if (!has_scheduled_tile_tasks_) {
724 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this); 707 TRACE_EVENT_ASYNC_BEGIN0("cc", "ScheduledTasks", this);
725 } 708 }
726 709
727 // Cancel existing OnTaskSetFinished callbacks. 710 // Cancel existing OnTaskSetFinished callbacks.
728 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); 711 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs();
729 712
730 // Even when scheduling an empty set of tiles, the TTWP does some work, and 713 // Even when scheduling an empty set of tiles, the TTWP does some work, and
731 // will always trigger a DidFinishRunningTileTasks notification. Because of 714 // will always trigger a DidFinishRunningTileTasks notification. Because of
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 // allowed to keep around unreferenced raster tasks after ScheduleTasks() has 797 // allowed to keep around unreferenced raster tasks after ScheduleTasks() has
815 // been called. 798 // been called.
816 orphan_tasks_.clear(); 799 orphan_tasks_.clear();
817 800
818 // It's also now safe to replace our *_done_task_ tasks. 801 // It's also now safe to replace our *_done_task_ tasks.
819 required_for_activation_done_task_ = 802 required_for_activation_done_task_ =
820 std::move(required_for_activation_done_task); 803 std::move(required_for_activation_done_task);
821 required_for_draw_done_task_ = std::move(required_for_draw_done_task); 804 required_for_draw_done_task_ = std::move(required_for_draw_done_task);
822 all_done_task_ = std::move(all_done_task); 805 all_done_task_ = std::move(all_done_task);
823 806
824 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; 807 did_check_and_process_completed_tasks_since_last_schedule_tasks_ = false;
825 808
826 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", 809 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state",
827 ScheduledTasksStateAsValue()); 810 ScheduledTasksStateAsValue());
828 } 811 }
829 812
830 scoped_refptr<RasterTask> TileManager::CreateRasterTask( 813 scoped_refptr<RasterTask> TileManager::CreateRasterTask(
831 const PrioritizedTile& prioritized_tile) { 814 const PrioritizedTile& prioritized_tile) {
832 Tile* tile = prioritized_tile.tile(); 815 Tile* tile = prioritized_tile.tile();
833 816
834 // Get the resource. 817 // Get the resource.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 *it, prepare_tiles_count_, &task); 855 *it, prepare_tiles_count_, &task);
873 if (task) 856 if (task)
874 decode_tasks.push_back(task); 857 decode_tasks.push_back(task);
875 858
876 if (need_to_unref_when_finished) 859 if (need_to_unref_when_finished)
877 ++it; 860 ++it;
878 else 861 else
879 it = images.erase(it); 862 it = images.erase(it);
880 } 863 }
881 864
865 std::unique_ptr<RasterBuffer> raster_buffer =
866 tile_task_runner_->AsTileTaskClient()->AcquireBufferForRaster(
867 resource, resource_content_id, tile->invalidated_id());
882 return make_scoped_refptr(new RasterTaskImpl( 868 return make_scoped_refptr(new RasterTaskImpl(
883 resource, prioritized_tile.raster_source(), tile->content_rect(), 869 resource, prioritized_tile.raster_source(), tile->content_rect(),
884 tile->invalidated_content_rect(), tile->contents_scale(), 870 tile->invalidated_content_rect(), tile->contents_scale(),
885 playback_settings, prioritized_tile.priority().resolution, 871 playback_settings, prioritized_tile.priority().resolution,
886 tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile), 872 tile->layer_id(), prepare_tiles_count_, tile, tile->id(),
887 tile->id(), tile->invalidated_id(), resource_content_id, 873 tile->invalidated_id(), resource_content_id, tile->source_frame_number(),
888 tile->source_frame_number(), 874 std::move(raster_buffer), &decode_tasks));
889 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this),
890 tile->id(), resource),
891 &decode_tasks));
892 } 875 }
893 876
894 void TileManager::OnRasterTaskCompleted( 877 void TileManager::CheckAndProcessCompletedTasks() {
895 Tile::Id tile_id, 878 Task::Vector completed_tasks;
896 Resource* resource, 879 tile_task_runner_->CollectCompletedTasks(&completed_tasks);
897 bool was_canceled) {
898 DCHECK(tiles_.find(tile_id) != tiles_.end());
899 880
900 Tile* tile = tiles_[tile_id]; 881 for (auto task : completed_tasks) {
882 if (task->GetTaskTypeId() == kImageDecodeTaskTypeId) {
883 image_decode_controller_->CompleteTask(task.get());
884 } else if (task->GetTaskTypeId() == kRasterTaskTypeId) {
885 RasterTaskImpl* raster_task = static_cast<RasterTaskImpl*>(task.get());
886 DCHECK(raster_task);
887 CompleteRasterTask(raster_task->tile_, raster_task->resource_,
888 !raster_task->HasFinishedRunning());
889 }
890
891 static_cast<TileTask*>(task.get())->DidComplete();
892 }
893
894 completed_tasks.clear();
895
896 did_check_and_process_completed_tasks_since_last_schedule_tasks_ = true;
897 }
898
899 void TileManager::CompleteRasterTask(Tile* tile,
900 Resource* resource,
901 bool was_canceled) {
902 DCHECK(tiles_.find(tile->id()) == tiles_.end());
903
901 TileDrawInfo& draw_info = tile->draw_info(); 904 TileDrawInfo& draw_info = tile->draw_info();
902 DCHECK(tile->raster_task_.get()); 905 DCHECK(tile->raster_task_.get());
903 orphan_tasks_.push_back(tile->raster_task_); 906 orphan_tasks_.push_back(tile->raster_task_);
904 tile->raster_task_ = nullptr; 907 tile->raster_task_ = nullptr;
905 908
906 // Unref all the images. 909 // Unref all the images.
907 auto images_it = scheduled_draw_images_.find(tile->id()); 910 auto images_it = scheduled_draw_images_.find(tile->id());
908 const std::vector<DrawImage>& images = images_it->second; 911 const std::vector<DrawImage>& images = images_it->second;
909 for (const auto& image : images) 912 for (const auto& image : images)
910 image_decode_controller_->UnrefImage(image); 913 image_decode_controller_->UnrefImage(image);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } 988 }
986 989
987 bool TileManager::IsReadyToDraw() const { 990 bool TileManager::IsReadyToDraw() const {
988 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); 991 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw");
989 return AreRequiredTilesReadyToDraw( 992 return AreRequiredTilesReadyToDraw(
990 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); 993 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW);
991 } 994 }
992 995
993 void TileManager::CheckAndIssueSignals() { 996 void TileManager::CheckAndIssueSignals() {
994 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); 997 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals");
995 tile_task_runner_->CheckForCompletedTasks(); 998 CheckAndProcessCompletedTasks();
996 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
997 999
998 // Ready to activate. 1000 // Ready to activate.
999 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { 1001 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) {
1000 signals_.ready_to_activate = false; 1002 signals_.ready_to_activate = false;
1001 if (IsReadyToActivate()) { 1003 if (IsReadyToActivate()) {
1002 TRACE_EVENT0("disabled-by-default-cc.debug", 1004 TRACE_EVENT0("disabled-by-default-cc.debug",
1003 "TileManager::CheckAndIssueSignals - ready to activate"); 1005 "TileManager::CheckAndIssueSignals - ready to activate");
1004 signals_.did_notify_ready_to_activate = true; 1006 signals_.did_notify_ready_to_activate = true;
1005 client_->NotifyReadyToActivate(); 1007 client_->NotifyReadyToActivate();
1006 } 1008 }
(...skipping 18 matching lines...) Expand all
1025 TRACE_EVENT0( 1027 TRACE_EVENT0(
1026 "disabled-by-default-cc.debug", 1028 "disabled-by-default-cc.debug",
1027 "TileManager::CheckAndIssueSignals - all tile tasks completed"); 1029 "TileManager::CheckAndIssueSignals - all tile tasks completed");
1028 signals_.did_notify_all_tile_tasks_completed = true; 1030 signals_.did_notify_all_tile_tasks_completed = true;
1029 client_->NotifyAllTileTasksCompleted(); 1031 client_->NotifyAllTileTasksCompleted();
1030 } 1032 }
1031 } 1033 }
1032 } 1034 }
1033 1035
1034 void TileManager::CheckIfMoreTilesNeedToBePrepared() { 1036 void TileManager::CheckIfMoreTilesNeedToBePrepared() {
1035 tile_task_runner_->CheckForCompletedTasks(); 1037 CheckAndProcessCompletedTasks();
1036 did_check_for_completed_tasks_since_last_schedule_tasks_ = true;
1037 1038
1038 // When OOM, keep re-assigning memory until we reach a steady state 1039 // When OOM, keep re-assigning memory until we reach a steady state
1039 // where top-priority tiles are initialized. 1040 // where top-priority tiles are initialized.
1040 PrioritizedTileVector tiles_that_need_to_be_rasterized; 1041 PrioritizedTileVector tiles_that_need_to_be_rasterized;
1041 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue( 1042 std::unique_ptr<RasterTilePriorityQueue> raster_priority_queue(
1042 client_->BuildRasterQueue(global_state_.tree_priority, 1043 client_->BuildRasterQueue(global_state_.tree_priority,
1043 RasterTilePriorityQueue::Type::ALL)); 1044 RasterTilePriorityQueue::Type::ALL));
1044 AssignGpuMemoryToTiles(raster_priority_queue.get(), 1045 AssignGpuMemoryToTiles(raster_priority_queue.get(),
1045 scheduled_raster_task_limit_, 1046 scheduled_raster_task_limit_,
1046 &tiles_that_need_to_be_rasterized); 1047 &tiles_that_need_to_be_rasterized);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 void TileManager::Signals::reset() { 1219 void TileManager::Signals::reset() {
1219 ready_to_activate = false; 1220 ready_to_activate = false;
1220 did_notify_ready_to_activate = false; 1221 did_notify_ready_to_activate = false;
1221 ready_to_draw = false; 1222 ready_to_draw = false;
1222 did_notify_ready_to_draw = false; 1223 did_notify_ready_to_draw = false;
1223 all_tile_tasks_completed = false; 1224 all_tile_tasks_completed = false;
1224 did_notify_all_tile_tasks_completed = false; 1225 did_notify_all_tile_tasks_completed = false;
1225 } 1226 }
1226 1227
1227 } // namespace cc 1228 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698