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