| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 const size_t kMaxBytesPerCopyOperation = 1000U; | 44 const size_t kMaxBytesPerCopyOperation = 1000U; |
| 45 const size_t kMaxStagingBuffers = 32U; | 45 const size_t kMaxStagingBuffers = 32U; |
| 46 | 46 |
| 47 enum TileTaskWorkerPoolType { | 47 enum TileTaskWorkerPoolType { |
| 48 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 48 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
| 49 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 49 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
| 50 TILE_TASK_WORKER_POOL_TYPE_GPU, | 50 TILE_TASK_WORKER_POOL_TYPE_GPU, |
| 51 TILE_TASK_WORKER_POOL_TYPE_BITMAP | 51 TILE_TASK_WORKER_POOL_TYPE_BITMAP |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 class TestRasterTaskImpl : public RasterTask { | 54 class TestRasterTaskImpl : public TileTask { |
| 55 public: | 55 public: |
| 56 typedef base::Callback<void(bool was_canceled)> Reply; | 56 typedef base::Callback<void(bool was_canceled)> Reply; |
| 57 | 57 |
| 58 TestRasterTaskImpl(const Resource* resource, | 58 TestRasterTaskImpl(const Resource* resource, |
| 59 const Reply& reply, | 59 const Reply& reply, |
| 60 ImageDecodeTask::Vector* dependencies) | 60 TileTask::Vector* dependencies) |
| 61 : RasterTask(dependencies), | 61 : TileTask(true, dependencies), |
| 62 resource_(resource), | 62 resource_(resource), |
| 63 reply_(reply), | 63 reply_(reply), |
| 64 raster_source_(FakeRasterSource::CreateFilled(gfx::Size(1, 1))) {} | 64 raster_source_(FakeRasterSource::CreateFilled(gfx::Size(1, 1))) {} |
| 65 | 65 |
| 66 // Overridden from Task: | 66 // Overridden from Task: |
| 67 void RunOnWorkerThread() override { | 67 void RunOnWorkerThread() override { |
| 68 uint64_t new_content_id = 0; | 68 uint64_t new_content_id = 0; |
| 69 raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1), | 69 raster_buffer_->Playback(raster_source_.get(), gfx::Rect(1, 1), |
| 70 gfx::Rect(1, 1), new_content_id, 1.f, | 70 gfx::Rect(1, 1), new_content_id, 1.f, |
| 71 RasterSource::PlaybackSettings()); | 71 RasterSource::PlaybackSettings()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 92 scoped_refptr<RasterSource> raster_source_; | 92 scoped_refptr<RasterSource> raster_source_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); | 94 DISALLOW_COPY_AND_ASSIGN(TestRasterTaskImpl); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { | 97 class BlockingTestRasterTaskImpl : public TestRasterTaskImpl { |
| 98 public: | 98 public: |
| 99 BlockingTestRasterTaskImpl(const Resource* resource, | 99 BlockingTestRasterTaskImpl(const Resource* resource, |
| 100 const Reply& reply, | 100 const Reply& reply, |
| 101 base::Lock* lock, | 101 base::Lock* lock, |
| 102 ImageDecodeTask::Vector* dependencies) | 102 TileTask::Vector* dependencies) |
| 103 : TestRasterTaskImpl(resource, reply, dependencies), lock_(lock) {} | 103 : TestRasterTaskImpl(resource, reply, dependencies), lock_(lock) {} |
| 104 | 104 |
| 105 // Overridden from Task: | 105 // Overridden from Task: |
| 106 void RunOnWorkerThread() override { | 106 void RunOnWorkerThread() override { |
| 107 base::AutoLock lock(*lock_); | 107 base::AutoLock lock(*lock_); |
| 108 TestRasterTaskImpl::RunOnWorkerThread(); | 108 TestRasterTaskImpl::RunOnWorkerThread(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 protected: | 111 protected: |
| 112 ~BlockingTestRasterTaskImpl() override {} | 112 ~BlockingTestRasterTaskImpl() override {} |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 base::Lock* lock_; | 115 base::Lock* lock_; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(BlockingTestRasterTaskImpl); | 117 DISALLOW_COPY_AND_ASSIGN(BlockingTestRasterTaskImpl); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 class TileTaskWorkerPoolTest | 120 class TileTaskWorkerPoolTest |
| 121 : public testing::TestWithParam<TileTaskWorkerPoolType> { | 121 : public testing::TestWithParam<TileTaskWorkerPoolType> { |
| 122 public: | 122 public: |
| 123 struct RasterTaskResult { | 123 struct RasterTaskResult { |
| 124 unsigned id; | 124 unsigned id; |
| 125 bool canceled; | 125 bool canceled; |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 typedef std::vector<scoped_refptr<RasterTask>> RasterTaskVector; | 128 typedef std::vector<scoped_refptr<TileTask>> RasterTaskVector; |
| 129 | 129 |
| 130 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL }; | 130 enum NamedTaskSet { REQUIRED_FOR_ACTIVATION, REQUIRED_FOR_DRAW, ALL }; |
| 131 | 131 |
| 132 TileTaskWorkerPoolTest() | 132 TileTaskWorkerPoolTest() |
| 133 : context_provider_(TestContextProvider::Create()), | 133 : context_provider_(TestContextProvider::Create()), |
| 134 worker_context_provider_(TestContextProvider::CreateWorker()), | 134 worker_context_provider_(TestContextProvider::CreateWorker()), |
| 135 all_tile_tasks_finished_( | 135 all_tile_tasks_finished_( |
| 136 base::ThreadTaskRunnerHandle::Get() | 136 base::ThreadTaskRunnerHandle::Get() |
| 137 .get(), | 137 .get(), |
| 138 base::Bind(&TileTaskWorkerPoolTest::AllTileTasksFinished, | 138 base::Bind(&TileTaskWorkerPoolTest::AllTileTasksFinished, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&graph_); | 203 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&graph_); |
| 204 } | 204 } |
| 205 | 205 |
| 206 void AppendTask(unsigned id, const gfx::Size& size) { | 206 void AppendTask(unsigned id, const gfx::Size& size) { |
| 207 std::unique_ptr<ScopedResource> resource( | 207 std::unique_ptr<ScopedResource> resource( |
| 208 ScopedResource::Create(resource_provider_.get())); | 208 ScopedResource::Create(resource_provider_.get())); |
| 209 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 209 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 210 RGBA_8888); | 210 RGBA_8888); |
| 211 const Resource* const_resource = resource.get(); | 211 const Resource* const_resource = resource.get(); |
| 212 | 212 |
| 213 ImageDecodeTask::Vector empty; | 213 TileTask::Vector empty; |
| 214 tasks_.push_back(new TestRasterTaskImpl( | 214 tasks_.push_back(new TestRasterTaskImpl( |
| 215 const_resource, | 215 const_resource, |
| 216 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, | 216 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, |
| 217 base::Unretained(this), base::Passed(&resource), id), | 217 base::Unretained(this), base::Passed(&resource), id), |
| 218 &empty)); | 218 &empty)); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); } | 221 void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); } |
| 222 | 222 |
| 223 void AppendBlockingTask(unsigned id, base::Lock* lock) { | 223 void AppendBlockingTask(unsigned id, base::Lock* lock) { |
| 224 const gfx::Size size(1, 1); | 224 const gfx::Size size(1, 1); |
| 225 | 225 |
| 226 std::unique_ptr<ScopedResource> resource( | 226 std::unique_ptr<ScopedResource> resource( |
| 227 ScopedResource::Create(resource_provider_.get())); | 227 ScopedResource::Create(resource_provider_.get())); |
| 228 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, | 228 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 229 RGBA_8888); | 229 RGBA_8888); |
| 230 const Resource* const_resource = resource.get(); | 230 const Resource* const_resource = resource.get(); |
| 231 | 231 |
| 232 ImageDecodeTask::Vector empty; | 232 TileTask::Vector empty; |
| 233 tasks_.push_back(new BlockingTestRasterTaskImpl( | 233 tasks_.push_back(new BlockingTestRasterTaskImpl( |
| 234 const_resource, | 234 const_resource, |
| 235 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, | 235 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, |
| 236 base::Unretained(this), base::Passed(&resource), id), | 236 base::Unretained(this), base::Passed(&resource), id), |
| 237 lock, &empty)); | 237 lock, &empty)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 const std::vector<RasterTaskResult>& completed_tasks() const { | 240 const std::vector<RasterTaskResult>& completed_tasks() const { |
| 241 return completed_tasks_; | 241 return completed_tasks_; |
| 242 } | 242 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 369 |
| 370 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolTests, | 370 INSTANTIATE_TEST_CASE_P(TileTaskWorkerPoolTests, |
| 371 TileTaskWorkerPoolTest, | 371 TileTaskWorkerPoolTest, |
| 372 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 372 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
| 373 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 373 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
| 374 TILE_TASK_WORKER_POOL_TYPE_GPU, | 374 TILE_TASK_WORKER_POOL_TYPE_GPU, |
| 375 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); | 375 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); |
| 376 | 376 |
| 377 } // namespace | 377 } // namespace |
| 378 } // namespace cc | 378 } // namespace cc |
| OLD | NEW |