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/zero_copy_tile_task_worker_pool.h" | 5 #include "cc/raster/zero_copy_tile_task_worker_pool.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::Shutdown"); | 97 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::Shutdown"); |
98 | 98 |
99 TaskGraph empty; | 99 TaskGraph empty; |
100 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 100 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
101 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 101 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
102 } | 102 } |
103 | 103 |
104 void ZeroCopyTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { | 104 void ZeroCopyTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { |
105 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::ScheduleTasks"); | 105 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::ScheduleTasks"); |
106 | 106 |
107 ScheduleTasksOnOriginThread(this, graph); | |
108 task_graph_runner_->ScheduleTasks(namespace_token_, graph); | 107 task_graph_runner_->ScheduleTasks(namespace_token_, graph); |
109 } | 108 } |
110 | 109 |
111 void ZeroCopyTileTaskWorkerPool::CheckForCompletedTasks() { | 110 void ZeroCopyTileTaskWorkerPool::CollectCompletedTasks( |
| 111 Task::Vector* completed_tasks) { |
112 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::CheckForCompletedTasks"); | 112 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::CheckForCompletedTasks"); |
113 | 113 |
114 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 114 task_graph_runner_->CollectCompletedTasks(namespace_token_, completed_tasks); |
115 &completed_tasks_); | |
116 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | |
117 it != completed_tasks_.end(); ++it) { | |
118 TileTask* task = static_cast<TileTask*>(it->get()); | |
119 | |
120 task->WillComplete(); | |
121 task->CompleteOnOriginThread(this); | |
122 task->DidComplete(); | |
123 } | |
124 completed_tasks_.clear(); | |
125 } | 115 } |
126 | 116 |
127 ResourceFormat ZeroCopyTileTaskWorkerPool::GetResourceFormat( | 117 ResourceFormat ZeroCopyTileTaskWorkerPool::GetResourceFormat( |
128 bool must_support_alpha) const { | 118 bool must_support_alpha) const { |
129 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && | 119 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && |
130 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || | 120 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || |
131 !must_support_alpha)) { | 121 !must_support_alpha)) { |
132 return preferred_tile_format_; | 122 return preferred_tile_format_; |
133 } | 123 } |
134 | 124 |
135 return resource_provider_->best_texture_format(); | 125 return resource_provider_->best_texture_format(); |
136 } | 126 } |
137 | 127 |
138 bool ZeroCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( | 128 bool ZeroCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( |
139 bool must_support_alpha) const { | 129 bool must_support_alpha) const { |
140 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | 130 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); |
141 } | 131 } |
142 | 132 |
| 133 TileTaskClient* ZeroCopyTileTaskWorkerPool::AsTileTaskClient() { |
| 134 return this; |
| 135 } |
| 136 |
143 scoped_ptr<RasterBuffer> ZeroCopyTileTaskWorkerPool::AcquireBufferForRaster( | 137 scoped_ptr<RasterBuffer> ZeroCopyTileTaskWorkerPool::AcquireBufferForRaster( |
144 const Resource* resource, | 138 const Resource* resource, |
145 uint64_t resource_content_id, | 139 uint64_t resource_content_id, |
146 uint64_t previous_content_id) { | 140 uint64_t previous_content_id) { |
147 return make_scoped_ptr<RasterBuffer>( | 141 return make_scoped_ptr<RasterBuffer>( |
148 new RasterBufferImpl(resource_provider_, resource)); | 142 new RasterBufferImpl(resource_provider_, resource)); |
149 } | 143 } |
150 | 144 |
151 void ZeroCopyTileTaskWorkerPool::ReleaseBufferForRaster( | 145 void ZeroCopyTileTaskWorkerPool::ReleaseBufferForRaster( |
152 scoped_ptr<RasterBuffer> buffer) { | 146 scoped_ptr<RasterBuffer> buffer) { |
153 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 147 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
154 } | 148 } |
155 | 149 |
156 } // namespace cc | 150 } // namespace cc |
OLD | NEW |