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" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 draw_texture_target_ = GL_TEXTURE_2D; | 120 draw_texture_target_ = GL_TEXTURE_2D; |
121 resource_pool_option_ = PIXEL_BUFFER_TILE_TASK_WORKER_POOL; | 121 resource_pool_option_ = PIXEL_BUFFER_TILE_TASK_WORKER_POOL; |
122 return; | 122 return; |
123 } | 123 } |
124 NOTREACHED(); | 124 NOTREACHED(); |
125 } | 125 } |
126 | 126 |
127 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( | 127 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( |
128 LayerTreeHostImpl* host_impl, | 128 LayerTreeHostImpl* host_impl, |
129 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 129 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
130 scoped_ptr<ResourcePool>* resource_pool) { | 130 scoped_ptr<ResourcePool>* resource_pool, |
| 131 scoped_ptr<ResourcePool>* staging_resource_pool) { |
131 base::SingleThreadTaskRunner* task_runner = | 132 base::SingleThreadTaskRunner* task_runner = |
132 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() | 133 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() |
133 : proxy()->MainThreadTaskRunner(); | 134 : proxy()->MainThreadTaskRunner(); |
134 DCHECK(task_runner); | 135 DCHECK(task_runner); |
135 DCHECK(initialized_); | 136 DCHECK(initialized_); |
136 | 137 |
137 ContextProvider* context_provider = | 138 ContextProvider* context_provider = |
138 host_impl->output_surface()->context_provider(); | 139 host_impl->output_surface()->context_provider(); |
139 ResourceProvider* resource_provider = host_impl->resource_provider(); | 140 ResourceProvider* resource_provider = host_impl->resource_provider(); |
140 size_t max_transfer_buffer_usage_bytes = 1024u * 1024u * 60u; | 141 size_t max_transfer_buffer_usage_bytes = 1024u * 1024u * 60u; |
141 int max_bytes_per_copy_operation = 1024 * 1024; | 142 int max_bytes_per_copy_operation = 1024 * 1024; |
142 int max_staging_buffers = 32; | |
143 | 143 |
144 switch (resource_pool_option_) { | 144 switch (resource_pool_option_) { |
145 case BITMAP_TILE_TASK_WORKER_POOL: | 145 case BITMAP_TILE_TASK_WORKER_POOL: |
146 EXPECT_FALSE(context_provider); | 146 EXPECT_FALSE(context_provider); |
147 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); | 147 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); |
148 *resource_pool = | 148 *resource_pool = |
149 ResourcePool::Create(resource_provider, | 149 ResourcePool::Create(resource_provider, |
150 draw_texture_target_); | 150 draw_texture_target_); |
151 | 151 |
152 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( | 152 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( |
(...skipping 17 matching lines...) Expand all Loading... |
170 *resource_pool = | 170 *resource_pool = |
171 ResourcePool::Create(resource_provider, draw_texture_target_); | 171 ResourcePool::Create(resource_provider, draw_texture_target_); |
172 | 172 |
173 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( | 173 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( |
174 task_runner, task_graph_runner(), resource_provider); | 174 task_runner, task_graph_runner(), resource_provider); |
175 break; | 175 break; |
176 case ONE_COPY_TILE_TASK_WORKER_POOL: | 176 case ONE_COPY_TILE_TASK_WORKER_POOL: |
177 EXPECT_TRUE(context_provider); | 177 EXPECT_TRUE(context_provider); |
178 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 178 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
179 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); | 179 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); |
| 180 // We need to create a staging resource pool when using copy rasterizer. |
| 181 *staging_resource_pool = |
| 182 ResourcePool::Create(resource_provider, staging_texture_target_); |
180 *resource_pool = | 183 *resource_pool = |
181 ResourcePool::Create(resource_provider, draw_texture_target_); | 184 ResourcePool::Create(resource_provider, draw_texture_target_); |
182 | 185 |
183 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 186 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
184 task_runner, task_graph_runner(), context_provider, resource_provider, | 187 task_runner, task_graph_runner(), context_provider, resource_provider, |
185 max_bytes_per_copy_operation, false, staging_texture_target_, | 188 staging_resource_pool->get(), max_bytes_per_copy_operation, false); |
186 max_staging_buffers); | |
187 break; | 189 break; |
188 case PIXEL_BUFFER_TILE_TASK_WORKER_POOL: | 190 case PIXEL_BUFFER_TILE_TASK_WORKER_POOL: |
189 EXPECT_TRUE(context_provider); | 191 EXPECT_TRUE(context_provider); |
190 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 192 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
191 *resource_pool = ResourcePool::Create( | 193 *resource_pool = ResourcePool::Create( |
192 resource_provider, draw_texture_target_); | 194 resource_provider, draw_texture_target_); |
193 | 195 |
194 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( | 196 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( |
195 task_runner, task_graph_runner(), context_provider, resource_provider, | 197 task_runner, task_graph_runner(), context_provider, resource_provider, |
196 max_transfer_buffer_usage_bytes); | 198 max_transfer_buffer_usage_bytes); |
197 break; | 199 break; |
198 } | 200 } |
199 } | 201 } |
200 | 202 |
201 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( | 203 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( |
202 scoped_refptr<Layer> content_root, | 204 scoped_refptr<Layer> content_root, |
203 base::FilePath file_name) { | 205 base::FilePath file_name) { |
204 if (!IsTestCaseSupported(test_case_)) | 206 if (!IsTestCaseSupported(test_case_)) |
205 return; | 207 return; |
206 RunPixelTest(test_type_, content_root, file_name); | 208 RunPixelTest(test_type_, content_root, file_name); |
207 } | 209 } |
208 | 210 |
209 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() | 211 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() |
210 : LayerTreeHostPixelResourceTest(GetParam()) { | 212 : LayerTreeHostPixelResourceTest(GetParam()) { |
211 } | 213 } |
212 | 214 |
213 } // namespace cc | 215 } // namespace cc |
OLD | NEW |