| 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 "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "cc/output/context_provider.h" | 8 #include "cc/output/context_provider.h" |
| 9 #include "cc/resources/direct_raster_worker_pool.h" | 9 #include "cc/resources/direct_raster_worker_pool.h" |
| 10 #include "cc/resources/image_copy_raster_worker_pool.h" |
| 10 #include "cc/resources/image_raster_worker_pool.h" | 11 #include "cc/resources/image_raster_worker_pool.h" |
| 11 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 12 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 12 #include "cc/resources/rasterizer.h" | 13 #include "cc/resources/rasterizer.h" |
| 14 #include "cc/resources/resource_pool.h" |
| 13 #include "cc/resources/resource_provider.h" | 15 #include "cc/resources/resource_provider.h" |
| 14 #include "cc/resources/scoped_resource.h" | 16 #include "cc/resources/scoped_resource.h" |
| 15 #include "cc/test/fake_output_surface.h" | 17 #include "cc/test/fake_output_surface.h" |
| 16 #include "cc/test/fake_output_surface_client.h" | 18 #include "cc/test/fake_output_surface_client.h" |
| 17 #include "cc/test/lap_timer.h" | 19 #include "cc/test/lap_timer.h" |
| 18 #include "cc/test/test_context_support.h" | 20 #include "cc/test/test_context_support.h" |
| 19 #include "cc/test/test_shared_bitmap_manager.h" | 21 #include "cc/test/test_shared_bitmap_manager.h" |
| 20 #include "cc/test/test_web_graphics_context_3d.h" | 22 #include "cc/test/test_web_graphics_context_3d.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "testing/perf/perf_test.h" | 24 #include "testing/perf/perf_test.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 private: | 69 private: |
| 68 virtual ~PerfContextProvider() {} | 70 virtual ~PerfContextProvider() {} |
| 69 | 71 |
| 70 scoped_ptr<PerfGLES2Interface> context_gl_; | 72 scoped_ptr<PerfGLES2Interface> context_gl_; |
| 71 TestContextSupport support_; | 73 TestContextSupport support_; |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 enum RasterWorkerPoolType { | 76 enum RasterWorkerPoolType { |
| 75 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 77 RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 76 RASTER_WORKER_POOL_TYPE_IMAGE, | 78 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 79 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, |
| 77 RASTER_WORKER_POOL_TYPE_DIRECT | 80 RASTER_WORKER_POOL_TYPE_DIRECT |
| 78 }; | 81 }; |
| 79 | 82 |
| 80 static const int kTimeLimitMillis = 2000; | 83 static const int kTimeLimitMillis = 2000; |
| 81 static const int kWarmupRuns = 5; | 84 static const int kWarmupRuns = 5; |
| 82 static const int kTimeCheckInterval = 10; | 85 static const int kTimeCheckInterval = 10; |
| 83 | 86 |
| 84 class PerfImageDecodeTaskImpl : public ImageDecodeTask { | 87 class PerfImageDecodeTaskImpl : public ImageDecodeTask { |
| 85 public: | 88 public: |
| 86 PerfImageDecodeTaskImpl() {} | 89 PerfImageDecodeTaskImpl() {} |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 153 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 151 kTimeCheckInterval) { | 154 kTimeCheckInterval) { |
| 152 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 155 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 153 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 156 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 154 | 157 |
| 155 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 158 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 156 resource_provider_ = | 159 resource_provider_ = |
| 157 ResourceProvider::Create( | 160 ResourceProvider::Create( |
| 158 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1) | 161 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1) |
| 159 .Pass(); | 162 .Pass(); |
| 163 staging_resource_pool_ = ResourcePool::Create( |
| 164 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); |
| 160 } | 165 } |
| 161 | 166 |
| 162 void CreateImageDecodeTasks(unsigned num_image_decode_tasks, | 167 void CreateImageDecodeTasks(unsigned num_image_decode_tasks, |
| 163 ImageDecodeTask::Vector* image_decode_tasks) { | 168 ImageDecodeTask::Vector* image_decode_tasks) { |
| 164 for (unsigned i = 0; i < num_image_decode_tasks; ++i) | 169 for (unsigned i = 0; i < num_image_decode_tasks; ++i) |
| 165 image_decode_tasks->push_back(new PerfImageDecodeTaskImpl); | 170 image_decode_tasks->push_back(new PerfImageDecodeTaskImpl); |
| 166 } | 171 } |
| 167 | 172 |
| 168 void CreateRasterTasks(unsigned num_raster_tasks, | 173 void CreateRasterTasks(unsigned num_raster_tasks, |
| 169 const ImageDecodeTask::Vector& image_decode_tasks, | 174 const ImageDecodeTask::Vector& image_decode_tasks, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 190 queue->required_for_activation_count += required_for_activation; | 195 queue->required_for_activation_count += required_for_activation; |
| 191 } | 196 } |
| 192 } | 197 } |
| 193 | 198 |
| 194 protected: | 199 protected: |
| 195 scoped_refptr<ContextProvider> context_provider_; | 200 scoped_refptr<ContextProvider> context_provider_; |
| 196 FakeOutputSurfaceClient output_surface_client_; | 201 FakeOutputSurfaceClient output_surface_client_; |
| 197 scoped_ptr<FakeOutputSurface> output_surface_; | 202 scoped_ptr<FakeOutputSurface> output_surface_; |
| 198 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 203 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 199 scoped_ptr<ResourceProvider> resource_provider_; | 204 scoped_ptr<ResourceProvider> resource_provider_; |
| 205 scoped_ptr<ResourcePool> staging_resource_pool_; |
| 200 scoped_ptr<TaskGraphRunner> task_graph_runner_; | 206 scoped_ptr<TaskGraphRunner> task_graph_runner_; |
| 201 LapTimer timer_; | 207 LapTimer timer_; |
| 202 }; | 208 }; |
| 203 | 209 |
| 204 class RasterWorkerPoolPerfTest | 210 class RasterWorkerPoolPerfTest |
| 205 : public RasterWorkerPoolPerfTestBase, | 211 : public RasterWorkerPoolPerfTestBase, |
| 206 public testing::TestWithParam<RasterWorkerPoolType>, | 212 public testing::TestWithParam<RasterWorkerPoolType>, |
| 207 public RasterizerClient { | 213 public RasterizerClient { |
| 208 public: | 214 public: |
| 209 RasterWorkerPoolPerfTest() { | 215 RasterWorkerPoolPerfTest() { |
| 210 switch (GetParam()) { | 216 switch (GetParam()) { |
| 211 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 217 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
| 212 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 218 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( |
| 213 base::MessageLoopProxy::current().get(), | 219 base::MessageLoopProxy::current().get(), |
| 214 task_graph_runner_.get(), | 220 task_graph_runner_.get(), |
| 215 resource_provider_.get(), | 221 resource_provider_.get(), |
| 216 std::numeric_limits<size_t>::max()); | 222 std::numeric_limits<size_t>::max()); |
| 217 break; | 223 break; |
| 218 case RASTER_WORKER_POOL_TYPE_IMAGE: | 224 case RASTER_WORKER_POOL_TYPE_IMAGE: |
| 219 raster_worker_pool_ = ImageRasterWorkerPool::Create( | 225 raster_worker_pool_ = ImageRasterWorkerPool::Create( |
| 220 base::MessageLoopProxy::current().get(), | 226 base::MessageLoopProxy::current().get(), |
| 221 task_graph_runner_.get(), | 227 task_graph_runner_.get(), |
| 222 resource_provider_.get()); | 228 resource_provider_.get()); |
| 223 break; | 229 break; |
| 230 case RASTER_WORKER_POOL_TYPE_IMAGE_COPY: |
| 231 raster_worker_pool_ = ImageCopyRasterWorkerPool::Create( |
| 232 base::MessageLoopProxy::current().get(), |
| 233 task_graph_runner_.get(), |
| 234 resource_provider_.get(), |
| 235 staging_resource_pool_.get()); |
| 236 break; |
| 224 case RASTER_WORKER_POOL_TYPE_DIRECT: | 237 case RASTER_WORKER_POOL_TYPE_DIRECT: |
| 225 raster_worker_pool_ = DirectRasterWorkerPool::Create( | 238 raster_worker_pool_ = DirectRasterWorkerPool::Create( |
| 226 base::MessageLoopProxy::current().get(), | 239 base::MessageLoopProxy::current().get(), |
| 227 resource_provider_.get(), | 240 resource_provider_.get(), |
| 228 context_provider_.get()); | 241 context_provider_.get()); |
| 229 break; | 242 break; |
| 230 } | 243 } |
| 231 | 244 |
| 232 DCHECK(raster_worker_pool_); | 245 DCHECK(raster_worker_pool_); |
| 233 raster_worker_pool_->AsRasterizer()->SetClient(this); | 246 raster_worker_pool_->AsRasterizer()->SetClient(this); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 true); | 370 true); |
| 358 } | 371 } |
| 359 | 372 |
| 360 private: | 373 private: |
| 361 std::string TestModifierString() const { | 374 std::string TestModifierString() const { |
| 362 switch (GetParam()) { | 375 switch (GetParam()) { |
| 363 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 376 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
| 364 return std::string("_pixel_raster_worker_pool"); | 377 return std::string("_pixel_raster_worker_pool"); |
| 365 case RASTER_WORKER_POOL_TYPE_IMAGE: | 378 case RASTER_WORKER_POOL_TYPE_IMAGE: |
| 366 return std::string("_image_raster_worker_pool"); | 379 return std::string("_image_raster_worker_pool"); |
| 380 case RASTER_WORKER_POOL_TYPE_IMAGE_COPY: |
| 381 return std::string("_image_copy_raster_worker_pool"); |
| 367 case RASTER_WORKER_POOL_TYPE_DIRECT: | 382 case RASTER_WORKER_POOL_TYPE_DIRECT: |
| 368 return std::string("_direct_raster_worker_pool"); | 383 return std::string("_direct_raster_worker_pool"); |
| 369 } | 384 } |
| 370 NOTREACHED(); | 385 NOTREACHED(); |
| 371 return std::string(); | 386 return std::string(); |
| 372 } | 387 } |
| 373 | 388 |
| 374 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 389 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 375 }; | 390 }; |
| 376 | 391 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 398 RunScheduleAndExecuteTasksTest("1_1", 1, 1); | 413 RunScheduleAndExecuteTasksTest("1_1", 1, 1); |
| 399 RunScheduleAndExecuteTasksTest("32_1", 32, 1); | 414 RunScheduleAndExecuteTasksTest("32_1", 32, 1); |
| 400 RunScheduleAndExecuteTasksTest("1_4", 1, 4); | 415 RunScheduleAndExecuteTasksTest("1_4", 1, 4); |
| 401 RunScheduleAndExecuteTasksTest("32_4", 32, 4); | 416 RunScheduleAndExecuteTasksTest("32_4", 32, 4); |
| 402 } | 417 } |
| 403 | 418 |
| 404 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolPerfTests, | 419 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolPerfTests, |
| 405 RasterWorkerPoolPerfTest, | 420 RasterWorkerPoolPerfTest, |
| 406 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 421 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 407 RASTER_WORKER_POOL_TYPE_IMAGE, | 422 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 423 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, |
| 408 RASTER_WORKER_POOL_TYPE_DIRECT)); | 424 RASTER_WORKER_POOL_TYPE_DIRECT)); |
| 409 | 425 |
| 410 class RasterWorkerPoolCommonPerfTest : public RasterWorkerPoolPerfTestBase, | 426 class RasterWorkerPoolCommonPerfTest : public RasterWorkerPoolPerfTestBase, |
| 411 public testing::Test { | 427 public testing::Test { |
| 412 public: | 428 public: |
| 413 void RunBuildRasterTaskQueueTest(const std::string& test_name, | 429 void RunBuildRasterTaskQueueTest(const std::string& test_name, |
| 414 unsigned num_raster_tasks, | 430 unsigned num_raster_tasks, |
| 415 unsigned num_image_decode_tasks) { | 431 unsigned num_image_decode_tasks) { |
| 416 ImageDecodeTask::Vector image_decode_tasks; | 432 ImageDecodeTask::Vector image_decode_tasks; |
| 417 RasterTaskVector raster_tasks; | 433 RasterTaskVector raster_tasks; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 441 RunBuildRasterTaskQueueTest("1_0", 1, 0); | 457 RunBuildRasterTaskQueueTest("1_0", 1, 0); |
| 442 RunBuildRasterTaskQueueTest("32_0", 32, 0); | 458 RunBuildRasterTaskQueueTest("32_0", 32, 0); |
| 443 RunBuildRasterTaskQueueTest("1_1", 1, 1); | 459 RunBuildRasterTaskQueueTest("1_1", 1, 1); |
| 444 RunBuildRasterTaskQueueTest("32_1", 32, 1); | 460 RunBuildRasterTaskQueueTest("32_1", 32, 1); |
| 445 RunBuildRasterTaskQueueTest("1_4", 1, 4); | 461 RunBuildRasterTaskQueueTest("1_4", 1, 4); |
| 446 RunBuildRasterTaskQueueTest("32_4", 32, 4); | 462 RunBuildRasterTaskQueueTest("32_4", 32, 4); |
| 447 } | 463 } |
| 448 | 464 |
| 449 } // namespace | 465 } // namespace |
| 450 } // namespace cc | 466 } // namespace cc |
| OLD | NEW |