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/raster_worker_pool.h" | 5 #include "cc/resources/raster_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/resources/gpu_raster_worker_pool.h" | 11 #include "cc/resources/gpu_raster_worker_pool.h" |
12 #include "cc/resources/image_copy_raster_worker_pool.h" | 12 #include "cc/resources/one_copy_raster_worker_pool.h" |
13 #include "cc/resources/image_raster_worker_pool.h" | |
14 #include "cc/resources/picture_pile.h" | 13 #include "cc/resources/picture_pile.h" |
15 #include "cc/resources/picture_pile_impl.h" | 14 #include "cc/resources/picture_pile_impl.h" |
16 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 15 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
17 #include "cc/resources/raster_buffer.h" | 16 #include "cc/resources/raster_buffer.h" |
18 #include "cc/resources/rasterizer.h" | 17 #include "cc/resources/rasterizer.h" |
19 #include "cc/resources/resource_pool.h" | 18 #include "cc/resources/resource_pool.h" |
20 #include "cc/resources/resource_provider.h" | 19 #include "cc/resources/resource_provider.h" |
21 #include "cc/resources/scoped_resource.h" | 20 #include "cc/resources/scoped_resource.h" |
| 21 #include "cc/resources/zero_copy_raster_worker_pool.h" |
22 #include "cc/test/fake_output_surface.h" | 22 #include "cc/test/fake_output_surface.h" |
23 #include "cc/test/fake_output_surface_client.h" | 23 #include "cc/test/fake_output_surface_client.h" |
24 #include "cc/test/test_shared_bitmap_manager.h" | 24 #include "cc/test/test_shared_bitmap_manager.h" |
25 #include "cc/test/test_web_graphics_context_3d.h" | 25 #include "cc/test/test_web_graphics_context_3d.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
28 namespace cc { | 28 namespace cc { |
29 namespace { | 29 namespace { |
30 | 30 |
31 const size_t kMaxTransferBufferUsageBytes = 10000U; | 31 const size_t kMaxTransferBufferUsageBytes = 10000U; |
32 // A resource of this dimension^2 * 4 must be greater than the above transfer | 32 // A resource of this dimension^2 * 4 must be greater than the above transfer |
33 // buffer constant. | 33 // buffer constant. |
34 const size_t kLargeResourceDimension = 1000U; | 34 const size_t kLargeResourceDimension = 1000U; |
35 | 35 |
36 enum RasterWorkerPoolType { | 36 enum RasterWorkerPoolType { |
37 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 37 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
38 RASTER_WORKER_POOL_TYPE_IMAGE, | 38 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
39 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, | 39 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
40 RASTER_WORKER_POOL_TYPE_GPU | 40 RASTER_WORKER_POOL_TYPE_GPU |
41 }; | 41 }; |
42 | 42 |
43 class TestRasterTaskImpl : public RasterTask { | 43 class TestRasterTaskImpl : public RasterTask { |
44 public: | 44 public: |
45 typedef base::Callback< | 45 typedef base::Callback< |
46 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; | 46 void(const PicturePileImpl::Analysis& analysis, bool was_canceled)> Reply; |
47 | 47 |
48 TestRasterTaskImpl(const Resource* resource, | 48 TestRasterTaskImpl(const Resource* resource, |
49 const Reply& reply, | 49 const Reply& reply, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 switch (GetParam()) { | 142 switch (GetParam()) { |
143 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 143 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
144 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 144 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( |
145 base::MessageLoopProxy::current().get(), | 145 base::MessageLoopProxy::current().get(), |
146 RasterWorkerPool::GetTaskGraphRunner(), | 146 RasterWorkerPool::GetTaskGraphRunner(), |
147 context_provider_.get(), | 147 context_provider_.get(), |
148 resource_provider_.get(), | 148 resource_provider_.get(), |
149 kMaxTransferBufferUsageBytes); | 149 kMaxTransferBufferUsageBytes); |
150 break; | 150 break; |
151 case RASTER_WORKER_POOL_TYPE_IMAGE: | 151 case RASTER_WORKER_POOL_TYPE_ZERO_COPY: |
152 raster_worker_pool_ = ImageRasterWorkerPool::Create( | 152 raster_worker_pool_ = ZeroCopyRasterWorkerPool::Create( |
153 base::MessageLoopProxy::current().get(), | 153 base::MessageLoopProxy::current().get(), |
154 RasterWorkerPool::GetTaskGraphRunner(), | 154 RasterWorkerPool::GetTaskGraphRunner(), |
155 resource_provider_.get()); | 155 resource_provider_.get()); |
156 break; | 156 break; |
157 case RASTER_WORKER_POOL_TYPE_IMAGE_COPY: | 157 case RASTER_WORKER_POOL_TYPE_ONE_COPY: |
158 raster_worker_pool_ = ImageCopyRasterWorkerPool::Create( | 158 raster_worker_pool_ = OneCopyRasterWorkerPool::Create( |
159 base::MessageLoopProxy::current().get(), | 159 base::MessageLoopProxy::current().get(), |
160 RasterWorkerPool::GetTaskGraphRunner(), | 160 RasterWorkerPool::GetTaskGraphRunner(), |
161 context_provider_.get(), | 161 context_provider_.get(), |
162 resource_provider_.get(), | 162 resource_provider_.get(), |
163 staging_resource_pool_.get()); | 163 staging_resource_pool_.get()); |
164 break; | 164 break; |
165 case RASTER_WORKER_POOL_TYPE_GPU: | 165 case RASTER_WORKER_POOL_TYPE_GPU: |
166 raster_worker_pool_ = | 166 raster_worker_pool_ = |
167 GpuRasterWorkerPool::Create(base::MessageLoopProxy::current().get(), | 167 GpuRasterWorkerPool::Create(base::MessageLoopProxy::current().get(), |
168 context_provider_.get(), | 168 context_provider_.get(), |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ScheduleTasks(); | 364 ScheduleTasks(); |
365 | 365 |
366 // This will time out if a resource that is larger than the throttle limit | 366 // This will time out if a resource that is larger than the throttle limit |
367 // never gets scheduled. | 367 // never gets scheduled. |
368 RunMessageLoopUntilAllTasksHaveCompleted(); | 368 RunMessageLoopUntilAllTasksHaveCompleted(); |
369 } | 369 } |
370 | 370 |
371 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 371 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
372 RasterWorkerPoolTest, | 372 RasterWorkerPoolTest, |
373 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 373 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
374 RASTER_WORKER_POOL_TYPE_IMAGE, | 374 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
375 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, | 375 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
376 RASTER_WORKER_POOL_TYPE_GPU)); | 376 RASTER_WORKER_POOL_TYPE_GPU)); |
377 | 377 |
378 } // namespace | 378 } // namespace |
379 } // namespace cc | 379 } // namespace cc |
OLD | NEW |