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 #include "cc/test/test_in_process_context_provider.h" |
9 | 10 |
10 #if !defined(OS_ANDROID) | 11 #if !defined(OS_ANDROID) |
11 | 12 |
12 namespace cc { | 13 namespace cc { |
13 namespace { | 14 namespace { |
14 | 15 |
15 SkXfermode::Mode const kBlendModes[] = { | 16 SkXfermode::Mode const kBlendModes[] = { |
16 SkXfermode::kSrcOver_Mode, SkXfermode::kScreen_Mode, | 17 SkXfermode::kSrcOver_Mode, SkXfermode::kScreen_Mode, |
17 SkXfermode::kOverlay_Mode, SkXfermode::kDarken_Mode, | 18 SkXfermode::kOverlay_Mode, SkXfermode::kDarken_Mode, |
18 SkXfermode::kLighten_Mode, SkXfermode::kColorDodge_Mode, | 19 SkXfermode::kLighten_Mode, SkXfermode::kColorDodge_Mode, |
(...skipping 26 matching lines...) Expand all Loading... |
45 0x00000000 // transparent | 46 0x00000000 // transparent |
46 }; | 47 }; |
47 | 48 |
48 const int kBlendModesCount = arraysize(kBlendModes); | 49 const int kBlendModesCount = arraysize(kBlendModes); |
49 const int kCSSTestColorsCount = arraysize(kCSSTestColors); | 50 const int kCSSTestColorsCount = arraysize(kCSSTestColors); |
50 | 51 |
51 using RenderPassOptions = uint32; | 52 using RenderPassOptions = uint32; |
52 const uint32 kUseMasks = 1 << 0; | 53 const uint32 kUseMasks = 1 << 0; |
53 const uint32 kUseAntialiasing = 1 << 1; | 54 const uint32 kUseAntialiasing = 1 << 1; |
54 const uint32 kUseColorMatrix = 1 << 2; | 55 const uint32 kUseColorMatrix = 1 << 2; |
| 56 const uint32 kUseBlendMinMax = 1 << 3; |
| 57 |
| 58 class BlendingTestInProcessContextProvider |
| 59 : public TestInProcessContextProvider { |
| 60 public: |
| 61 BlendingTestInProcessContextProvider(bool minmax) : blend_minmax_(minmax) {} |
| 62 virtual ContextProvider::Capabilities ContextCapabilities() override { |
| 63 ContextProvider::Capabilities caps = ContextProvider::Capabilities(); |
| 64 caps.gpu.blend_minmax = blend_minmax_; |
| 65 return caps; |
| 66 } |
| 67 |
| 68 private: |
| 69 virtual ~BlendingTestInProcessContextProvider() {} |
| 70 bool blend_minmax_; |
| 71 }; |
55 | 72 |
56 class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest { | 73 class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest { |
57 public: | 74 public: |
58 LayerTreeHostBlendingPixelTest() { | 75 LayerTreeHostBlendingPixelTest() { |
59 pixel_comparator_.reset(new FuzzyPixelOffByOneComparator(true)); | 76 pixel_comparator_.reset(new FuzzyPixelOffByOneComparator(true)); |
60 } | 77 } |
61 | 78 |
| 79 virtual scoped_refptr<ContextProvider> CreteTestContextProvider() override { |
| 80 return new BlendingTestInProcessContextProvider(blend_minmax_); |
| 81 } |
| 82 |
62 virtual void InitializeSettings(LayerTreeSettings* settings) override { | 83 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
63 settings->force_antialiasing = force_antialiasing_; | 84 settings->force_antialiasing = force_antialiasing_; |
64 } | 85 } |
65 | 86 |
66 protected: | 87 protected: |
67 void RunBlendingWithRootPixelTestType(PixelTestType type) { | 88 void RunBlendingWithRootPixelTestType(PixelTestType type) { |
68 const int kLaneWidth = 15; | 89 const int kLaneWidth = 15; |
69 const int kLaneHeight = kBlendModesCount * kLaneWidth; | 90 const int kLaneHeight = kBlendModesCount * kLaneWidth; |
70 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; | 91 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; |
71 | 92 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 scoped_refptr<Layer> background = | 244 scoped_refptr<Layer> background = |
224 CreateColorfulBackdropLayer(kRootSize, kRootSize); | 245 CreateColorfulBackdropLayer(kRootSize, kRootSize); |
225 | 246 |
226 background->SetIsRootForIsolatedGroup(true); | 247 background->SetIsRootForIsolatedGroup(true); |
227 root->AddChild(background); | 248 root->AddChild(background); |
228 | 249 |
229 CreateBlendingColorLayers(kRootSize, kRootSize, background.get(), flags); | 250 CreateBlendingColorLayers(kRootSize, kRootSize, background.get(), flags); |
230 | 251 |
231 this->impl_side_painting_ = false; | 252 this->impl_side_painting_ = false; |
232 this->force_antialiasing_ = (flags & kUseAntialiasing); | 253 this->force_antialiasing_ = (flags & kUseAntialiasing); |
| 254 this->blend_minmax_ = (flags & kUseBlendMinMax); |
233 | 255 |
234 if ((flags & kUseAntialiasing) && (type == PIXEL_TEST_GL)) { | 256 if ((flags & kUseAntialiasing) && (type == PIXEL_TEST_GL)) { |
235 // Anti aliasing causes differences up to 7 pixels at the edges. | 257 // Anti aliasing causes differences up to 7 pixels at the edges. |
236 int large_error_allowed = 7; | 258 int large_error_allowed = 7; |
237 // Blending results might differ with one pixel. | 259 // Blending results might differ with one pixel. |
238 int small_error_allowed = 1; | 260 int small_error_allowed = 1; |
239 // Most of the errors are one pixel errors. | 261 // Most of the errors are one pixel errors. |
240 float percentage_pixels_small_error = 12.5f; | 262 float percentage_pixels_small_error = 12.5f; |
241 // Because of anti-aliasing, around 3% of pixels (at the edges) have | 263 // Because of anti-aliasing, around 3% of pixels (at the edges) have |
242 // bigger errors (from small_error_allowed + 1 to large_error_allowed). | 264 // bigger errors (from small_error_allowed + 1 to large_error_allowed). |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 percentage_pixels_small_error, | 299 percentage_pixels_small_error, |
278 average_error_allowed_in_bad_pixels, | 300 average_error_allowed_in_bad_pixels, |
279 large_error_allowed, | 301 large_error_allowed, |
280 small_error_allowed)); | 302 small_error_allowed)); |
281 } | 303 } |
282 | 304 |
283 RunPixelTest(type, root, base::FilePath(expected_path)); | 305 RunPixelTest(type, root, base::FilePath(expected_path)); |
284 } | 306 } |
285 | 307 |
286 bool force_antialiasing_ = false; | 308 bool force_antialiasing_ = false; |
| 309 bool blend_minmax_ = false; |
287 }; | 310 }; |
288 | 311 |
289 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) { | 312 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) { |
290 RunBlendingWithRootPixelTestType(PIXEL_TEST_GL); | 313 RunBlendingWithRootPixelTestType(PIXEL_TEST_GL); |
291 } | 314 } |
292 | 315 |
293 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_Software) { | 316 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_Software) { |
294 RunBlendingWithRootPixelTestType(PIXEL_TEST_SOFTWARE); | 317 RunBlendingWithRootPixelTestType(PIXEL_TEST_SOFTWARE); |
295 } | 318 } |
296 | 319 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 } | 453 } |
431 | 454 |
432 TEST_F(LayerTreeHostBlendingPixelTest, | 455 TEST_F(LayerTreeHostBlendingPixelTest, |
433 BlendingWithRenderPassWithMaskColorMatrixAA_Software) { | 456 BlendingWithRenderPassWithMaskColorMatrixAA_Software) { |
434 RunBlendingWithRenderPass( | 457 RunBlendingWithRenderPass( |
435 PIXEL_TEST_SOFTWARE, | 458 PIXEL_TEST_SOFTWARE, |
436 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), | 459 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
437 kUseMasks | kUseAntialiasing | kUseColorMatrix); | 460 kUseMasks | kUseAntialiasing | kUseColorMatrix); |
438 } | 461 } |
439 | 462 |
| 463 // Tests for render passes with GL_EXT_blend_minmax enabled. |
| 464 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPass_MMGL) { |
| 465 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
| 466 FILE_PATH_LITERAL("blending_render_pass.png"), |
| 467 kUseBlendMinMax); |
| 468 } |
| 469 |
| 470 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassAA_MMGL) { |
| 471 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
| 472 FILE_PATH_LITERAL("blending_render_pass.png"), |
| 473 kUseAntialiasing | kUseBlendMinMax); |
| 474 } |
| 475 |
| 476 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassWithMask_MMGL) { |
| 477 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
| 478 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
| 479 kUseMasks | kUseBlendMinMax); |
| 480 } |
| 481 |
| 482 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassWithMaskAA_MMGL) { |
| 483 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
| 484 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
| 485 kUseMasks | kUseAntialiasing | kUseBlendMinMax); |
| 486 } |
| 487 |
| 488 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRenderPassColorMatrix_MMGL) { |
| 489 RunBlendingWithRenderPass(PIXEL_TEST_GL, |
| 490 FILE_PATH_LITERAL("blending_render_pass_cm.png"), |
| 491 kUseColorMatrix | kUseBlendMinMax); |
| 492 } |
| 493 |
| 494 TEST_F(LayerTreeHostBlendingPixelTest, |
| 495 BlendingWithRenderPassColorMatrixAA_MMGL) { |
| 496 RunBlendingWithRenderPass( |
| 497 PIXEL_TEST_GL, |
| 498 FILE_PATH_LITERAL("blending_render_pass_cm.png"), |
| 499 kUseAntialiasing | kUseColorMatrix | kUseBlendMinMax); |
| 500 } |
| 501 |
| 502 TEST_F(LayerTreeHostBlendingPixelTest, |
| 503 BlendingWithRenderPassWithMaskColorMatrix_MMGL) { |
| 504 RunBlendingWithRenderPass( |
| 505 PIXEL_TEST_GL, |
| 506 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
| 507 kUseMasks | kUseColorMatrix | kUseBlendMinMax); |
| 508 } |
| 509 |
| 510 TEST_F(LayerTreeHostBlendingPixelTest, |
| 511 BlendingWithRenderPassWithMaskColorMatrixAA_MMGL) { |
| 512 RunBlendingWithRenderPass( |
| 513 PIXEL_TEST_GL, |
| 514 FILE_PATH_LITERAL("blending_render_pass_mask_cm.png"), |
| 515 kUseMasks | kUseAntialiasing | kUseColorMatrix | kUseBlendMinMax); |
| 516 } |
| 517 |
440 } // namespace | 518 } // namespace |
441 } // namespace cc | 519 } // namespace cc |
442 | 520 |
443 #endif // OS_ANDROID | 521 #endif // OS_ANDROID |
OLD | NEW |