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> |
11 #include <limits> | 11 #include <limits> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/numerics/safe_conversions.h" | 19 #include "base/numerics/safe_conversions.h" |
20 #include "base/trace_event/trace_event_argument.h" | 20 #include "base/trace_event/trace_event_argument.h" |
21 #include "cc/base/histograms.h" | 21 #include "cc/base/histograms.h" |
22 #include "cc/debug/devtools_instrumentation.h" | 22 #include "cc/debug/devtools_instrumentation.h" |
23 #include "cc/debug/frame_viewer_instrumentation.h" | 23 #include "cc/debug/frame_viewer_instrumentation.h" |
24 #include "cc/debug/traced_value.h" | 24 #include "cc/debug/traced_value.h" |
25 #include "cc/layers/picture_layer_impl.h" | 25 #include "cc/layers/picture_layer_impl.h" |
26 #include "cc/raster/raster_buffer.h" | |
27 #include "cc/raster/task_category.h" | 26 #include "cc/raster/task_category.h" |
28 #include "cc/raster/tile_task_runner.h" | 27 #include "cc/raster/tile_task_runner.h" |
29 #include "cc/tiles/tile.h" | 28 #include "cc/tiles/tile.h" |
30 #include "ui/gfx/geometry/rect_conversions.h" | 29 #include "ui/gfx/geometry/rect_conversions.h" |
31 | 30 |
32 namespace cc { | 31 namespace cc { |
33 namespace { | 32 namespace { |
34 | 33 |
35 // Flag to indicate whether we should try and detect that | 34 // Flag to indicate whether we should try and detect that |
36 // a tile is of solid color. | 35 // a tile is of solid color. |
37 const bool kUseColorEstimator = true; | 36 const bool kUseColorEstimator = true; |
38 | 37 |
39 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( | 38 DEFINE_SCOPED_UMA_HISTOGRAM_AREA_TIMER( |
40 ScopedRasterTaskTimer, | 39 ScopedRasterTaskTimer, |
41 "Compositing.%s.RasterTask.RasterUs", | 40 "Compositing.%s.RasterTask.RasterUs", |
42 "Compositing.%s.RasterTask.RasterPixelsPerMs"); | 41 "Compositing.%s.RasterTask.RasterPixelsPerMs"); |
43 | 42 |
44 class RasterTaskImpl : public RasterTask { | 43 class RasterTaskImpl : public Task { |
45 public: | 44 public: |
46 RasterTaskImpl(const Resource* resource, | 45 RasterTaskImpl(RasterBufferProvider* raster_buffer_provider, |
46 const 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 const base::Callback<void(bool)>& reply) |
61 ImageDecodeTask::Vector* dependencies) | 61 : raster_buffer_provider_(raster_buffer_provider), |
62 : RasterTask(dependencies), | |
63 resource_(resource), | 62 resource_(resource), |
64 raster_source_(std::move(raster_source)), | 63 raster_source_(std::move(raster_source)), |
65 content_rect_(content_rect), | 64 content_rect_(content_rect), |
66 invalid_content_rect_(invalid_content_rect), | 65 invalid_content_rect_(invalid_content_rect), |
67 contents_scale_(contents_scale), | 66 contents_scale_(contents_scale), |
68 playback_settings_(playback_settings), | 67 playback_settings_(playback_settings), |
69 tile_resolution_(tile_resolution), | 68 tile_resolution_(tile_resolution), |
70 layer_id_(layer_id), | 69 layer_id_(layer_id), |
71 source_prepare_tiles_id_(source_prepare_tiles_id), | 70 source_prepare_tiles_id_(source_prepare_tiles_id), |
72 tile_(tile), | 71 tile_(tile), |
73 new_content_id_(new_content_id), | 72 new_content_id_(new_content_id), |
74 previous_content_id_(previous_content_id), | 73 previous_content_id_(previous_content_id), |
75 resource_content_id_(resource_content_id), | 74 resource_content_id_(resource_content_id), |
76 source_frame_number_(source_frame_number), | 75 source_frame_number_(source_frame_number), |
77 reply_(reply) {} | 76 reply_(reply) {} |
78 | 77 |
79 // Overridden from Task: | 78 // Overridden from Task: |
79 void ScheduleOnOriginThread() override { | |
80 DCHECK(raster_buffer_provider_); | |
81 DCHECK(!raster_buffer_); | |
82 raster_buffer_ = raster_buffer_provider_->AcquireBufferForRaster( | |
83 resource_, resource_content_id_, previous_content_id_); | |
84 } | |
85 | |
86 void CompleteOnOriginThread() override { | |
87 DCHECK(raster_buffer_provider_); | |
88 raster_buffer_provider_->ReleaseBufferForRaster(std::move(raster_buffer_)); | |
89 reply_.Run(!HasFinishedRunning()); | |
90 } | |
91 | |
80 void RunOnWorkerThread() override { | 92 void RunOnWorkerThread() override { |
81 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", | 93 TRACE_EVENT1("cc", "RasterizerTaskImpl::RunOnWorkerThread", |
82 "source_prepare_tiles_id", source_prepare_tiles_id_); | 94 "source_prepare_tiles_id", source_prepare_tiles_id_); |
83 | 95 |
84 DCHECK(raster_source_.get()); | 96 DCHECK(raster_source_.get()); |
85 DCHECK(raster_buffer_); | 97 DCHECK(raster_buffer_); |
86 | 98 |
87 frame_viewer_instrumentation::ScopedRasterTask raster_task( | 99 frame_viewer_instrumentation::ScopedRasterTask raster_task( |
88 tile_, tile_resolution_, source_frame_number_, layer_id_); | 100 tile_, tile_resolution_, source_frame_number_, layer_id_); |
89 ScopedRasterTaskTimer timer; | 101 ScopedRasterTaskTimer timer; |
90 timer.SetArea(content_rect_.size().GetArea()); | 102 timer.SetArea(content_rect_.size().GetArea()); |
91 | 103 |
92 DCHECK(raster_source_); | 104 DCHECK(raster_source_); |
93 | 105 |
94 raster_buffer_->Playback(raster_source_.get(), content_rect_, | 106 raster_buffer_->Playback(raster_source_.get(), content_rect_, |
95 invalid_content_rect_, new_content_id_, | 107 invalid_content_rect_, new_content_id_, |
96 contents_scale_, playback_settings_); | 108 contents_scale_, playback_settings_); |
97 } | 109 } |
98 | 110 |
99 // Overridden from TileTask: | |
100 void ScheduleOnOriginThread(TileTaskClient* client) 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 | |
110 protected: | 111 protected: |
111 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } | 112 ~RasterTaskImpl() override { DCHECK(!raster_buffer_); } |
112 | 113 |
113 private: | 114 private: |
115 RasterBufferProvider* raster_buffer_provider_; | |
114 const Resource* resource_; | 116 const Resource* resource_; |
115 scoped_refptr<RasterSource> raster_source_; | 117 scoped_refptr<RasterSource> raster_source_; |
116 gfx::Rect content_rect_; | 118 gfx::Rect content_rect_; |
117 gfx::Rect invalid_content_rect_; | 119 gfx::Rect invalid_content_rect_; |
118 float contents_scale_; | 120 float contents_scale_; |
119 RasterSource::PlaybackSettings playback_settings_; | 121 RasterSource::PlaybackSettings playback_settings_; |
120 TileResolution tile_resolution_; | 122 TileResolution tile_resolution_; |
121 int layer_id_; | 123 int layer_id_; |
122 uint64_t source_prepare_tiles_id_; | 124 uint64_t source_prepare_tiles_id_; |
123 const void* tile_; | 125 const void* tile_; |
(...skipping 11 matching lines...) Expand all Loading... | |
135 // other remaining tasks. | 137 // other remaining tasks. |
136 const size_t kRequiredForActivationDoneTaskPriority = 1u; | 138 const size_t kRequiredForActivationDoneTaskPriority = 1u; |
137 const size_t kRequiredForDrawDoneTaskPriority = 2u; | 139 const size_t kRequiredForDrawDoneTaskPriority = 2u; |
138 const size_t kAllDoneTaskPriority = 3u; | 140 const size_t kAllDoneTaskPriority = 3u; |
139 | 141 |
140 // For correctness, |kTileTaskPriorityBase| must be greater than | 142 // For correctness, |kTileTaskPriorityBase| must be greater than |
141 // all task set done task priorities. | 143 // all task set done task priorities. |
142 size_t kTileTaskPriorityBase = 10u; | 144 size_t kTileTaskPriorityBase = 10u; |
143 | 145 |
144 void InsertNodeForTask(TaskGraph* graph, | 146 void InsertNodeForTask(TaskGraph* graph, |
145 TileTask* task, | 147 Task* task, |
146 uint16_t category, | 148 uint16_t category, |
147 uint16_t priority, | 149 uint16_t priority, |
148 size_t dependencies) { | 150 size_t dependencies) { |
149 DCHECK(std::find_if(graph->nodes.begin(), graph->nodes.end(), | 151 DCHECK(std::find_if(graph->nodes.begin(), graph->nodes.end(), |
150 [task](const TaskGraph::Node& node) { | 152 [task](const TaskGraph::Node& node) { |
151 return node.task == task; | 153 return node.task == task; |
152 }) == graph->nodes.end()); | 154 }) == graph->nodes.end()); |
153 graph->nodes.push_back( | 155 graph->nodes.push_back( |
154 TaskGraph::Node(task, category, priority, dependencies)); | 156 TaskGraph::Node(task, category, priority, dependencies)); |
155 } | 157 } |
156 | 158 |
157 void InsertNodesForRasterTask(TaskGraph* graph, | 159 void InsertNodesForRasterTask(TaskGraph* graph, |
158 RasterTask* raster_task, | 160 Task* raster_task, |
159 const ImageDecodeTask::Vector& decode_tasks, | 161 const Task::Vector& decode_tasks, |
160 size_t priority, | 162 size_t priority, |
161 bool use_gpu_rasterization, | 163 bool use_gpu_rasterization, |
162 bool high_priority) { | 164 bool high_priority) { |
163 size_t dependencies = 0u; | 165 size_t dependencies = 0u; |
164 | 166 |
165 // Determine the TaskCategory for raster tasks - if a task uses GPU, it | 167 // Determine the TaskCategory for raster tasks - if a task uses GPU, it |
166 // cannot run concurrently and is assigned | 168 // cannot run concurrently and is assigned |
167 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND, regardless of its priority. | 169 // TASK_CATEGORY_NONCONCURRENT_FOREGROUND, regardless of its priority. |
168 // Otherwise its category is based on its priority. | 170 // Otherwise its category is based on its priority. |
169 TaskCategory raster_task_category; | 171 TaskCategory raster_task_category; |
170 if (use_gpu_rasterization) { | 172 if (use_gpu_rasterization) { |
171 raster_task_category = TASK_CATEGORY_NONCONCURRENT_FOREGROUND; | 173 raster_task_category = TASK_CATEGORY_NONCONCURRENT_FOREGROUND; |
172 } else { | 174 } else { |
173 raster_task_category = | 175 raster_task_category = |
174 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; | 176 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; |
175 } | 177 } |
176 | 178 |
177 // Determine the TaskCategory for decode tasks. This category is based on | 179 // Determine the TaskCategory for decode tasks. This category is based on |
178 // the priority of the raster task which depends on it. | 180 // the priority of the raster task which depends on it. |
179 TaskCategory decode_task_category = | 181 TaskCategory decode_task_category = |
180 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; | 182 high_priority ? TASK_CATEGORY_FOREGROUND : TASK_CATEGORY_BACKGROUND; |
181 | 183 |
182 // Insert image decode tasks. | 184 // Insert image decode tasks. |
183 for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin(); | 185 for (Task::Vector::const_iterator it = decode_tasks.begin(); |
184 it != decode_tasks.end(); ++it) { | 186 it != decode_tasks.end(); ++it) { |
185 ImageDecodeTask* decode_task = it->get(); | 187 Task* decode_task = it->get(); |
186 | 188 |
187 // Skip if already decoded. | 189 // Skip if already decoded. |
188 if (decode_task->HasCompleted()) | 190 if (decode_task->HasCompleted()) |
189 continue; | 191 continue; |
190 | 192 |
191 dependencies++; | 193 dependencies++; |
192 | 194 |
193 // Add decode task if it doesn't already exists in graph. | 195 // Add decode task if it doesn't already exists in graph. |
194 TaskGraph::Node::Vector::iterator decode_it = | 196 TaskGraph::Node::Vector::iterator decode_it = |
195 std::find_if(graph->nodes.begin(), graph->nodes.end(), | 197 std::find_if(graph->nodes.begin(), graph->nodes.end(), |
(...skipping 15 matching lines...) Expand all Loading... | |
211 InsertNodeForTask(graph, decode_task, decode_task_category, priority, 0u); | 213 InsertNodeForTask(graph, decode_task, decode_task_category, priority, 0u); |
212 } | 214 } |
213 | 215 |
214 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); | 216 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); |
215 } | 217 } |
216 | 218 |
217 InsertNodeForTask(graph, raster_task, raster_task_category, priority, | 219 InsertNodeForTask(graph, raster_task, raster_task_category, priority, |
218 dependencies); | 220 dependencies); |
219 } | 221 } |
220 | 222 |
221 class TaskSetFinishedTaskImpl : public TileTask { | 223 class TaskSetFinishedTaskImpl : public Task { |
222 public: | 224 public: |
223 explicit TaskSetFinishedTaskImpl( | 225 explicit TaskSetFinishedTaskImpl( |
224 base::SequencedTaskRunner* task_runner, | 226 base::SequencedTaskRunner* task_runner, |
225 const base::Closure& on_task_set_finished_callback) | 227 const base::Closure& on_task_set_finished_callback) |
226 : task_runner_(task_runner), | 228 : task_runner_(task_runner), |
227 on_task_set_finished_callback_(on_task_set_finished_callback) {} | 229 on_task_set_finished_callback_(on_task_set_finished_callback) {} |
228 | 230 |
229 // Overridden from Task: | 231 // Overridden from Task: |
232 void ScheduleOnOriginThread() override {} | |
233 void CompleteOnOriginThread() override {} | |
230 void RunOnWorkerThread() override { | 234 void RunOnWorkerThread() override { |
231 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); | 235 TRACE_EVENT0("cc", "TaskSetFinishedTaskImpl::RunOnWorkerThread"); |
232 TaskSetFinished(); | 236 TaskSetFinished(); |
233 } | 237 } |
234 | 238 |
235 // Overridden from TileTask: | |
236 void ScheduleOnOriginThread(TileTaskClient* client) override {} | |
237 void CompleteOnOriginThread(TileTaskClient* client) override {} | |
238 | |
239 protected: | 239 protected: |
240 ~TaskSetFinishedTaskImpl() override {} | 240 ~TaskSetFinishedTaskImpl() override {} |
241 | 241 |
242 void TaskSetFinished() { | 242 void TaskSetFinished() { |
243 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); | 243 task_runner_->PostTask(FROM_HERE, on_task_set_finished_callback_); |
244 } | 244 } |
245 | 245 |
246 private: | 246 private: |
247 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 247 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
248 const base::Closure on_task_set_finished_callback_; | 248 const base::Closure on_task_set_finished_callback_; |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 | 733 |
734 // Track the number of dependents for each *_done task. | 734 // Track the number of dependents for each *_done task. |
735 size_t required_for_activate_count = 0; | 735 size_t required_for_activate_count = 0; |
736 size_t required_for_draw_count = 0; | 736 size_t required_for_draw_count = 0; |
737 size_t all_count = 0; | 737 size_t all_count = 0; |
738 | 738 |
739 size_t priority = kTileTaskPriorityBase; | 739 size_t priority = kTileTaskPriorityBase; |
740 | 740 |
741 graph_.Reset(); | 741 graph_.Reset(); |
742 | 742 |
743 scoped_refptr<TileTask> required_for_activation_done_task = | 743 scoped_refptr<Task> required_for_activation_done_task = |
744 CreateTaskSetFinishedTask( | 744 CreateTaskSetFinishedTask( |
745 &TileManager::DidFinishRunningTileTasksRequiredForActivation); | 745 &TileManager::DidFinishRunningTileTasksRequiredForActivation); |
746 scoped_refptr<TileTask> required_for_draw_done_task = | 746 scoped_refptr<Task> required_for_draw_done_task = CreateTaskSetFinishedTask( |
747 CreateTaskSetFinishedTask( | 747 &TileManager::DidFinishRunningTileTasksRequiredForDraw); |
748 &TileManager::DidFinishRunningTileTasksRequiredForDraw); | 748 scoped_refptr<Task> all_done_task = |
749 scoped_refptr<TileTask> all_done_task = | |
750 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); | 749 CreateTaskSetFinishedTask(&TileManager::DidFinishRunningAllTileTasks); |
751 | 750 |
752 // Build a new task queue containing all task currently needed. Tasks | 751 // Build a new task queue containing all task currently needed. Tasks |
753 // are added in order of priority, highest priority task first. | 752 // are added in order of priority, highest priority task first. |
754 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { | 753 for (auto& prioritized_tile : tiles_that_need_to_be_rasterized) { |
755 Tile* tile = prioritized_tile.tile(); | 754 Tile* tile = prioritized_tile.tile(); |
756 | 755 |
757 DCHECK(tile->draw_info().requires_resource()); | 756 DCHECK(tile->draw_info().requires_resource()); |
758 DCHECK(!tile->draw_info().resource_); | 757 DCHECK(!tile->draw_info().resource_); |
759 | 758 |
759 Task::Vector dependencies; | |
760 if (!tile->raster_task_) | 760 if (!tile->raster_task_) |
761 tile->raster_task_ = CreateRasterTask(prioritized_tile); | 761 tile->raster_task_ = CreateRasterTask(prioritized_tile, &dependencies); |
prashant.n
2016/04/06 14:59:47
When same tile is rescheduled, this will pose inco
| |
762 | 762 |
763 RasterTask* task = tile->raster_task_.get(); | 763 Task* task = tile->raster_task_.get(); |
764 DCHECK(!task->HasCompleted()); | 764 DCHECK(!task->HasCompleted()); |
765 | 765 |
766 if (tile->required_for_activation()) { | 766 if (tile->required_for_activation()) { |
767 required_for_activate_count++; | 767 required_for_activate_count++; |
768 graph_.edges.push_back( | 768 graph_.edges.push_back( |
769 TaskGraph::Edge(task, required_for_activation_done_task.get())); | 769 TaskGraph::Edge(task, required_for_activation_done_task.get())); |
770 } | 770 } |
771 if (tile->required_for_draw()) { | 771 if (tile->required_for_draw()) { |
772 required_for_draw_count++; | 772 required_for_draw_count++; |
773 graph_.edges.push_back( | 773 graph_.edges.push_back( |
774 TaskGraph::Edge(task, required_for_draw_done_task.get())); | 774 TaskGraph::Edge(task, required_for_draw_done_task.get())); |
775 } | 775 } |
776 all_count++; | 776 all_count++; |
777 graph_.edges.push_back(TaskGraph::Edge(task, all_done_task.get())); | 777 graph_.edges.push_back(TaskGraph::Edge(task, all_done_task.get())); |
778 | 778 |
779 // A tile is high priority if it is either blocking future compositing | 779 // A tile is high priority if it is either blocking future compositing |
780 // (required for draw or required for activation), or if it has a priority | 780 // (required for draw or required for activation), or if it has a priority |
781 // bin of NOW for another reason (low resolution tiles). | 781 // bin of NOW for another reason (low resolution tiles). |
782 bool high_priority = | 782 bool high_priority = |
783 tile->required_for_draw() || tile->required_for_activation() || | 783 tile->required_for_draw() || tile->required_for_activation() || |
784 prioritized_tile.priority().priority_bin == TilePriority::NOW; | 784 prioritized_tile.priority().priority_bin == TilePriority::NOW; |
785 InsertNodesForRasterTask(&graph_, task, task->dependencies(), priority++, | 785 InsertNodesForRasterTask(&graph_, task, dependencies, priority++, |
786 use_gpu_rasterization_, high_priority); | 786 use_gpu_rasterization_, high_priority); |
787 } | 787 } |
788 | 788 |
789 // Insert nodes for our task completion tasks. We enqueue these using | 789 // Insert nodes for our task completion tasks. We enqueue these using |
790 // FOREGROUND priority as they are relatively quick tasks and we'd like | 790 // FOREGROUND priority as they are relatively quick tasks and we'd like |
791 // to trigger our callbacks quickly to aid in scheduling. | 791 // to trigger our callbacks quickly to aid in scheduling. |
792 InsertNodeForTask(&graph_, required_for_activation_done_task.get(), | 792 InsertNodeForTask(&graph_, required_for_activation_done_task.get(), |
793 TASK_CATEGORY_FOREGROUND, | 793 TASK_CATEGORY_FOREGROUND, |
794 kRequiredForActivationDoneTaskPriority, | 794 kRequiredForActivationDoneTaskPriority, |
795 required_for_activate_count); | 795 required_for_activate_count); |
(...skipping 23 matching lines...) Expand all Loading... | |
819 std::move(required_for_activation_done_task); | 819 std::move(required_for_activation_done_task); |
820 required_for_draw_done_task_ = std::move(required_for_draw_done_task); | 820 required_for_draw_done_task_ = std::move(required_for_draw_done_task); |
821 all_done_task_ = std::move(all_done_task); | 821 all_done_task_ = std::move(all_done_task); |
822 | 822 |
823 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; | 823 did_check_for_completed_tasks_since_last_schedule_tasks_ = false; |
824 | 824 |
825 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", | 825 TRACE_EVENT_ASYNC_STEP_INTO1("cc", "ScheduledTasks", this, "running", "state", |
826 ScheduledTasksStateAsValue()); | 826 ScheduledTasksStateAsValue()); |
827 } | 827 } |
828 | 828 |
829 scoped_refptr<RasterTask> TileManager::CreateRasterTask( | 829 scoped_refptr<Task> TileManager::CreateRasterTask( |
830 const PrioritizedTile& prioritized_tile) { | 830 const PrioritizedTile& prioritized_tile, |
831 Task::Vector* dependencies) { | |
831 Tile* tile = prioritized_tile.tile(); | 832 Tile* tile = prioritized_tile.tile(); |
833 DCHECK(dependencies); | |
832 | 834 |
833 // Get the resource. | 835 // Get the resource. |
834 uint64_t resource_content_id = 0; | 836 uint64_t resource_content_id = 0; |
835 Resource* resource = nullptr; | 837 Resource* resource = nullptr; |
836 if (use_partial_raster_ && tile->invalidated_id()) { | 838 if (use_partial_raster_ && tile->invalidated_id()) { |
837 // TODO(danakj): For resources that are in use, we should still grab them | 839 // 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 | 840 // and copy from them instead of rastering everything. crbug.com/492754 |
839 resource = | 841 resource = |
840 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); | 842 resource_pool_->TryAcquireResourceWithContentId(tile->invalidated_id()); |
841 } | 843 } |
842 if (resource) { | 844 if (resource) { |
843 resource_content_id = tile->invalidated_id(); | 845 resource_content_id = tile->invalidated_id(); |
844 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); | 846 DCHECK_EQ(DetermineResourceFormat(tile), resource->format()); |
845 } else { | 847 } else { |
846 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), | 848 resource = resource_pool_->AcquireResource(tile->desired_texture_size(), |
847 DetermineResourceFormat(tile)); | 849 DetermineResourceFormat(tile)); |
848 } | 850 } |
849 | 851 |
850 // For LOW_RESOLUTION tiles, we don't draw or predecode images. | 852 // For LOW_RESOLUTION tiles, we don't draw or predecode images. |
851 RasterSource::PlaybackSettings playback_settings; | 853 RasterSource::PlaybackSettings playback_settings; |
852 playback_settings.skip_images = | 854 playback_settings.skip_images = |
853 prioritized_tile.priority().resolution == LOW_RESOLUTION; | 855 prioritized_tile.priority().resolution == LOW_RESOLUTION; |
854 | 856 |
855 // Create and queue all image decode tasks that this tile depends on. | 857 // Create and queue all image decode tasks that this tile depends on. |
856 ImageDecodeTask::Vector decode_tasks; | |
857 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; | 858 std::vector<DrawImage>& images = scheduled_draw_images_[tile->id()]; |
858 images.clear(); | 859 images.clear(); |
859 if (!playback_settings.skip_images) { | 860 if (!playback_settings.skip_images) { |
860 prioritized_tile.raster_source()->GetDiscardableImagesInRect( | 861 prioritized_tile.raster_source()->GetDiscardableImagesInRect( |
861 tile->enclosing_layer_rect(), tile->contents_scale(), &images); | 862 tile->enclosing_layer_rect(), tile->contents_scale(), &images); |
862 } | 863 } |
863 | 864 |
864 // TODO(vmpstr): We should disable image hijack canvas in | 865 // TODO(vmpstr): We should disable image hijack canvas in |
865 // |playback_settings| here if |images| is empty. | 866 // |playback_settings| here if |images| is empty. |
866 | 867 |
867 for (auto it = images.begin(); it != images.end();) { | 868 for (auto it = images.begin(); it != images.end();) { |
868 scoped_refptr<ImageDecodeTask> task; | 869 scoped_refptr<Task> task; |
869 bool need_to_unref_when_finished = | 870 bool need_to_unref_when_finished = |
870 image_decode_controller_->GetTaskForImageAndRef( | 871 image_decode_controller_->GetTaskForImageAndRef( |
871 *it, prepare_tiles_count_, &task); | 872 *it, prepare_tiles_count_, &task); |
872 if (task) | 873 if (task) |
873 decode_tasks.push_back(task); | 874 dependencies->push_back(task); |
874 | 875 |
875 if (need_to_unref_when_finished) | 876 if (need_to_unref_when_finished) |
876 ++it; | 877 ++it; |
877 else | 878 else |
878 it = images.erase(it); | 879 it = images.erase(it); |
879 } | 880 } |
880 | 881 |
881 return make_scoped_refptr(new RasterTaskImpl( | 882 return make_scoped_refptr(new RasterTaskImpl( |
882 resource, prioritized_tile.raster_source(), tile->content_rect(), | 883 tile_task_runner_, resource, prioritized_tile.raster_source(), |
883 tile->invalidated_content_rect(), tile->contents_scale(), | 884 tile->content_rect(), tile->invalidated_content_rect(), |
884 playback_settings, prioritized_tile.priority().resolution, | 885 tile->contents_scale(), playback_settings, |
885 tile->layer_id(), prepare_tiles_count_, static_cast<const void*>(tile), | 886 prioritized_tile.priority().resolution, tile->layer_id(), |
886 tile->id(), tile->invalidated_id(), resource_content_id, | 887 prepare_tiles_count_, static_cast<const void*>(tile), tile->id(), |
887 tile->source_frame_number(), | 888 tile->invalidated_id(), resource_content_id, tile->source_frame_number(), |
888 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), | 889 base::Bind(&TileManager::OnRasterTaskCompleted, base::Unretained(this), |
889 tile->id(), resource), | 890 tile->id(), resource))); |
890 &decode_tasks)); | |
891 } | 891 } |
892 | 892 |
893 void TileManager::OnRasterTaskCompleted( | 893 void TileManager::OnRasterTaskCompleted( |
894 Tile::Id tile_id, | 894 Tile::Id tile_id, |
895 Resource* resource, | 895 Resource* resource, |
896 bool was_canceled) { | 896 bool was_canceled) { |
897 DCHECK(tiles_.find(tile_id) != tiles_.end()); | 897 DCHECK(tiles_.find(tile_id) != tiles_.end()); |
898 | 898 |
899 Tile* tile = tiles_[tile_id]; | 899 Tile* tile = tiles_[tile_id]; |
900 TileDrawInfo& draw_info = tile->draw_info(); | 900 TileDrawInfo& draw_info = tile->draw_info(); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1133 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); | 1133 state->SetBoolean("ready_to_activate", signals_.ready_to_activate); |
1134 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); | 1134 state->SetBoolean("ready_to_draw", signals_.ready_to_draw); |
1135 state->SetBoolean("all_tile_tasks_completed", | 1135 state->SetBoolean("all_tile_tasks_completed", |
1136 signals_.all_tile_tasks_completed); | 1136 signals_.all_tile_tasks_completed); |
1137 state->EndDictionary(); | 1137 state->EndDictionary(); |
1138 return std::move(state); | 1138 return std::move(state); |
1139 } | 1139 } |
1140 | 1140 |
1141 // Utility function that can be used to create a "Task set finished" task that | 1141 // Utility function that can be used to create a "Task set finished" task that |
1142 // posts |callback| to |task_runner| when run. | 1142 // posts |callback| to |task_runner| when run. |
1143 scoped_refptr<TileTask> TileManager::CreateTaskSetFinishedTask( | 1143 scoped_refptr<Task> TileManager::CreateTaskSetFinishedTask( |
1144 void (TileManager::*callback)()) { | 1144 void (TileManager::*callback)()) { |
1145 return make_scoped_refptr(new TaskSetFinishedTaskImpl( | 1145 return make_scoped_refptr(new TaskSetFinishedTaskImpl( |
1146 task_runner_.get(), | 1146 task_runner_.get(), |
1147 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); | 1147 base::Bind(callback, task_set_finished_weak_ptr_factory_.GetWeakPtr()))); |
1148 } | 1148 } |
1149 | 1149 |
1150 TileManager::MemoryUsage::MemoryUsage() | 1150 TileManager::MemoryUsage::MemoryUsage() |
1151 : memory_bytes_(0), resource_count_(0) {} | 1151 : memory_bytes_(0), resource_count_(0) {} |
1152 | 1152 |
1153 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, | 1153 TileManager::MemoryUsage::MemoryUsage(size_t memory_bytes, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1217 void TileManager::Signals::reset() { | 1217 void TileManager::Signals::reset() { |
1218 ready_to_activate = false; | 1218 ready_to_activate = false; |
1219 did_notify_ready_to_activate = false; | 1219 did_notify_ready_to_activate = false; |
1220 ready_to_draw = false; | 1220 ready_to_draw = false; |
1221 did_notify_ready_to_draw = false; | 1221 did_notify_ready_to_draw = false; |
1222 all_tile_tasks_completed = false; | 1222 all_tile_tasks_completed = false; |
1223 did_notify_all_tile_tasks_completed = false; | 1223 did_notify_all_tile_tasks_completed = false; |
1224 } | 1224 } |
1225 | 1225 |
1226 } // namespace cc | 1226 } // namespace cc |
OLD | NEW |