| 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/bitmap_raster_worker_pool.h" | 11 #include "cc/resources/bitmap_raster_worker_pool.h" |
| 12 #include "cc/resources/gpu_raster_worker_pool.h" | 12 #include "cc/resources/gpu_raster_worker_pool.h" |
| 13 #include "cc/resources/one_copy_raster_worker_pool.h" | 13 #include "cc/resources/one_copy_raster_worker_pool.h" |
| 14 #include "cc/resources/picture_pile.h" | 14 #include "cc/resources/picture_pile.h" |
| 15 #include "cc/resources/picture_pile_impl.h" | 15 #include "cc/resources/picture_pile_impl.h" |
| 16 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 16 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 17 #include "cc/resources/raster_buffer.h" | 17 #include "cc/resources/raster_buffer.h" |
| 18 #include "cc/resources/rasterizer.h" | 18 #include "cc/resources/rasterizer.h" |
| 19 #include "cc/resources/resource_pool.h" | 19 #include "cc/resources/resource_pool.h" |
| 20 #include "cc/resources/resource_provider.h" | 20 #include "cc/resources/resource_provider.h" |
| 21 #include "cc/resources/scoped_resource.h" | 21 #include "cc/resources/scoped_resource.h" |
| 22 #include "cc/resources/zero_copy_raster_worker_pool.h" | 22 #include "cc/resources/zero_copy_raster_worker_pool.h" |
| 23 #include "cc/test/fake_output_surface.h" | 23 #include "cc/test/fake_output_surface.h" |
| 24 #include "cc/test/fake_output_surface_client.h" | 24 #include "cc/test/fake_output_surface_client.h" |
| 25 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 25 #include "cc/test/test_shared_bitmap_manager.h" | 26 #include "cc/test/test_shared_bitmap_manager.h" |
| 26 #include "cc/test/test_web_graphics_context_3d.h" | 27 #include "cc/test/test_web_graphics_context_3d.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 namespace cc { | 30 namespace cc { |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const size_t kMaxTransferBufferUsageBytes = 10000U; | 33 const size_t kMaxTransferBufferUsageBytes = 10000U; |
| 33 // A resource of this dimension^2 * 4 must be greater than the above transfer | 34 // A resource of this dimension^2 * 4 must be greater than the above transfer |
| 34 // buffer constant. | 35 // buffer constant. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 const std::vector<RasterTaskResult>& completed_tasks() const { | 263 const std::vector<RasterTaskResult>& completed_tasks() const { |
| 263 return completed_tasks_; | 264 return completed_tasks_; |
| 264 } | 265 } |
| 265 | 266 |
| 266 private: | 267 private: |
| 267 void Create3dOutputSurfaceAndResourceProvider() { | 268 void Create3dOutputSurfaceAndResourceProvider() { |
| 268 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 269 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 269 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 270 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 270 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); | 271 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
| 271 context3d->set_support_sync_query(true); | 272 context3d->set_support_sync_query(true); |
| 272 resource_provider_ = | 273 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 273 ResourceProvider::Create( | 274 NULL, |
| 274 output_surface_.get(), NULL, NULL, 0, false, 1, false).Pass(); | 275 &gpu_memory_buffer_manager_, |
| 276 NULL, |
| 277 0, |
| 278 false, |
| 279 1, |
| 280 false).Pass(); |
| 275 } | 281 } |
| 276 | 282 |
| 277 void CreateSoftwareOutputSurfaceAndResourceProvider() { | 283 void CreateSoftwareOutputSurfaceAndResourceProvider() { |
| 278 output_surface_ = FakeOutputSurface::CreateSoftware( | 284 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 279 make_scoped_ptr(new SoftwareOutputDevice)); | 285 make_scoped_ptr(new SoftwareOutputDevice)); |
| 280 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 286 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 281 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 287 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 282 &shared_bitmap_manager_, | 288 &shared_bitmap_manager_, |
| 283 NULL, | 289 NULL, |
| 290 NULL, |
| 284 0, | 291 0, |
| 285 false, | 292 false, |
| 286 1, | 293 1, |
| 287 false).Pass(); | 294 false).Pass(); |
| 288 } | 295 } |
| 289 | 296 |
| 290 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, | 297 void OnTaskCompleted(scoped_ptr<ScopedResource> resource, |
| 291 unsigned id, | 298 unsigned id, |
| 292 const PicturePileImpl::Analysis& analysis, | 299 const PicturePileImpl::Analysis& analysis, |
| 293 bool was_canceled) { | 300 bool was_canceled) { |
| 294 RasterTaskResult result; | 301 RasterTaskResult result; |
| 295 result.id = id; | 302 result.id = id; |
| 296 result.canceled = was_canceled; | 303 result.canceled = was_canceled; |
| 297 completed_tasks_.push_back(result); | 304 completed_tasks_.push_back(result); |
| 298 } | 305 } |
| 299 | 306 |
| 300 void OnTimeout() { | 307 void OnTimeout() { |
| 301 timed_out_ = true; | 308 timed_out_ = true; |
| 302 base::MessageLoop::current()->Quit(); | 309 base::MessageLoop::current()->Quit(); |
| 303 } | 310 } |
| 304 | 311 |
| 305 protected: | 312 protected: |
| 306 scoped_refptr<TestContextProvider> context_provider_; | 313 scoped_refptr<TestContextProvider> context_provider_; |
| 307 FakeOutputSurfaceClient output_surface_client_; | 314 FakeOutputSurfaceClient output_surface_client_; |
| 308 scoped_ptr<FakeOutputSurface> output_surface_; | 315 scoped_ptr<FakeOutputSurface> output_surface_; |
| 309 scoped_ptr<ResourceProvider> resource_provider_; | 316 scoped_ptr<ResourceProvider> resource_provider_; |
| 310 scoped_ptr<ResourcePool> staging_resource_pool_; | 317 scoped_ptr<ResourcePool> staging_resource_pool_; |
| 311 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 318 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 319 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 312 TestSharedBitmapManager shared_bitmap_manager_; | 320 TestSharedBitmapManager shared_bitmap_manager_; |
| 313 base::CancelableClosure timeout_; | 321 base::CancelableClosure timeout_; |
| 314 int timeout_seconds_; | 322 int timeout_seconds_; |
| 315 bool timed_out_; | 323 bool timed_out_; |
| 316 RasterTaskVector tasks_; | 324 RasterTaskVector tasks_; |
| 317 std::vector<RasterTaskResult> completed_tasks_; | 325 std::vector<RasterTaskResult> completed_tasks_; |
| 318 }; | 326 }; |
| 319 | 327 |
| 320 TEST_P(RasterWorkerPoolTest, Basic) { | 328 TEST_P(RasterWorkerPoolTest, Basic) { |
| 321 AppendTask(0u); | 329 AppendTask(0u); |
| 322 AppendTask(1u); | 330 AppendTask(1u); |
| 323 ScheduleTasks(); | 331 ScheduleTasks(); |
| 324 | 332 |
| 325 RunMessageLoopUntilAllTasksHaveCompleted(); | 333 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 326 | 334 |
| 327 ASSERT_EQ(2u, completed_tasks().size()); | 335 ASSERT_EQ(2u, completed_tasks().size()); |
| 328 EXPECT_FALSE(completed_tasks()[0].canceled); | 336 EXPECT_FALSE(completed_tasks()[0].canceled); |
| 329 EXPECT_FALSE(completed_tasks()[1].canceled); | 337 EXPECT_FALSE(completed_tasks()[1].canceled); |
| 330 } | 338 } |
| 331 | 339 |
| 332 TEST_P(RasterWorkerPoolTest, FailedMapResource) { | 340 TEST_P(RasterWorkerPoolTest, FailedMapResource) { |
| 333 if (GetParam() == RASTER_WORKER_POOL_TYPE_BITMAP) | 341 if (GetParam() == RASTER_WORKER_POOL_TYPE_BITMAP) |
| 334 return; | 342 return; |
| 335 | 343 |
| 336 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); | 344 TestWebGraphicsContext3D* context3d = context_provider_->TestContext3d(); |
| 337 context3d->set_times_map_image_chromium_succeeds(0); | |
| 338 context3d->set_times_map_buffer_chromium_succeeds(0); | 345 context3d->set_times_map_buffer_chromium_succeeds(0); |
| 339 AppendTask(0u); | 346 AppendTask(0u); |
| 340 ScheduleTasks(); | 347 ScheduleTasks(); |
| 341 | 348 |
| 342 RunMessageLoopUntilAllTasksHaveCompleted(); | 349 RunMessageLoopUntilAllTasksHaveCompleted(); |
| 343 | 350 |
| 344 ASSERT_EQ(1u, completed_tasks().size()); | 351 ASSERT_EQ(1u, completed_tasks().size()); |
| 345 EXPECT_FALSE(completed_tasks()[0].canceled); | 352 EXPECT_FALSE(completed_tasks()[0].canceled); |
| 346 } | 353 } |
| 347 | 354 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 400 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
| 394 RasterWorkerPoolTest, | 401 RasterWorkerPoolTest, |
| 395 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 402 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 396 RASTER_WORKER_POOL_TYPE_ZERO_COPY, | 403 RASTER_WORKER_POOL_TYPE_ZERO_COPY, |
| 397 RASTER_WORKER_POOL_TYPE_ONE_COPY, | 404 RASTER_WORKER_POOL_TYPE_ONE_COPY, |
| 398 RASTER_WORKER_POOL_TYPE_GPU, | 405 RASTER_WORKER_POOL_TYPE_GPU, |
| 399 RASTER_WORKER_POOL_TYPE_BITMAP)); | 406 RASTER_WORKER_POOL_TYPE_BITMAP)); |
| 400 | 407 |
| 401 } // namespace | 408 } // namespace |
| 402 } // namespace cc | 409 } // namespace cc |
| OLD | NEW |