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 27 matching lines...) Expand all Loading... |
38 } | 38 } |
39 | 39 |
40 NOTREACHED(); | 40 NOTREACHED(); |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest( | 46 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest( |
47 PixelResourceTestCase test_case) | 47 PixelResourceTestCase test_case) |
48 : staging_texture_target_(GL_INVALID_VALUE), | 48 : draw_texture_target_(GL_INVALID_VALUE), |
49 draw_texture_target_(GL_INVALID_VALUE), | |
50 resource_pool_option_(BITMAP_TILE_TASK_WORKER_POOL), | 49 resource_pool_option_(BITMAP_TILE_TASK_WORKER_POOL), |
51 initialized_(false), | 50 initialized_(false), |
52 test_case_(test_case) { | 51 test_case_(test_case) { |
53 InitializeFromTestCase(test_case); | 52 InitializeFromTestCase(test_case); |
54 } | 53 } |
55 | 54 |
56 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest() | 55 LayerTreeHostPixelResourceTest::LayerTreeHostPixelResourceTest() |
57 : staging_texture_target_(GL_INVALID_VALUE), | 56 : draw_texture_target_(GL_INVALID_VALUE), |
58 draw_texture_target_(GL_INVALID_VALUE), | |
59 resource_pool_option_(BITMAP_TILE_TASK_WORKER_POOL), | 57 resource_pool_option_(BITMAP_TILE_TASK_WORKER_POOL), |
60 initialized_(false), | 58 initialized_(false), |
61 test_case_(SOFTWARE) { | 59 test_case_(SOFTWARE) {} |
62 } | |
63 | 60 |
64 void LayerTreeHostPixelResourceTest::InitializeFromTestCase( | 61 void LayerTreeHostPixelResourceTest::InitializeFromTestCase( |
65 PixelResourceTestCase test_case) { | 62 PixelResourceTestCase test_case) { |
66 DCHECK(!initialized_); | 63 DCHECK(!initialized_); |
67 initialized_ = true; | 64 initialized_ = true; |
68 switch (test_case) { | 65 switch (test_case) { |
69 case SOFTWARE: | 66 case SOFTWARE: |
70 test_type_ = PIXEL_TEST_SOFTWARE; | 67 test_type_ = PIXEL_TEST_SOFTWARE; |
71 staging_texture_target_ = GL_INVALID_VALUE; | |
72 draw_texture_target_ = GL_INVALID_VALUE; | 68 draw_texture_target_ = GL_INVALID_VALUE; |
73 resource_pool_option_ = BITMAP_TILE_TASK_WORKER_POOL; | 69 resource_pool_option_ = BITMAP_TILE_TASK_WORKER_POOL; |
74 return; | 70 return; |
75 case GL_GPU_RASTER_2D_DRAW: | 71 case GL_GPU_RASTER_2D_DRAW: |
76 test_type_ = PIXEL_TEST_GL; | 72 test_type_ = PIXEL_TEST_GL; |
77 staging_texture_target_ = GL_INVALID_VALUE; | |
78 draw_texture_target_ = GL_TEXTURE_2D; | 73 draw_texture_target_ = GL_TEXTURE_2D; |
79 resource_pool_option_ = GPU_TILE_TASK_WORKER_POOL; | 74 resource_pool_option_ = GPU_TILE_TASK_WORKER_POOL; |
80 return; | 75 return; |
81 case GL_ONE_COPY_2D_STAGING_2D_DRAW: | 76 case GL_ONE_COPY_2D_STAGING_2D_DRAW: |
82 test_type_ = PIXEL_TEST_GL; | 77 test_type_ = PIXEL_TEST_GL; |
83 staging_texture_target_ = GL_TEXTURE_2D; | |
84 draw_texture_target_ = GL_TEXTURE_2D; | 78 draw_texture_target_ = GL_TEXTURE_2D; |
85 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; | 79 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; |
86 return; | 80 return; |
87 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: | 81 case GL_ONE_COPY_RECT_STAGING_2D_DRAW: |
88 test_type_ = PIXEL_TEST_GL; | 82 test_type_ = PIXEL_TEST_GL; |
89 staging_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; | |
90 draw_texture_target_ = GL_TEXTURE_2D; | 83 draw_texture_target_ = GL_TEXTURE_2D; |
91 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; | 84 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; |
92 return; | 85 return; |
93 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: | 86 case GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW: |
94 test_type_ = PIXEL_TEST_GL; | 87 test_type_ = PIXEL_TEST_GL; |
95 staging_texture_target_ = GL_TEXTURE_EXTERNAL_OES; | |
96 draw_texture_target_ = GL_TEXTURE_2D; | 88 draw_texture_target_ = GL_TEXTURE_2D; |
97 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; | 89 resource_pool_option_ = ONE_COPY_TILE_TASK_WORKER_POOL; |
98 return; | 90 return; |
99 case GL_ZERO_COPY_2D_DRAW: | 91 case GL_ZERO_COPY_2D_DRAW: |
100 test_type_ = PIXEL_TEST_GL; | 92 test_type_ = PIXEL_TEST_GL; |
101 staging_texture_target_ = GL_INVALID_VALUE; | |
102 draw_texture_target_ = GL_TEXTURE_2D; | 93 draw_texture_target_ = GL_TEXTURE_2D; |
103 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 94 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; |
104 return; | 95 return; |
105 case GL_ZERO_COPY_RECT_DRAW: | 96 case GL_ZERO_COPY_RECT_DRAW: |
106 test_type_ = PIXEL_TEST_GL; | 97 test_type_ = PIXEL_TEST_GL; |
107 staging_texture_target_ = GL_INVALID_VALUE; | |
108 draw_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; | 98 draw_texture_target_ = GL_TEXTURE_RECTANGLE_ARB; |
109 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 99 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; |
110 return; | 100 return; |
111 case GL_ZERO_COPY_EXTERNAL_DRAW: | 101 case GL_ZERO_COPY_EXTERNAL_DRAW: |
112 test_type_ = PIXEL_TEST_GL; | 102 test_type_ = PIXEL_TEST_GL; |
113 staging_texture_target_ = GL_INVALID_VALUE; | |
114 draw_texture_target_ = GL_TEXTURE_EXTERNAL_OES; | 103 draw_texture_target_ = GL_TEXTURE_EXTERNAL_OES; |
115 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; | 104 resource_pool_option_ = ZERO_COPY_TILE_TASK_WORKER_POOL; |
116 return; | 105 return; |
117 case GL_ASYNC_UPLOAD_2D_DRAW: | 106 case GL_ASYNC_UPLOAD_2D_DRAW: |
118 test_type_ = PIXEL_TEST_GL; | 107 test_type_ = PIXEL_TEST_GL; |
119 staging_texture_target_ = GL_INVALID_VALUE; | |
120 draw_texture_target_ = GL_TEXTURE_2D; | 108 draw_texture_target_ = GL_TEXTURE_2D; |
121 resource_pool_option_ = PIXEL_BUFFER_TILE_TASK_WORKER_POOL; | 109 resource_pool_option_ = PIXEL_BUFFER_TILE_TASK_WORKER_POOL; |
122 return; | 110 return; |
123 } | 111 } |
124 NOTREACHED(); | 112 NOTREACHED(); |
125 } | 113 } |
126 | 114 |
127 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( | 115 void LayerTreeHostPixelResourceTest::CreateResourceAndTileTaskWorkerPool( |
128 LayerTreeHostImpl* host_impl, | 116 LayerTreeHostImpl* host_impl, |
129 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 117 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
130 scoped_ptr<ResourcePool>* resource_pool, | 118 scoped_ptr<ResourcePool>* resource_pool) { |
131 scoped_ptr<ResourcePool>* staging_resource_pool) { | |
132 base::SingleThreadTaskRunner* task_runner = | 119 base::SingleThreadTaskRunner* task_runner = |
133 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() | 120 proxy()->HasImplThread() ? proxy()->ImplThreadTaskRunner() |
134 : proxy()->MainThreadTaskRunner(); | 121 : proxy()->MainThreadTaskRunner(); |
135 DCHECK(task_runner); | 122 DCHECK(task_runner); |
136 DCHECK(initialized_); | 123 DCHECK(initialized_); |
137 | 124 |
138 ContextProvider* context_provider = | 125 ContextProvider* context_provider = |
139 host_impl->output_surface()->context_provider(); | 126 host_impl->output_surface()->context_provider(); |
140 ResourceProvider* resource_provider = host_impl->resource_provider(); | 127 ResourceProvider* resource_provider = host_impl->resource_provider(); |
141 size_t max_transfer_buffer_usage_bytes = 1024u * 1024u * 60u; | 128 size_t max_transfer_buffer_usage_bytes = 1024u * 1024u * 60u; |
142 int max_bytes_per_copy_operation = 1024 * 1024; | 129 int max_bytes_per_copy_operation = 1024 * 1024; |
| 130 int max_staging_buffers = 32; |
143 | 131 |
144 switch (resource_pool_option_) { | 132 switch (resource_pool_option_) { |
145 case BITMAP_TILE_TASK_WORKER_POOL: | 133 case BITMAP_TILE_TASK_WORKER_POOL: |
146 EXPECT_FALSE(context_provider); | 134 EXPECT_FALSE(context_provider); |
147 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); | 135 EXPECT_EQ(PIXEL_TEST_SOFTWARE, test_type_); |
148 *resource_pool = | 136 *resource_pool = |
149 ResourcePool::Create(resource_provider, | 137 ResourcePool::Create(resource_provider, |
150 draw_texture_target_); | 138 draw_texture_target_); |
151 | 139 |
152 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( | 140 *tile_task_worker_pool = BitmapTileTaskWorkerPool::Create( |
(...skipping 17 matching lines...) Expand all Loading... |
170 *resource_pool = | 158 *resource_pool = |
171 ResourcePool::Create(resource_provider, draw_texture_target_); | 159 ResourcePool::Create(resource_provider, draw_texture_target_); |
172 | 160 |
173 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( | 161 *tile_task_worker_pool = ZeroCopyTileTaskWorkerPool::Create( |
174 task_runner, task_graph_runner(), resource_provider); | 162 task_runner, task_graph_runner(), resource_provider); |
175 break; | 163 break; |
176 case ONE_COPY_TILE_TASK_WORKER_POOL: | 164 case ONE_COPY_TILE_TASK_WORKER_POOL: |
177 EXPECT_TRUE(context_provider); | 165 EXPECT_TRUE(context_provider); |
178 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 166 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
179 EXPECT_TRUE(host_impl->GetRendererCapabilities().using_image); | 167 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_); | |
183 *resource_pool = | 168 *resource_pool = |
184 ResourcePool::Create(resource_provider, draw_texture_target_); | 169 ResourcePool::Create(resource_provider, draw_texture_target_); |
185 | 170 |
186 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( | 171 *tile_task_worker_pool = OneCopyTileTaskWorkerPool::Create( |
187 task_runner, task_graph_runner(), context_provider, resource_provider, | 172 task_runner, task_graph_runner(), context_provider, resource_provider, |
188 staging_resource_pool->get(), max_bytes_per_copy_operation, false); | 173 max_bytes_per_copy_operation, false, max_staging_buffers); |
189 break; | 174 break; |
190 case PIXEL_BUFFER_TILE_TASK_WORKER_POOL: | 175 case PIXEL_BUFFER_TILE_TASK_WORKER_POOL: |
191 EXPECT_TRUE(context_provider); | 176 EXPECT_TRUE(context_provider); |
192 EXPECT_EQ(PIXEL_TEST_GL, test_type_); | 177 EXPECT_EQ(PIXEL_TEST_GL, test_type_); |
193 *resource_pool = ResourcePool::Create( | 178 *resource_pool = ResourcePool::Create( |
194 resource_provider, draw_texture_target_); | 179 resource_provider, draw_texture_target_); |
195 | 180 |
196 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( | 181 *tile_task_worker_pool = PixelBufferTileTaskWorkerPool::Create( |
197 task_runner, task_graph_runner(), context_provider, resource_provider, | 182 task_runner, task_graph_runner(), context_provider, resource_provider, |
198 max_transfer_buffer_usage_bytes); | 183 max_transfer_buffer_usage_bytes); |
199 break; | 184 break; |
200 } | 185 } |
201 } | 186 } |
202 | 187 |
203 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( | 188 void LayerTreeHostPixelResourceTest::RunPixelResourceTest( |
204 scoped_refptr<Layer> content_root, | 189 scoped_refptr<Layer> content_root, |
205 base::FilePath file_name) { | 190 base::FilePath file_name) { |
206 if (!IsTestCaseSupported(test_case_)) | 191 if (!IsTestCaseSupported(test_case_)) |
207 return; | 192 return; |
208 RunPixelTest(test_type_, content_root, file_name); | 193 RunPixelTest(test_type_, content_root, file_name); |
209 } | 194 } |
210 | 195 |
211 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() | 196 ParameterizedPixelResourceTest::ParameterizedPixelResourceTest() |
212 : LayerTreeHostPixelResourceTest(GetParam()) { | 197 : LayerTreeHostPixelResourceTest(GetParam()) { |
213 } | 198 } |
214 | 199 |
215 } // namespace cc | 200 } // namespace cc |
OLD | NEW |