Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: cc/raster/gpu_tile_task_worker_pool.cc

Issue 1910213005: cc: Refactor TileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@task_states
Patch Set: nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gpu_tile_task_worker_pool.h" 5 #include "cc/raster/gpu_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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 ResourceProvider::ScopedWriteLockGr lock_; 83 ResourceProvider::ScopedWriteLockGr lock_;
84 bool resource_has_previous_content_; 84 bool resource_has_previous_content_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); 86 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
87 }; 87 };
88 88
89 } // namespace 89 } // namespace
90 90
91 // static 91 // static
92 std::unique_ptr<TileTaskWorkerPool> GpuTileTaskWorkerPool::Create( 92 std::unique_ptr<TileTaskWorkerPool> GpuTileTaskWorkerPool::Create(
93 base::SequencedTaskRunner* task_runner,
94 TaskGraphRunner* task_graph_runner,
95 ContextProvider* context_provider, 93 ContextProvider* context_provider,
96 ResourceProvider* resource_provider, 94 ResourceProvider* resource_provider,
97 bool use_distance_field_text, 95 bool use_distance_field_text,
98 int gpu_rasterization_msaa_sample_count) { 96 int gpu_rasterization_msaa_sample_count) {
99 return base::WrapUnique<TileTaskWorkerPool>(new GpuTileTaskWorkerPool( 97 return base::WrapUnique<TileTaskWorkerPool>(new GpuTileTaskWorkerPool(
100 task_runner, task_graph_runner, context_provider, resource_provider, 98 context_provider, resource_provider, use_distance_field_text,
101 use_distance_field_text, gpu_rasterization_msaa_sample_count)); 99 gpu_rasterization_msaa_sample_count));
102 } 100 }
103 101
104 GpuTileTaskWorkerPool::GpuTileTaskWorkerPool( 102 GpuTileTaskWorkerPool::GpuTileTaskWorkerPool(
105 base::SequencedTaskRunner* task_runner,
106 TaskGraphRunner* task_graph_runner,
107 ContextProvider* context_provider, 103 ContextProvider* context_provider,
108 ResourceProvider* resource_provider, 104 ResourceProvider* resource_provider,
109 bool use_distance_field_text, 105 bool use_distance_field_text,
110 int gpu_rasterization_msaa_sample_count) 106 int gpu_rasterization_msaa_sample_count)
111 : task_runner_(task_runner), 107 : rasterizer_(new GpuRasterizer(context_provider,
112 task_graph_runner_(task_graph_runner),
113 namespace_token_(task_graph_runner_->GetNamespaceToken()),
114 rasterizer_(new GpuRasterizer(context_provider,
115 resource_provider, 108 resource_provider,
116 use_distance_field_text, 109 use_distance_field_text,
117 gpu_rasterization_msaa_sample_count)) {} 110 gpu_rasterization_msaa_sample_count)) {}
118 111
119 GpuTileTaskWorkerPool::~GpuTileTaskWorkerPool() { 112 GpuTileTaskWorkerPool::~GpuTileTaskWorkerPool() {
120 DCHECK_EQ(0u, completed_tasks_.size());
121 } 113 }
122 114
123 void GpuTileTaskWorkerPool::Shutdown() { 115 void GpuTileTaskWorkerPool::BarrierToSyncResources() {
124 TRACE_EVENT0("cc", "GpuTileTaskWorkerPool::Shutdown"); 116 TRACE_EVENT0("cc", "GpuTileTaskWorkerPool::BarrierToSyncResources");
125 117
126 TaskGraph empty;
127 task_graph_runner_->ScheduleTasks(namespace_token_, &empty);
128 task_graph_runner_->WaitForTasksToFinishRunning(namespace_token_);
129 }
130
131 void GpuTileTaskWorkerPool::ScheduleTasks(TaskGraph* graph) {
132 TRACE_EVENT0("cc", "GpuTileTaskWorkerPool::ScheduleTasks");
133
134 ScheduleTasksOnOriginThread(this, graph);
135
136 // Barrier to sync any new resources to the worker context.
137 rasterizer_->resource_provider() 118 rasterizer_->resource_provider()
138 ->output_surface() 119 ->output_surface()
139 ->context_provider() 120 ->context_provider()
140 ->ContextGL() 121 ->ContextGL()
141 ->OrderingBarrierCHROMIUM(); 122 ->OrderingBarrierCHROMIUM();
142
143 task_graph_runner_->ScheduleTasks(namespace_token_, graph);
144 }
145
146 void GpuTileTaskWorkerPool::CheckForCompletedTasks() {
147 TRACE_EVENT0("cc", "GpuTileTaskWorkerPool::CheckForCompletedTasks");
148
149 task_graph_runner_->CollectCompletedTasks(namespace_token_,
150 &completed_tasks_);
151 CompleteTasks(completed_tasks_);
152 completed_tasks_.clear();
153 } 123 }
154 124
155 ResourceFormat GpuTileTaskWorkerPool::GetResourceFormat( 125 ResourceFormat GpuTileTaskWorkerPool::GetResourceFormat(
156 bool must_support_alpha) const { 126 bool must_support_alpha) const {
157 return rasterizer_->resource_provider()->best_render_buffer_format(); 127 return rasterizer_->resource_provider()->best_render_buffer_format();
158 } 128 }
159 129
160 bool GpuTileTaskWorkerPool::GetResourceRequiresSwizzle( 130 bool GpuTileTaskWorkerPool::GetResourceRequiresSwizzle(
161 bool must_support_alpha) const { 131 bool must_support_alpha) const {
162 // This doesn't require a swizzle because we rasterize to the correct format. 132 // This doesn't require a swizzle because we rasterize to the correct format.
163 return false; 133 return false;
164 } 134 }
165 135
166 RasterBufferProvider* GpuTileTaskWorkerPool::AsRasterBufferProvider() { 136 RasterBufferProvider* GpuTileTaskWorkerPool::AsRasterBufferProvider() {
167 return this; 137 return this;
168 } 138 }
169 139
170 void GpuTileTaskWorkerPool::CompleteTasks(const Task::Vector& tasks) {
171 for (auto& task : tasks) {
172 TileTask* tile_task = static_cast<TileTask*>(task.get());
173
174 tile_task->WillComplete();
175 tile_task->CompleteOnOriginThread(this);
176 tile_task->DidComplete();
177 }
178 completed_tasks_.clear();
179 }
180
181 std::unique_ptr<RasterBuffer> GpuTileTaskWorkerPool::AcquireBufferForRaster( 140 std::unique_ptr<RasterBuffer> GpuTileTaskWorkerPool::AcquireBufferForRaster(
182 const Resource* resource, 141 const Resource* resource,
183 uint64_t resource_content_id, 142 uint64_t resource_content_id,
184 uint64_t previous_content_id) { 143 uint64_t previous_content_id) {
185 return std::unique_ptr<RasterBuffer>(new RasterBufferImpl( 144 return std::unique_ptr<RasterBuffer>(new RasterBufferImpl(
186 rasterizer_.get(), resource, resource_content_id, previous_content_id)); 145 rasterizer_.get(), resource, resource_content_id, previous_content_id));
187 } 146 }
188 147
189 void GpuTileTaskWorkerPool::ReleaseBufferForRaster( 148 void GpuTileTaskWorkerPool::ReleaseBufferForRaster(
190 std::unique_ptr<RasterBuffer> buffer) { 149 std::unique_ptr<RasterBuffer> buffer) {
191 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. 150 // Nothing to do here. RasterBufferImpl destructor cleans up after itself.
192 } 151 }
193 152
194 } // namespace cc 153 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698