| 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/raster/tile_task_worker_pool.h" | 5 #include "cc/raster/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" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "cc/test/test_task_graph_runner.h" | 34 #include "cc/test/test_task_graph_runner.h" |
| 35 #include "cc/test/test_web_graphics_context_3d.h" | 35 #include "cc/test/test_web_graphics_context_3d.h" |
| 36 #include "gpu/GLES2/gl2extchromium.h" | 36 #include "gpu/GLES2/gl2extchromium.h" |
| 37 #include "testing/gtest/include/gtest/gtest.h" | 37 #include "testing/gtest/include/gtest/gtest.h" |
| 38 | 38 |
| 39 namespace cc { | 39 namespace cc { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 const size_t kMaxTransferBufferUsageBytes = 10000U; | 42 const size_t kMaxTransferBufferUsageBytes = 10000U; |
| 43 const size_t kMaxBytesPerCopyOperation = 1000U; | 43 const size_t kMaxBytesPerCopyOperation = 1000U; |
| 44 const size_t kMaxStagingBuffers = 32U; | |
| 45 | 44 |
| 46 // A resource of this dimension^2 * 4 must be greater than the above transfer | 45 // A resource of this dimension^2 * 4 must be greater than the above transfer |
| 47 // buffer constant. | 46 // buffer constant. |
| 48 const size_t kLargeResourceDimension = 1000U; | 47 const size_t kLargeResourceDimension = 1000U; |
| 49 | 48 |
| 50 enum TileTaskWorkerPoolType { | 49 enum TileTaskWorkerPoolType { |
| 51 TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, | 50 TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 52 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 51 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
| 53 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 52 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
| 54 TILE_TASK_WORKER_POOL_TYPE_GPU, | 53 TILE_TASK_WORKER_POOL_TYPE_GPU, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 kMaxTransferBufferUsageBytes); | 158 kMaxTransferBufferUsageBytes); |
| 160 break; | 159 break; |
| 161 case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: | 160 case TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY: |
| 162 Create3dOutputSurfaceAndResourceProvider(); | 161 Create3dOutputSurfaceAndResourceProvider(); |
| 163 tile_task_worker_pool_ = ZeroCopyTileTaskWorkerPool::Create( | 162 tile_task_worker_pool_ = ZeroCopyTileTaskWorkerPool::Create( |
| 164 base::ThreadTaskRunnerHandle::Get().get(), &task_graph_runner_, | 163 base::ThreadTaskRunnerHandle::Get().get(), &task_graph_runner_, |
| 165 resource_provider_.get()); | 164 resource_provider_.get()); |
| 166 break; | 165 break; |
| 167 case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: | 166 case TILE_TASK_WORKER_POOL_TYPE_ONE_COPY: |
| 168 Create3dOutputSurfaceAndResourceProvider(); | 167 Create3dOutputSurfaceAndResourceProvider(); |
| 168 staging_resource_pool_ = ResourcePool::Create(resource_provider_.get(), |
| 169 GL_TEXTURE_2D); |
| 169 tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( | 170 tile_task_worker_pool_ = OneCopyTileTaskWorkerPool::Create( |
| 170 base::ThreadTaskRunnerHandle::Get().get(), &task_graph_runner_, | 171 base::ThreadTaskRunnerHandle::Get().get(), &task_graph_runner_, |
| 171 context_provider_.get(), resource_provider_.get(), | 172 context_provider_.get(), resource_provider_.get(), |
| 172 kMaxBytesPerCopyOperation, false, GL_TEXTURE_2D, | 173 staging_resource_pool_.get(), kMaxBytesPerCopyOperation, false); |
| 173 kMaxStagingBuffers); | |
| 174 break; | 174 break; |
| 175 case TILE_TASK_WORKER_POOL_TYPE_GPU: | 175 case TILE_TASK_WORKER_POOL_TYPE_GPU: |
| 176 Create3dOutputSurfaceAndResourceProvider(); | 176 Create3dOutputSurfaceAndResourceProvider(); |
| 177 tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( | 177 tile_task_worker_pool_ = GpuTileTaskWorkerPool::Create( |
| 178 base::ThreadTaskRunnerHandle::Get().get(), &task_graph_runner_, | 178 base::ThreadTaskRunnerHandle::Get().get(), &task_graph_runner_, |
| 179 context_provider_.get(), resource_provider_.get(), false, 0); | 179 context_provider_.get(), resource_provider_.get(), false, 0); |
| 180 break; | 180 break; |
| 181 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: | 181 case TILE_TASK_WORKER_POOL_TYPE_BITMAP: |
| 182 CreateSoftwareOutputSurfaceAndResourceProvider(); | 182 CreateSoftwareOutputSurfaceAndResourceProvider(); |
| 183 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( | 183 tile_task_worker_pool_ = BitmapTileTaskWorkerPool::Create( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 timed_out_ = true; | 325 timed_out_ = true; |
| 326 base::MessageLoop::current()->Quit(); | 326 base::MessageLoop::current()->Quit(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 protected: | 329 protected: |
| 330 scoped_refptr<TestContextProvider> context_provider_; | 330 scoped_refptr<TestContextProvider> context_provider_; |
| 331 scoped_refptr<TestContextProvider> worker_context_provider_; | 331 scoped_refptr<TestContextProvider> worker_context_provider_; |
| 332 FakeOutputSurfaceClient output_surface_client_; | 332 FakeOutputSurfaceClient output_surface_client_; |
| 333 scoped_ptr<FakeOutputSurface> output_surface_; | 333 scoped_ptr<FakeOutputSurface> output_surface_; |
| 334 scoped_ptr<ResourceProvider> resource_provider_; | 334 scoped_ptr<ResourceProvider> resource_provider_; |
| 335 scoped_ptr<ResourcePool> staging_resource_pool_; |
| 335 scoped_ptr<TileTaskWorkerPool> tile_task_worker_pool_; | 336 scoped_ptr<TileTaskWorkerPool> tile_task_worker_pool_; |
| 336 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; | 337 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 337 TestSharedBitmapManager shared_bitmap_manager_; | 338 TestSharedBitmapManager shared_bitmap_manager_; |
| 338 TestTaskGraphRunner task_graph_runner_; | 339 TestTaskGraphRunner task_graph_runner_; |
| 339 base::CancelableClosure timeout_; | 340 base::CancelableClosure timeout_; |
| 340 UniqueNotifier all_tile_tasks_finished_; | 341 UniqueNotifier all_tile_tasks_finished_; |
| 341 int timeout_seconds_; | 342 int timeout_seconds_; |
| 342 bool timed_out_; | 343 bool timed_out_; |
| 343 RasterTaskVector tasks_; | 344 RasterTaskVector tasks_; |
| 344 std::vector<RasterTaskResult> completed_tasks_; | 345 std::vector<RasterTaskResult> completed_tasks_; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 TileTaskWorkerPoolTests, | 455 TileTaskWorkerPoolTests, |
| 455 TileTaskWorkerPoolTest, | 456 TileTaskWorkerPoolTest, |
| 456 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, | 457 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 457 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 458 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
| 458 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 459 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
| 459 TILE_TASK_WORKER_POOL_TYPE_GPU, | 460 TILE_TASK_WORKER_POOL_TYPE_GPU, |
| 460 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); | 461 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); |
| 461 | 462 |
| 462 } // namespace | 463 } // namespace |
| 463 } // namespace cc | 464 } // namespace cc |
| OLD | NEW |