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