Chromium Code Reviews| 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" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 : public testing::TestWithParam<RasterWorkerPoolType>, | 102 : public testing::TestWithParam<RasterWorkerPoolType>, |
| 103 public RasterizerClient { | 103 public RasterizerClient { |
| 104 public: | 104 public: |
| 105 struct RasterTaskResult { | 105 struct RasterTaskResult { |
| 106 unsigned id; | 106 unsigned id; |
| 107 bool canceled; | 107 bool canceled; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 typedef std::vector<scoped_refptr<RasterTask> > RasterTaskVector; | 110 typedef std::vector<scoped_refptr<RasterTask> > RasterTaskVector; |
| 111 | 111 |
| 112 enum NamedTaskSet { | |
| 113 HIGH_RESOLUTION_IN_NOW_BIN_ON_ACTIVE_TREE = 0, | |
| 114 REQUIRED_FOR_ACTIVATION = 1, | |
| 115 ALL = 2 | |
| 116 }; | |
| 117 | |
| 112 RasterWorkerPoolTest() | 118 RasterWorkerPoolTest() |
| 113 : context_provider_(TestContextProvider::Create()), | 119 : context_provider_(TestContextProvider::Create()), |
| 114 timeout_seconds_(5), | 120 timeout_seconds_(5), |
| 115 timed_out_(false) { | 121 timed_out_(false) { |
| 116 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 122 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 117 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 123 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 118 | 124 |
| 119 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 125 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 120 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 126 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 121 shared_bitmap_manager_.get(), | 127 shared_bitmap_manager_.get(), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 resource_provider_.reset(); | 172 resource_provider_.reset(); |
| 167 } | 173 } |
| 168 | 174 |
| 169 // Overridden from testing::Test: | 175 // Overridden from testing::Test: |
| 170 virtual void TearDown() OVERRIDE { | 176 virtual void TearDown() OVERRIDE { |
| 171 raster_worker_pool_->AsRasterizer()->Shutdown(); | 177 raster_worker_pool_->AsRasterizer()->Shutdown(); |
| 172 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks(); | 178 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks(); |
| 173 } | 179 } |
| 174 | 180 |
| 175 // Overriden from RasterWorkerPoolClient: | 181 // Overriden from RasterWorkerPoolClient: |
| 176 virtual bool ShouldForceTasksRequiredForActivationToComplete() const | 182 virtual void DidFinishRunningTasks(TaskSet task_set) OVERRIDE { |
| 177 OVERRIDE { | 183 if (task_set == ALL) { |
| 178 return false; | 184 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks(); |
|
reveman
2014/09/16 22:49:05
remove the conditional for this if possible.
ernstm
2014/09/17 19:57:15
Done.
| |
| 185 base::MessageLoop::current()->Quit(); | |
|
reveman
2014/09/16 22:49:05
We should switch this test over to using TestSimpl
ernstm
2014/09/17 19:57:15
Done.
| |
| 186 } | |
| 179 } | 187 } |
| 180 virtual void DidFinishRunningTasks() OVERRIDE { | 188 virtual TaskSetCollection TasksThatShouldBeForcedToComplete() const OVERRIDE { |
| 181 raster_worker_pool_->AsRasterizer()->CheckForCompletedTasks(); | 189 return TaskSetCollection(); |
| 182 base::MessageLoop::current()->Quit(); | |
| 183 } | 190 } |
| 184 virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE {} | |
| 185 | 191 |
| 186 void RunMessageLoopUntilAllTasksHaveCompleted() { | 192 void RunMessageLoopUntilAllTasksHaveCompleted() { |
| 187 if (timeout_seconds_) { | 193 if (timeout_seconds_) { |
| 188 timeout_.Reset( | 194 timeout_.Reset( |
| 189 base::Bind(&RasterWorkerPoolTest::OnTimeout, base::Unretained(this))); | 195 base::Bind(&RasterWorkerPoolTest::OnTimeout, base::Unretained(this))); |
| 190 base::MessageLoopProxy::current()->PostDelayedTask( | 196 base::MessageLoopProxy::current()->PostDelayedTask( |
| 191 FROM_HERE, | 197 FROM_HERE, |
| 192 timeout_.callback(), | 198 timeout_.callback(), |
| 193 base::TimeDelta::FromSeconds(timeout_seconds_)); | 199 base::TimeDelta::FromSeconds(timeout_seconds_)); |
| 194 } | 200 } |
| 195 | 201 |
| 196 base::MessageLoop::current()->Run(); | 202 base::MessageLoop::current()->Run(); |
| 197 | 203 |
| 198 timeout_.Cancel(); | 204 timeout_.Cancel(); |
| 199 | 205 |
| 200 ASSERT_FALSE(timed_out_) << "Test timed out"; | 206 ASSERT_FALSE(timed_out_) << "Test timed out"; |
| 201 } | 207 } |
| 202 | 208 |
| 203 void ScheduleTasks() { | 209 void ScheduleTasks() { |
| 204 RasterTaskQueue queue; | 210 RasterTaskQueue queue; |
| 205 | 211 |
| 206 for (RasterTaskVector::const_iterator it = tasks_.begin(); | 212 for (RasterTaskVector::const_iterator it = tasks_.begin(); |
| 207 it != tasks_.end(); | 213 it != tasks_.end(); |
| 208 ++it) | 214 ++it) { |
| 209 queue.items.push_back(RasterTaskQueue::Item(it->get(), false)); | 215 TaskSetCollection task_set_collection; |
|
reveman
2014/09/16 22:49:05
nit: s/task_set_collection/task_sets/
ernstm
2014/09/17 19:57:15
Done.
| |
| 216 task_set_collection[ALL] = true; | |
| 217 queue.items.push_back( | |
| 218 RasterTaskQueue::Item(it->get(), task_set_collection)); | |
| 219 } | |
| 210 | 220 |
| 211 raster_worker_pool_->AsRasterizer()->ScheduleTasks(&queue); | 221 raster_worker_pool_->AsRasterizer()->ScheduleTasks(&queue); |
| 212 } | 222 } |
| 213 | 223 |
| 214 void AppendTask(unsigned id, const gfx::Size& size) { | 224 void AppendTask(unsigned id, const gfx::Size& size) { |
| 215 scoped_ptr<ScopedResource> resource( | 225 scoped_ptr<ScopedResource> resource( |
| 216 ScopedResource::Create(resource_provider_.get())); | 226 ScopedResource::Create(resource_provider_.get())); |
| 217 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); | 227 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); |
| 218 const Resource* const_resource = resource.get(); | 228 const Resource* const_resource = resource.get(); |
| 219 | 229 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 | 365 |
| 356 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, | 366 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolTests, |
| 357 RasterWorkerPoolTest, | 367 RasterWorkerPoolTest, |
| 358 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 368 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 359 RASTER_WORKER_POOL_TYPE_IMAGE, | 369 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 360 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, | 370 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, |
| 361 RASTER_WORKER_POOL_TYPE_GPU)); | 371 RASTER_WORKER_POOL_TYPE_GPU)); |
| 362 | 372 |
| 363 } // namespace | 373 } // namespace |
| 364 } // namespace cc | 374 } // namespace cc |
| OLD | NEW |