| 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/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "cc/debug/lap_timer.h" | 9 #include "cc/debug/lap_timer.h" |
| 10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
| 11 #include "cc/resources/bitmap_raster_worker_pool.h" | 11 #include "cc/resources/bitmap_raster_worker_pool.h" |
| 12 #include "cc/resources/gpu_raster_worker_pool.h" | 12 #include "cc/resources/gpu_raster_worker_pool.h" |
| 13 #include "cc/resources/one_copy_raster_worker_pool.h" | 13 #include "cc/resources/one_copy_raster_worker_pool.h" |
| 14 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | 14 #include "cc/resources/pixel_buffer_raster_worker_pool.h" |
| 15 #include "cc/resources/raster_buffer.h" | 15 #include "cc/resources/raster_buffer.h" |
| 16 #include "cc/resources/rasterizer.h" | 16 #include "cc/resources/rasterizer.h" |
| 17 #include "cc/resources/resource_pool.h" | 17 #include "cc/resources/resource_pool.h" |
| 18 #include "cc/resources/resource_provider.h" | 18 #include "cc/resources/resource_provider.h" |
| 19 #include "cc/resources/scoped_resource.h" | 19 #include "cc/resources/scoped_resource.h" |
| 20 #include "cc/resources/zero_copy_raster_worker_pool.h" | 20 #include "cc/resources/zero_copy_raster_worker_pool.h" |
| 21 #include "cc/test/fake_output_surface.h" | 21 #include "cc/test/fake_output_surface.h" |
| 22 #include "cc/test/fake_output_surface_client.h" | 22 #include "cc/test/fake_output_surface_client.h" |
| 23 #include "cc/test/test_context_support.h" | 23 #include "cc/test/test_context_support.h" |
| 24 #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 24 #include "cc/test/test_shared_bitmap_manager.h" | 25 #include "cc/test/test_shared_bitmap_manager.h" |
| 25 #include "cc/test/test_web_graphics_context_3d.h" | 26 #include "cc/test/test_web_graphics_context_3d.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "testing/perf/perf_test.h" | 28 #include "testing/perf/perf_test.h" |
| 28 #include "third_party/khronos/GLES2/gl2.h" | 29 #include "third_party/khronos/GLES2/gl2.h" |
| 29 | 30 |
| 30 namespace cc { | 31 namespace cc { |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub { | 34 class PerfGLES2Interface : public gpu::gles2::GLES2InterfaceStub { |
| 34 // Overridden from gpu::gles2::GLES2Interface: | 35 // Overridden from gpu::gles2::GLES2Interface: |
| 35 virtual GLuint CreateImageCHROMIUM(GLsizei width, | 36 virtual GLuint CreateImageCHROMIUM(ClientBuffer buffer, |
| 37 GLsizei width, |
| 36 GLsizei height, | 38 GLsizei height, |
| 37 GLenum internalformat, | 39 GLenum internalformat) override { |
| 38 GLenum usage) override { | |
| 39 return 1u; | 40 return 1u; |
| 40 } | 41 } |
| 41 virtual void GenBuffers(GLsizei n, GLuint* buffers) override { | 42 virtual void GenBuffers(GLsizei n, GLuint* buffers) override { |
| 42 for (GLsizei i = 0; i < n; ++i) | 43 for (GLsizei i = 0; i < n; ++i) |
| 43 buffers[i] = 1u; | 44 buffers[i] = 1u; |
| 44 } | 45 } |
| 45 virtual void GenTextures(GLsizei n, GLuint* textures) override { | 46 virtual void GenTextures(GLsizei n, GLuint* textures) override { |
| 46 for (GLsizei i = 0; i < n; ++i) | 47 for (GLsizei i = 0; i < n; ++i) |
| 47 textures[i] = 1u; | 48 textures[i] = 1u; |
| 48 } | 49 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 test_name, | 393 test_name, |
| 393 timer_.LapsPerSecond(), | 394 timer_.LapsPerSecond(), |
| 394 "runs/s", | 395 "runs/s", |
| 395 true); | 396 true); |
| 396 } | 397 } |
| 397 | 398 |
| 398 private: | 399 private: |
| 399 void Create3dOutputSurfaceAndResourceProvider() { | 400 void Create3dOutputSurfaceAndResourceProvider() { |
| 400 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 401 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 401 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 402 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 402 resource_provider_ = | 403 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 403 ResourceProvider::Create( | 404 NULL, |
| 404 output_surface_.get(), NULL, NULL, 0, false, 1, false).Pass(); | 405 &gpu_memory_buffer_manager_, |
| 406 NULL, |
| 407 0, |
| 408 false, |
| 409 1, |
| 410 false).Pass(); |
| 405 } | 411 } |
| 406 | 412 |
| 407 void CreateSoftwareOutputSurfaceAndResourceProvider() { | 413 void CreateSoftwareOutputSurfaceAndResourceProvider() { |
| 408 output_surface_ = FakeOutputSurface::CreateSoftware( | 414 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 409 make_scoped_ptr(new SoftwareOutputDevice)); | 415 make_scoped_ptr(new SoftwareOutputDevice)); |
| 410 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 416 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 411 resource_provider_ = ResourceProvider::Create(output_surface_.get(), | 417 resource_provider_ = ResourceProvider::Create(output_surface_.get(), |
| 412 &shared_bitmap_manager_, | 418 &shared_bitmap_manager_, |
| 413 NULL, | 419 NULL, |
| 420 NULL, |
| 414 0, | 421 0, |
| 415 false, | 422 false, |
| 416 1, | 423 1, |
| 417 false).Pass(); | 424 false).Pass(); |
| 418 } | 425 } |
| 419 | 426 |
| 420 std::string TestModifierString() const { | 427 std::string TestModifierString() const { |
| 421 switch (GetParam()) { | 428 switch (GetParam()) { |
| 422 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: | 429 case RASTER_WORKER_POOL_TYPE_PIXEL_BUFFER: |
| 423 return std::string("_pixel_raster_worker_pool"); | 430 return std::string("_pixel_raster_worker_pool"); |
| 424 case RASTER_WORKER_POOL_TYPE_ZERO_COPY: | 431 case RASTER_WORKER_POOL_TYPE_ZERO_COPY: |
| 425 return std::string("_zero_copy_raster_worker_pool"); | 432 return std::string("_zero_copy_raster_worker_pool"); |
| 426 case RASTER_WORKER_POOL_TYPE_ONE_COPY: | 433 case RASTER_WORKER_POOL_TYPE_ONE_COPY: |
| 427 return std::string("_one_copy_raster_worker_pool"); | 434 return std::string("_one_copy_raster_worker_pool"); |
| 428 case RASTER_WORKER_POOL_TYPE_GPU: | 435 case RASTER_WORKER_POOL_TYPE_GPU: |
| 429 return std::string("_gpu_raster_worker_pool"); | 436 return std::string("_gpu_raster_worker_pool"); |
| 430 case RASTER_WORKER_POOL_TYPE_BITMAP: | 437 case RASTER_WORKER_POOL_TYPE_BITMAP: |
| 431 return std::string("_bitmap_raster_worker_pool"); | 438 return std::string("_bitmap_raster_worker_pool"); |
| 432 } | 439 } |
| 433 NOTREACHED(); | 440 NOTREACHED(); |
| 434 return std::string(); | 441 return std::string(); |
| 435 } | 442 } |
| 436 | 443 |
| 437 scoped_ptr<ResourcePool> staging_resource_pool_; | 444 scoped_ptr<ResourcePool> staging_resource_pool_; |
| 438 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 445 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 446 TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 439 TestSharedBitmapManager shared_bitmap_manager_; | 447 TestSharedBitmapManager shared_bitmap_manager_; |
| 440 }; | 448 }; |
| 441 | 449 |
| 442 TEST_P(RasterWorkerPoolPerfTest, ScheduleTasks) { | 450 TEST_P(RasterWorkerPoolPerfTest, ScheduleTasks) { |
| 443 RunScheduleTasksTest("1_0", 1, 0); | 451 RunScheduleTasksTest("1_0", 1, 0); |
| 444 RunScheduleTasksTest("32_0", 32, 0); | 452 RunScheduleTasksTest("32_0", 32, 0); |
| 445 RunScheduleTasksTest("1_1", 1, 1); | 453 RunScheduleTasksTest("1_1", 1, 1); |
| 446 RunScheduleTasksTest("32_1", 32, 1); | 454 RunScheduleTasksTest("32_1", 32, 1); |
| 447 RunScheduleTasksTest("1_4", 1, 4); | 455 RunScheduleTasksTest("1_4", 1, 4); |
| 448 RunScheduleTasksTest("32_4", 32, 4); | 456 RunScheduleTasksTest("32_4", 32, 4); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 476 | 484 |
| 477 class RasterWorkerPoolCommonPerfTest : public RasterWorkerPoolPerfTestBase, | 485 class RasterWorkerPoolCommonPerfTest : public RasterWorkerPoolPerfTestBase, |
| 478 public testing::Test { | 486 public testing::Test { |
| 479 public: | 487 public: |
| 480 // Overridden from testing::Test: | 488 // Overridden from testing::Test: |
| 481 virtual void SetUp() override { | 489 virtual void SetUp() override { |
| 482 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); | 490 output_surface_ = FakeOutputSurface::Create3d(context_provider_).Pass(); |
| 483 CHECK(output_surface_->BindToClient(&output_surface_client_)); | 491 CHECK(output_surface_->BindToClient(&output_surface_client_)); |
| 484 resource_provider_ = | 492 resource_provider_ = |
| 485 ResourceProvider::Create( | 493 ResourceProvider::Create( |
| 486 output_surface_.get(), NULL, NULL, 0, false, 1, false).Pass(); | 494 output_surface_.get(), NULL, NULL, NULL, 0, false, 1, false).Pass(); |
| 487 } | 495 } |
| 488 | 496 |
| 489 void RunBuildRasterTaskQueueTest(const std::string& test_name, | 497 void RunBuildRasterTaskQueueTest(const std::string& test_name, |
| 490 unsigned num_raster_tasks, | 498 unsigned num_raster_tasks, |
| 491 unsigned num_image_decode_tasks) { | 499 unsigned num_image_decode_tasks) { |
| 492 ImageDecodeTask::Vector image_decode_tasks; | 500 ImageDecodeTask::Vector image_decode_tasks; |
| 493 RasterTaskVector raster_tasks; | 501 RasterTaskVector raster_tasks; |
| 494 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); | 502 CreateImageDecodeTasks(num_image_decode_tasks, &image_decode_tasks); |
| 495 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks); | 503 CreateRasterTasks(num_raster_tasks, image_decode_tasks, &raster_tasks); |
| 496 | 504 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 517 RunBuildRasterTaskQueueTest("1_0", 1, 0); | 525 RunBuildRasterTaskQueueTest("1_0", 1, 0); |
| 518 RunBuildRasterTaskQueueTest("32_0", 32, 0); | 526 RunBuildRasterTaskQueueTest("32_0", 32, 0); |
| 519 RunBuildRasterTaskQueueTest("1_1", 1, 1); | 527 RunBuildRasterTaskQueueTest("1_1", 1, 1); |
| 520 RunBuildRasterTaskQueueTest("32_1", 32, 1); | 528 RunBuildRasterTaskQueueTest("32_1", 32, 1); |
| 521 RunBuildRasterTaskQueueTest("1_4", 1, 4); | 529 RunBuildRasterTaskQueueTest("1_4", 1, 4); |
| 522 RunBuildRasterTaskQueueTest("32_4", 32, 4); | 530 RunBuildRasterTaskQueueTest("32_4", 32, 4); |
| 523 } | 531 } |
| 524 | 532 |
| 525 } // namespace | 533 } // namespace |
| 526 } // namespace cc | 534 } // namespace cc |
| OLD | NEW |