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 "cc/layers/image_layer.h" | 5 #include "cc/layers/image_layer.h" |
6 #include "cc/layers/solid_color_layer.h" | 6 #include "cc/layers/solid_color_layer.h" |
7 #include "cc/test/layer_tree_pixel_test.h" | 7 #include "cc/test/layer_tree_pixel_test.h" |
8 #include "cc/test/pixel_comparator.h" | 8 #include "cc/test/pixel_comparator.h" |
9 | 9 |
10 #if !defined(OS_ANDROID) | 10 #if !defined(OS_ANDROID) |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 CreateColorfulBackdropLayer(kRootSize, kRootSize); | 224 CreateColorfulBackdropLayer(kRootSize, kRootSize); |
225 | 225 |
226 background->SetIsRootForIsolatedGroup(true); | 226 background->SetIsRootForIsolatedGroup(true); |
227 root->AddChild(background); | 227 root->AddChild(background); |
228 | 228 |
229 CreateBlendingColorLayers(kRootSize, kRootSize, background.get(), flags); | 229 CreateBlendingColorLayers(kRootSize, kRootSize, background.get(), flags); |
230 | 230 |
231 this->impl_side_painting_ = false; | 231 this->impl_side_painting_ = false; |
232 this->force_antialiasing_ = (flags & kUseAntialiasing); | 232 this->force_antialiasing_ = (flags & kUseAntialiasing); |
233 | 233 |
234 if ((flags & kUseAntialiasing) && (type == GL_WITH_BITMAP)) { | 234 if ((flags & kUseAntialiasing) && (type == PIXEL_TEST_GL)) { |
235 // Anti aliasing causes differences up to 7 pixels at the edges. | 235 // Anti aliasing causes differences up to 7 pixels at the edges. |
236 int large_error_allowed = 7; | 236 int large_error_allowed = 7; |
237 // Blending results might differ with one pixel. | 237 // Blending results might differ with one pixel. |
238 int small_error_allowed = 1; | 238 int small_error_allowed = 1; |
239 // Most of the errors are one pixel errors. | 239 // Most of the errors are one pixel errors. |
240 float percentage_pixels_small_error = 12.5f; | 240 float percentage_pixels_small_error = 12.5f; |
241 // Because of anti-aliasing, around 3% of pixels (at the edges) have | 241 // Because of anti-aliasing, around 3% of pixels (at the edges) have |
242 // bigger errors (from small_error_allowed + 1 to large_error_allowed). | 242 // bigger errors (from small_error_allowed + 1 to large_error_allowed). |
243 float percentage_pixels_error = 15.0f; | 243 float percentage_pixels_error = 15.0f; |
244 // The average error is still close to 1. | 244 // The average error is still close to 1. |
(...skipping 13 matching lines...) Expand all Loading... |
258 if (!(flags & kUseMasks)) | 258 if (!(flags & kUseMasks)) |
259 large_error_allowed = 255; | 259 large_error_allowed = 255; |
260 | 260 |
261 pixel_comparator_.reset( | 261 pixel_comparator_.reset( |
262 new FuzzyPixelComparator(false, // discard_alpha | 262 new FuzzyPixelComparator(false, // discard_alpha |
263 percentage_pixels_error, | 263 percentage_pixels_error, |
264 percentage_pixels_small_error, | 264 percentage_pixels_small_error, |
265 average_error_allowed_in_bad_pixels, | 265 average_error_allowed_in_bad_pixels, |
266 large_error_allowed, | 266 large_error_allowed, |
267 small_error_allowed)); | 267 small_error_allowed)); |
268 } else if ((flags & kUseColorMatrix) && (type == GL_WITH_BITMAP)) { | 268 } else if ((flags & kUseColorMatrix) && (type == PIXEL_TEST_GL)) { |
269 float percentage_pixels_error = 100.f; | 269 float percentage_pixels_error = 100.f; |
270 float percentage_pixels_small_error = 0.f; | 270 float percentage_pixels_small_error = 0.f; |
271 float average_error_allowed_in_bad_pixels = 1.f; | 271 float average_error_allowed_in_bad_pixels = 1.f; |
272 int large_error_allowed = 2; | 272 int large_error_allowed = 2; |
273 int small_error_allowed = 0; | 273 int small_error_allowed = 0; |
274 pixel_comparator_.reset( | 274 pixel_comparator_.reset( |
275 new FuzzyPixelComparator(false, // discard_alpha | 275 new FuzzyPixelComparator(false, // discard_alpha |
276 percentage_pixels_error, | 276 percentage_pixels_error, |
277 percentage_pixels_small_error, | 277 percentage_pixels_small_error, |
278 average_error_allowed_in_bad_pixels, | 278 average_error_allowed_in_bad_pixels, |
279 large_error_allowed, | 279 large_error_allowed, |
280 small_error_allowed)); | 280 small_error_allowed)); |
281 } | 281 } |
282 | 282 |
283 RunPixelTest(type, root, base::FilePath(expected_path)); | 283 RunPixelTest(type, root, base::FilePath(expected_path)); |
284 } | 284 } |
285 | 285 |
286 bool force_antialiasing_ = false; | 286 bool force_antialiasing_ = false; |
287 }; | 287 }; |
288 | 288 |
289 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) { | 289 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) { |
290 RunBlendingWithRootPixelTestType(GL_WITH_BITMAP); | 290 RunBlendingWithRootPixelTestType(PIXEL_TEST_GL); |
291 } | 291 } |
292 | 292 |
293 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_Software) { | 293 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_Software) { |
294 RunBlendingWithRootPixelTestType(SOFTWARE_WITH_BITMAP); | 294 RunBlendingWithRootPixelTestType(PIXEL_TEST_SOFTWARE); |
295 } | 295 } |
296 | 296 |
297 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) { | 297 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) { |
298 const int kLaneWidth = 15; | 298 const int kLaneWidth = 15; |
299 const int kLaneHeight = kBlendModesCount * kLaneWidth; | 299 const int kLaneHeight = kBlendModesCount * kLaneWidth; |
300 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; | 300 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; |
301 | 301 |
302 scoped_refptr<SolidColorLayer> background = | 302 scoped_refptr<SolidColorLayer> background = |
303 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange); | 303 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange); |
304 | 304 |
305 // Orange child layers have a background filter set and they will blend with | 305 // Orange child layers have a background filter set and they will blend with |
306 // the green background | 306 // the green background |
307 for (int i = 0; i < kBlendModesCount; ++i) { | 307 for (int i = 0; i < kBlendModesCount; ++i) { |
308 gfx::Rect child_rect( | 308 gfx::Rect child_rect( |
309 (i + 1) * kLaneWidth, kLaneWidth, kLaneWidth, kLaneHeight); | 309 (i + 1) * kLaneWidth, kLaneWidth, kLaneWidth, kLaneHeight); |
310 scoped_refptr<SolidColorLayer> green_lane = | 310 scoped_refptr<SolidColorLayer> green_lane = |
311 CreateSolidColorLayer(child_rect, kCSSGreen); | 311 CreateSolidColorLayer(child_rect, kCSSGreen); |
312 background->AddChild(green_lane); | 312 background->AddChild(green_lane); |
313 | 313 |
314 FilterOperations filters; | 314 FilterOperations filters; |
315 filters.Append(FilterOperation::CreateGrayscaleFilter(.75)); | 315 filters.Append(FilterOperation::CreateGrayscaleFilter(.75)); |
316 green_lane->SetBackgroundFilters(filters); | 316 green_lane->SetBackgroundFilters(filters); |
317 green_lane->SetBlendMode(kBlendModes[i]); | 317 green_lane->SetBlendMode(kBlendModes[i]); |
318 } | 318 } |
319 | 319 |
320 RunPixelTest(GL_WITH_BITMAP, | 320 RunPixelTest(PIXEL_TEST_GL, |
321 background, | 321 background, |
322 base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png"))); | 322 base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png"))); |
323 } | 323 } |
324 | 324 |
325 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) { | 325 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) { |
326 RunBlendingWithTransparentPixelTestType(GL_WITH_BITMAP); | 326 RunBlendingWithTransparentPixelTestType(PIXEL_TEST_GL); |
327 } | 327 } |
328 | 328 |
329 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_Software) { | 329 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_Software) { |
330 RunBlendingWithTransparentPixelTestType(SOFTWARE_WITH_BITMAP); | 330 RunBlendingWithTransparentPixelTestType(PIXEL_TEST_SOFTWARE); |
331 } | 331 } |
332 | 332 |
333 // Tests for render passes | 333 // Tests for render passes |
334 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPass_GL) { | 334 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPass_GL) { |
335 RunBlendingWithRenderPass( | 335 RunBlendingWithRenderPass( |
336 GL_WITH_BITMAP, FILE_PATH_LITERAL("blending_render_pass.png"), 0); | 336 PIXEL_TEST_GL, FILE_PATH_LITERAL("blending_render_pass.png"), 0); |
337 } | 337 } |
338 | 338 |
339 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPass_Software) { | 339 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPass_Software) { |
340 RunBlendingWithRenderPass( | 340 RunBlendingWithRenderPass( |
341 SOFTWARE_WITH_BITMAP, FILE_PATH_LITERAL("blending_render_pass.png"), 0); | 341 PIXEL_TEST_SOFTWARE, FILE_PATH_LITERAL("blending_render_pass.png"), 0); |
342 } | 342 } |
343 | 343 |
344 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassAA_GL) { | 344 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassAA_GL) { |
345 RunBlendingWithRenderPass(GL_WITH_BITMAP, | 345 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
346 FILE_PATH_LITERAL("blending_render_pass.png"), | 346 FILE_PATH_LITERAL("blending_render_pass.png"), |
347 kUseAntialiasing); | 347 kUseAntialiasing); |
348 } | 348 } |
349 | 349 |
350 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassAA_Software) { | 350 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassAA_Software) { |
351 RunBlendingWithRenderPass(SOFTWARE_WITH_BITMAP, | 351 RunBlendingWithRenderPass(PIXEL_TEST_SOFTWARE, |
352 FILE_PATH_LITERAL("blending_render_pass.png"), | 352 FILE_PATH_LITERAL("blending_render_pass.png"), |
353 kUseAntialiasing); | 353 kUseAntialiasing); |
354 } | 354 } |
355 | 355 |
356 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassWithMask_GL) { | 356 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassWithMask_GL) { |
357 RunBlendingWithRenderPass(GL_WITH_BITMAP, | 357 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
358 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 358 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
359 kUseMasks); | 359 kUseMasks); |
360 } | 360 } |
361 | 361 |
362 TEST_F(LayerTreeHostBlendingPixelTest, | 362 TEST_F(LayerTreeHostBlendingPixelTest, |
363 BlendingWithRenderPassWithMask_Software) { | 363 BlendingWithRenderPassWithMask_Software) { |
364 RunBlendingWithRenderPass(SOFTWARE_WITH_BITMAP, | 364 RunBlendingWithRenderPass(PIXEL_TEST_SOFTWARE, |
365 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 365 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
366 kUseMasks); | 366 kUseMasks); |
367 } | 367 } |
368 | 368 |
369 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassWithMaskAA_GL) { | 369 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassWithMaskAA_GL) { |
370 RunBlendingWithRenderPass(GL_WITH_BITMAP, | 370 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
371 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 371 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
372 kUseMasks | kUseAntialiasing); | 372 kUseMasks | kUseAntialiasing); |
373 } | 373 } |
374 | 374 |
375 TEST_F(LayerTreeHostBlendingPixelTest, | 375 TEST_F(LayerTreeHostBlendingPixelTest, |
376 BlendingWithRenderPassWithMaskAA_Software) { | 376 BlendingWithRenderPassWithMaskAA_Software) { |
377 RunBlendingWithRenderPass(SOFTWARE_WITH_BITMAP, | 377 RunBlendingWithRenderPass(PIXEL_TEST_SOFTWARE, |
378 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 378 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
379 kUseMasks | kUseAntialiasing); | 379 kUseMasks | kUseAntialiasing); |
380 } | 380 } |
381 | 381 |
382 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassColorMatrix_GL) { | 382 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassColorMatrix_GL) { |
383 RunBlendingWithRenderPass(GL_WITH_BITMAP, | 383 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
384 FILE_PATH_LITERAL("blending_render_pass_cm.png"), | 384 FILE_PATH_LITERAL("blending_render_pass_cm.png"), |
385 kUseColorMatrix); | 385 kUseColorMatrix); |
386 } | 386 } |
387 | 387 |
388 TEST_F(LayerTreeHostBlendingPixelTest, | 388 TEST_F(LayerTreeHostBlendingPixelTest, |
389 BlendingWithRenderPassColorMatrix_Software) { | 389 BlendingWithRenderPassColorMatrix_Software) { |
390 RunBlendingWithRenderPass(SOFTWARE_WITH_BITMAP, | 390 RunBlendingWithRenderPass(PIXEL_TEST_SOFTWARE, |
391 FILE_PATH_LITERAL("blending_render_pass_cm.png"), | 391 FILE_PATH_LITERAL("blending_render_pass_cm.png"), |
392 kUseColorMatrix); | 392 kUseColorMatrix); |
393 } | 393 } |
394 | 394 |
395 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassColorMatrixAA_GL) { | 395 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassColorMatrixAA_GL) { |
396 RunBlendingWithRenderPass(GL_WITH_BITMAP, | 396 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
397 FILE_PATH_LITERAL("blending_render_pass_cm.png"), | 397 FILE_PATH_LITERAL("blending_render_pass_cm.png"), |
398 kUseAntialiasing | kUseColorMatrix); | 398 kUseAntialiasing | kUseColorMatrix); |
399 } | 399 } |
400 | 400 |
401 TEST_F(LayerTreeHostBlendingPixelTest, | 401 TEST_F(LayerTreeHostBlendingPixelTest, |
402 BlendingWithRenderPassColorMatrixAA_Software) { | 402 BlendingWithRenderPassColorMatrixAA_Software) { |
403 RunBlendingWithRenderPass(SOFTWARE_WITH_BITMAP, | 403 RunBlendingWithRenderPass(PIXEL_TEST_SOFTWARE, |
404 FILE_PATH_LITERAL("blending_render_pass_cm.png"), | 404 FILE_PATH_LITERAL("blending_render_pass_cm.png"), |
405 kUseAntialiasing | kUseColorMatrix); | 405 kUseAntialiasing | kUseColorMatrix); |
406 } | 406 } |
407 | 407 |
408 TEST_F(LayerTreeHostBlendingPixelTest, | 408 TEST_F(LayerTreeHostBlendingPixelTest, |
409 BlendingWithRenderPassWithMaskColorMatrix_GL) { | 409 BlendingWithRenderPassWithMaskColorMatrix_GL) { |
410 RunBlendingWithRenderPass( | 410 RunBlendingWithRenderPass( |
411 GL_WITH_BITMAP, | 411 PIXEL_TEST_GL, |
412 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), | 412 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
413 kUseMasks | kUseColorMatrix); | 413 kUseMasks | kUseColorMatrix); |
414 } | 414 } |
415 | 415 |
416 TEST_F(LayerTreeHostBlendingPixelTest, | 416 TEST_F(LayerTreeHostBlendingPixelTest, |
417 BlendingWithRenderPassWithMaskColorMatrix_Software) { | 417 BlendingWithRenderPassWithMaskColorMatrix_Software) { |
418 RunBlendingWithRenderPass( | 418 RunBlendingWithRenderPass( |
419 SOFTWARE_WITH_BITMAP, | 419 PIXEL_TEST_SOFTWARE, |
420 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), | 420 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
421 kUseMasks | kUseColorMatrix); | 421 kUseMasks | kUseColorMatrix); |
422 } | 422 } |
423 | 423 |
424 TEST_F(LayerTreeHostBlendingPixelTest, | 424 TEST_F(LayerTreeHostBlendingPixelTest, |
425 BlendingWithRenderPassWithMaskColorMatrixAA_GL) { | 425 BlendingWithRenderPassWithMaskColorMatrixAA_GL) { |
426 RunBlendingWithRenderPass( | 426 RunBlendingWithRenderPass( |
427 GL_WITH_BITMAP, | 427 PIXEL_TEST_GL, |
428 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), | 428 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
429 kUseMasks | kUseAntialiasing | kUseColorMatrix); | 429 kUseMasks | kUseAntialiasing | kUseColorMatrix); |
430 } | 430 } |
431 | 431 |
432 TEST_F(LayerTreeHostBlendingPixelTest, | 432 TEST_F(LayerTreeHostBlendingPixelTest, |
433 BlendingWithRenderPassWithMaskColorMatrixAA_Software) { | 433 BlendingWithRenderPassWithMaskColorMatrixAA_Software) { |
434 RunBlendingWithRenderPass( | 434 RunBlendingWithRenderPass( |
435 SOFTWARE_WITH_BITMAP, | 435 PIXEL_TEST_SOFTWARE, |
436 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), | 436 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
437 kUseMasks | kUseAntialiasing | kUseColorMatrix); | 437 kUseMasks | kUseAntialiasing | kUseColorMatrix); |
438 } | 438 } |
439 | 439 |
440 } // namespace | 440 } // namespace |
441 } // namespace cc | 441 } // namespace cc |
442 | 442 |
443 #endif // OS_ANDROID | 443 #endif // OS_ANDROID |
OLD | NEW |