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/resources/image_raster_worker_pool.h" | 5 #include "cc/resources/image_raster_worker_pool.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "cc/resources/resource.h" | 8 #include "cc/resources/resource.h" |
9 #include "third_party/skia/include/core/SkDevice.h" | 9 #include "third_party/skia/include/core/SkDevice.h" |
10 | 10 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void ImageRasterWorkerPool::ScheduleTasks(RasterTask::Queue* queue) { | 74 void ImageRasterWorkerPool::ScheduleTasks(RasterTask::Queue* queue) { |
75 TRACE_EVENT0("cc", "ImageRasterWorkerPool::ScheduleTasks"); | 75 TRACE_EVENT0("cc", "ImageRasterWorkerPool::ScheduleTasks"); |
76 | 76 |
77 internal::WorkerPoolTask::TaskVector tasks; | 77 internal::WorkerPoolTask::TaskVector tasks; |
78 | 78 |
79 RasterWorkerPool::SetRasterTasks(queue); | 79 RasterWorkerPool::SetRasterTasks(queue); |
80 | 80 |
81 for (RasterTask::Queue::TaskVector::const_iterator it = | 81 for (RasterTask::Queue::TaskVector::const_iterator it = |
82 raster_tasks().begin(); | 82 raster_tasks().begin(); |
83 it != raster_tasks().end(); ++it) { | 83 it != raster_tasks().end(); ++it) { |
84 internal::RasterWorkerPoolTask* task = *it; | 84 internal::RasterWorkerPoolTask* task = it->get(); |
85 | 85 |
86 TaskMap::iterator image_it = image_tasks_.find(task); | 86 TaskMap::iterator image_it = image_tasks_.find(task); |
87 if (image_it != image_tasks_.end()) { | 87 if (image_it != image_tasks_.end()) { |
88 internal::WorkerPoolTask* image_task = image_it->second; | 88 internal::WorkerPoolTask* image_task = image_it->second.get(); |
89 tasks.push_back(image_task); | 89 tasks.push_back(image_task); |
90 continue; | 90 continue; |
91 } | 91 } |
92 | 92 |
93 // Acquire image for resource. | 93 // Acquire image for resource. |
94 resource_provider()->AcquireImage(task->resource()->id()); | 94 resource_provider()->AcquireImage(task->resource()->id()); |
95 | 95 |
96 // Map image for raster. | 96 // Map image for raster. |
97 uint8* buffer = resource_provider()->MapImage(task->resource()->id()); | 97 uint8* buffer = resource_provider()->MapImage(task->resource()->id()); |
98 int stride = resource_provider()->GetImageStride(task->resource()->id()); | 98 int stride = resource_provider()->GetImageStride(task->resource()->id()); |
(...skipping 22 matching lines...) Expand all Loading... |
121 RootTask root(&tasks); | 121 RootTask root(&tasks); |
122 ScheduleRasterTasks(root); | 122 ScheduleRasterTasks(root); |
123 } | 123 } |
124 | 124 |
125 void ImageRasterWorkerPool::OnRasterTaskCompleted( | 125 void ImageRasterWorkerPool::OnRasterTaskCompleted( |
126 scoped_refptr<internal::RasterWorkerPoolTask> task, | 126 scoped_refptr<internal::RasterWorkerPoolTask> task, |
127 bool was_canceled) { | 127 bool was_canceled) { |
128 TRACE_EVENT1("cc", "ImageRasterWorkerPool::OnRasterTaskCompleted", | 128 TRACE_EVENT1("cc", "ImageRasterWorkerPool::OnRasterTaskCompleted", |
129 "was_canceled", was_canceled); | 129 "was_canceled", was_canceled); |
130 | 130 |
131 DCHECK(image_tasks_.find(task) != image_tasks_.end()); | 131 DCHECK(image_tasks_.find(task.get()) != image_tasks_.end()); |
132 | 132 |
133 // Balanced with MapImage() call in ScheduleTasks(). | 133 // Balanced with MapImage() call in ScheduleTasks(). |
134 resource_provider()->UnmapImage(task->resource()->id()); | 134 resource_provider()->UnmapImage(task->resource()->id()); |
135 | 135 |
136 // Bind image to resource. | 136 // Bind image to resource. |
137 resource_provider()->BindImage(task->resource()->id()); | 137 resource_provider()->BindImage(task->resource()->id()); |
138 | 138 |
139 if (!was_canceled) | 139 if (!was_canceled) |
140 task->DidRun(); | 140 task->DidRun(); |
141 | 141 |
142 task->DidComplete(); | 142 task->DidComplete(); |
143 task->DispatchCompletionCallback(); | 143 task->DispatchCompletionCallback(); |
144 | 144 |
145 image_tasks_.erase(task); | 145 image_tasks_.erase(task.get()); |
146 } | 146 } |
147 | 147 |
148 } // namespace cc | 148 } // namespace cc |
OLD | NEW |