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/tile_task_worker_pool.h" | 5 #include "cc/resources/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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 queue.items.push_back(TileTaskQueue::Item(it->get(), task_sets)); | 233 queue.items.push_back(TileTaskQueue::Item(it->get(), task_sets)); |
234 } | 234 } |
235 | 235 |
236 completed_task_sets_.reset(); | 236 completed_task_sets_.reset(); |
237 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&queue); | 237 tile_task_worker_pool_->AsTileTaskRunner()->ScheduleTasks(&queue); |
238 } | 238 } |
239 | 239 |
240 void AppendTask(unsigned id, const gfx::Size& size) { | 240 void AppendTask(unsigned id, const gfx::Size& size) { |
241 scoped_ptr<ScopedResource> resource( | 241 scoped_ptr<ScopedResource> resource( |
242 ScopedResource::Create(resource_provider_.get())); | 242 ScopedResource::Create(resource_provider_.get())); |
243 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); | 243 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 244 RGBA_8888); |
244 const Resource* const_resource = resource.get(); | 245 const Resource* const_resource = resource.get(); |
245 | 246 |
246 ImageDecodeTask::Vector empty; | 247 ImageDecodeTask::Vector empty; |
247 tasks_.push_back(new TestRasterTaskImpl( | 248 tasks_.push_back(new TestRasterTaskImpl( |
248 const_resource, | 249 const_resource, |
249 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, | 250 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, |
250 base::Unretained(this), base::Passed(&resource), id), | 251 base::Unretained(this), base::Passed(&resource), id), |
251 &empty)); | 252 &empty)); |
252 } | 253 } |
253 | 254 |
254 void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); } | 255 void AppendTask(unsigned id) { AppendTask(id, gfx::Size(1, 1)); } |
255 | 256 |
256 void AppendBlockingTask(unsigned id, base::Lock* lock) { | 257 void AppendBlockingTask(unsigned id, base::Lock* lock) { |
257 const gfx::Size size(1, 1); | 258 const gfx::Size size(1, 1); |
258 | 259 |
259 scoped_ptr<ScopedResource> resource( | 260 scoped_ptr<ScopedResource> resource( |
260 ScopedResource::Create(resource_provider_.get())); | 261 ScopedResource::Create(resource_provider_.get())); |
261 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); | 262 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 263 RGBA_8888); |
262 const Resource* const_resource = resource.get(); | 264 const Resource* const_resource = resource.get(); |
263 | 265 |
264 ImageDecodeTask::Vector empty; | 266 ImageDecodeTask::Vector empty; |
265 tasks_.push_back(new BlockingTestRasterTaskImpl( | 267 tasks_.push_back(new BlockingTestRasterTaskImpl( |
266 const_resource, | 268 const_resource, |
267 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, | 269 base::Bind(&TileTaskWorkerPoolTest::OnTaskCompleted, |
268 base::Unretained(this), base::Passed(&resource), id), | 270 base::Unretained(this), base::Passed(&resource), id), |
269 lock, &empty)); | 271 lock, &empty)); |
270 } | 272 } |
271 | 273 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 RunMessageLoopUntilAllTasksHaveCompleted(); | 382 RunMessageLoopUntilAllTasksHaveCompleted(); |
381 } | 383 } |
382 | 384 |
383 TEST_P(TileTaskWorkerPoolTest, LargeResources) { | 385 TEST_P(TileTaskWorkerPoolTest, LargeResources) { |
384 gfx::Size size(kLargeResourceDimension, kLargeResourceDimension); | 386 gfx::Size size(kLargeResourceDimension, kLargeResourceDimension); |
385 | 387 |
386 { | 388 { |
387 // Verify a resource of this size is larger than the transfer buffer. | 389 // Verify a resource of this size is larger than the transfer buffer. |
388 scoped_ptr<ScopedResource> resource( | 390 scoped_ptr<ScopedResource> resource( |
389 ScopedResource::Create(resource_provider_.get())); | 391 ScopedResource::Create(resource_provider_.get())); |
390 resource->Allocate(size, ResourceProvider::TextureHintImmutable, RGBA_8888); | 392 resource->Allocate(size, ResourceProvider::TEXTURE_HINT_IMMUTABLE, |
| 393 RGBA_8888); |
391 EXPECT_GE(resource->bytes(), kMaxTransferBufferUsageBytes); | 394 EXPECT_GE(resource->bytes(), kMaxTransferBufferUsageBytes); |
392 } | 395 } |
393 | 396 |
394 AppendTask(0u, size); | 397 AppendTask(0u, size); |
395 AppendTask(1u, size); | 398 AppendTask(1u, size); |
396 AppendTask(2u, size); | 399 AppendTask(2u, size); |
397 ScheduleTasks(); | 400 ScheduleTasks(); |
398 | 401 |
399 // This will time out if a resource that is larger than the throttle limit | 402 // This will time out if a resource that is larger than the throttle limit |
400 // never gets scheduled. | 403 // never gets scheduled. |
401 RunMessageLoopUntilAllTasksHaveCompleted(); | 404 RunMessageLoopUntilAllTasksHaveCompleted(); |
402 } | 405 } |
403 | 406 |
404 INSTANTIATE_TEST_CASE_P( | 407 INSTANTIATE_TEST_CASE_P( |
405 TileTaskWorkerPoolTests, | 408 TileTaskWorkerPoolTests, |
406 TileTaskWorkerPoolTest, | 409 TileTaskWorkerPoolTest, |
407 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, | 410 ::testing::Values(TILE_TASK_WORKER_POOL_TYPE_PIXEL_BUFFER, |
408 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, | 411 TILE_TASK_WORKER_POOL_TYPE_ZERO_COPY, |
409 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, | 412 TILE_TASK_WORKER_POOL_TYPE_ONE_COPY, |
410 TILE_TASK_WORKER_POOL_TYPE_GPU, | 413 TILE_TASK_WORKER_POOL_TYPE_GPU, |
411 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); | 414 TILE_TASK_WORKER_POOL_TYPE_BITMAP)); |
412 | 415 |
413 } // namespace | 416 } // namespace |
414 } // namespace cc | 417 } // namespace cc |
OLD | NEW |