| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/layer_tree_pixel_resource_test.h" | 5 #include "cc/test/layer_tree_pixel_resource_test.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/raster/bitmap_tile_task_worker_pool.h" | 8 #include "cc/raster/bitmap_raster_buffer_provider.h" |
| 9 #include "cc/raster/gpu_raster_buffer_provider.h" |
| 9 #include "cc/raster/gpu_rasterizer.h" | 10 #include "cc/raster/gpu_rasterizer.h" |
| 10 #include "cc/raster/gpu_tile_task_worker_pool.h" | 11 #include "cc/raster/one_copy_raster_buffer_provider.h" |
| 11 #include "cc/raster/one_copy_tile_task_worker_pool.h" | 12 #include "cc/raster/raster_buffer_provider.h" |
| 12 #include "cc/raster/tile_task_worker_pool.h" | 13 #include "cc/raster/zero_copy_raster_buffer_provider.h" |
| 13 #include "cc/raster/zero_copy_tile_task_worker_pool.h" | |
| 14 #include "cc/resources/resource_pool.h" | 14 #include "cc/resources/resource_pool.h" |
| 15 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
| 16 #include "gpu/GLES2/gl2extchromium.h" | 16 #include "gpu/GLES2/gl2extchromium.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 bool IsTestCaseSupported(PixelResourceTestCase test_case) { | 22 bool IsTestCaseSupported(PixelResourceTestCase test_case) { |
| 23 switch (test_case) { | 23 switch (test_case) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 NOTREACHED(); | 38 NOTREACHED(); |
| 39 return false; | 39 return false; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest( | 44 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest( |
| 45 PixelResourceTestCase test_case) | 45 PixelResourceTestCase test_case) |
| 46 : draw_texture_target_(GL_INVALID_VALUE), | 46 : draw_texture_target_(GL_INVALID_VALUE), |
| 47 resource_pool_option_(BITMAP_TILE_TASK_WORKER_POOL), | 47 raster_buffer_provider_type_(RASTER_BUFFER_PROVIDER_TYPE_BITMAP), |
| 48 initialized_(false), | 48 initialized_(false), |
| 49 test_case_(test_case) { | 49 test_case_(test_case) { |
| 50 InitializeFromTestCase(test_case); | 50 InitializeFromTestCase(test_case); |
| 51 } | 51 } |
| 52 | 52 |
| 53 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest() | 53 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest() |
| 54 : draw_texture_target_(GL_INVALID_VALUE), | 54 : draw_texture_target_(GL_INVALID_VALUE), |
| 55 resource_pool_option_(BITMAP_TILE_TASK_WORKER_POOL), | 55 raster_buffer_provider_type_(RASTER_BUFFER_PROVIDER_TYPE_BITMAP), |
| 56 initialized_(false), | 56 initialized_(false), |
| 57 test_case_(SOFTWARE) {} | 57 test_case_(SOFTWARE) {} |
| 58 | 58 |
| 59 void LayerTreeHostPixelResourceTest::InitializeFromTestCase( | 59 void LayerTreeHostPixelResourceTest::InitializeFromTestCase( |
| 60 PixelResourceTestCase test_case) { | 60 PixelResourceTestCase test_case) { |
| 61 DCHECK(!initialized_); | 61 DCHECK(!initialized_); |
| 62 initialized_ = true; | 62 initialized_ = true; |
| 63 switch (test_case) { | 63 switch (test_case) { |
| 64 case SOFTWARE: | 64 case SOFTWARE: |
| 65 test_type_ = PIXEL_TEST_SOFTWARE; | 65 test_type_ = PIXEL_TEST_SOFTWARE; |
| 66 draw_texture_target_ = GL_INVALID_VALUE; | 66 draw_texture_target_ = GL_INVALID_VALUE; |
| 67 resource_pool_option_ = BITMAP_TILE_TASK_WORKER_POOL; | 67 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_BITMAP; |
| 68 return; | 68 return; |
| 69 case GL_GPU_RASTER_2D_DRAW: | 69 case GL_GPU_RASTER_2D_DRAW: |
| 70 test_type_ = PIXEL_TEST_GL; | 70 test_type_ = PIXEL_TEST_GL; |
| 71 draw_texture_target_ = GL_TEXTURE_2D; | 71 draw_texture_target_ = GL_TEXTURE_2D; |
| 72 resource_pool_option_ = GPU_TILE_TASK_WORKER_POOL; | 72 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_GPU; |
| 73 return; | 73 return; |
| 74 case GL_ONE_COPY_2D_STAGING_2D_DRAW: | 74 case GL_ONE_COPY_2D_STAGING_2D_DRAW: |
| 75 test_type_ = PIXEL_TEST_GL; | 75 test_type_ = PIXEL_TEST_GL; |
| 76 draw_texture_target_ = GL_TEXTURE_2D; | 76 draw_texture_target_ = GL_TEXTURE_2D; |
| 77 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; | 77 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY; |
| 78 return; | 78 return; |
| 79 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: | 79 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: |
| 80 test_type_ = PIXEL_TEST_GL; | 80 test_type_ = PIXEL_TEST_GL; |
| 81 draw_texture_target_ = GL_TEXTURE_2D; | 81 draw_texture_target_ = GL_TEXTURE_2D; |
| 82 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; | 82 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY; |
| 83 return; | 83 return; |
| 84 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: | 84 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: |
| 85 test_type_ = PIXEL_TEST_GL; | 85 test_type_ = PIXEL_TEST_GL; |
| 86 draw_texture_target_ = GL_TEXTURE_2D; | 86 draw_texture_target_ = GL_TEXTURE_2D; |
| 87 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; | 87 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY; |
| 88 return; | 88 return; |
| 89 case GL_ZERO_COPY_2D_DRAW: | 89 case GL_ZERO_COPY_2D_DRAW: |
| 90 test_type_ = PIXEL_TEST_GL; | 90 test_type_ = PIXEL_TEST_GL; |
| 91 draw_texture_target_ = GL_TEXTURE_2D; | 91 draw_texture_target_ = GL_TEXTURE_2D; |
| 92 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 92 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY; |
| 93 return; | 93 return; |
| 94 case GL_ZERO_COPY_RECT_DRAW: | 94 case GL_ZERO_COPY_RECT_DRAW: |
| 95 test_type_ = PIXEL_TEST_GL; | 95 test_type_ = PIXEL_TEST_GL; |
| 96 draw_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; | 96 draw_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; |
| 97 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 97 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY; |
| 98 return; | 98 return; |
| 99 case GL_ZERO_COPY_EXTERNAL_DRAW: | 99 case GL_ZERO_COPY_EXTERNAL_DRAW: |
| 100 test_type_ = PIXEL_TEST_GL; | 100 test_type_ = PIXEL_TEST_GL; |
| 101 draw_texture_target_ = GL_TEXTURE_EXTERNAL_OES; | 101 draw_texture_target_ = GL_TEXTURE_EXTERNAL_OES; |
| 102 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 102 raster_buffer_provider_type_ = RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY; |
| 103 return; | 103 return; |
| 104 } | 104 } |
| 105 NOTREACHED(); | 105 NOTREACHED(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( | 108 void LayerTreeHostPixelResourceTest::CreateResourceAndRasterBufferProvider( |
| 109 LayerTreeHostImpl* host_impl, | 109 LayerTreeHostImpl* host_impl, |
| 110 std::unique_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 110 std::unique_ptr<RasterBufferProvider>* raster_buffer_provider, |
| 111 std::unique_ptr<ResourcePool>* resource_pool) { | 111 std::unique_ptr<ResourcePool>* resource_pool) { |
| 112 base::SingleThreadTaskRunner* task_runner = | 112 base::SingleThreadTaskRunner* task_runner = |
| 113 task_runner_provider()->HasImplThread() | 113 task_runner_provider()->HasImplThread() |
| 114 ? task_runner_provider()->ImplThreadTaskRunner() | 114 ? task_runner_provider()->ImplThreadTaskRunner() |
| 115 : task_runner_provider()->MainThreadTaskRunner(); | 115 : task_runner_provider()->MainThreadTaskRunner(); |
| 116 DCHECK(task_runner); | 116 DCHECK(task_runner); |
| 117 DCHECK(initialized_); | 117 DCHECK(initialized_); |
| 118 | 118 |
| 119 ContextProvider* context_provider = | 119 ContextProvider* context_provider = |
| 120 host_impl->output_surface()->context_provider(); | 120 host_impl->output_surface()->context_provider(); |
| 121 ResourceProvider* resource_provider = host_impl->resource_provider(); | 121 ResourceProvider* resource_provider = host_impl->resource_provider(); |
| 122 int max_bytes_per_copy_operation = 1024 * 1024; | 122 int max_bytes_per_copy_operation = 1024 * 1024; |
| 123 int max_staging_buffer_usage_in_bytes = 32 * 1024 * 1024; | 123 int max_staging_buffer_usage_in_bytes = 32 * 1024 * 1024; |
| 124 | 124 |
| 125 switch (resource_pool_option_) { | 125 // Create resource pool. |
| 126 case BITMAP_TILE_TASK_WORKER_POOL: | 126 *resource_pool = ResourcePool::Create(resource_provider, task_runner); |
| 127 |
| 128 switch (raster_buffer_provider_type_) { |
| 129 case RASTER_BUFFER_PROVIDER_TYPE_BITMAP: |
| 127 EXPECT_FALSE(context_provider); | 130 EXPECT_FALSE(context_provider); |
| 128 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); | 131 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); |
| 129 *resource_pool = ResourcePool::Create(resource_provider, task_runner); | |
| 130 | 132 |
| 131 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( | 133 *raster_buffer_provider = |
| 132 task_runner, task_graph_runner(), resource_provider); | 134 BitmapRasterBufferProvider::Create(resource_provider); |
| 133 break; | 135 break; |
| 134 case GPU_TILE_TASK_WORKER_POOL: | 136 case RASTER_BUFFER_PROVIDER_TYPE_GPU: |
| 135 EXPECT_TRUE(context_provider); | 137 EXPECT_TRUE(context_provider); |
| 136 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 138 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
| 137 *resource_pool = ResourcePool::Create(resource_provider, task_runner); | |
| 138 | 139 |
| 139 *tile_task_worker_pool = GpuTileTaskWorkerPool::Create( | 140 *raster_buffer_provider = GpuRasterBufferProvider::Create( |
| 140 task_runner, task_graph_runner(), context_provider, resource_provider, | 141 context_provider, resource_provider, false, 0); |
| 141 false, 0); | |
| 142 break; | 142 break; |
| 143 case ZERO_COPY_TILE_TASK_WORKER_POOL: | 143 case RASTER_BUFFER_PROVIDER_TYPE_ZERO_COPY: |
| 144 EXPECT_TRUE(context_provider); | 144 EXPECT_TRUE(context_provider); |
| 145 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 145 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
| 146 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); | 146 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); |
| 147 *resource_pool = ResourcePool::Create(resource_provider, task_runner); | |
| 148 | 147 |
| 149 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( | 148 *raster_buffer_provider = ZeroCopyRasterBufferProvider::Create( |
| 150 task_runner, task_graph_runner(), resource_provider, | 149 resource_provider, PlatformColor::BestTextureFormat()); |
| 151 PlatformColor::BestTextureFormat()); | |
| 152 break; | 150 break; |
| 153 case ONE_COPY_TILE_TASK_WORKER_POOL: | 151 case RASTER_BUFFER_PROVIDER_TYPE_ONE_COPY: |
| 154 EXPECT_TRUE(context_provider); | 152 EXPECT_TRUE(context_provider); |
| 155 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 153 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
| 156 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); | 154 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); |
| 157 *resource_pool = ResourcePool::Create(resource_provider, task_runner); | |
| 158 | 155 |
| 159 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 156 *raster_buffer_provider = OneCopyRasterBufferProvider::Create( |
| 160 task_runner, task_graph_runner(), context_provider, resource_provider, | 157 task_runner, context_provider, resource_provider, |
| 161 max_bytes_per_copy_operation, false, | 158 max_bytes_per_copy_operation, false, |
| 162 max_staging_buffer_usage_in_bytes, | 159 max_staging_buffer_usage_in_bytes, |
| 163 PlatformColor::BestTextureFormat()); | 160 PlatformColor::BestTextureFormat()); |
| 164 break; | 161 break; |
| 165 } | 162 } |
| 166 } | 163 } |
| 167 | 164 |
| 168 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( | 165 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( |
| 169 scoped_refptr<Layer> content_root, | 166 scoped_refptr<Layer> content_root, |
| 170 base::FilePath file_name) { | 167 base::FilePath file_name) { |
| 171 if (!IsTestCaseSupported(test_case_)) | 168 if (!IsTestCaseSupported(test_case_)) |
| 172 return; | 169 return; |
| 173 RunPixelTest(test_type_, content_root, file_name); | 170 RunPixelTest(test_type_, content_root, file_name); |
| 174 } | 171 } |
| 175 | 172 |
| 176 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() | 173 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() |
| 177 : LayerTreeHostPixelResourceTest(GetParam()) { | 174 : LayerTreeHostPixelResourceTest(GetParam()) { |
| 178 } | 175 } |
| 179 | 176 |
| 180 } // namespace cc | 177 } // namespace cc |
| OLD | NEW |