| 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_tile_task_worker_pool.h" |
| 9 #include "cc/raster/gpu_rasterizer.h" | 9 #include "cc/raster/gpu_rasterizer.h" |
| 10 #include "cc/raster/gpu_tile_task_worker_pool.h" | 10 #include "cc/raster/gpu_tile_task_worker_pool.h" |
| 11 #include "cc/raster/one_copy_tile_task_worker_pool.h" | 11 #include "cc/raster/one_copy_tile_task_worker_pool.h" |
| 12 #include "cc/raster/pixel_buffer_tile_task_worker_pool.h" | |
| 13 #include "cc/raster/tile_task_worker_pool.h" | 12 #include "cc/raster/tile_task_worker_pool.h" |
| 14 #include "cc/raster/zero_copy_tile_task_worker_pool.h" | 13 #include "cc/raster/zero_copy_tile_task_worker_pool.h" |
| 15 #include "cc/resources/resource_pool.h" | 14 #include "cc/resources/resource_pool.h" |
| 16 #include "cc/test/fake_output_surface.h" | 15 #include "cc/test/fake_output_surface.h" |
| 17 #include "gpu/GLES2/gl2extchromium.h" | 16 #include "gpu/GLES2/gl2extchromium.h" |
| 18 | 17 |
| 19 namespace cc { | 18 namespace cc { |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| 23 bool IsTestCaseSupported(PixelResourceTestCase test_case) { | 22 bool IsTestCaseSupported(PixelResourceTestCase test_case) { |
| 24 switch (test_case) { | 23 switch (test_case) { |
| 25 case SOFTWARE: | 24 case SOFTWARE: |
| 26 case GL_GPU_RASTER_2D_DRAW: | 25 case GL_GPU_RASTER_2D_DRAW: |
| 27 case GL_ZERO_COPY_2D_DRAW: | 26 case GL_ZERO_COPY_2D_DRAW: |
| 28 case GL_ZERO_COPY_RECT_DRAW: | 27 case GL_ZERO_COPY_RECT_DRAW: |
| 29 case GL_ONE_COPY_2D_STAGING_2D_DRAW: | 28 case GL_ONE_COPY_2D_STAGING_2D_DRAW: |
| 30 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: | 29 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: |
| 31 case GL_ASYNC_UPLOAD_2D_DRAW: | |
| 32 return true; | 30 return true; |
| 33 case GL_ZERO_COPY_EXTERNAL_DRAW: | 31 case GL_ZERO_COPY_EXTERNAL_DRAW: |
| 34 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: | 32 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: |
| 35 // These should all be enabled in practice. | 33 // These should all be enabled in practice. |
| 36 // TODO(enne): look into getting texture external oes enabled. | 34 // TODO(enne): look into getting texture external oes enabled. |
| 37 return false; | 35 return false; |
| 38 } | 36 } |
| 39 | 37 |
| 40 NOTREACHED(); | 38 NOTREACHED(); |
| 41 return false; | 39 return false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 case GL_ZERO_COPY_RECT_DRAW: | 94 case GL_ZERO_COPY_RECT_DRAW: |
| 97 test_type_ = PIXEL_TEST_GL; | 95 test_type_ = PIXEL_TEST_GL; |
| 98 draw_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; | 96 draw_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; |
| 99 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 97 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; |
| 100 return; | 98 return; |
| 101 case GL_ZERO_COPY_EXTERNAL_DRAW: | 99 case GL_ZERO_COPY_EXTERNAL_DRAW: |
| 102 test_type_ = PIXEL_TEST_GL; | 100 test_type_ = PIXEL_TEST_GL; |
| 103 draw_texture_target_ = GL_TEXTURE_EXTERNAL_OES; | 101 draw_texture_target_ = GL_TEXTURE_EXTERNAL_OES; |
| 104 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 102 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; |
| 105 return; | 103 return; |
| 106 case GL_ASYNC_UPLOAD_2D_DRAW: | |
| 107 test_type_ = PIXEL_TEST_GL; | |
| 108 draw_texture_target_ = GL_TEXTURE_2D; | |
| 109 resource_pool_option_ = PIXEL_BUFFER_TILE_TASK_WORKER_POOL; | |
| 110 return; | |
| 111 } | 104 } |
| 112 NOTREACHED(); | 105 NOTREACHED(); |
| 113 } | 106 } |
| 114 | 107 |
| 115 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( | 108 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( |
| 116 LayerTreeHostImpl* host_impl, | 109 LayerTreeHostImpl* host_impl, |
| 117 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 110 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 118 scoped_ptr<ResourcePool>* resource_pool) { | 111 scoped_ptr<ResourcePool>* resource_pool) { |
| 119 base::SingleThreadTaskRunner* task_runner = | 112 base::SingleThreadTaskRunner* task_runner = |
| 120 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() | 113 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() |
| 121 : proxy()->MainThreadTaskRunner(); | 114 : proxy()->MainThreadTaskRunner(); |
| 122 DCHECK(task_runner); | 115 DCHECK(task_runner); |
| 123 DCHECK(initialized_); | 116 DCHECK(initialized_); |
| 124 | 117 |
| 125 ContextProvider* context_provider = | 118 ContextProvider* context_provider = |
| 126 host_impl->output_surface()->context_provider(); | 119 host_impl->output_surface()->context_provider(); |
| 127 ResourceProvider* resource_provider = host_impl->resource_provider(); | 120 ResourceProvider* resource_provider = host_impl->resource_provider(); |
| 128 size_t max_transfer_buffer_usage_bytes = 1024u * 1024u * 60u; | |
| 129 int max_bytes_per_copy_operation = 1024 * 1024; | 121 int max_bytes_per_copy_operation = 1024 * 1024; |
| 130 int max_staging_buffers = 32; | 122 int max_staging_buffers = 32; |
| 131 | 123 |
| 132 switch (resource_pool_option_) { | 124 switch (resource_pool_option_) { |
| 133 case BITMAP_TILE_TASK_WORKER_POOL: | 125 case BITMAP_TILE_TASK_WORKER_POOL: |
| 134 EXPECT_FALSE(context_provider); | 126 EXPECT_FALSE(context_provider); |
| 135 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); | 127 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); |
| 136 *resource_pool = ResourcePool::Create(resource_provider, task_runner, | 128 *resource_pool = ResourcePool::Create(resource_provider, task_runner, |
| 137 draw_texture_target_); | 129 draw_texture_target_); |
| 138 | 130 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 163 EXPECT_TRUE(context_provider); | 155 EXPECT_TRUE(context_provider); |
| 164 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 156 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
| 165 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); | 157 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); |
| 166 *resource_pool = ResourcePool::Create(resource_provider, task_runner, | 158 *resource_pool = ResourcePool::Create(resource_provider, task_runner, |
| 167 draw_texture_target_); | 159 draw_texture_target_); |
| 168 | 160 |
| 169 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 161 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
| 170 task_runner, task_graph_runner(), context_provider, resource_provider, | 162 task_runner, task_graph_runner(), context_provider, resource_provider, |
| 171 max_bytes_per_copy_operation, false, max_staging_buffers); | 163 max_bytes_per_copy_operation, false, max_staging_buffers); |
| 172 break; | 164 break; |
| 173 case PIXEL_BUFFER_TILE_TASK_WORKER_POOL: | |
| 174 EXPECT_TRUE(context_provider); | |
| 175 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | |
| 176 *resource_pool = ResourcePool::Create(resource_provider, task_runner, | |
| 177 draw_texture_target_); | |
| 178 | |
| 179 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( | |
| 180 task_runner, task_graph_runner(), context_provider, resource_provider, | |
| 181 max_transfer_buffer_usage_bytes); | |
| 182 break; | |
| 183 } | 165 } |
| 184 } | 166 } |
| 185 | 167 |
| 186 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( | 168 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( |
| 187 scoped_refptr<Layer> content_root, | 169 scoped_refptr<Layer> content_root, |
| 188 base::FilePath file_name) { | 170 base::FilePath file_name) { |
| 189 if (!IsTestCaseSupported(test_case_)) | 171 if (!IsTestCaseSupported(test_case_)) |
| 190 return; | 172 return; |
| 191 RunPixelTest(test_type_, content_root, file_name); | 173 RunPixelTest(test_type_, content_root, file_name); |
| 192 } | 174 } |
| 193 | 175 |
| 194 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() | 176 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() |
| 195 : LayerTreeHostPixelResourceTest(GetParam()) { | 177 : LayerTreeHostPixelResourceTest(GetParam()) { |
| 196 } | 178 } |
| 197 | 179 |
| 198 } // namespace cc | 180 } // namespace cc |
| OLD | NEW |