| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), | 151 base::TimeDelta::FromMilliseconds(kTimeLimitMillis), |
| 149 kTimeCheckInterval) { | 152 kTimeCheckInterval) { |
| 150 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 153 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 151 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 154 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 152 | 155 |
| 153 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | 156 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); |
| 154 resource_provider_ = | 157 resource_provider_ = |
| 155 ResourceProvider::Create( | 158 ResourceProvider::Create( |
| 156 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1) | 159 output_surface_.get(), shared_bitmap_manager_.get(), 0, false, 1) |
| 157 .Pass(); | 160 .Pass(); |
| 161 staging_resource_pool_ = ResourcePool::Create( |
| 162 resource_provider_.get(), GL_TEXTURE_2D, RGBA_8888); |
| 158 } | 163 } |
| 159 | 164 |
| 160 void CreateImageDecodeTasks(unsigned num_image_decode_tasks, | 165 void CreateImageDecodeTasks(unsigned num_image_decode_tasks, |
| 161 ImageDecodeTask::Vector* image_decode_tasks) { | 166 ImageDecodeTask::Vector* image_decode_tasks) { |
| 162 for (unsigned i = 0; i < num_image_decode_tasks; ++i) | 167 for (unsigned i = 0; i < num_image_decode_tasks; ++i) |
| 163 image_decode_tasks->push_back(new PerfImageDecodeTaskImpl); | 168 image_decode_tasks->push_back(new PerfImageDecodeTaskImpl); |
| 164 } | 169 } |
| 165 | 170 |
| 166 void CreateRasterTasks(unsigned num_raster_tasks, | 171 void CreateRasterTasks(unsigned num_raster_tasks, |
| 167 const ImageDecodeTask::Vector& image_decode_tasks, | 172 const ImageDecodeTask::Vector& image_decode_tasks, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 188 queue->required_for_activation_count += required_for_activation; | 193 queue->required_for_activation_count += required_for_activation; |
| 189 } | 194 } |
| 190 } | 195 } |
| 191 | 196 |
| 192 protected: | 197 protected: |
| 193 scoped_refptr<ContextProvider> context_provider_; | 198 scoped_refptr<ContextProvider> context_provider_; |
| 194 FakeOutputSurfaceClient output_surface_client_; | 199 FakeOutputSurfaceClient output_surface_client_; |
| 195 scoped_ptr<FakeOutputSurface> output_surface_; | 200 scoped_ptr<FakeOutputSurface> output_surface_; |
| 196 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 201 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
| 197 scoped_ptr<ResourceProvider> resource_provider_; | 202 scoped_ptr<ResourceProvider> resource_provider_; |
| 203 scoped_ptr<ResourcePool> staging_resource_pool_; |
| 198 scoped_ptr<TaskGraphRunner> task_graph_runner_; | 204 scoped_ptr<TaskGraphRunner> task_graph_runner_; |
| 199 LapTimer timer_; | 205 LapTimer timer_; |
| 200 }; | 206 }; |
| 201 | 207 |
| 202 class RasterWorkerPoolPerfTest | 208 class RasterWorkerPoolPerfTest |
| 203 : public RasterWorkerPoolPerfTestBase, | 209 : public RasterWorkerPoolPerfTestBase, |
| 204 public testing::TestWithParam<RasterWorkerPoolType>, | 210 public testing::TestWithParam<RasterWorkerPoolType>, |
| 205 public RasterizerClient { | 211 public RasterizerClient { |
| 206 public: | 212 public: |
| 207 RasterWorkerPoolPerfTest() { | 213 RasterWorkerPoolPerfTest() { |
| 208 switch (GetParam()) { | 214 switch (GetParam()) { |
| 209 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 215 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
| 210 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( | 216 raster_worker_pool_ = PixelBufferRasterWorkerPool::Create( |
| 211 base::MessageLoopProxy::current().get(), | 217 base::MessageLoopProxy::current().get(), |
| 212 task_graph_runner_.get(), | 218 task_graph_runner_.get(), |
| 213 resource_provider_.get(), | 219 resource_provider_.get(), |
| 214 std::numeric_limits<size_t>::max()); | 220 std::numeric_limits<size_t>::max()); |
| 215 break; | 221 break; |
| 216 case RASTER_WORKER_POOL_TYPE_IMAGE: | 222 case RASTER_WORKER_POOL_TYPE_IMAGE: |
| 217 raster_worker_pool_ = ImageRasterWorkerPool::Create( | 223 raster_worker_pool_ = ImageRasterWorkerPool::Create( |
| 218 base::MessageLoopProxy::current().get(), | 224 base::MessageLoopProxy::current().get(), |
| 219 task_graph_runner_.get(), | 225 task_graph_runner_.get(), |
| 220 resource_provider_.get()); | 226 resource_provider_.get()); |
| 221 break; | 227 break; |
| 228 case RASTER_WORKER_POOL_TYPE_IMAGE_COPY: |
| 229 raster_worker_pool_ = ImageCopyRasterWorkerPool::Create( |
| 230 base::MessageLoopProxy::current().get(), |
| 231 task_graph_runner_.get(), |
| 232 resource_provider_.get(), |
| 233 staging_resource_pool_.get()); |
| 234 break; |
| 222 case RASTER_WORKER_POOL_TYPE_DIRECT: | 235 case RASTER_WORKER_POOL_TYPE_DIRECT: |
| 223 raster_worker_pool_ = DirectRasterWorkerPool::Create( | 236 raster_worker_pool_ = DirectRasterWorkerPool::Create( |
| 224 base::MessageLoopProxy::current().get(), | 237 base::MessageLoopProxy::current().get(), |
| 225 resource_provider_.get(), | 238 resource_provider_.get(), |
| 226 context_provider_.get()); | 239 context_provider_.get()); |
| 227 break; | 240 break; |
| 228 } | 241 } |
| 229 | 242 |
| 230 DCHECK(raster_worker_pool_); | 243 DCHECK(raster_worker_pool_); |
| 231 raster_worker_pool_->AsRasterizer()->SetClient(this); | 244 raster_worker_pool_->AsRasterizer()->SetClient(this); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 true); | 368 true); |
| 356 } | 369 } |
| 357 | 370 |
| 358 private: | 371 private: |
| 359 std::string TestModifierString() const { | 372 std::string TestModifierString() const { |
| 360 switch (GetParam()) { | 373 switch (GetParam()) { |
| 361 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 374 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
| 362 return std::string("_pixel_raster_worker_pool"); | 375 return std::string("_pixel_raster_worker_pool"); |
| 363 case RASTER_WORKER_POOL_TYPE_IMAGE: | 376 case RASTER_WORKER_POOL_TYPE_IMAGE: |
| 364 return std::string("_image_raster_worker_pool"); | 377 return std::string("_image_raster_worker_pool"); |
| 378 case RASTER_WORKER_POOL_TYPE_IMAGE_COPY: |
| 379 return std::string("_image_copy_raster_worker_pool"); |
| 365 case RASTER_WORKER_POOL_TYPE_DIRECT: | 380 case RASTER_WORKER_POOL_TYPE_DIRECT: |
| 366 return std::string("_direct_raster_worker_pool"); | 381 return std::string("_direct_raster_worker_pool"); |
| 367 } | 382 } |
| 368 NOTREACHED(); | 383 NOTREACHED(); |
| 369 return std::string(); | 384 return std::string(); |
| 370 } | 385 } |
| 371 | 386 |
| 372 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 387 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 373 }; | 388 }; |
| 374 | 389 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 396 RunScheduleAndExecuteTasksTest("1_1", 1, 1); | 411 RunScheduleAndExecuteTasksTest("1_1", 1, 1); |
| 397 RunScheduleAndExecuteTasksTest("32_1", 32, 1); | 412 RunScheduleAndExecuteTasksTest("32_1", 32, 1); |
| 398 RunScheduleAndExecuteTasksTest("1_4", 1, 4); | 413 RunScheduleAndExecuteTasksTest("1_4", 1, 4); |
| 399 RunScheduleAndExecuteTasksTest("32_4", 32, 4); | 414 RunScheduleAndExecuteTasksTest("32_4", 32, 4); |
| 400 } | 415 } |
| 401 | 416 |
| 402 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolPerfTests, | 417 INSTANTIATE_TEST_CASE_P(RasterWorkerPoolPerfTests, |
| 403 RasterWorkerPoolPerfTest, | 418 RasterWorkerPoolPerfTest, |
| 404 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, | 419 ::testing::Values(RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER, |
| 405 RASTER_WORKER_POOL_TYPE_IMAGE, | 420 RASTER_WORKER_POOL_TYPE_IMAGE, |
| 421 RASTER_WORKER_POOL_TYPE_IMAGE_COPY, |
| 406 RASTER_WORKER_POOL_TYPE_DIRECT)); | 422 RASTER_WORKER_POOL_TYPE_DIRECT)); |
| 407 | 423 |
| 408 class RasterWorkerPoolCommonPerfTest : public RasterWorkerPoolPerfTestBase, | 424 class RasterWorkerPoolCommonPerfTest : public RasterWorkerPoolPerfTestBase, |
| 409 public testing::Test { | 425 public testing::Test { |
| 410 public: | 426 public: |
| 411 void RunBuildRasterTaskQueueTest(const std::string& test_name, | 427 void RunBuildRasterTaskQueueTest(const std::string& test_name, |
| 412 unsigned num_raster_tasks, | 428 unsigned num_raster_tasks, |
| 413 unsigned num_image_decode_tasks) { | 429 unsigned num_image_decode_tasks) { |
| 414 ImageDecodeTask::Vector image_decode_tasks; | 430 ImageDecodeTask::Vector image_decode_tasks; |
| 415 RasterTaskVector raster_tasks; | 431 RasterTaskVector raster_tasks; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 439 RunBuildRasterTaskQueueTest("1_0", 1, 0); | 455 RunBuildRasterTaskQueueTest("1_0", 1, 0); |
| 440 RunBuildRasterTaskQueueTest("32_0", 32, 0); | 456 RunBuildRasterTaskQueueTest("32_0", 32, 0); |
| 441 RunBuildRasterTaskQueueTest("1_1", 1, 1); | 457 RunBuildRasterTaskQueueTest("1_1", 1, 1); |
| 442 RunBuildRasterTaskQueueTest("32_1", 32, 1); | 458 RunBuildRasterTaskQueueTest("32_1", 32, 1); |
| 443 RunBuildRasterTaskQueueTest("1_4", 1, 4); | 459 RunBuildRasterTaskQueueTest("1_4", 1, 4); |
| 444 RunBuildRasterTaskQueueTest("32_4", 32, 4); | 460 RunBuildRasterTaskQueueTest("32_4", 32, 4); |
| 445 } | 461 } |
| 446 | 462 |
| 447 } // namespace | 463 } // namespace |
| 448 } // namespace cc | 464 } // namespace cc |
| OLD | NEW |