Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "cc/test/layer_tree_pixel_resource_test.h" | |
| 6 | |
| 7 #include "cc/layers/layer.h" | |
| 8 #include "cc/resources/bitmap_raster_worker_pool.h" | |
| 9 #include "cc/resources/gpu_raster_worker_pool.h" | |
| 10 #include "cc/resources/one_copy_raster_worker_pool.h" | |
| 11 #include "cc/resources/pixel_buffer_raster_worker_pool.h" | |
| 12 #include "cc/resources/raster_worker_pool.h" | |
| 13 #include "cc/resources/resource_pool.h" | |
| 14 #include "cc/resources/zero_copy_raster_worker_pool.h" | |
| 15 #include "cc/test/fake_output_surface.h" | |
| 16 #include "gpu/GLES2/gl2extchromium.h" | |
| 17 | |
| 18 namespace cc { | |
| 19 | |
| 20 namespace { | |
| 21 | |
| 22 bool IsTestCaseSupported(PixelResourceTestCase test_case) { | |
| 23 switch (test_case) { | |
| 24 case SOFTWARE: | |
| 25 case GL_GPU_RASTER_2D_DRAW: | |
| 26 case GL_ZERO_COPY_2D_DRAW: | |
| 27 case GL_ZERO_COPY_RECT_DRAW: | |
| 28 case GL_ASYNC_UPLOAD_2D_DRAW: | |
| 29 return true; | |
| 30 case GL_ONE_COPY_2D_STAGING_2D_DRAW: | |
| 31 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: | |
| 32 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: | |
| 33 // TODO(reveman): one copy not supported in unit tests yet. | |
|
enne (OOO)
2014/10/23 19:24:15
These tests all yell about sync_query, so I've dis
| |
| 34 return false; | |
| 35 case GL_ZERO_COPY_EXTERNAL_DRAW: | |
| 36 #if !defined(OS_ANDROID) | |
|
reveman
2014/10/23 20:39:27
what happens without this ifdef? what do we need t
enne (OOO)
2014/10/24 22:21:28
Lots of GL errors.
I don't know what's needed to
reveman
2014/10/27 17:19:04
Sounds like we're missing a check to determine if
enne (OOO)
2014/10/27 17:56:22
That seemed likely to me too. It seems like somet
| |
| 37 return false; | |
| 38 #else | |
| 39 return true; | |
| 40 #endif | |
| 41 case NUM_PIXEL_RESOURCE_TEST_CASES: | |
| 42 NOTREACHED(); | |
| 43 break; | |
| 44 } | |
| 45 | |
| 46 NOTREACHED(); | |
| 47 return false; | |
| 48 } | |
|
reveman
2014/10/23 20:39:27
I think we should try to get this function removed
enne (OOO)
2014/10/24 22:21:28
No question! I just wanted to start somewhere. Th
reveman
2014/10/27 17:19:04
Sounds good. I just wanted to make sure we're on t
| |
| 49 | |
| 50 struct { | |
| 51 LayerTreePixelTest::PixelTestType test_type; | |
| 52 unsigned staging_texture_target; | |
| 53 unsigned draw_texture_target; | |
| 54 LayerTreeHostPixelResourceTest::ResourcePoolOption resource_pool_option; | |
| 55 } ResourcePoolTestConfig[NUM_PIXEL_RESOURCE_TEST_CASES] = { | |
|
reveman
2014/10/23 20:39:27
Please consider replacing this with a set of funct
enne (OOO)
2014/10/24 22:21:28
I like all the values set together, because it mad
| |
| 56 // SOFTWARE | |
| 57 { | |
| 58 LayerTreePixelTest::PIXEL_TEST_SOFTWARE, | |
| 59 GL_INVALID_VALUE, | |
| 60 GL_INVALID_VALUE, | |
| 61 LayerTreeHostPixelResourceTest::RESOURCE_POOL_BITMAP_RASTER_WORKER, | |
| 62 }, | |
| 63 // GL_GPU_RASTER_2D_DRAW | |
| 64 { | |
| 65 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 66 GL_INVALID_VALUE, | |
| 67 GL_TEXTURE_2D, | |
| 68 LayerTreeHostPixelResourceTest::RESOURCE_POOL_GPU_RASTER, | |
| 69 }, | |
| 70 // GL_ONE_COPY_2D_STAGING_2D_DRAW | |
| 71 { | |
| 72 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 73 GL_TEXTURE_RECTANGLE_ARB, | |
| 74 GL_TEXTURE_2D, | |
| 75 LayerTreeHostPixelResourceTest::RESOURCE_POOL_ONE_COPY, | |
| 76 }, | |
| 77 // GL_ONE_COPY_RECT_STAGING_2D_DRAW | |
| 78 { | |
| 79 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 80 GL_TEXTURE_2D, | |
| 81 GL_TEXTURE_2D, | |
| 82 LayerTreeHostPixelResourceTest::RESOURCE_POOL_ONE_COPY, | |
| 83 }, | |
| 84 // GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW | |
| 85 { | |
| 86 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 87 GL_TEXTURE_EXTERNAL_OES, | |
| 88 GL_TEXTURE_2D, | |
| 89 LayerTreeHostPixelResourceTest::RESOURCE_POOL_ONE_COPY, | |
| 90 }, | |
| 91 // GL_ZERO_COPY_2D_DRAW | |
| 92 { | |
| 93 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 94 GL_INVALID_VALUE, | |
| 95 GL_TEXTURE_RECTANGLE_ARB, | |
| 96 LayerTreeHostPixelResourceTest::RESOURCE_POOL_ZERO_COPY, | |
| 97 }, | |
| 98 // GL_ZERO_COPY_RECT_DRAW | |
| 99 { | |
| 100 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 101 GL_INVALID_VALUE, | |
| 102 GL_TEXTURE_2D, | |
| 103 LayerTreeHostPixelResourceTest::RESOURCE_POOL_ZERO_COPY, | |
| 104 }, | |
| 105 // GL_ZERO_COPY_EXTERNAL_DRAW | |
| 106 { | |
| 107 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 108 GL_INVALID_VALUE, | |
| 109 GL_TEXTURE_EXTERNAL_OES, | |
| 110 LayerTreeHostPixelResourceTest::RESOURCE_POOL_ZERO_COPY, | |
| 111 }, | |
| 112 // GL_ASYNC_UPLOAD_2D_DRAW | |
| 113 { | |
| 114 LayerTreePixelTest::PIXEL_TEST_GL, | |
| 115 GL_INVALID_VALUE, | |
| 116 GL_TEXTURE_2D, | |
| 117 LayerTreeHostPixelResourceTest::RESOURCE_POOL_PIXEL_BUFFER_RASTER, | |
| 118 }, | |
| 119 }; | |
| 120 | |
| 121 } // namespace | |
| 122 | |
| 123 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest( | |
| 124 PixelResourceTestCase test_case) | |
| 125 : staging_texture_target_( | |
| 126 ResourcePoolTestConfig[test_case].staging_texture_target), | |
| 127 draw_texture_target_( | |
| 128 ResourcePoolTestConfig[test_case].draw_texture_target), | |
| 129 resource_pool_option_( | |
| 130 ResourcePoolTestConfig[test_case].resource_pool_option), | |
| 131 test_case_(test_case) { | |
| 132 test_type_ = ResourcePoolTestConfig[test_case].test_type; | |
| 133 } | |
| 134 | |
| 135 void LayerTreeHostPixelResourceTest::CreateResourceAndRasterWorkerPool( | |
|
enne (OOO)
2014/10/23 19:24:15
This function ends up looking really long, but I d
| |
| 136 LayerTreeHostImpl* host_impl, | |
| 137 scoped_ptr<RasterWorkerPool>* raster_worker_pool, | |
| 138 scoped_ptr<ResourcePool>* resource_pool, | |
| 139 scoped_ptr<ResourcePool>* staging_resource_pool) { | |
| 140 base::SingleThreadTaskRunner* task_runner = | |
| 141 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() | |
| 142 : proxy()->MainThreadTaskRunner(); | |
| 143 DCHECK(task_runner); | |
| 144 | |
| 145 ContextProvider* context_provider = | |
| 146 host_impl->output_surface()->context_provider(); | |
| 147 ResourceProvider* resource_provider = host_impl->resource_provider(); | |
| 148 if (resource_pool_option_ == RESOURCE_POOL_BITMAP_RASTER_WORKER) { | |
|
reveman
2014/10/23 20:39:27
Can you use a switch statement here instead of thi
enne (OOO)
2014/10/24 22:21:28
Sure.
| |
| 149 EXPECT_FALSE(context_provider); | |
| 150 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); | |
| 151 *resource_pool = | |
| 152 ResourcePool::Create(resource_provider, | |
| 153 draw_texture_target_, | |
| 154 resource_provider->best_texture_format()); | |
| 155 | |
| 156 *raster_worker_pool = BitmapRasterWorkerPool::Create( | |
| 157 task_runner, RasterWorkerPool::GetTaskGraphRunner(), resource_provider); | |
| 158 } else if (resource_pool_option_ == RESOURCE_POOL_GPU_RASTER) { | |
| 159 EXPECT_TRUE(context_provider); | |
| 160 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | |
| 161 *resource_pool = | |
| 162 ResourcePool::Create(resource_provider, | |
| 163 draw_texture_target_, | |
| 164 resource_provider->best_texture_format()); | |
| 165 | |
| 166 bool use_distance_field_text = false; | |
| 167 *raster_worker_pool = GpuRasterWorkerPool::Create(task_runner, | |
| 168 context_provider, | |
| 169 resource_provider, | |
| 170 use_distance_field_text); | |
| 171 } else if (resource_pool_option_ == RESOURCE_POOL_ZERO_COPY) { | |
| 172 EXPECT_TRUE(context_provider); | |
| 173 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | |
| 174 EXPECT_TRUE(host_impl->CanUseZeroCopyRasterizer()); | |
| 175 *resource_pool = | |
| 176 ResourcePool::Create(resource_provider, | |
| 177 draw_texture_target_, | |
| 178 resource_provider->best_texture_format()); | |
| 179 | |
| 180 *raster_worker_pool = ZeroCopyRasterWorkerPool::Create( | |
| 181 task_runner, RasterWorkerPool::GetTaskGraphRunner(), resource_provider); | |
| 182 } else if (resource_pool_option_ == RESOURCE_POOL_ONE_COPY) { | |
| 183 EXPECT_TRUE(context_provider); | |
| 184 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | |
| 185 EXPECT_TRUE(host_impl->CanUseOneCopyRasterizer()); | |
| 186 // We need to create a staging resource pool when using copy rasterizer. | |
| 187 *staging_resource_pool = | |
| 188 ResourcePool::Create(resource_provider, | |
| 189 staging_texture_target_, | |
| 190 resource_provider->best_texture_format()); | |
| 191 *resource_pool = | |
| 192 ResourcePool::Create(resource_provider, | |
| 193 draw_texture_target_, | |
| 194 resource_provider->best_texture_format()); | |
| 195 | |
| 196 *raster_worker_pool = | |
| 197 OneCopyRasterWorkerPool::Create(task_runner, | |
| 198 RasterWorkerPool::GetTaskGraphRunner(), | |
| 199 context_provider, | |
| 200 resource_provider, | |
| 201 staging_resource_pool->get()); | |
| 202 } else if (resource_pool_option_ == RESOURCE_POOL_PIXEL_BUFFER_RASTER) { | |
| 203 EXPECT_TRUE(context_provider); | |
| 204 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | |
| 205 *resource_pool = ResourcePool::Create( | |
| 206 resource_provider, | |
| 207 draw_texture_target_, | |
| 208 resource_provider->memory_efficient_texture_format()); | |
| 209 | |
| 210 size_t max_transfer_buffer_usage_bytes = 1024u * 1024u * 60u; | |
| 211 *raster_worker_pool = PixelBufferRasterWorkerPool::Create( | |
| 212 task_runner, | |
| 213 RasterWorkerPool::GetTaskGraphRunner(), | |
| 214 context_provider, | |
| 215 resource_provider, | |
| 216 max_transfer_buffer_usage_bytes); | |
| 217 } else { | |
| 218 NOTREACHED(); | |
| 219 } | |
| 220 } | |
| 221 | |
| 222 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( | |
| 223 scoped_refptr<Layer> content_root, | |
| 224 base::FilePath file_name) { | |
| 225 if (!IsTestCaseSupported(test_case_)) | |
| 226 return; | |
| 227 RunPixelTest(test_type_, content_root, file_name); | |
| 228 } | |
| 229 | |
| 230 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() | |
| 231 : LayerTreeHostPixelResourceTest(GetParam()) { | |
| 232 } | |
| 233 | |
| 234 } // namespace cc | |
| OLD | NEW |