OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raster/tile_task_worker_pool.h" | 5 #include "cc/raster/tile_task_worker_pool.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/playback/display_list_raster_source.h" | 10 #include "cc/playback/display_list_raster_source.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // since it should finish as quickly as possible. | 54 // since it should finish as quickly as possible. |
55 size_t TileTaskWorkerPool::kBenchmarkTaskPriority = 0u; | 55 size_t TileTaskWorkerPool::kBenchmarkTaskPriority = 0u; |
56 // Task priorities that make sure task set finished tasks run before any | 56 // Task priorities that make sure task set finished tasks run before any |
57 // other remaining tasks. This is combined with the task set type to ensure | 57 // other remaining tasks. This is combined with the task set type to ensure |
58 // proper prioritization ordering between task set types. | 58 // proper prioritization ordering between task set types. |
59 size_t TileTaskWorkerPool::kTaskSetFinishedTaskPriorityBase = 1u; | 59 size_t TileTaskWorkerPool::kTaskSetFinishedTaskPriorityBase = 1u; |
60 // For correctness, |kTileTaskPriorityBase| must be greater than | 60 // For correctness, |kTileTaskPriorityBase| must be greater than |
61 // |kTaskSetFinishedTaskPriorityBase + kNumberOfTaskSets|. | 61 // |kTaskSetFinishedTaskPriorityBase + kNumberOfTaskSets|. |
62 size_t TileTaskWorkerPool::kTileTaskPriorityBase = 10u; | 62 size_t TileTaskWorkerPool::kTileTaskPriorityBase = 10u; |
63 | 63 |
64 TileTaskWorkerPool::TileTaskWorkerPool() { | 64 TileTaskWorkerPool::TileTaskWorkerPool() {} |
65 } | |
66 | 65 |
67 TileTaskWorkerPool::~TileTaskWorkerPool() { | 66 TileTaskWorkerPool::~TileTaskWorkerPool() {} |
68 } | |
69 | 67 |
70 // static | 68 // static |
71 scoped_refptr<TileTask> TileTaskWorkerPool::CreateTaskSetFinishedTask( | 69 scoped_refptr<TileTask> TileTaskWorkerPool::CreateTaskSetFinishedTask( |
72 base::SequencedTaskRunner* task_runner, | 70 base::SequencedTaskRunner* task_runner, |
73 const base::Closure& on_task_set_finished_callback) { | 71 const base::Closure& on_task_set_finished_callback) { |
74 return make_scoped_refptr( | 72 return make_scoped_refptr( |
75 new TaskSetFinishedTaskImpl(task_runner, on_task_set_finished_callback)); | 73 new TaskSetFinishedTaskImpl(task_runner, on_task_set_finished_callback)); |
76 } | 74 } |
77 | 75 |
78 // static | 76 // static |
(...skipping 13 matching lines...) Expand all Loading... |
92 } | 90 } |
93 } | 91 } |
94 } | 92 } |
95 | 93 |
96 // static | 94 // static |
97 void TileTaskWorkerPool::InsertNodeForTask(TaskGraph* graph, | 95 void TileTaskWorkerPool::InsertNodeForTask(TaskGraph* graph, |
98 TileTask* task, | 96 TileTask* task, |
99 size_t priority, | 97 size_t priority, |
100 size_t dependencies) { | 98 size_t dependencies) { |
101 DCHECK(std::find_if(graph->nodes.begin(), graph->nodes.end(), | 99 DCHECK(std::find_if(graph->nodes.begin(), graph->nodes.end(), |
102 TaskGraph::Node::TaskComparator(task)) == | 100 [task](const TaskGraph::Node& node) { |
103 graph->nodes.end()); | 101 return node.task == task; |
| 102 }) == graph->nodes.end()); |
104 graph->nodes.push_back(TaskGraph::Node(task, priority, dependencies)); | 103 graph->nodes.push_back(TaskGraph::Node(task, priority, dependencies)); |
105 } | 104 } |
106 | 105 |
107 // static | 106 // static |
108 void TileTaskWorkerPool::InsertNodesForRasterTask( | 107 void TileTaskWorkerPool::InsertNodesForRasterTask( |
109 TaskGraph* graph, | 108 TaskGraph* graph, |
110 RasterTask* raster_task, | 109 RasterTask* raster_task, |
111 const ImageDecodeTask::Vector& decode_tasks, | 110 const ImageDecodeTask::Vector& decode_tasks, |
112 size_t priority) { | 111 size_t priority) { |
113 size_t dependencies = 0u; | 112 size_t dependencies = 0u; |
114 | 113 |
115 // Insert image decode tasks. | 114 // Insert image decode tasks. |
116 for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin(); | 115 for (ImageDecodeTask::Vector::const_iterator it = decode_tasks.begin(); |
117 it != decode_tasks.end(); ++it) { | 116 it != decode_tasks.end(); ++it) { |
118 ImageDecodeTask* decode_task = it->get(); | 117 ImageDecodeTask* decode_task = it->get(); |
119 | 118 |
120 // Skip if already decoded. | 119 // Skip if already decoded. |
121 if (decode_task->HasCompleted()) | 120 if (decode_task->HasCompleted()) |
122 continue; | 121 continue; |
123 | 122 |
124 dependencies++; | 123 dependencies++; |
125 | 124 |
126 // Add decode task if it doesn't already exists in graph. | 125 // Add decode task if it doesn't already exists in graph. |
127 TaskGraph::Node::Vector::iterator decode_it = | 126 TaskGraph::Node::Vector::iterator decode_it = |
128 std::find_if(graph->nodes.begin(), graph->nodes.end(), | 127 std::find_if(graph->nodes.begin(), graph->nodes.end(), |
129 TaskGraph::Node::TaskComparator(decode_task)); | 128 [decode_task](const TaskGraph::Node& node) { |
| 129 return node.task == decode_task; |
| 130 }); |
130 if (decode_it == graph->nodes.end()) | 131 if (decode_it == graph->nodes.end()) |
131 InsertNodeForTask(graph, decode_task, priority, 0u); | 132 InsertNodeForTask(graph, decode_task, priority, 0u); |
132 | 133 |
133 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); | 134 graph->edges.push_back(TaskGraph::Edge(decode_task, raster_task)); |
134 } | 135 } |
135 | 136 |
136 InsertNodeForTask(graph, raster_task, priority, dependencies); | 137 InsertNodeForTask(graph, raster_task, priority, dependencies); |
137 } | 138 } |
138 | 139 |
139 static bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) { | 140 static bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 225 |
225 SkImageInfo dst_info = | 226 SkImageInfo dst_info = |
226 SkImageInfo::Make(info.width(), info.height(), buffer_color_type, | 227 SkImageInfo::Make(info.width(), info.height(), buffer_color_type, |
227 info.alphaType(), info.profileType()); | 228 info.alphaType(), info.profileType()); |
228 bool rv = canvas->readPixels(dst_info, memory, stride, 0, 0); | 229 bool rv = canvas->readPixels(dst_info, memory, stride, 0, 0); |
229 DCHECK(rv); | 230 DCHECK(rv); |
230 } | 231 } |
231 } | 232 } |
232 | 233 |
233 } // namespace cc | 234 } // namespace cc |
OLD | NEW |