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 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
14 #include "base/trace_event/trace_event_argument.h" | 14 #include "base/trace_event/trace_event_argument.h" |
15 #include "cc/debug/traced_value.h" | 15 #include "cc/debug/traced_value.h" |
16 #include "cc/raster/raster_buffer.h" | |
17 #include "cc/resources/platform_color.h" | 16 #include "cc/resources/platform_color.h" |
18 #include "cc/resources/resource.h" | 17 #include "cc/resources/resource.h" |
19 #include "ui/gfx/buffer_format_util.h" | 18 #include "ui/gfx/buffer_format_util.h" |
20 #include "ui/gfx/gpu_memory_buffer.h" | 19 #include "ui/gfx/gpu_memory_buffer.h" |
21 | 20 |
22 namespace cc { | 21 namespace cc { |
23 namespace { | 22 namespace { |
24 | 23 |
25 class RasterBufferImpl : public RasterBuffer { | 24 class RasterBufferImpl : public RasterBuffer { |
26 public: | 25 public: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::Shutdown"); | 96 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::Shutdown"); |
98 | 97 |
99 TaskGraph empty; | 98 TaskGraph empty; |
100 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); | 99 task_graph_runner_->ScheduleTasks(namespace_token_, &empty); |
101 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); | 100 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_); |
102 } | 101 } |
103 | 102 |
104 void ZeroCopyTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { | 103 void ZeroCopyTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) { |
105 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::ScheduleTasks"); | 104 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::ScheduleTasks"); |
106 | 105 |
107 ScheduleTasksOnOriginThread(this, graph); | 106 ScheduleTasksOnOriginThread(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::CheckForCompletedTasks() { |
112 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::CheckForCompletedTasks"); | 111 TRACE_EVENT0("cc", "ZeroCopyTileTaskWorkerPool::CheckForCompletedTasks"); |
113 | 112 |
114 task_graph_runner_->CollectCompletedTasks(namespace_token_, | 113 task_graph_runner_->CollectCompletedTasks(namespace_token_, |
115 &completed_tasks_); | 114 &completed_tasks_); |
116 for (Task::Vector::const_iterator it = completed_tasks_.begin(); | 115 for (Task::Vector::const_iterator it = completed_tasks_.begin(); |
117 it != completed_tasks_.end(); ++it) { | 116 it != completed_tasks_.end(); ++it) { |
118 TileTask* task = static_cast<TileTask*>(it->get()); | 117 Task* task = it->get(); |
119 | 118 |
120 task->WillComplete(); | 119 task->WillComplete(); |
121 task->CompleteOnOriginThread(this); | 120 task->CompleteOnOriginThread(); |
122 task->DidComplete(); | 121 task->DidComplete(); |
123 } | 122 } |
124 completed_tasks_.clear(); | 123 completed_tasks_.clear(); |
125 } | 124 } |
126 | 125 |
127 ResourceFormat ZeroCopyTileTaskWorkerPool::GetResourceFormat( | 126 ResourceFormat ZeroCopyTileTaskWorkerPool::GetResourceFormat( |
128 bool must_support_alpha) const { | 127 bool must_support_alpha) const { |
129 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && | 128 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && |
130 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || | 129 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || |
131 !must_support_alpha)) { | 130 !must_support_alpha)) { |
(...skipping 15 matching lines...) Expand all Loading... |
147 return make_scoped_ptr<RasterBuffer>( | 146 return make_scoped_ptr<RasterBuffer>( |
148 new RasterBufferImpl(resource_provider_, resource)); | 147 new RasterBufferImpl(resource_provider_, resource)); |
149 } | 148 } |
150 | 149 |
151 void ZeroCopyTileTaskWorkerPool::ReleaseBufferForRaster( | 150 void ZeroCopyTileTaskWorkerPool::ReleaseBufferForRaster( |
152 scoped_ptr<RasterBuffer> buffer) { | 151 scoped_ptr<RasterBuffer> buffer) { |
153 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 152 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
154 } | 153 } |
155 | 154 |
156 } // namespace cc | 155 } // namespace cc |
OLD | NEW |