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/tile_task_worker_pool.h" | 5 #include "cc/resources/tile_task_worker_pool.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
11 #include "cc/base/unique_notifier.h" | 11 #include "cc/base/unique_notifier.h" |
12 #include "cc/resources/bitmap_tile_task_worker_pool.h" | 12 #include "cc/resources/bitmap_tile_task_worker_pool.h" |
| 13 #include "cc/resources/gpu_rasterizer.h" |
13 #include "cc/resources/gpu_tile_task_worker_pool.h" | 14 #include "cc/resources/gpu_tile_task_worker_pool.h" |
14 #include "cc/resources/one_copy_tile_task_worker_pool.h" | 15 #include "cc/resources/one_copy_tile_task_worker_pool.h" |
15 #include "cc/resources/picture_pile.h" | 16 #include "cc/resources/picture_pile.h" |
16 #include "cc/resources/picture_pile_impl.h" | 17 #include "cc/resources/picture_pile_impl.h" |
17 #include "cc/resources/pixel_buffer_tile_task_worker_pool.h" | 18 #include "cc/resources/pixel_buffer_tile_task_worker_pool.h" |
18 #include "cc/resources/raster_buffer.h" | 19 #include "cc/resources/raster_buffer.h" |
19 #include "cc/resources/resource_pool.h" | 20 #include "cc/resources/resource_pool.h" |
20 #include "cc/resources/resource_provider.h" | 21 #include "cc/resources/resource_provider.h" |
21 #include "cc/resources/scoped_resource.h" | 22 #include "cc/resources/scoped_resource.h" |
22 #include "cc/resources/tile_task_runner.h" | 23 #include "cc/resources/tile_task_runner.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 unsigned id; | 120 unsigned id; |
120 bool canceled; | 121 bool canceled; |
121 }; | 122 }; |
122 | 123 |
123 typedef std::vector<scoped_refptr<RasterTask>> RasterTaskVector; | 124 typedef std::vector<scoped_refptr<RasterTask>> RasterTaskVector; |
124 | 125 |
125 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL }; | 126 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL }; |
126 | 127 |
127 TileTaskWorkerPoolTest() | 128 TileTaskWorkerPoolTest() |
128 : context_provider_(TestContextProvider::Create()), | 129 : context_provider_(TestContextProvider::Create()), |
| 130 worker_context_provider_(TestContextProvider::Create()), |
129 all_tile_tasks_finished_( | 131 all_tile_tasks_finished_( |
130 base::MessageLoopProxy::current().get(), | 132 base::MessageLoopProxy::current().get(), |
131 base::Bind(&TileTaskWorkerPoolTest::AllTileTasksFinished, | 133 base::Bind(&TileTaskWorkerPoolTest::AllTileTasksFinished, |
132 base::Unretained(this))), | 134 base::Unretained(this))), |
133 timeout_seconds_(5), | 135 timeout_seconds_(5), |
134 timed_out_(false) {} | 136 timed_out_(false) {} |
135 | 137 |
136 // Overridden from testing::Test: | 138 // Overridden from testing::Test: |
137 void SetUp() override { | 139 void SetUp() override { |
138 switch (GetParam()) { | 140 switch (GetParam()) { |
(...skipping 14 matching lines...) Expand all Loading... |
153 Create3dOutputSurfaceAndResourceProvider(); | 155 Create3dOutputSurfaceAndResourceProvider(); |
154 staging_resource_pool_ = ResourcePool::Create(resource_provider_.get(), | 156 staging_resource_pool_ = ResourcePool::Create(resource_provider_.get(), |
155 GL_TEXTURE_2D); | 157 GL_TEXTURE_2D); |
156 tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( | 158 tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( |
157 base::MessageLoopProxy::current().get(), | 159 base::MessageLoopProxy::current().get(), |
158 TileTaskWorkerPool::GetTaskGraphRunner(), context_provider_.get(), | 160 TileTaskWorkerPool::GetTaskGraphRunner(), context_provider_.get(), |
159 resource_provider_.get(), staging_resource_pool_.get()); | 161 resource_provider_.get(), staging_resource_pool_.get()); |
160 break; | 162 break; |
161 case TILE_TASK_WORKER_POOL_TYPE_GPU: | 163 case TILE_TASK_WORKER_POOL_TYPE_GPU: |
162 Create3dOutputSurfaceAndResourceProvider(); | 164 Create3dOutputSurfaceAndResourceProvider(); |
| 165 rasterizer_ = GpuRasterizer::Create( |
| 166 context_provider_.get(), resource_provider_.get(), false, false, 0); |
163 tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( | 167 tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( |
164 base::MessageLoopProxy::current().get(), | 168 base::MessageLoopProxy::current().get(), |
165 TileTaskWorkerPool::GetTaskGraphRunner(), | 169 TileTaskWorkerPool::GetTaskGraphRunner(), |
166 resource_provider_.get()); | 170 static_cast<GpuRasterizer*>(rasterizer_.get())); |
167 break; | 171 break; |
168 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: | 172 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: |
169 CreateSoftwareOutputSurfaceAndResourceProvider(); | 173 CreateSoftwareOutputSurfaceAndResourceProvider(); |
170 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( | 174 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( |
171 base::MessageLoopProxy::current().get(), | 175 base::MessageLoopProxy::current().get(), |
172 TileTaskWorkerPool::GetTaskGraphRunner(), resource_provider_.get()); | 176 TileTaskWorkerPool::GetTaskGraphRunner(), resource_provider_.get()); |
173 break; | 177 break; |
174 } | 178 } |
175 | 179 |
176 DCHECK(tile_task_worker_pool_); | 180 DCHECK(tile_task_worker_pool_); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 base::Unretained(this), base::Passed(&resource), id), | 268 base::Unretained(this), base::Passed(&resource), id), |
265 lock, &empty)); | 269 lock, &empty)); |
266 } | 270 } |
267 | 271 |
268 const std::vector<RasterTaskResult>& completed_tasks() const { | 272 const std::vector<RasterTaskResult>& completed_tasks() const { |
269 return completed_tasks_; | 273 return completed_tasks_; |
270 } | 274 } |
271 | 275 |
272 private: | 276 private: |
273 void Create3dOutputSurfaceAndResourceProvider() { | 277 void Create3dOutputSurfaceAndResourceProvider() { |
274 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 278 output_surface_ = FakeOutputSurface::Create3d( |
| 279 context_provider_, worker_context_provider_).Pass(); |
275 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 280 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
276 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); | 281 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
277 context3d->set_support_sync_query(true); | 282 context3d->set_support_sync_query(true); |
278 resource_provider_ = ResourceProvider::Create(output_surface_.get(), NULL, | 283 resource_provider_ = ResourceProvider::Create(output_surface_.get(), NULL, |
279 &gpu_memory_buffer_manager_, | 284 &gpu_memory_buffer_manager_, |
280 NULL, 0, false, 1).Pass(); | 285 NULL, 0, false, 1).Pass(); |
281 } | 286 } |
282 | 287 |
283 void CreateSoftwareOutputSurfaceAndResourceProvider() { | 288 void CreateSoftwareOutputSurfaceAndResourceProvider() { |
284 output_surface_ = FakeOutputSurface::CreateSoftware( | 289 output_surface_ = FakeOutputSurface::CreateSoftware( |
(...skipping 14 matching lines...) Expand all Loading... |
299 completed_tasks_.push_back(result); | 304 completed_tasks_.push_back(result); |
300 } | 305 } |
301 | 306 |
302 void OnTimeout() { | 307 void OnTimeout() { |
303 timed_out_ = true; | 308 timed_out_ = true; |
304 base::MessageLoop::current()->Quit(); | 309 base::MessageLoop::current()->Quit(); |
305 } | 310 } |
306 | 311 |
307 protected: | 312 protected: |
308 scoped_refptr<TestContextProvider> context_provider_; | 313 scoped_refptr<TestContextProvider> context_provider_; |
| 314 scoped_refptr<TestContextProvider> worker_context_provider_; |
| 315 scoped_ptr<Rasterizer> rasterizer_; |
309 FakeOutputSurfaceClient output_surface_client_; | 316 FakeOutputSurfaceClient output_surface_client_; |
310 scoped_ptr<FakeOutputSurface> output_surface_; | 317 scoped_ptr<FakeOutputSurface> output_surface_; |
311 scoped_ptr<ResourceProvider> resource_provider_; | 318 scoped_ptr<ResourceProvider> resource_provider_; |
312 scoped_ptr<ResourcePool> staging_resource_pool_; | 319 scoped_ptr<ResourcePool> staging_resource_pool_; |
313 scoped_ptr<TileTaskWorkerPool> tile_task_worker_pool_; | 320 scoped_ptr<TileTaskWorkerPool> tile_task_worker_pool_; |
314 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | 321 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
315 TestSharedBitmapManager shared_bitmap_manager_; | 322 TestSharedBitmapManager shared_bitmap_manager_; |
316 base::CancelableClosure timeout_; | 323 base::CancelableClosure timeout_; |
317 UniqueNotifier all_tile_tasks_finished_; | 324 UniqueNotifier all_tile_tasks_finished_; |
318 int timeout_seconds_; | 325 int timeout_seconds_; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 TileTaskWorkerPoolTests, | 405 TileTaskWorkerPoolTests, |
399 TileTaskWorkerPoolTest, | 406 TileTaskWorkerPoolTest, |
400 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, | 407 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, |
401 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 408 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
402 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 409 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
403 TILE_TASK_WORKER_POOL_TYPE_GPU, | 410 TILE_TASK_WORKER_POOL_TYPE_GPU, |
404 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); | 411 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); |
405 | 412 |
406 } // namespace | 413 } // namespace |
407 } // namespace cc | 414 } // namespace cc |
OLD | NEW |