OLD | NEW |
---|---|
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 25 matching lines...) Expand all Loading... | |
36 // a tile is of solid color. | 36 // a tile is of solid color. |
37 const bool kUseColorEstimator = true; | 37 const bool kUseColorEstimator = true; |
38 | 38 |
39 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | 39 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
40 ScopedRasterTaskTimer, | 40 ScopedRasterTaskTimer, |
41 "Compositing.%s.RasterTask.RasterUs", | 41 "Compositing.%s.RasterTask.RasterUs", |
42 "Compositing.%s.RasterTask.RasterPixelsPerMs"); | 42 "Compositing.%s.RasterTask.RasterPixelsPerMs"); |
43 | 43 |
44 class RasterTaskImpl : public RasterTask { | 44 class RasterTaskImpl : public RasterTask { |
45 public: | 45 public: |
46 RasterTaskImpl(const Resource* resource, | 46 RasterTaskImpl(Resource* resource, |
47 scoped_refptr<RasterSource> raster_source, | 47 scoped_refptr<RasterSource> raster_source, |
48 const gfx::Rect& content_rect, | 48 const gfx::Rect& content_rect, |
49 const gfx::Rect& invalid_content_rect, | 49 const gfx::Rect& invalid_content_rect, |
50 float contents_scale, | 50 float contents_scale, |
51 const RasterSource::PlaybackSettings& playback_settings, | 51 const RasterSource::PlaybackSettings& playback_settings, |
52 TileResolution tile_resolution, | 52 TileResolution tile_resolution, |
53 int layer_id, | 53 int layer_id, |
54 uint64_t source_prepare_tiles_id, | 54 uint64_t source_prepare_tiles_id, |
55 const void* tile, | 55 const void* tile, |
56 uint64_t new_content_id, | 56 uint64_t new_content_id, |
57 uint64_t previous_content_id, | 57 uint64_t previous_content_id, |
58 uint64_t resource_content_id, | 58 uint64_t resource_content_id, |
59 int source_frame_number, | 59 int source_frame_number, |
60 const base::Callback<void(bool)>& reply, | 60 scoped_ptr<RasterBuffer> raster_buffer, |
61 ImageDecodeTask::Vector* dependencies) | 61 ImageDecodeTask::Vector* dependencies) |
62 : RasterTask(dependencies), | 62 : RasterTask(dependencies), |
63 resource_(resource), | 63 resource_(resource), |
64 raster_source_(std::move(raster_source)), | 64 raster_source_(std::move(raster_source)), |
65 content_rect_(content_rect), | 65 content_rect_(content_rect), |
66 invalid_content_rect_(invalid_content_rect), | 66 invalid_content_rect_(invalid_content_rect), |
67 contents_scale_(contents_scale), | 67 contents_scale_(contents_scale), |
68 playback_settings_(playback_settings), | 68 playback_settings_(playback_settings), |
69 tile_resolution_(tile_resolution), | 69 tile_resolution_(tile_resolution), |
70 layer_id_(layer_id), | 70 layer_id_(layer_id), |
71 source_prepare_tiles_id_(source_prepare_tiles_id), | 71 source_prepare_tiles_id_(source_prepare_tiles_id), |
72 tile_(tile), | 72 tile_(tile), |
73 new_content_id_(new_content_id), | 73 new_content_id_(new_content_id), |
74 previous_content_id_(previous_content_id), | 74 previous_content_id_(previous_content_id), |
75 resource_content_id_(resource_content_id), | 75 resource_content_id_(resource_content_id), |
76 source_frame_number_(source_frame_number), | 76 source_frame_number_(source_frame_number), |
77 reply_(reply) {} | 77 raster_buffer_(std::move(raster_buffer)) {} |
78 | 78 |
79 // Overridden from Task: | 79 // Overridden from Task: |
80 void RunOnWorkerThread() override { | 80 void RunOnWorkerThread() override { |
81 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 81 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
82 "source_prepare_tiles_id", source_prepare_tiles_id_); | 82 "source_prepare_tiles_id", source_prepare_tiles_id_); |
83 | 83 |
84 DCHECK(raster_source_.get()); | 84 DCHECK(raster_source_.get()); |
85 DCHECK(raster_buffer_); | 85 DCHECK(raster_buffer_); |
86 | 86 |
87 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 87 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
88 tile_, tile_resolution_, source_frame_number_, layer_id_); | 88 tile_, tile_resolution_, source_frame_number_, layer_id_); |
89 ScopedRasterTaskTimer timer; | 89 ScopedRasterTaskTimer timer; |
90 timer.SetArea(content_rect_.size().GetArea()); | 90 timer.SetArea(content_rect_.size().GetArea()); |
91 | 91 |
92 DCHECK(raster_source_); | 92 DCHECK(raster_source_); |
93 | 93 |
94 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 94 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
95 invalid_content_rect_, new_content_id_, | 95 invalid_content_rect_, new_content_id_, |
96 contents_scale_, playback_settings_); | 96 contents_scale_, playback_settings_); |
97 } | 97 } |
98 | 98 |
99 // Overridden from TileTask: | 99 protected: |
100 void ScheduleOnOriginThread(TileTaskClient* client) override { | 100 ~RasterTaskImpl() override {} |
101 DCHECK(!raster_buffer_); | |
102 raster_buffer_ = client->AcquireBufferForRaster( | |
103 resource_, resource_content_id_, previous_content_id_); | |
104 } | |
105 void CompleteOnOriginThread(TileTaskClient* client) override { | |
106 client->ReleaseBufferForRaster(std::move(raster_buffer_)); | |
107 reply_.Run(!HasFinishedRunning()); | |
108 } | |
109 | 101 |
110 protected: | 102 public: |
111 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } | 103 Resource* resource_; |
112 | |
113 private: | |
114 const Resource* resource_; | |
115 scoped_refptr<RasterSource> raster_source_; | 104 scoped_refptr<RasterSource> raster_source_; |
116 gfx::Rect content_rect_; | 105 gfx::Rect content_rect_; |
117 gfx::Rect invalid_content_rect_; | 106 gfx::Rect invalid_content_rect_; |
118 float contents_scale_; | 107 float contents_scale_; |
119 RasterSource::PlaybackSettings playback_settings_; | 108 RasterSource::PlaybackSettings playback_settings_; |
120 TileResolution tile_resolution_; | 109 TileResolution tile_resolution_; |
121 int layer_id_; | 110 int layer_id_; |
122 uint64_t source_prepare_tiles_id_; | 111 uint64_t source_prepare_tiles_id_; |
123 const void* tile_; | 112 const void* tile_; |
124 uint64_t new_content_id_; | 113 uint64_t new_content_id_; |
125 uint64_t previous_content_id_; | 114 uint64_t previous_content_id_; |
126 uint64_t resource_content_id_; | 115 uint64_t resource_content_id_; |
127 int source_frame_number_; | 116 int source_frame_number_; |
128 const base::Callback<void(bool)> reply_; | |
129 scoped_ptr<RasterBuffer> raster_buffer_; | 117 scoped_ptr<RasterBuffer> raster_buffer_; |
130 | 118 |
119 private: | |
131 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); | 120 DISALLOW_COPY_AND_ASSIGN(RasterTaskImpl); |
132 }; | 121 }; |
133 | 122 |
134 // Task priorities that make sure that the task set done tasks run before any | 123 // Task priorities that make sure that the task set done tasks run before any |
135 // other remaining tasks. | 124 // other remaining tasks. |
136 const size_t kRequiredForActivationDoneTaskPriority = 1u; | 125 const size_t kRequiredForActivationDoneTaskPriority = 1u; |
137 const size_t kRequiredForDrawDoneTaskPriority = 2u; | 126 const size_t kRequiredForDrawDoneTaskPriority = 2u; |
138 const size_t kAllDoneTaskPriority = 3u; | 127 const size_t kAllDoneTaskPriority = 3u; |
139 | 128 |
140 // For correctness, |kTileTaskPriorityBase| must be greater than | 129 // For correctness, |kTileTaskPriorityBase| must be greater than |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; | 169 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; |
181 | 170 |
182 // Insert image decode tasks. | 171 // Insert image decode tasks. |
183 for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin(); | 172 for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin(); |
184 it != decode_tasks.end(); ++it) { | 173 it != decode_tasks.end(); ++it) { |
185 ImageDecodeTask* decode_task = it->get(); | 174 ImageDecodeTask* decode_task = it->get(); |
186 | 175 |
187 // Skip if already decoded. | 176 // Skip if already decoded. |
188 if (decode_task->HasCompleted()) | 177 if (decode_task->HasCompleted()) |
189 continue; | 178 continue; |
190 | |
191 dependencies++; | 179 dependencies++; |
192 | 180 |
193 // Add decode task if it doesn't already exists in graph. | 181 // Add decode task if it doesn't already exists in graph. |
194 TaskGraph::Node::Vector::iterator decode_it = | 182 TaskGraph::Node::Vector::iterator decode_it = |
195 std::find_if(graph->nodes.begin(), graph->nodes.end(), | 183 std::find_if(graph->nodes.begin(), graph->nodes.end(), |
196 [decode_task](const TaskGraph::Node& node) { | 184 [decode_task](const TaskGraph::Node& node) { |
197 return node.task == decode_task; | 185 return node.task == decode_task; |
198 }); | 186 }); |
199 | 187 |
200 // In rare circumstances, a low priority task may come in before a high | 188 // In rare circumstances, a low priority task may come in before a high |
(...skipping 24 matching lines...) Expand all Loading... | |
225 const base::Closure& on_task_set_finished_callback) | 213 const base::Closure& on_task_set_finished_callback) |
226 : task_runner_(task_runner), | 214 : task_runner_(task_runner), |
227 on_task_set_finished_callback_(on_task_set_finished_callback) {} | 215 on_task_set_finished_callback_(on_task_set_finished_callback) {} |
228 | 216 |
229 // Overridden from Task: | 217 // Overridden from Task: |
230 void RunOnWorkerThread() override { | 218 void RunOnWorkerThread() override { |
231 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); | 219 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); |
232 TaskSetFinished(); | 220 TaskSetFinished(); |
233 } | 221 } |
234 | 222 |
235 // Overridden from TileTask: | |
236 void ScheduleOnOriginThread(TileTaskClient* client) override {} | |
237 void CompleteOnOriginThread(TileTaskClient* client) override {} | |
238 | |
239 protected: | 223 protected: |
240 ~TaskSetFinishedTaskImpl() override {} | 224 ~TaskSetFinishedTaskImpl() override {} |
241 | 225 |
242 void TaskSetFinished() { | 226 void TaskSetFinished() { |
243 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); | 227 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); |
244 } | 228 } |
245 | 229 |
246 private: | 230 private: |
247 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 231 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
248 const base::Closure on_task_set_finished_callback_; | 232 const base::Closure on_task_set_finished_callback_; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 global_state_ = GlobalStateThatImpactsTilePriority(); | 300 global_state_ = GlobalStateThatImpactsTilePriority(); |
317 | 301 |
318 // This cancels tasks if possible, finishes pending tasks, and release any | 302 // This cancels tasks if possible, finishes pending tasks, and release any |
319 // uninitialized resources. | 303 // uninitialized resources. |
320 tile_task_runner_->Shutdown(); | 304 tile_task_runner_->Shutdown(); |
321 | 305 |
322 // Now that all tasks have been finished, we can clear any | 306 // Now that all tasks have been finished, we can clear any |
323 // |orphan_tasks_|. | 307 // |orphan_tasks_|. |
324 orphan_tasks_.clear(); | 308 orphan_tasks_.clear(); |
325 | 309 |
326 tile_task_runner_->CheckForCompletedTasks(); | 310 CheckForCompletedTasks(); |
327 | 311 |
328 FreeResourcesForReleasedTiles(); | 312 FreeResourcesForReleasedTiles(); |
329 CleanUpReleasedTiles(); | 313 CleanUpReleasedTiles(); |
330 | 314 |
331 tile_task_runner_ = nullptr; | 315 tile_task_runner_ = nullptr; |
332 resource_pool_ = nullptr; | 316 resource_pool_ = nullptr; |
333 more_tiles_need_prepare_check_notifier_.Cancel(); | 317 more_tiles_need_prepare_check_notifier_.Cancel(); |
334 signals_check_notifier_.Cancel(); | 318 signals_check_notifier_.Cancel(); |
335 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); | 319 task_set_finished_weak_ptr_factory_.InvalidateWeakPtrs(); |
336 } | 320 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 TRACE_EVENT_SCOPE_THREAD); | 413 TRACE_EVENT_SCOPE_THREAD); |
430 return false; | 414 return false; |
431 } | 415 } |
432 | 416 |
433 signals_.reset(); | 417 signals_.reset(); |
434 global_state_ = state; | 418 global_state_ = state; |
435 | 419 |
436 // We need to call CheckForCompletedTasks() once in-between each call | 420 // We need to call CheckForCompletedTasks() once in-between each call |
437 // to ScheduleTasks() to prevent canceled tasks from being scheduled. | 421 // to ScheduleTasks() to prevent canceled tasks from being scheduled. |
438 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { | 422 if (!did_check_for_completed_tasks_since_last_schedule_tasks_) { |
439 tile_task_runner_->CheckForCompletedTasks(); | 423 CheckForCompletedTasks(); |
440 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 424 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
441 } | 425 } |
442 | 426 |
443 FreeResourcesForReleasedTiles(); | 427 FreeResourcesForReleasedTiles(); |
444 CleanUpReleasedTiles(); | 428 CleanUpReleasedTiles(); |
445 | 429 |
446 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 430 PrioritizedTileVector tiles_that_need_to_be_rasterized; |
447 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 431 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
448 client_->BuildRasterQueue(global_state_.tree_priority, | 432 client_->BuildRasterQueue(global_state_.tree_priority, |
449 RasterTilePriorityQueue::Type::ALL)); | 433 RasterTilePriorityQueue::Type::ALL)); |
(...skipping 16 matching lines...) Expand all Loading... | |
466 } | 450 } |
467 | 451 |
468 void TileManager::Flush() { | 452 void TileManager::Flush() { |
469 TRACE_EVENT0("cc", "TileManager::Flush"); | 453 TRACE_EVENT0("cc", "TileManager::Flush"); |
470 | 454 |
471 if (!tile_task_runner_) { | 455 if (!tile_task_runner_) { |
472 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); | 456 TRACE_EVENT_INSTANT0("cc", "Flush aborted", TRACE_EVENT_SCOPE_THREAD); |
473 return; | 457 return; |
474 } | 458 } |
475 | 459 |
476 tile_task_runner_->CheckForCompletedTasks(); | 460 CheckForCompletedTasks(); |
477 | 461 |
478 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 462 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
479 | 463 |
480 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", | 464 TRACE_EVENT_INSTANT1("cc", "DidFlush", TRACE_EVENT_SCOPE_THREAD, "stats", |
481 RasterTaskCompletionStatsAsValue(flush_stats_)); | 465 RasterTaskCompletionStatsAsValue(flush_stats_)); |
482 flush_stats_ = RasterTaskCompletionStats(); | 466 flush_stats_ = RasterTaskCompletionStats(); |
483 } | 467 } |
484 | 468 |
485 scoped_ptr<base::trace_event::ConvertableToTraceFormat> | 469 scoped_ptr<base::trace_event::ConvertableToTraceFormat> |
486 TileManager::BasicStateAsValue() const { | 470 TileManager::BasicStateAsValue() const { |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
750 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); | 734 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); |
751 | 735 |
752 // Build a new task queue containing all task currently needed. Tasks | 736 // Build a new task queue containing all task currently needed. Tasks |
753 // are added in order of priority, highest priority task first. | 737 // are added in order of priority, highest priority task first. |
754 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { | 738 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { |
755 Tile* tile = prioritized_tile.tile(); | 739 Tile* tile = prioritized_tile.tile(); |
756 | 740 |
757 DCHECK(tile->draw_info().requires_resource()); | 741 DCHECK(tile->draw_info().requires_resource()); |
758 DCHECK(!tile->draw_info().resource_); | 742 DCHECK(!tile->draw_info().resource_); |
759 | 743 |
760 if (!tile->raster_task_) | 744 if (!tile->raster_task_) { |
761 tile->raster_task_ = CreateRasterTask(prioritized_tile); | 745 tile->raster_task_ = CreateRasterTask(prioritized_tile); |
746 raster_tasks_.push_back(tile->raster_task_); | |
747 } | |
762 | 748 |
763 RasterTask* task = tile->raster_task_.get(); | 749 RasterTask* task = tile->raster_task_.get(); |
764 DCHECK(!task->HasCompleted()); | 750 DCHECK(!task->HasCompleted()); |
765 | 751 |
766 if (tile->required_for_activation()) { | 752 if (tile->required_for_activation()) { |
767 required_for_activate_count++; | 753 required_for_activate_count++; |
768 graph_.edges.push_back( | 754 graph_.edges.push_back( |
769 TaskGraph::Edge(task, required_for_activation_done_task.get())); | 755 TaskGraph::Edge(task, required_for_activation_done_task.get())); |
770 } | 756 } |
771 if (tile->required_for_draw()) { | 757 if (tile->required_for_draw()) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 | 808 |
823 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 809 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
824 | 810 |
825 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 811 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
826 ScheduledTasksStateAsValue()); | 812 ScheduledTasksStateAsValue()); |
827 } | 813 } |
828 | 814 |
829 scoped_refptr<RasterTask> TileManager::CreateRasterTask( | 815 scoped_refptr<RasterTask> TileManager::CreateRasterTask( |
830 const PrioritizedTile& prioritized_tile) { | 816 const PrioritizedTile& prioritized_tile) { |
831 Tile* tile = prioritized_tile.tile(); | 817 Tile* tile = prioritized_tile.tile(); |
832 | |
833 // Get the resource. | 818 // Get the resource. |
834 uint64_t resource_content_id = 0; | 819 uint64_t resource_content_id = 0; |
835 Resource* resource = nullptr; | 820 Resource* resource = nullptr; |
836 if (use_partial_raster_ && tile->invalidated_id()) { | 821 if (use_partial_raster_ && tile->invalidated_id()) { |
837 // TODO(danakj): For resources that are in use, we should still grab them | 822 // TODO(danakj): For resources that are in use, we should still grab them |
838 // and copy from them instead of rastering everything. crbug.com/492754 | 823 // and copy from them instead of rastering everything. crbug.com/492754 |
839 resource = | 824 resource = |
840 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); | 825 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); |
841 } | 826 } |
842 if (resource) { | 827 if (resource) { |
(...skipping 28 matching lines...) Expand all Loading... | |
871 *it, prepare_tiles_count_, &task); | 856 *it, prepare_tiles_count_, &task); |
872 if (task) | 857 if (task) |
873 decode_tasks.push_back(task); | 858 decode_tasks.push_back(task); |
874 | 859 |
875 if (need_to_unref_when_finished) | 860 if (need_to_unref_when_finished) |
876 ++it; | 861 ++it; |
877 else | 862 else |
878 it = images.erase(it); | 863 it = images.erase(it); |
879 } | 864 } |
880 | 865 |
866 scoped_ptr<RasterBuffer> raster_buffer = | |
867 tile_task_runner_->AsTileTaskClient()->AcquireBufferForRaster( | |
868 resource, resource_content_id, tile->invalidated_id()); | |
881 return make_scoped_refptr(new RasterTaskImpl( | 869 return make_scoped_refptr(new RasterTaskImpl( |
882 resource, prioritized_tile.raster_source(), tile->content_rect(), | 870 resource, prioritized_tile.raster_source(), tile->content_rect(), |
883 tile->invalidated_content_rect(), tile->contents_scale(), | 871 tile->invalidated_content_rect(), tile->contents_scale(), |
884 playback_settings, prioritized_tile.priority().resolution, | 872 playback_settings, prioritized_tile.priority().resolution, |
885 tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile), | 873 tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile), |
886 tile->id(), tile->invalidated_id(), resource_content_id, | 874 tile->id(), tile->invalidated_id(), resource_content_id, |
887 tile->source_frame_number(), | 875 tile->source_frame_number(), std::move(raster_buffer), &decode_tasks)); |
888 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | |
889 tile->id(), resource), | |
890 &decode_tasks)); | |
891 } | 876 } |
892 | 877 |
893 void TileManager::OnRasterTaskCompleted( | 878 void TileManager::CheckForCompletedTasks() { |
894 Tile::Id tile_id, | 879 Task::Vector completed_tasks; |
895 Resource* resource, | 880 tile_task_runner_->CollectCompletedTasks(&completed_tasks); |
896 bool was_canceled) { | 881 |
882 for (auto task : completed_tasks) { | |
vmpstr
2016/04/08 18:59:16
auto& task? or auto* task? depending on what compl
| |
883 Task::Vector::iterator it = | |
884 std::find(raster_tasks_.begin(), raster_tasks_.end(), task); | |
vmpstr
2016/04/08 18:59:16
This is a n^2 loop... how's the performance here i
| |
885 if (it != raster_tasks_.end()) { | |
886 raster_tasks_.erase(it); | |
887 RasterTaskImpl* raster_task = static_cast<RasterTaskImpl*>(task.get()); | |
888 DCHECK(raster_task); | |
889 CompleteRasterTask(raster_task->new_content_id_, raster_task->resource_, | |
890 !raster_task->HasFinishedRunning()); | |
891 } | |
892 | |
893 static_cast<TileTask*>(task.get())->DidComplete(); | |
894 } | |
895 | |
896 completed_tasks.clear(); | |
897 } | |
898 | |
899 void TileManager::CompleteRasterTask(Tile::Id tile_id, | |
900 Resource* resource, | |
901 bool was_canceled) { | |
897 DCHECK(tiles_.find(tile_id) != tiles_.end()); | 902 DCHECK(tiles_.find(tile_id) != tiles_.end()); |
898 | 903 |
899 Tile* tile = tiles_[tile_id]; | 904 Tile* tile = tiles_[tile_id]; |
900 TileDrawInfo& draw_info = tile->draw_info(); | 905 TileDrawInfo& draw_info = tile->draw_info(); |
901 DCHECK(tile->raster_task_.get()); | 906 DCHECK(tile->raster_task_.get()); |
902 orphan_tasks_.push_back(tile->raster_task_); | 907 orphan_tasks_.push_back(tile->raster_task_); |
903 tile->raster_task_ = nullptr; | 908 tile->raster_task_ = nullptr; |
904 | 909 |
905 // Unref all the images. | 910 // Unref all the images. |
906 auto images_it = scheduled_draw_images_.find(tile->id()); | 911 auto images_it = scheduled_draw_images_.find(tile->id()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 } | 989 } |
985 | 990 |
986 bool TileManager::IsReadyToDraw() const { | 991 bool TileManager::IsReadyToDraw() const { |
987 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); | 992 TRACE_EVENT0("cc", "TileManager::IsReadyToDraw"); |
988 return AreRequiredTilesReadyToDraw( | 993 return AreRequiredTilesReadyToDraw( |
989 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); | 994 RasterTilePriorityQueue::Type::REQUIRED_FOR_DRAW); |
990 } | 995 } |
991 | 996 |
992 void TileManager::CheckAndIssueSignals() { | 997 void TileManager::CheckAndIssueSignals() { |
993 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); | 998 TRACE_EVENT0("cc", "TileManager::CheckAndIssueSignals"); |
994 tile_task_runner_->CheckForCompletedTasks(); | 999 CheckForCompletedTasks(); |
995 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1000 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
996 | 1001 |
997 // Ready to activate. | 1002 // Ready to activate. |
998 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { | 1003 if (signals_.ready_to_activate && !signals_.did_notify_ready_to_activate) { |
999 signals_.ready_to_activate = false; | 1004 signals_.ready_to_activate = false; |
1000 if (IsReadyToActivate()) { | 1005 if (IsReadyToActivate()) { |
1001 TRACE_EVENT0("disabled-by-default-cc.debug", | 1006 TRACE_EVENT0("disabled-by-default-cc.debug", |
1002 "TileManager::CheckAndIssueSignals - ready to activate"); | 1007 "TileManager::CheckAndIssueSignals - ready to activate"); |
1003 signals_.did_notify_ready_to_activate = true; | 1008 signals_.did_notify_ready_to_activate = true; |
1004 client_->NotifyReadyToActivate(); | 1009 client_->NotifyReadyToActivate(); |
(...skipping 19 matching lines...) Expand all Loading... | |
1024 TRACE_EVENT0( | 1029 TRACE_EVENT0( |
1025 "disabled-by-default-cc.debug", | 1030 "disabled-by-default-cc.debug", |
1026 "TileManager::CheckAndIssueSignals - all tile tasks completed"); | 1031 "TileManager::CheckAndIssueSignals - all tile tasks completed"); |
1027 signals_.did_notify_all_tile_tasks_completed = true; | 1032 signals_.did_notify_all_tile_tasks_completed = true; |
1028 client_->NotifyAllTileTasksCompleted(); | 1033 client_->NotifyAllTileTasksCompleted(); |
1029 } | 1034 } |
1030 } | 1035 } |
1031 } | 1036 } |
1032 | 1037 |
1033 void TileManager::CheckIfMoreTilesNeedToBePrepared() { | 1038 void TileManager::CheckIfMoreTilesNeedToBePrepared() { |
1034 tile_task_runner_->CheckForCompletedTasks(); | 1039 CheckForCompletedTasks(); |
1035 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; | 1040 did_check_for_completed_tasks_since_last_schedule_tasks_ = true; |
1036 | 1041 |
1037 // When OOM, keep re-assigning memory until we reach a steady state | 1042 // When OOM, keep re-assigning memory until we reach a steady state |
1038 // where top-priority tiles are initialized. | 1043 // where top-priority tiles are initialized. |
1039 PrioritizedTileVector tiles_that_need_to_be_rasterized; | 1044 PrioritizedTileVector tiles_that_need_to_be_rasterized; |
1040 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( | 1045 scoped_ptr<RasterTilePriorityQueue> raster_priority_queue( |
1041 client_->BuildRasterQueue(global_state_.tree_priority, | 1046 client_->BuildRasterQueue(global_state_.tree_priority, |
1042 RasterTilePriorityQueue::Type::ALL)); | 1047 RasterTilePriorityQueue::Type::ALL)); |
1043 AssignGpuMemoryToTiles(raster_priority_queue.get(), | 1048 AssignGpuMemoryToTiles(raster_priority_queue.get(), |
1044 scheduled_raster_task_limit_, | 1049 scheduled_raster_task_limit_, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1217 void TileManager::Signals::reset() { | 1222 void TileManager::Signals::reset() { |
1218 ready_to_activate = false; | 1223 ready_to_activate = false; |
1219 did_notify_ready_to_activate = false; | 1224 did_notify_ready_to_activate = false; |
1220 ready_to_draw = false; | 1225 ready_to_draw = false; |
1221 did_notify_ready_to_draw = false; | 1226 did_notify_ready_to_draw = false; |
1222 all_tile_tasks_completed = false; | 1227 all_tile_tasks_completed = false; |
1223 did_notify_all_tile_tasks_completed = false; | 1228 did_notify_all_tile_tasks_completed = false; |
1224 } | 1229 } |
1225 | 1230 |
1226 } // namespace cc | 1231 } // namespace cc |
OLD | NEW |