OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 #include "cc/layers/solid_color_layer.h" | 6 #include "cc/layers/solid_color_layer.h" |
7 #include "cc/layers/texture_layer.h" | 7 #include "cc/layers/texture_layer.h" |
8 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
9 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
10 #include "cc/test/fake_picture_layer.h" | 10 #include "cc/test/fake_picture_layer.h" |
11 #include "cc/test/fake_picture_layer_impl.h" | 11 #include "cc/test/fake_picture_layer_impl.h" |
12 #include "cc/test/layer_tree_pixel_test.h" | 12 #include "cc/test/layer_tree_pixel_test.h" |
13 #include "cc/test/paths.h" | 13 #include "cc/test/paths.h" |
14 #include "cc/test/solid_color_content_layer_client.h" | 14 #include "cc/test/solid_color_content_layer_client.h" |
15 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
16 | 16 |
17 #if !defined(OS_ANDROID) | 17 #if !defined(OS_ANDROID) |
18 | 18 |
19 namespace cc { | 19 namespace cc { |
20 namespace { | 20 namespace { |
21 | 21 |
22 class LayerTreeHostReadbackPixelTest : public LayerTreePixelTest { | 22 // Can't templatize a class on its own members, so ReadbackType and |
| 23 // ReadbackTestConfig are declared here, before LayerTreeHostReadbackPixelTest. |
| 24 enum ReadbackType { |
| 25 READBACK_INVALID, |
| 26 READBACK_DEFAULT, |
| 27 READBACK_BITMAP, |
| 28 }; |
| 29 |
| 30 struct ReadbackTestConfig { |
| 31 ReadbackTestConfig(LayerTreePixelTest::PixelTestType pixel_test_type_, |
| 32 ReadbackType readback_type_) |
| 33 : pixel_test_type(pixel_test_type_), readback_type(readback_type_) {} |
| 34 LayerTreePixelTest::PixelTestType pixel_test_type; |
| 35 ReadbackType readback_type; |
| 36 }; |
| 37 |
| 38 class LayerTreeHostReadbackPixelTest |
| 39 : public LayerTreePixelTest, |
| 40 public testing::WithParamInterface<ReadbackTestConfig> { |
23 protected: | 41 protected: |
24 LayerTreeHostReadbackPixelTest() | 42 LayerTreeHostReadbackPixelTest() |
25 : readback_type_(READBACK_INVALID), | 43 : readback_type_(READBACK_INVALID), |
26 insert_copy_request_after_frame_count_(0) {} | 44 insert_copy_request_after_frame_count_(0) {} |
27 | 45 |
28 enum ReadbackType { | |
29 READBACK_INVALID, | |
30 READBACK_DEFAULT, | |
31 READBACK_BITMAP, | |
32 }; | |
33 | |
34 void RunReadbackTest(PixelTestType test_type, | 46 void RunReadbackTest(PixelTestType test_type, |
35 ReadbackType readback_type, | 47 ReadbackType readback_type, |
36 scoped_refptr<Layer> content_root, | 48 scoped_refptr<Layer> content_root, |
37 base::FilePath file_name) { | 49 base::FilePath file_name) { |
38 readback_type_ = readback_type; | 50 readback_type_ = readback_type; |
39 RunPixelTest(test_type, content_root, file_name); | 51 RunPixelTest(test_type, content_root, file_name); |
40 } | 52 } |
41 | 53 |
42 void RunReadbackTestWithReadbackTarget(PixelTestType type, | 54 void RunReadbackTestWithReadbackTarget(PixelTestType type, |
43 ReadbackType readback_type, | 55 ReadbackType readback_type, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 129 } |
118 | 130 |
119 ReadbackType readback_type_; | 131 ReadbackType readback_type_; |
120 gfx::Rect copy_subrect_; | 132 gfx::Rect copy_subrect_; |
121 int insert_copy_request_after_frame_count_; | 133 int insert_copy_request_after_frame_count_; |
122 }; | 134 }; |
123 | 135 |
124 void IgnoreReadbackResult(scoped_ptr<CopyOutputResult> result) { | 136 void IgnoreReadbackResult(scoped_ptr<CopyOutputResult> result) { |
125 } | 137 } |
126 | 138 |
127 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software) { | 139 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackRootLayer) { |
128 scoped_refptr<SolidColorLayer> background = | 140 scoped_refptr<SolidColorLayer> background = |
129 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 141 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
130 | 142 |
131 scoped_refptr<SolidColorLayer> green = | |
132 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
133 background->AddChild(green); | |
134 | |
135 RunReadbackTest(PIXEL_TEST_SOFTWARE, | |
136 READBACK_DEFAULT, | |
137 background, | |
138 base::FilePath(FILE_PATH_LITERAL("green.png"))); | |
139 } | |
140 | |
141 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_Software_Bitmap) { | |
142 scoped_refptr<SolidColorLayer> background = | |
143 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
144 | |
145 scoped_refptr<SolidColorLayer> green = | |
146 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
147 background->AddChild(green); | |
148 | |
149 RunReadbackTest(PIXEL_TEST_SOFTWARE, | |
150 READBACK_BITMAP, | |
151 background, | |
152 base::FilePath(FILE_PATH_LITERAL("green.png"))); | |
153 } | |
154 | |
155 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL_Bitmap) { | |
156 scoped_refptr<SolidColorLayer> background = | |
157 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
158 | |
159 scoped_refptr<SolidColorLayer> green = | |
160 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
161 background->AddChild(green); | |
162 | |
163 RunReadbackTest(PIXEL_TEST_GL, | |
164 READBACK_BITMAP, | |
165 background, | |
166 base::FilePath(FILE_PATH_LITERAL("green.png"))); | |
167 } | |
168 | |
169 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayer_GL) { | |
170 scoped_refptr<SolidColorLayer> background = | |
171 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
172 | |
173 scoped_refptr<SolidColorLayer> green = | 143 scoped_refptr<SolidColorLayer> green = |
174 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 144 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
175 background->AddChild(green); | 145 background->AddChild(green); |
176 | 146 |
177 RunReadbackTest(PIXEL_TEST_GL, | 147 RunReadbackTest(GetParam().pixel_test_type, GetParam().readback_type, |
178 READBACK_DEFAULT, | 148 background, base::FilePath(FILE_PATH_LITERAL("green.png"))); |
179 background, | |
180 base::FilePath(FILE_PATH_LITERAL("green.png"))); | |
181 } | 149 } |
182 | 150 |
183 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_Software) { | 151 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild) { |
184 scoped_refptr<SolidColorLayer> background = | 152 scoped_refptr<SolidColorLayer> background = |
185 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 153 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
186 | 154 |
187 scoped_refptr<SolidColorLayer> green = | 155 scoped_refptr<SolidColorLayer> green = |
188 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 156 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
189 background->AddChild(green); | 157 background->AddChild(green); |
190 | 158 |
191 scoped_refptr<SolidColorLayer> blue = | 159 scoped_refptr<SolidColorLayer> blue = |
192 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 160 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
193 green->AddChild(blue); | 161 green->AddChild(blue); |
194 | 162 |
195 RunReadbackTest( | 163 RunReadbackTest( |
196 PIXEL_TEST_SOFTWARE, | 164 GetParam().pixel_test_type, GetParam().readback_type, background, |
197 READBACK_DEFAULT, | |
198 background, | |
199 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | 165 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
200 } | 166 } |
201 | 167 |
202 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL_Bitmap) { | 168 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer) { |
203 scoped_refptr<SolidColorLayer> background = | 169 scoped_refptr<SolidColorLayer> background = |
204 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 170 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
205 | 171 |
206 scoped_refptr<SolidColorLayer> green = | |
207 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
208 background->AddChild(green); | |
209 | |
210 scoped_refptr<SolidColorLayer> blue = | |
211 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
212 green->AddChild(blue); | |
213 | |
214 RunReadbackTest( | |
215 PIXEL_TEST_GL, | |
216 READBACK_BITMAP, | |
217 background, | |
218 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | |
219 } | |
220 | |
221 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackRootLayerWithChild_GL) { | |
222 scoped_refptr<SolidColorLayer> background = | |
223 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
224 | |
225 scoped_refptr<SolidColorLayer> green = | |
226 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
227 background->AddChild(green); | |
228 | |
229 scoped_refptr<SolidColorLayer> blue = | |
230 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
231 green->AddChild(blue); | |
232 | |
233 RunReadbackTest( | |
234 PIXEL_TEST_GL, | |
235 READBACK_DEFAULT, | |
236 background, | |
237 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | |
238 } | |
239 | |
240 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_Software) { | |
241 scoped_refptr<SolidColorLayer> background = | |
242 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
243 | |
244 scoped_refptr<SolidColorLayer> green = | 172 scoped_refptr<SolidColorLayer> green = |
245 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 173 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
246 background->AddChild(green); | 174 background->AddChild(green); |
247 | 175 |
248 RunReadbackTestWithReadbackTarget( | 176 RunReadbackTestWithReadbackTarget( |
249 PIXEL_TEST_SOFTWARE, | 177 GetParam().pixel_test_type, GetParam().readback_type, background, |
250 READBACK_DEFAULT, | 178 green.get(), base::FilePath(FILE_PATH_LITERAL("green.png"))); |
251 background, | 179 } |
| 180 |
| 181 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer) { |
| 182 scoped_refptr<SolidColorLayer> background = |
| 183 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 184 |
| 185 scoped_refptr<SolidColorLayer> green = |
| 186 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 187 background->AddChild(green); |
| 188 |
| 189 RunReadbackTestWithReadbackTarget( |
| 190 GetParam().pixel_test_type, GetParam().readback_type, background, |
| 191 green.get(), base::FilePath(FILE_PATH_LITERAL("green_small.png"))); |
| 192 } |
| 193 |
| 194 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild) { |
| 195 scoped_refptr<SolidColorLayer> background = |
| 196 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
| 197 |
| 198 scoped_refptr<SolidColorLayer> green = |
| 199 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); |
| 200 background->AddChild(green); |
| 201 |
| 202 scoped_refptr<SolidColorLayer> blue = |
| 203 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
| 204 green->AddChild(blue); |
| 205 |
| 206 RunReadbackTestWithReadbackTarget( |
| 207 GetParam().pixel_test_type, GetParam().readback_type, background, |
252 green.get(), | 208 green.get(), |
253 base::FilePath(FILE_PATH_LITERAL("green.png"))); | 209 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
254 } | 210 } |
255 | 211 |
256 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL_Bitmap) { | 212 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSubtreeSurroundsTargetLayer) { |
257 scoped_refptr<SolidColorLayer> background = | |
258 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
259 | |
260 scoped_refptr<SolidColorLayer> green = | |
261 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
262 background->AddChild(green); | |
263 | |
264 RunReadbackTestWithReadbackTarget( | |
265 PIXEL_TEST_GL, | |
266 READBACK_BITMAP, | |
267 background, | |
268 green.get(), | |
269 base::FilePath(FILE_PATH_LITERAL("green.png"))); | |
270 } | |
271 | |
272 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayer_GL) { | |
273 scoped_refptr<SolidColorLayer> background = | |
274 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
275 | |
276 scoped_refptr<SolidColorLayer> green = | |
277 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
278 background->AddChild(green); | |
279 | |
280 RunReadbackTestWithReadbackTarget( | |
281 PIXEL_TEST_GL, | |
282 READBACK_DEFAULT, | |
283 background, | |
284 green.get(), | |
285 base::FilePath(FILE_PATH_LITERAL("green.png"))); | |
286 } | |
287 | |
288 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_Software) { | |
289 scoped_refptr<SolidColorLayer> background = | |
290 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
291 | |
292 scoped_refptr<SolidColorLayer> green = | |
293 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | |
294 background->AddChild(green); | |
295 | |
296 RunReadbackTestWithReadbackTarget( | |
297 PIXEL_TEST_SOFTWARE, | |
298 READBACK_DEFAULT, | |
299 background, | |
300 green.get(), | |
301 base::FilePath(FILE_PATH_LITERAL("green_small.png"))); | |
302 } | |
303 | |
304 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL_Bitmap) { | |
305 scoped_refptr<SolidColorLayer> background = | |
306 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
307 | |
308 scoped_refptr<SolidColorLayer> green = | |
309 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | |
310 background->AddChild(green); | |
311 | |
312 RunReadbackTestWithReadbackTarget( | |
313 PIXEL_TEST_GL, | |
314 READBACK_BITMAP, | |
315 background, | |
316 green.get(), | |
317 base::FilePath(FILE_PATH_LITERAL("green_small.png"))); | |
318 } | |
319 | |
320 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayer_GL) { | |
321 scoped_refptr<SolidColorLayer> background = | |
322 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
323 | |
324 scoped_refptr<SolidColorLayer> green = | |
325 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | |
326 background->AddChild(green); | |
327 | |
328 RunReadbackTestWithReadbackTarget( | |
329 PIXEL_TEST_GL, | |
330 READBACK_DEFAULT, | |
331 background, | |
332 green.get(), | |
333 base::FilePath(FILE_PATH_LITERAL("green_small.png"))); | |
334 } | |
335 | |
336 TEST_F(LayerTreeHostReadbackPixelTest, | |
337 ReadbackSmallNonRootLayerWithChild_Software) { | |
338 scoped_refptr<SolidColorLayer> background = | |
339 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
340 | |
341 scoped_refptr<SolidColorLayer> green = | |
342 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | |
343 background->AddChild(green); | |
344 | |
345 scoped_refptr<SolidColorLayer> blue = | |
346 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
347 green->AddChild(blue); | |
348 | |
349 RunReadbackTestWithReadbackTarget( | |
350 PIXEL_TEST_SOFTWARE, | |
351 READBACK_DEFAULT, | |
352 background, | |
353 green.get(), | |
354 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
355 } | |
356 | |
357 TEST_F(LayerTreeHostReadbackPixelTest, | |
358 ReadbackSmallNonRootLayerWithChild_GL_Bitmap) { | |
359 scoped_refptr<SolidColorLayer> background = | |
360 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
361 | |
362 scoped_refptr<SolidColorLayer> green = | |
363 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | |
364 background->AddChild(green); | |
365 | |
366 scoped_refptr<SolidColorLayer> blue = | |
367 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
368 green->AddChild(blue); | |
369 | |
370 RunReadbackTestWithReadbackTarget( | |
371 PIXEL_TEST_GL, | |
372 READBACK_BITMAP, | |
373 background, | |
374 green.get(), | |
375 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
376 } | |
377 | |
378 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSmallNonRootLayerWithChild_GL) { | |
379 scoped_refptr<SolidColorLayer> background = | |
380 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
381 | |
382 scoped_refptr<SolidColorLayer> green = | |
383 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorGREEN); | |
384 background->AddChild(green); | |
385 | |
386 scoped_refptr<SolidColorLayer> blue = | |
387 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
388 green->AddChild(blue); | |
389 | |
390 RunReadbackTestWithReadbackTarget( | |
391 PIXEL_TEST_GL, | |
392 READBACK_DEFAULT, | |
393 background, | |
394 green.get(), | |
395 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
396 } | |
397 | |
398 TEST_F(LayerTreeHostReadbackPixelTest, | |
399 ReadbackSubtreeSurroundsTargetLayer_Software) { | |
400 scoped_refptr<SolidColorLayer> background = | 213 scoped_refptr<SolidColorLayer> background = |
401 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 214 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
402 | 215 |
403 scoped_refptr<SolidColorLayer> target = | 216 scoped_refptr<SolidColorLayer> target = |
404 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); | 217 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); |
405 background->AddChild(target); | 218 background->AddChild(target); |
406 | 219 |
407 scoped_refptr<SolidColorLayer> green = | 220 scoped_refptr<SolidColorLayer> green = |
408 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); | 221 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); |
409 target->AddChild(green); | 222 target->AddChild(green); |
410 | 223 |
411 scoped_refptr<SolidColorLayer> blue = | 224 scoped_refptr<SolidColorLayer> blue = |
412 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 225 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
413 target->AddChild(blue); | 226 target->AddChild(blue); |
414 | 227 |
415 copy_subrect_ = gfx::Rect(0, 0, 100, 100); | 228 copy_subrect_ = gfx::Rect(0, 0, 100, 100); |
416 RunReadbackTestWithReadbackTarget( | 229 RunReadbackTestWithReadbackTarget( |
417 PIXEL_TEST_SOFTWARE, | 230 GetParam().pixel_test_type, GetParam().readback_type, background, |
418 READBACK_DEFAULT, | 231 target.get(), |
419 background, | 232 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
420 target.get(), | 233 } |
421 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 234 |
422 } | 235 TEST_P(LayerTreeHostReadbackPixelTest, |
423 | 236 ReadbackSubtreeExtendsBeyondTargetLayer) { |
424 TEST_F(LayerTreeHostReadbackPixelTest, | |
425 ReadbackSubtreeSurroundsLayer_GL_Bitmap) { | |
426 scoped_refptr<SolidColorLayer> background = | |
427 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | |
428 | |
429 scoped_refptr<SolidColorLayer> target = | |
430 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); | |
431 background->AddChild(target); | |
432 | |
433 scoped_refptr<SolidColorLayer> green = | |
434 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); | |
435 target->AddChild(green); | |
436 | |
437 scoped_refptr<SolidColorLayer> blue = | |
438 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
439 target->AddChild(blue); | |
440 | |
441 copy_subrect_ = gfx::Rect(0, 0, 100, 100); | |
442 RunReadbackTestWithReadbackTarget( | |
443 PIXEL_TEST_GL, | |
444 READBACK_BITMAP, | |
445 background, | |
446 target.get(), | |
447 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
448 } | |
449 | |
450 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubtreeSurroundsTargetLayer_GL) { | |
451 scoped_refptr<SolidColorLayer> background = | |
452 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | |
453 | |
454 scoped_refptr<SolidColorLayer> target = | |
455 CreateSolidColorLayer(gfx::Rect(100, 100, 100, 100), SK_ColorRED); | |
456 background->AddChild(target); | |
457 | |
458 scoped_refptr<SolidColorLayer> green = | |
459 CreateSolidColorLayer(gfx::Rect(-100, -100, 300, 300), SK_ColorGREEN); | |
460 target->AddChild(green); | |
461 | |
462 scoped_refptr<SolidColorLayer> blue = | |
463 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
464 target->AddChild(blue); | |
465 | |
466 copy_subrect_ = gfx::Rect(0, 0, 100, 100); | |
467 RunReadbackTestWithReadbackTarget( | |
468 PIXEL_TEST_GL, | |
469 READBACK_DEFAULT, | |
470 background, | |
471 target.get(), | |
472 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
473 } | |
474 | |
475 TEST_F(LayerTreeHostReadbackPixelTest, | |
476 ReadbackSubtreeExtendsBeyondTargetLayer_Software) { | |
477 scoped_refptr<SolidColorLayer> background = | 237 scoped_refptr<SolidColorLayer> background = |
478 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 238 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
479 | 239 |
480 scoped_refptr<SolidColorLayer> target = | 240 scoped_refptr<SolidColorLayer> target = |
481 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); | 241 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); |
482 background->AddChild(target); | 242 background->AddChild(target); |
483 | 243 |
484 scoped_refptr<SolidColorLayer> green = | 244 scoped_refptr<SolidColorLayer> green = |
485 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); | 245 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); |
486 target->AddChild(green); | 246 target->AddChild(green); |
487 | 247 |
488 scoped_refptr<SolidColorLayer> blue = | 248 scoped_refptr<SolidColorLayer> blue = |
489 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 249 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
490 target->AddChild(blue); | 250 target->AddChild(blue); |
491 | 251 |
492 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 252 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
493 RunReadbackTestWithReadbackTarget( | 253 RunReadbackTestWithReadbackTarget( |
494 PIXEL_TEST_SOFTWARE, | 254 GetParam().pixel_test_type, GetParam().readback_type, background, |
495 READBACK_DEFAULT, | 255 target.get(), |
496 background, | 256 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
497 target.get(), | 257 } |
498 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 258 |
499 } | 259 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree) { |
500 | |
501 TEST_F(LayerTreeHostReadbackPixelTest, | |
502 ReadbackSubtreeExtendsBeyondTargetLayer_GL_Bitmap) { | |
503 scoped_refptr<SolidColorLayer> background = | |
504 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | |
505 | |
506 scoped_refptr<SolidColorLayer> target = | |
507 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); | |
508 background->AddChild(target); | |
509 | |
510 scoped_refptr<SolidColorLayer> green = | |
511 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); | |
512 target->AddChild(green); | |
513 | |
514 scoped_refptr<SolidColorLayer> blue = | |
515 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | |
516 target->AddChild(blue); | |
517 | |
518 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | |
519 RunReadbackTestWithReadbackTarget( | |
520 PIXEL_TEST_GL, | |
521 READBACK_BITMAP, | |
522 background, | |
523 target.get(), | |
524 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
525 } | |
526 | |
527 TEST_F(LayerTreeHostReadbackPixelTest, | |
528 ReadbackSubtreeExtendsBeyondTargetLayer_GL) { | |
529 scoped_refptr<SolidColorLayer> background = | |
530 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | |
531 | |
532 scoped_refptr<SolidColorLayer> target = | |
533 CreateSolidColorLayer(gfx::Rect(50, 50, 150, 150), SK_ColorRED); | |
534 background->AddChild(target); | |
535 | |
536 scoped_refptr<SolidColorLayer> green = | |
537 CreateSolidColorLayer(gfx::Rect(50, 50, 200, 200), SK_ColorGREEN); | |
538 target->AddChild(green); | |
539 | |
540 scoped_refptr<SolidColorLayer> blue = | |
541 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | |
542 target->AddChild(blue); | |
543 | |
544 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | |
545 RunReadbackTestWithReadbackTarget( | |
546 PIXEL_TEST_GL, | |
547 READBACK_DEFAULT, | |
548 background, | |
549 target.get(), | |
550 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
551 } | |
552 | |
553 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_Software) { | |
554 scoped_refptr<SolidColorLayer> background = | 260 scoped_refptr<SolidColorLayer> background = |
555 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 261 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
556 | 262 |
557 scoped_refptr<SolidColorLayer> hidden_target = | 263 scoped_refptr<SolidColorLayer> hidden_target = |
558 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 264 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
559 hidden_target->SetHideLayerAndSubtree(true); | 265 hidden_target->SetHideLayerAndSubtree(true); |
560 background->AddChild(hidden_target); | 266 background->AddChild(hidden_target); |
561 | 267 |
562 scoped_refptr<SolidColorLayer> blue = | 268 scoped_refptr<SolidColorLayer> blue = |
563 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 269 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
564 hidden_target->AddChild(blue); | 270 hidden_target->AddChild(blue); |
565 | 271 |
566 RunReadbackTestWithReadbackTarget( | 272 RunReadbackTestWithReadbackTarget( |
567 PIXEL_TEST_SOFTWARE, | 273 GetParam().pixel_test_type, GetParam().readback_type, background, |
568 READBACK_DEFAULT, | |
569 background, | |
570 hidden_target.get(), | 274 hidden_target.get(), |
571 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | 275 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
572 } | 276 } |
573 | 277 |
574 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL_Bitmap) { | 278 TEST_P(LayerTreeHostReadbackPixelTest, |
| 279 HiddenSubtreeNotVisibleWhenDrawnForReadback) { |
575 scoped_refptr<SolidColorLayer> background = | 280 scoped_refptr<SolidColorLayer> background = |
576 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | 281 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); |
577 | 282 |
578 scoped_refptr<SolidColorLayer> hidden_target = | 283 scoped_refptr<SolidColorLayer> hidden_target = |
579 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 284 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
580 hidden_target->SetHideLayerAndSubtree(true); | 285 hidden_target->SetHideLayerAndSubtree(true); |
581 background->AddChild(hidden_target); | 286 background->AddChild(hidden_target); |
582 | 287 |
583 scoped_refptr<SolidColorLayer> blue = | 288 scoped_refptr<SolidColorLayer> blue = |
584 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | 289 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
585 hidden_target->AddChild(blue); | 290 hidden_target->AddChild(blue); |
586 | 291 |
587 RunReadbackTestWithReadbackTarget( | |
588 PIXEL_TEST_GL, | |
589 READBACK_BITMAP, | |
590 background, | |
591 hidden_target.get(), | |
592 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | |
593 } | |
594 | |
595 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackHiddenSubtree_GL) { | |
596 scoped_refptr<SolidColorLayer> background = | |
597 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | |
598 | |
599 scoped_refptr<SolidColorLayer> hidden_target = | |
600 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
601 hidden_target->SetHideLayerAndSubtree(true); | |
602 background->AddChild(hidden_target); | |
603 | |
604 scoped_refptr<SolidColorLayer> blue = | |
605 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
606 hidden_target->AddChild(blue); | |
607 | |
608 RunReadbackTestWithReadbackTarget( | |
609 PIXEL_TEST_GL, | |
610 READBACK_DEFAULT, | |
611 background, | |
612 hidden_target.get(), | |
613 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | |
614 } | |
615 | |
616 TEST_F(LayerTreeHostReadbackPixelTest, | |
617 HiddenSubtreeNotVisibleWhenDrawnForReadback_Software) { | |
618 scoped_refptr<SolidColorLayer> background = | |
619 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | |
620 | |
621 scoped_refptr<SolidColorLayer> hidden_target = | |
622 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
623 hidden_target->SetHideLayerAndSubtree(true); | |
624 background->AddChild(hidden_target); | |
625 | |
626 scoped_refptr<SolidColorLayer> blue = | |
627 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
628 hidden_target->AddChild(blue); | |
629 | |
630 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 292 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
631 base::Bind(&IgnoreReadbackResult))); | 293 base::Bind(&IgnoreReadbackResult))); |
632 RunReadbackTest(PIXEL_TEST_SOFTWARE, | 294 RunReadbackTest(GetParam().pixel_test_type, GetParam().readback_type, |
633 READBACK_DEFAULT, | 295 background, base::FilePath(FILE_PATH_LITERAL("black.png"))); |
634 background, | 296 } |
635 base::FilePath(FILE_PATH_LITERAL("black.png"))); | 297 |
636 } | 298 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackSubrect) { |
637 | |
638 TEST_F(LayerTreeHostReadbackPixelTest, | |
639 HiddenSubtreeNotVisibleWhenDrawnForReadback_GL_Bitmap) { | |
640 scoped_refptr<SolidColorLayer> background = | |
641 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | |
642 | |
643 scoped_refptr<SolidColorLayer> hidden_target = | |
644 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
645 hidden_target->SetHideLayerAndSubtree(true); | |
646 background->AddChild(hidden_target); | |
647 | |
648 scoped_refptr<SolidColorLayer> blue = | |
649 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
650 hidden_target->AddChild(blue); | |
651 | |
652 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | |
653 base::Bind(&IgnoreReadbackResult))); | |
654 RunReadbackTest(PIXEL_TEST_GL, | |
655 READBACK_BITMAP, | |
656 background, | |
657 base::FilePath(FILE_PATH_LITERAL("black.png"))); | |
658 } | |
659 | |
660 TEST_F(LayerTreeHostReadbackPixelTest, | |
661 HiddenSubtreeNotVisibleWhenDrawnForReadback_GL) { | |
662 scoped_refptr<SolidColorLayer> background = | |
663 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorBLACK); | |
664 | |
665 scoped_refptr<SolidColorLayer> hidden_target = | |
666 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
667 hidden_target->SetHideLayerAndSubtree(true); | |
668 background->AddChild(hidden_target); | |
669 | |
670 scoped_refptr<SolidColorLayer> blue = | |
671 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
672 hidden_target->AddChild(blue); | |
673 | |
674 hidden_target->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | |
675 base::Bind(&IgnoreReadbackResult))); | |
676 RunReadbackTest(PIXEL_TEST_GL, | |
677 READBACK_DEFAULT, | |
678 background, | |
679 base::FilePath(FILE_PATH_LITERAL("black.png"))); | |
680 } | |
681 | |
682 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_Software) { | |
683 scoped_refptr<SolidColorLayer> background = | 299 scoped_refptr<SolidColorLayer> background = |
684 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 300 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
685 | 301 |
686 scoped_refptr<SolidColorLayer> green = | 302 scoped_refptr<SolidColorLayer> green = |
687 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 303 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
688 background->AddChild(green); | 304 background->AddChild(green); |
689 | 305 |
690 scoped_refptr<SolidColorLayer> blue = | 306 scoped_refptr<SolidColorLayer> blue = |
691 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | 307 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); |
692 green->AddChild(blue); | 308 green->AddChild(blue); |
693 | 309 |
694 // Grab the middle of the root layer. | 310 // Grab the middle of the root layer. |
695 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | 311 copy_subrect_ = gfx::Rect(50, 50, 100, 100); |
696 | 312 |
697 RunReadbackTest( | 313 RunReadbackTest( |
698 PIXEL_TEST_SOFTWARE, | 314 GetParam().pixel_test_type, GetParam().readback_type, background, |
699 READBACK_DEFAULT, | 315 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
700 background, | 316 } |
701 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 317 |
702 } | 318 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect) { |
703 | |
704 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL_Bitmap) { | |
705 scoped_refptr<SolidColorLayer> background = | |
706 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
707 | |
708 scoped_refptr<SolidColorLayer> green = | |
709 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
710 background->AddChild(green); | |
711 | |
712 scoped_refptr<SolidColorLayer> blue = | |
713 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | |
714 green->AddChild(blue); | |
715 | |
716 // Grab the middle of the root layer. | |
717 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | |
718 | |
719 RunReadbackTest( | |
720 PIXEL_TEST_GL, | |
721 READBACK_BITMAP, | |
722 background, | |
723 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
724 } | |
725 | |
726 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackSubrect_GL) { | |
727 scoped_refptr<SolidColorLayer> background = | |
728 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
729 | |
730 scoped_refptr<SolidColorLayer> green = | |
731 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | |
732 background->AddChild(green); | |
733 | |
734 scoped_refptr<SolidColorLayer> blue = | |
735 CreateSolidColorLayer(gfx::Rect(100, 100, 50, 50), SK_ColorBLUE); | |
736 green->AddChild(blue); | |
737 | |
738 // Grab the middle of the root layer. | |
739 copy_subrect_ = gfx::Rect(50, 50, 100, 100); | |
740 | |
741 RunReadbackTest( | |
742 PIXEL_TEST_GL, | |
743 READBACK_DEFAULT, | |
744 background, | |
745 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
746 } | |
747 | |
748 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_Software) { | |
749 scoped_refptr<SolidColorLayer> background = | 319 scoped_refptr<SolidColorLayer> background = |
750 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 320 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
751 | 321 |
752 scoped_refptr<SolidColorLayer> green = | 322 scoped_refptr<SolidColorLayer> green = |
753 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); | 323 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); |
754 background->AddChild(green); | 324 background->AddChild(green); |
755 | 325 |
756 scoped_refptr<SolidColorLayer> blue = | 326 scoped_refptr<SolidColorLayer> blue = |
757 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); | 327 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); |
758 green->AddChild(blue); | 328 green->AddChild(blue); |
759 | 329 |
760 // Grab the middle of the green layer. | 330 // Grab the middle of the green layer. |
761 copy_subrect_ = gfx::Rect(25, 25, 100, 100); | 331 copy_subrect_ = gfx::Rect(25, 25, 100, 100); |
762 | 332 |
763 RunReadbackTestWithReadbackTarget( | 333 RunReadbackTestWithReadbackTarget( |
764 PIXEL_TEST_SOFTWARE, | 334 GetParam().pixel_test_type, GetParam().readback_type, background, |
765 READBACK_DEFAULT, | |
766 background, | |
767 green.get(), | 335 green.get(), |
768 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 336 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
769 } | 337 } |
770 | 338 |
771 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL_Bitmap) { | 339 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage) { |
772 scoped_refptr<SolidColorLayer> background = | |
773 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
774 | |
775 scoped_refptr<SolidColorLayer> green = | |
776 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); | |
777 background->AddChild(green); | |
778 | |
779 scoped_refptr<SolidColorLayer> blue = | |
780 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); | |
781 green->AddChild(blue); | |
782 | |
783 // Grab the middle of the green layer. | |
784 copy_subrect_ = gfx::Rect(25, 25, 100, 100); | |
785 | |
786 RunReadbackTestWithReadbackTarget( | |
787 PIXEL_TEST_GL, | |
788 READBACK_BITMAP, | |
789 background, | |
790 green.get(), | |
791 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
792 } | |
793 | |
794 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerSubrect_GL) { | |
795 scoped_refptr<SolidColorLayer> background = | |
796 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | |
797 | |
798 scoped_refptr<SolidColorLayer> green = | |
799 CreateSolidColorLayer(gfx::Rect(25, 25, 150, 150), SK_ColorGREEN); | |
800 background->AddChild(green); | |
801 | |
802 scoped_refptr<SolidColorLayer> blue = | |
803 CreateSolidColorLayer(gfx::Rect(75, 75, 50, 50), SK_ColorBLUE); | |
804 green->AddChild(blue); | |
805 | |
806 // Grab the middle of the green layer. | |
807 copy_subrect_ = gfx::Rect(25, 25, 100, 100); | |
808 | |
809 RunReadbackTestWithReadbackTarget( | |
810 PIXEL_TEST_GL, | |
811 READBACK_DEFAULT, | |
812 background, | |
813 green.get(), | |
814 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
815 } | |
816 | |
817 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_Software) { | |
818 scoped_refptr<SolidColorLayer> background = | 340 scoped_refptr<SolidColorLayer> background = |
819 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 341 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
820 | 342 |
821 scoped_refptr<SolidColorLayer> parent = | 343 scoped_refptr<SolidColorLayer> parent = |
822 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); | 344 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); |
823 background->AddChild(parent); | 345 background->AddChild(parent); |
824 | 346 |
825 scoped_refptr<SolidColorLayer> target = | 347 scoped_refptr<SolidColorLayer> target = |
826 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); | 348 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); |
827 parent->AddChild(target); | 349 parent->AddChild(target); |
828 | 350 |
829 scoped_refptr<SolidColorLayer> blue = | 351 scoped_refptr<SolidColorLayer> blue = |
830 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 352 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
831 target->AddChild(blue); | 353 target->AddChild(blue); |
832 | 354 |
833 insert_copy_request_after_frame_count_ = 1; | 355 insert_copy_request_after_frame_count_ = 1; |
834 RunReadbackTestWithReadbackTarget( | 356 RunReadbackTestWithReadbackTarget( |
835 PIXEL_TEST_SOFTWARE, | 357 GetParam().pixel_test_type, GetParam().readback_type, background, |
836 READBACK_DEFAULT, | 358 target.get(), |
837 background, | 359 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
838 target.get(), | 360 } |
839 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 361 |
840 } | 362 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackOutsideViewportWhenNoDamage) { |
841 | |
842 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL_Bitmap) { | |
843 scoped_refptr<SolidColorLayer> background = | |
844 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | |
845 | |
846 scoped_refptr<SolidColorLayer> parent = | |
847 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); | |
848 background->AddChild(parent); | |
849 | |
850 scoped_refptr<SolidColorLayer> target = | |
851 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); | |
852 parent->AddChild(target); | |
853 | |
854 scoped_refptr<SolidColorLayer> blue = | |
855 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
856 target->AddChild(blue); | |
857 | |
858 insert_copy_request_after_frame_count_ = 1; | |
859 RunReadbackTestWithReadbackTarget( | |
860 PIXEL_TEST_GL, | |
861 READBACK_BITMAP, | |
862 background, | |
863 target.get(), | |
864 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
865 } | |
866 | |
867 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackWhenNoDamage_GL) { | |
868 scoped_refptr<SolidColorLayer> background = | |
869 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | |
870 | |
871 scoped_refptr<SolidColorLayer> parent = | |
872 CreateSolidColorLayer(gfx::Rect(0, 0, 150, 150), SK_ColorRED); | |
873 background->AddChild(parent); | |
874 | |
875 scoped_refptr<SolidColorLayer> target = | |
876 CreateSolidColorLayer(gfx::Rect(0, 0, 100, 100), SK_ColorGREEN); | |
877 parent->AddChild(target); | |
878 | |
879 scoped_refptr<SolidColorLayer> blue = | |
880 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | |
881 target->AddChild(blue); | |
882 | |
883 insert_copy_request_after_frame_count_ = 1; | |
884 RunReadbackTestWithReadbackTarget( | |
885 PIXEL_TEST_GL, | |
886 READBACK_DEFAULT, | |
887 background, | |
888 target.get(), | |
889 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
890 } | |
891 | |
892 TEST_F(LayerTreeHostReadbackPixelTest, | |
893 ReadbackOutsideViewportWhenNoDamage_Software) { | |
894 scoped_refptr<SolidColorLayer> background = | 363 scoped_refptr<SolidColorLayer> background = |
895 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 364 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); |
896 | 365 |
897 scoped_refptr<SolidColorLayer> parent = | 366 scoped_refptr<SolidColorLayer> parent = |
898 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); | 367 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); |
899 EXPECT_FALSE(parent->masks_to_bounds()); | 368 EXPECT_FALSE(parent->masks_to_bounds()); |
900 background->AddChild(parent); | 369 background->AddChild(parent); |
901 | 370 |
902 scoped_refptr<SolidColorLayer> target = | 371 scoped_refptr<SolidColorLayer> target = |
903 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); | 372 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); |
904 parent->AddChild(target); | 373 parent->AddChild(target); |
905 | 374 |
906 scoped_refptr<SolidColorLayer> blue = | 375 scoped_refptr<SolidColorLayer> blue = |
907 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 376 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); |
908 target->AddChild(blue); | 377 target->AddChild(blue); |
909 | 378 |
910 insert_copy_request_after_frame_count_ = 1; | 379 insert_copy_request_after_frame_count_ = 1; |
911 RunReadbackTestWithReadbackTarget( | 380 RunReadbackTestWithReadbackTarget( |
912 PIXEL_TEST_SOFTWARE, | 381 GetParam().pixel_test_type, GetParam().readback_type, background, |
913 READBACK_DEFAULT, | 382 target.get(), |
914 background, | 383 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
915 target.get(), | 384 } |
916 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 385 |
917 } | 386 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { |
918 | 387 scoped_refptr<SolidColorLayer> background = |
919 TEST_F(LayerTreeHostReadbackPixelTest, | 388 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); |
920 ReadbackOutsideViewportWhenNoDamage_GL_Bitmap) { | 389 |
921 scoped_refptr<SolidColorLayer> background = | 390 scoped_refptr<SolidColorLayer> green = |
922 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 391 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
923 | 392 // Only the top left quarter of the layer is inside the viewport, so the |
924 scoped_refptr<SolidColorLayer> parent = | 393 // blue layer is entirely outside. |
925 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); | 394 green->SetPosition(gfx::Point(100, 100)); |
926 EXPECT_FALSE(parent->masks_to_bounds()); | 395 background->AddChild(green); |
927 background->AddChild(parent); | 396 |
928 | 397 scoped_refptr<SolidColorLayer> blue = |
929 scoped_refptr<SolidColorLayer> target = | 398 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
930 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); | 399 green->AddChild(blue); |
931 parent->AddChild(target); | 400 |
932 | 401 RunReadbackTestWithReadbackTarget( |
933 scoped_refptr<SolidColorLayer> blue = | 402 GetParam().pixel_test_type, GetParam().readback_type, background, |
934 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 403 green.get(), |
935 target->AddChild(blue); | 404 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
936 | 405 } |
937 insert_copy_request_after_frame_count_ = 1; | 406 |
938 RunReadbackTestWithReadbackTarget( | 407 TEST_P(LayerTreeHostReadbackPixelTest, ReadbackNonRootOrFirstLayer) { |
939 PIXEL_TEST_GL, | 408 // This test has 3 render passes with the copy request on the render pass in |
940 READBACK_BITMAP, | 409 // the middle. This test caught an issue where copy requests on non-root |
941 background, | 410 // non-first render passes were being treated differently from the first |
942 target.get(), | 411 // render pass. |
943 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 412 scoped_refptr<SolidColorLayer> background = |
944 } | 413 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
945 | 414 |
946 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackOutsideViewportWhenNoDamage_GL) { | 415 scoped_refptr<SolidColorLayer> blue = |
947 scoped_refptr<SolidColorLayer> background = | 416 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); |
948 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorWHITE); | 417 blue->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
949 | 418 base::Bind(&IgnoreReadbackResult))); |
950 scoped_refptr<SolidColorLayer> parent = | 419 background->AddChild(blue); |
951 CreateSolidColorLayer(gfx::Rect(0, 0, 200, 200), SK_ColorRED); | 420 |
952 EXPECT_FALSE(parent->masks_to_bounds()); | 421 RunReadbackTestWithReadbackTarget( |
953 background->AddChild(parent); | 422 GetParam().pixel_test_type, GetParam().readback_type, background, |
954 | 423 background.get(), |
955 scoped_refptr<SolidColorLayer> target = | 424 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); |
956 CreateSolidColorLayer(gfx::Rect(250, 250, 100, 100), SK_ColorGREEN); | 425 } |
957 parent->AddChild(target); | 426 |
958 | 427 TEST_P(LayerTreeHostReadbackPixelTest, MultipleReadbacksOnLayer) { |
959 scoped_refptr<SolidColorLayer> blue = | 428 // This test has 2 copy requests on the background layer. One is added in the |
960 CreateSolidColorLayer(gfx::Rect(50, 50, 50, 50), SK_ColorBLUE); | 429 // test body, another is added in RunReadbackTestWithReadbackTarget. For every |
961 target->AddChild(blue); | 430 // copy request after the first, state must be restored via a call to |
962 | 431 // UseRenderPass (see http://crbug.com/99393). This test ensures that the |
963 insert_copy_request_after_frame_count_ = 1; | 432 // renderer correctly handles cases where UseRenderPass is called multiple |
964 RunReadbackTestWithReadbackTarget( | 433 // times for a single layer. |
965 PIXEL_TEST_GL, | 434 scoped_refptr<SolidColorLayer> background = |
966 READBACK_DEFAULT, | 435 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); |
967 background, | 436 |
968 target.get(), | 437 background->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
969 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 438 base::Bind(&IgnoreReadbackResult))); |
970 } | 439 |
| 440 RunReadbackTestWithReadbackTarget( |
| 441 GetParam().pixel_test_type, GetParam().readback_type, background, |
| 442 background.get(), base::FilePath(FILE_PATH_LITERAL("green.png"))); |
| 443 } |
| 444 |
| 445 INSTANTIATE_TEST_CASE_P( |
| 446 LayerTreeHostReadbackPixelTests, |
| 447 LayerTreeHostReadbackPixelTest, |
| 448 ::testing::Values( |
| 449 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, |
| 450 READBACK_DEFAULT), |
| 451 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, |
| 452 READBACK_DEFAULT), |
| 453 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, |
| 454 READBACK_BITMAP))); |
971 | 455 |
972 class LayerTreeHostReadbackDeviceScalePixelTest | 456 class LayerTreeHostReadbackDeviceScalePixelTest |
973 : public LayerTreeHostReadbackPixelTest { | 457 : public LayerTreeHostReadbackPixelTest { |
974 protected: | 458 protected: |
975 LayerTreeHostReadbackDeviceScalePixelTest() | 459 LayerTreeHostReadbackDeviceScalePixelTest() |
976 : device_scale_factor_(1.f), | 460 : device_scale_factor_(1.f), |
977 white_client_(SK_ColorWHITE), | 461 white_client_(SK_ColorWHITE), |
978 green_client_(SK_ColorGREEN), | 462 green_client_(SK_ColorGREEN), |
979 blue_client_(SK_ColorBLUE) {} | 463 blue_client_(SK_ColorBLUE) {} |
980 | 464 |
(...skipping 11 matching lines...) Expand all Loading... |
992 EXPECT_EQ(device_scale_factor_, | 476 EXPECT_EQ(device_scale_factor_, |
993 host_impl->active_tree()->device_scale_factor()); | 477 host_impl->active_tree()->device_scale_factor()); |
994 } | 478 } |
995 | 479 |
996 float device_scale_factor_; | 480 float device_scale_factor_; |
997 SolidColorContentLayerClient white_client_; | 481 SolidColorContentLayerClient white_client_; |
998 SolidColorContentLayerClient green_client_; | 482 SolidColorContentLayerClient green_client_; |
999 SolidColorContentLayerClient blue_client_; | 483 SolidColorContentLayerClient blue_client_; |
1000 }; | 484 }; |
1001 | 485 |
1002 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_Software) { | 486 TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect) { |
1003 scoped_refptr<FakePictureLayer> background = | 487 scoped_refptr<FakePictureLayer> background = |
1004 FakePictureLayer::Create(&white_client_); | 488 FakePictureLayer::Create(&white_client_); |
1005 background->SetBounds(gfx::Size(100, 100)); | 489 background->SetBounds(gfx::Size(100, 100)); |
1006 background->SetIsDrawable(true); | |
1007 | |
1008 scoped_refptr<FakePictureLayer> green = | |
1009 FakePictureLayer::Create(&green_client_); | |
1010 green->SetBounds(gfx::Size(100, 100)); | |
1011 green->SetIsDrawable(true); | |
1012 background->AddChild(green); | |
1013 | |
1014 scoped_refptr<FakePictureLayer> blue = | |
1015 FakePictureLayer::Create(&blue_client_); | |
1016 blue->SetPosition(gfx::Point(50, 50)); | |
1017 blue->SetBounds(gfx::Size(25, 25)); | |
1018 blue->SetIsDrawable(true); | |
1019 green->AddChild(blue); | |
1020 | |
1021 // Grab the middle of the root layer. | |
1022 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | |
1023 device_scale_factor_ = 2.f; | |
1024 RunReadbackTest( | |
1025 PIXEL_TEST_SOFTWARE, | |
1026 READBACK_DEFAULT, | |
1027 background, | |
1028 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
1029 } | |
1030 | |
1031 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackSubrect_GL) { | |
1032 scoped_refptr<FakePictureLayer> background = | |
1033 FakePictureLayer::Create(&white_client_); | |
1034 background->SetBounds(gfx::Size(100, 100)); | |
1035 background->SetIsDrawable(true); | 490 background->SetIsDrawable(true); |
1036 | 491 |
1037 scoped_refptr<FakePictureLayer> green = | 492 scoped_refptr<FakePictureLayer> green = |
1038 FakePictureLayer::Create(&green_client_); | 493 FakePictureLayer::Create(&green_client_); |
1039 green->SetBounds(gfx::Size(100, 100)); | 494 green->SetBounds(gfx::Size(100, 100)); |
1040 green->SetIsDrawable(true); | 495 green->SetIsDrawable(true); |
1041 background->AddChild(green); | 496 background->AddChild(green); |
1042 | 497 |
1043 scoped_refptr<FakePictureLayer> blue = | 498 scoped_refptr<FakePictureLayer> blue = |
1044 FakePictureLayer::Create(&blue_client_); | 499 FakePictureLayer::Create(&blue_client_); |
1045 blue->SetPosition(gfx::Point(50, 50)); | 500 blue->SetPosition(gfx::Point(50, 50)); |
1046 blue->SetBounds(gfx::Size(25, 25)); | 501 blue->SetBounds(gfx::Size(25, 25)); |
1047 blue->SetIsDrawable(true); | 502 blue->SetIsDrawable(true); |
1048 green->AddChild(blue); | 503 green->AddChild(blue); |
1049 | 504 |
1050 // Grab the middle of the root layer. | 505 // Grab the middle of the root layer. |
1051 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 506 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
1052 device_scale_factor_ = 2.f; | 507 device_scale_factor_ = 2.f; |
1053 RunReadbackTest( | 508 RunReadbackTest( |
1054 PIXEL_TEST_GL, | 509 GetParam().pixel_test_type, GetParam().readback_type, background, |
1055 READBACK_DEFAULT, | |
1056 background, | |
1057 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 510 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
1058 } | 511 } |
1059 | 512 |
1060 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 513 TEST_P(LayerTreeHostReadbackDeviceScalePixelTest, ReadbackNonRootLayerSubrect) { |
1061 ReadbackNonRootLayerSubrect_Software) { | |
1062 scoped_refptr<FakePictureLayer> background = | 514 scoped_refptr<FakePictureLayer> background = |
1063 FakePictureLayer::Create(&white_client_); | 515 FakePictureLayer::Create(&white_client_); |
1064 background->SetBounds(gfx::Size(100, 100)); | 516 background->SetBounds(gfx::Size(100, 100)); |
1065 background->SetIsDrawable(true); | |
1066 | |
1067 scoped_refptr<FakePictureLayer> green = | |
1068 FakePictureLayer::Create(&green_client_); | |
1069 green->SetPosition(gfx::Point(10, 20)); | |
1070 green->SetBounds(gfx::Size(90, 80)); | |
1071 green->SetIsDrawable(true); | |
1072 background->AddChild(green); | |
1073 | |
1074 scoped_refptr<FakePictureLayer> blue = | |
1075 FakePictureLayer::Create(&blue_client_); | |
1076 blue->SetPosition(gfx::Point(50, 50)); | |
1077 blue->SetBounds(gfx::Size(25, 25)); | |
1078 blue->SetIsDrawable(true); | |
1079 green->AddChild(blue); | |
1080 | |
1081 // Grab the green layer's content with blue in the bottom right. | |
1082 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | |
1083 device_scale_factor_ = 2.f; | |
1084 RunReadbackTestWithReadbackTarget( | |
1085 PIXEL_TEST_SOFTWARE, | |
1086 READBACK_DEFAULT, | |
1087 background, | |
1088 green.get(), | |
1089 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | |
1090 } | |
1091 | |
1092 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | |
1093 ReadbackNonRootLayerSubrect_GL) { | |
1094 scoped_refptr<FakePictureLayer> background = | |
1095 FakePictureLayer::Create(&white_client_); | |
1096 background->SetBounds(gfx::Size(100, 100)); | |
1097 background->SetIsDrawable(true); | 517 background->SetIsDrawable(true); |
1098 | 518 |
1099 scoped_refptr<FakePictureLayer> green = | 519 scoped_refptr<FakePictureLayer> green = |
1100 FakePictureLayer::Create(&green_client_); | 520 FakePictureLayer::Create(&green_client_); |
1101 green->SetPosition(gfx::Point(10, 20)); | 521 green->SetPosition(gfx::Point(10, 20)); |
1102 green->SetBounds(gfx::Size(90, 80)); | 522 green->SetBounds(gfx::Size(90, 80)); |
1103 green->SetIsDrawable(true); | 523 green->SetIsDrawable(true); |
1104 background->AddChild(green); | 524 background->AddChild(green); |
1105 | 525 |
1106 scoped_refptr<FakePictureLayer> blue = | 526 scoped_refptr<FakePictureLayer> blue = |
1107 FakePictureLayer::Create(&blue_client_); | 527 FakePictureLayer::Create(&blue_client_); |
1108 blue->SetPosition(gfx::Point(50, 50)); | 528 blue->SetPosition(gfx::Point(50, 50)); |
1109 blue->SetBounds(gfx::Size(25, 25)); | 529 blue->SetBounds(gfx::Size(25, 25)); |
1110 blue->SetIsDrawable(true); | 530 blue->SetIsDrawable(true); |
1111 green->AddChild(blue); | 531 green->AddChild(blue); |
1112 | 532 |
1113 // Grab the green layer's content with blue in the bottom right. | 533 // Grab the green layer's content with blue in the bottom right. |
1114 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 534 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
1115 device_scale_factor_ = 2.f; | 535 device_scale_factor_ = 2.f; |
1116 RunReadbackTestWithReadbackTarget( | 536 RunReadbackTestWithReadbackTarget( |
1117 PIXEL_TEST_GL, | 537 GetParam().pixel_test_type, GetParam().readback_type, background, |
1118 READBACK_DEFAULT, | |
1119 background, | |
1120 green.get(), | 538 green.get(), |
1121 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); | 539 base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png"))); |
1122 } | 540 } |
1123 | 541 |
1124 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { | 542 INSTANTIATE_TEST_CASE_P( |
1125 scoped_refptr<SolidColorLayer> background = | 543 LayerTreeHostReadbackDeviceScalePixelTests, |
1126 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorWHITE); | 544 LayerTreeHostReadbackDeviceScalePixelTest, |
1127 | 545 ::testing::Values( |
1128 scoped_refptr<SolidColorLayer> green = | 546 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_SOFTWARE, |
1129 CreateSolidColorLayer(gfx::Rect(200, 200), SK_ColorGREEN); | 547 READBACK_DEFAULT), |
1130 // Only the top left quarter of the layer is inside the viewport, so the | 548 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, |
1131 // blue layer is entirely outside. | 549 READBACK_DEFAULT), |
1132 green->SetPosition(gfx::Point(100, 100)); | 550 ReadbackTestConfig(LayerTreeHostReadbackPixelTest::PIXEL_TEST_GL, |
1133 background->AddChild(green); | 551 READBACK_BITMAP))); |
1134 | |
1135 scoped_refptr<SolidColorLayer> blue = | |
1136 CreateSolidColorLayer(gfx::Rect(150, 150, 50, 50), SK_ColorBLUE); | |
1137 green->AddChild(blue); | |
1138 | |
1139 RunReadbackTestWithReadbackTarget( | |
1140 PIXEL_TEST_GL, | |
1141 READBACK_DEFAULT, | |
1142 background, | |
1143 green.get(), | |
1144 base::FilePath(FILE_PATH_LITERAL("green_with_blue_corner.png"))); | |
1145 } | |
1146 | 552 |
1147 } // namespace | 553 } // namespace |
1148 } // namespace cc | 554 } // namespace cc |
1149 | 555 |
1150 #endif // OS_ANDROID | 556 #endif // OS_ANDROID |
OLD | NEW |