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/direct_raster_worker_pool.h" | 11 #include "cc/resources/direct_raster_worker_pool.h" |
12 #include "cc/resources/image_raster_worker_pool.h" | 12 #include "cc/resources/image_raster_worker_pool.h" |
13 #include "cc/resources/picture_pile.h" | 13 #include "cc/resources/picture_pile.h" |
14 #include "cc/resources/picture_pile_impl.h" | 14 #include "cc/resources/picture_pile_impl.h" |
15 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 15 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
16 #include "cc/resources/resource_provider.h" | 16 #include "cc/resources/resource_provider.h" |
17 #include "cc/resources/scoped_resource.h" | 17 #include "cc/resources/scoped_resource.h" |
18 #include "cc/test/fake_output_surface.h" | 18 #include "cc/test/fake_output_surface.h" |
19 #include "cc/test/fake_output_surface_client.h" | 19 #include "cc/test/fake_output_surface_client.h" |
| 20 #include "cc/test/test_shared_bitmap_manager.h" |
20 #include "cc/test/test_web_graphics_context_3d.h" | 21 #include "cc/test/test_web_graphics_context_3d.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
24 namespace { | 25 namespace { |
25 | 26 |
26 enum RasterThread { | 27 enum RasterThread { |
27 RASTER_THREAD_NONE, | 28 RASTER_THREAD_NONE, |
28 RASTER_THREAD_ORIGIN, | 29 RASTER_THREAD_ORIGIN, |
29 RASTER_THREAD_WORKER | 30 RASTER_THREAD_WORKER |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > | 123 typedef std::vector<scoped_refptr<internal::RasterWorkerPoolTask> > |
123 RasterTaskVector; | 124 RasterTaskVector; |
124 | 125 |
125 RasterWorkerPoolTest() | 126 RasterWorkerPoolTest() |
126 : context_provider_(TestContextProvider::Create()), | 127 : context_provider_(TestContextProvider::Create()), |
127 timeout_seconds_(5), | 128 timeout_seconds_(5), |
128 timed_out_(false) { | 129 timed_out_(false) { |
129 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 130 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
130 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 131 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
131 | 132 |
132 resource_provider_ = ResourceProvider::Create( | 133 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
133 output_surface_.get(), NULL, 0, false, 1).Pass(); | 134 resource_provider_ = |
| 135 ResourceProvider::Create( |
| 136 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1) |
| 137 .Pass(); |
134 | 138 |
135 switch (GetParam()) { | 139 switch (GetParam()) { |
136 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 140 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
137 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 141 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( |
138 base::MessageLoopProxy::current().get(), | 142 base::MessageLoopProxy::current().get(), |
139 resource_provider_.get(), | 143 resource_provider_.get(), |
140 std::numeric_limits<size_t>::max()); | 144 std::numeric_limits<size_t>::max()); |
141 break; | 145 break; |
142 case RASTER_WORKER_POOL_TYPE_IMAGE: | 146 case RASTER_WORKER_POOL_TYPE_IMAGE: |
143 raster_worker_pool_ = ImageRasterWorkerPool::Create( | 147 raster_worker_pool_ = ImageRasterWorkerPool::Create( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 263 |
260 void OnTimeout() { | 264 void OnTimeout() { |
261 timed_out_ = true; | 265 timed_out_ = true; |
262 base::MessageLoop::current()->Quit(); | 266 base::MessageLoop::current()->Quit(); |
263 } | 267 } |
264 | 268 |
265 protected: | 269 protected: |
266 scoped_refptr<TestContextProvider> context_provider_; | 270 scoped_refptr<TestContextProvider> context_provider_; |
267 FakeOutputSurfaceClient output_surface_client_; | 271 FakeOutputSurfaceClient output_surface_client_; |
268 scoped_ptr<FakeOutputSurface> output_surface_; | 272 scoped_ptr<FakeOutputSurface> output_surface_; |
| 273 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
269 scoped_ptr<ResourceProvider> resource_provider_; | 274 scoped_ptr<ResourceProvider> resource_provider_; |
270 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 275 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
271 base::CancelableClosure timeout_; | 276 base::CancelableClosure timeout_; |
272 int timeout_seconds_; | 277 int timeout_seconds_; |
273 bool timed_out_; | 278 bool timed_out_; |
274 RasterTaskVector tasks_; | 279 RasterTaskVector tasks_; |
275 std::vector<RasterTaskResult> completed_tasks_; | 280 std::vector<RasterTaskResult> completed_tasks_; |
276 }; | 281 }; |
277 | 282 |
278 TEST_P(RasterWorkerPoolTest, Basic) { | 283 TEST_P(RasterWorkerPoolTest, Basic) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 333 } |
329 | 334 |
330 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 335 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
331 RasterWorkerPoolTest, | 336 RasterWorkerPoolTest, |
332 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 337 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
333 RASTER_WORKER_POOL_TYPE_IMAGE, | 338 RASTER_WORKER_POOL_TYPE_IMAGE, |
334 RASTER_WORKER_POOL_TYPE_DIRECT)); | 339 RASTER_WORKER_POOL_TYPE_DIRECT)); |
335 | 340 |
336 } // namespace | 341 } // namespace |
337 } // namespace cc | 342 } // namespace cc |
OLD | NEW |