| 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/solid_color_layer.h" | 5 #include "cc/layers/solid_color_layer.h" |
| 6 #include "cc/layers/texture_layer.h" | 6 #include "cc/layers/texture_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 | 9 |
| 9 #if !defined(OS_ANDROID) | 10 #if !defined(OS_ANDROID) |
| 10 | 11 |
| 11 namespace cc { | 12 namespace cc { |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 SkXfermode::Mode const kBlendModes[] = { | 15 SkXfermode::Mode const kBlendModes[] = { |
| 15 SkXfermode::kSrcOver_Mode, SkXfermode::kScreen_Mode, | 16 SkXfermode::kSrcOver_Mode, SkXfermode::kScreen_Mode, |
| 16 SkXfermode::kOverlay_Mode, SkXfermode::kDarken_Mode, | 17 SkXfermode::kOverlay_Mode, SkXfermode::kDarken_Mode, |
| 17 SkXfermode::kLighten_Mode, SkXfermode::kColorDodge_Mode, | 18 SkXfermode::kLighten_Mode, SkXfermode::kColorDodge_Mode, |
| 18 SkXfermode::kColorBurn_Mode, SkXfermode::kHardLight_Mode, | 19 SkXfermode::kColorBurn_Mode, SkXfermode::kHardLight_Mode, |
| 19 SkXfermode::kSoftLight_Mode, SkXfermode::kDifference_Mode, | 20 SkXfermode::kSoftLight_Mode, SkXfermode::kDifference_Mode, |
| 20 SkXfermode::kExclusion_Mode, SkXfermode::kMultiply_Mode, | 21 SkXfermode::kExclusion_Mode, SkXfermode::kMultiply_Mode, |
| 21 SkXfermode::kHue_Mode, SkXfermode::kSaturation_Mode, | 22 SkXfermode::kHue_Mode, SkXfermode::kSaturation_Mode, |
| 22 SkXfermode::kColor_Mode, SkXfermode::kLuminosity_Mode}; | 23 SkXfermode::kColor_Mode, SkXfermode::kLuminosity_Mode}; |
| 23 | 24 |
| 24 const int kBlendModesCount = arraysize(kBlendModes); | 25 const int kBlendModesCount = arraysize(kBlendModes); |
| 25 | 26 |
| 26 class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest { | 27 class LayerTreeHostBlendingPixelTest : public LayerTreePixelTest { |
| 28 public: |
| 29 LayerTreeHostBlendingPixelTest() { |
| 30 pixel_comparator_.reset(new FuzzyPixelOffByOneComparator(true)); |
| 31 } |
| 32 |
| 27 protected: | 33 protected: |
| 28 void RunBlendingWithRootPixelTestType(PixelTestType type) { | 34 void RunBlendingWithRootPixelTestType(PixelTestType type) { |
| 29 const int kLaneWidth = 15; | 35 const int kLaneWidth = 15; |
| 30 const int kLaneHeight = kBlendModesCount * kLaneWidth; | 36 const int kLaneHeight = kBlendModesCount * kLaneWidth; |
| 31 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; | 37 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; |
| 32 | 38 |
| 33 scoped_refptr<SolidColorLayer> background = | 39 scoped_refptr<SolidColorLayer> background = |
| 34 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange); | 40 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange); |
| 35 | 41 |
| 36 // Orange child layers will blend with the green background | 42 // Orange child layers will blend with the green background |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 RunPixelTest(type, | 81 RunPixelTest(type, |
| 76 root, | 82 root, |
| 77 base::FilePath(FILE_PATH_LITERAL("blending_transparent.png"))); | 83 base::FilePath(FILE_PATH_LITERAL("blending_transparent.png"))); |
| 78 } | 84 } |
| 79 }; | 85 }; |
| 80 | 86 |
| 81 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) { | 87 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_GL) { |
| 82 RunBlendingWithRootPixelTestType(GL_WITH_BITMAP); | 88 RunBlendingWithRootPixelTestType(GL_WITH_BITMAP); |
| 83 } | 89 } |
| 84 | 90 |
| 91 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithRoot_Software) { |
| 92 RunBlendingWithRootPixelTestType(SOFTWARE_WITH_BITMAP); |
| 93 } |
| 94 |
| 85 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) { | 95 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithBackgroundFilter) { |
| 86 const int kLaneWidth = 15; | 96 const int kLaneWidth = 15; |
| 87 const int kLaneHeight = kBlendModesCount * kLaneWidth; | 97 const int kLaneHeight = kBlendModesCount * kLaneWidth; |
| 88 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; | 98 const int kRootSize = (kBlendModesCount + 2) * kLaneWidth; |
| 89 | 99 |
| 90 scoped_refptr<SolidColorLayer> background = | 100 scoped_refptr<SolidColorLayer> background = |
| 91 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange); | 101 CreateSolidColorLayer(gfx::Rect(kRootSize, kRootSize), kCSSOrange); |
| 92 | 102 |
| 93 // Orange child layers have a background filter set and they will blend with | 103 // Orange child layers have a background filter set and they will blend with |
| 94 // the green background | 104 // the green background |
| (...skipping 12 matching lines...) Expand all Loading... |
| 107 | 117 |
| 108 RunPixelTest(GL_WITH_BITMAP, | 118 RunPixelTest(GL_WITH_BITMAP, |
| 109 background, | 119 background, |
| 110 base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png"))); | 120 base::FilePath(FILE_PATH_LITERAL("blending_and_filter.png"))); |
| 111 } | 121 } |
| 112 | 122 |
| 113 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) { | 123 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_GL) { |
| 114 RunBlendingWithTransparentPixelTestType(GL_WITH_BITMAP); | 124 RunBlendingWithTransparentPixelTestType(GL_WITH_BITMAP); |
| 115 } | 125 } |
| 116 | 126 |
| 127 TEST_F(LayerTreeHostBlendingPixelTest, BlendingWithTransparent_Software) { |
| 128 RunBlendingWithTransparentPixelTestType(SOFTWARE_WITH_BITMAP); |
| 129 } |
| 130 |
| 117 } // namespace | 131 } // namespace |
| 118 } // namespace cc | 132 } // namespace cc |
| 119 | 133 |
| 120 #endif // OS_ANDROID | 134 #endif // OS_ANDROID |
| OLD | NEW |