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/content_layer_client.h" | 6 #include "cc/layers/content_layer_client.h" |
7 #include "cc/layers/picture_image_layer.h" | 7 #include "cc/layers/picture_image_layer.h" |
8 #include "cc/layers/picture_layer.h" | 8 #include "cc/layers/picture_layer.h" |
9 #include "cc/layers/solid_color_layer.h" | 9 #include "cc/layers/solid_color_layer.h" |
10 #include "cc/test/layer_tree_pixel_test.h" | 10 #include "cc/test/layer_tree_pixel_test.h" |
11 #include "cc/test/pixel_comparator.h" | 11 #include "cc/test/pixel_comparator.h" |
12 | 12 |
13 #if !defined(OS_ANDROID) | 13 #if !defined(OS_ANDROID) |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 namespace { | 16 namespace { |
17 | 17 |
18 class LayerTreeHostMasksPixelTest : public LayerTreePixelTest {}; | 18 class LayerTreeHostMasksPixelTest : public LayerTreePixelTest, |
19 public ::testing::WithParamInterface< | |
20 LayerTreeSettings::TextureTargetPrefs> { | |
21 public: | |
22 void InitializeSettings(LayerTreeSettings* settings) override { | |
23 settings->texture_target_prefs = GetParam(); | |
24 LayerTreePixelTest::InitializeSettings(settings); | |
25 } | |
26 }; | |
27 | |
28 INSTANTIATE_TEST_CASE_P( | |
29 MaskTests, | |
30 LayerTreeHostMasksPixelTest, | |
31 ::testing::Values(LayerTreeSettings::FORCE_TEXTURE_2D_TARGET, | |
32 LayerTreeSettings::FORCE_TEXTURE_RECT_TARGET)); | |
reveman
2014/10/22 12:40:39
We should be testing EXTERNAL_OES target too.
| |
19 | 33 |
20 class MaskContentLayerClient : public ContentLayerClient { | 34 class MaskContentLayerClient : public ContentLayerClient { |
21 public: | 35 public: |
22 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} | 36 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} |
23 ~MaskContentLayerClient() override {} | 37 ~MaskContentLayerClient() override {} |
24 | 38 |
25 void DidChangeLayerCanUseLCDText() override {} | 39 void DidChangeLayerCanUseLCDText() override {} |
26 | 40 |
27 bool FillsBoundsCompletely() const override { return false; } | 41 bool FillsBoundsCompletely() const override { return false; } |
28 | 42 |
(...skipping 15 matching lines...) Expand all Loading... | |
44 inset_rect.width(), inset_rect.height()), | 58 inset_rect.width(), inset_rect.height()), |
45 paint); | 59 paint); |
46 inset_rect.Inset(3, 3, 2, 2); | 60 inset_rect.Inset(3, 3, 2, 2); |
47 } | 61 } |
48 } | 62 } |
49 | 63 |
50 private: | 64 private: |
51 gfx::Size bounds_; | 65 gfx::Size bounds_; |
52 }; | 66 }; |
53 | 67 |
54 TEST_F(LayerTreeHostMasksPixelTest, MaskOfLayer) { | 68 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { |
55 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 69 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
56 gfx::Rect(200, 200), SK_ColorWHITE); | 70 gfx::Rect(200, 200), SK_ColorWHITE); |
57 | 71 |
58 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 72 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
59 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 73 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
60 background->AddChild(green); | 74 background->AddChild(green); |
61 | 75 |
62 gfx::Size mask_bounds(100, 100); | 76 gfx::Size mask_bounds(100, 100); |
63 MaskContentLayerClient client(mask_bounds); | 77 MaskContentLayerClient client(mask_bounds); |
64 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 78 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
65 mask->SetBounds(mask_bounds); | 79 mask->SetBounds(mask_bounds); |
66 mask->SetIsDrawable(true); | 80 mask->SetIsDrawable(true); |
67 mask->SetIsMask(true); | 81 mask->SetIsMask(true); |
68 green->SetMaskLayer(mask.get()); | 82 green->SetMaskLayer(mask.get()); |
69 | 83 |
70 RunPixelTest(PIXEL_TEST_GL, | 84 RunPixelTest(PIXEL_TEST_GL, |
71 background, | 85 background, |
72 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); | 86 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); |
73 } | 87 } |
74 | 88 |
75 TEST_F(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { | 89 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { |
76 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 90 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
77 gfx::Rect(200, 200), SK_ColorWHITE); | 91 gfx::Rect(200, 200), SK_ColorWHITE); |
78 | 92 |
79 gfx::Size mask_bounds(100, 100); | 93 gfx::Size mask_bounds(100, 100); |
80 | 94 |
81 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 95 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); |
82 mask->SetIsDrawable(true); | 96 mask->SetIsDrawable(true); |
83 mask->SetIsMask(true); | 97 mask->SetIsMask(true); |
84 mask->SetBounds(mask_bounds); | 98 mask->SetBounds(mask_bounds); |
85 | 99 |
(...skipping 10 matching lines...) Expand all Loading... | |
96 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 110 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
97 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 111 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
98 green->SetMaskLayer(mask.get()); | 112 green->SetMaskLayer(mask.get()); |
99 background->AddChild(green); | 113 background->AddChild(green); |
100 | 114 |
101 RunPixelTest(PIXEL_TEST_GL, | 115 RunPixelTest(PIXEL_TEST_GL, |
102 background, | 116 background, |
103 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); | 117 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); |
104 } | 118 } |
105 | 119 |
106 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { | 120 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { |
107 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 121 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
108 gfx::Rect(200, 200), SK_ColorWHITE); | 122 gfx::Rect(200, 200), SK_ColorWHITE); |
109 | 123 |
110 // Clip to the top half of the green layer. | 124 // Clip to the top half of the green layer. |
111 scoped_refptr<Layer> clip = Layer::Create(); | 125 scoped_refptr<Layer> clip = Layer::Create(); |
112 clip->SetPosition(gfx::Point(0, 0)); | 126 clip->SetPosition(gfx::Point(0, 0)); |
113 clip->SetBounds(gfx::Size(200, 100)); | 127 clip->SetBounds(gfx::Size(200, 100)); |
114 clip->SetMasksToBounds(true); | 128 clip->SetMasksToBounds(true); |
115 background->AddChild(clip); | 129 background->AddChild(clip); |
116 | 130 |
117 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 131 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
118 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 132 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
119 clip->AddChild(green); | 133 clip->AddChild(green); |
120 | 134 |
121 gfx::Size mask_bounds(100, 100); | 135 gfx::Size mask_bounds(100, 100); |
122 MaskContentLayerClient client(mask_bounds); | 136 MaskContentLayerClient client(mask_bounds); |
123 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 137 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
124 mask->SetBounds(mask_bounds); | 138 mask->SetBounds(mask_bounds); |
125 mask->SetIsDrawable(true); | 139 mask->SetIsDrawable(true); |
126 mask->SetIsMask(true); | 140 mask->SetIsMask(true); |
127 green->SetMaskLayer(mask.get()); | 141 green->SetMaskLayer(mask.get()); |
128 | 142 |
129 RunPixelTest(PIXEL_TEST_GL, | 143 RunPixelTest(PIXEL_TEST_GL, |
130 background, | 144 background, |
131 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); | 145 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); |
132 } | 146 } |
133 | 147 |
134 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplica) { | 148 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) { |
135 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 149 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
136 gfx::Rect(200, 200), SK_ColorWHITE); | 150 gfx::Rect(200, 200), SK_ColorWHITE); |
137 | 151 |
138 gfx::Size mask_bounds(100, 100); | 152 gfx::Size mask_bounds(100, 100); |
139 MaskContentLayerClient client(mask_bounds); | 153 MaskContentLayerClient client(mask_bounds); |
140 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 154 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
141 mask->SetBounds(mask_bounds); | 155 mask->SetBounds(mask_bounds); |
142 mask->SetIsDrawable(true); | 156 mask->SetIsDrawable(true); |
143 mask->SetIsMask(true); | 157 mask->SetIsMask(true); |
144 | 158 |
145 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 159 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
146 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 160 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
147 background->AddChild(green); | 161 background->AddChild(green); |
148 green->SetMaskLayer(mask.get()); | 162 green->SetMaskLayer(mask.get()); |
149 | 163 |
150 gfx::Transform replica_transform; | 164 gfx::Transform replica_transform; |
151 replica_transform.Rotate(-90.0); | 165 replica_transform.Rotate(-90.0); |
152 | 166 |
153 scoped_refptr<Layer> replica = Layer::Create(); | 167 scoped_refptr<Layer> replica = Layer::Create(); |
154 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); | 168 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); |
155 replica->SetPosition(gfx::Point(100, 100)); | 169 replica->SetPosition(gfx::Point(100, 100)); |
156 replica->SetTransform(replica_transform); | 170 replica->SetTransform(replica_transform); |
157 green->SetReplicaLayer(replica.get()); | 171 green->SetReplicaLayer(replica.get()); |
158 | 172 |
159 RunPixelTest(PIXEL_TEST_GL, | 173 RunPixelTest(PIXEL_TEST_GL, |
160 background, | 174 background, |
161 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); | 175 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
162 } | 176 } |
163 | 177 |
164 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { | 178 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { |
165 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 179 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
166 gfx::Rect(200, 200), SK_ColorWHITE); | 180 gfx::Rect(200, 200), SK_ColorWHITE); |
167 | 181 |
168 gfx::Size mask_bounds(100, 100); | 182 gfx::Size mask_bounds(100, 100); |
169 MaskContentLayerClient client(mask_bounds); | 183 MaskContentLayerClient client(mask_bounds); |
170 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 184 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
171 mask->SetBounds(mask_bounds); | 185 mask->SetBounds(mask_bounds); |
172 mask->SetIsDrawable(true); | 186 mask->SetIsDrawable(true); |
173 mask->SetIsMask(true); | 187 mask->SetIsMask(true); |
174 | 188 |
(...skipping 18 matching lines...) Expand all Loading... | |
193 replica->SetPosition(gfx::Point(100, 100)); | 207 replica->SetPosition(gfx::Point(100, 100)); |
194 replica->SetTransform(replica_transform); | 208 replica->SetTransform(replica_transform); |
195 green->SetReplicaLayer(replica.get()); | 209 green->SetReplicaLayer(replica.get()); |
196 | 210 |
197 RunPixelTest(PIXEL_TEST_GL, | 211 RunPixelTest(PIXEL_TEST_GL, |
198 background, | 212 background, |
199 base::FilePath(FILE_PATH_LITERAL( | 213 base::FilePath(FILE_PATH_LITERAL( |
200 "mask_with_replica_of_clipped_layer.png"))); | 214 "mask_with_replica_of_clipped_layer.png"))); |
201 } | 215 } |
202 | 216 |
203 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplica) { | 217 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) { |
204 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 218 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
205 gfx::Rect(200, 200), SK_ColorWHITE); | 219 gfx::Rect(200, 200), SK_ColorWHITE); |
206 | 220 |
207 gfx::Size mask_bounds(100, 100); | 221 gfx::Size mask_bounds(100, 100); |
208 MaskContentLayerClient client(mask_bounds); | 222 MaskContentLayerClient client(mask_bounds); |
209 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 223 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
210 mask->SetBounds(mask_bounds); | 224 mask->SetBounds(mask_bounds); |
211 mask->SetIsDrawable(true); | 225 mask->SetIsDrawable(true); |
212 mask->SetIsMask(true); | 226 mask->SetIsMask(true); |
213 | 227 |
(...skipping 14 matching lines...) Expand all Loading... | |
228 replica->SetPosition(gfx::Point()); | 242 replica->SetPosition(gfx::Point()); |
229 replica->SetTransform(replica_transform); | 243 replica->SetTransform(replica_transform); |
230 replica->SetMaskLayer(mask.get()); | 244 replica->SetMaskLayer(mask.get()); |
231 green->SetReplicaLayer(replica.get()); | 245 green->SetReplicaLayer(replica.get()); |
232 | 246 |
233 RunPixelTest(PIXEL_TEST_GL, | 247 RunPixelTest(PIXEL_TEST_GL, |
234 background, | 248 background, |
235 base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); | 249 base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); |
236 } | 250 } |
237 | 251 |
238 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { | 252 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { |
239 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 253 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
240 gfx::Rect(200, 200), SK_ColorWHITE); | 254 gfx::Rect(200, 200), SK_ColorWHITE); |
241 | 255 |
242 gfx::Size mask_bounds(100, 100); | 256 gfx::Size mask_bounds(100, 100); |
243 MaskContentLayerClient client(mask_bounds); | 257 MaskContentLayerClient client(mask_bounds); |
244 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 258 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); |
245 mask->SetBounds(mask_bounds); | 259 mask->SetBounds(mask_bounds); |
246 mask->SetIsDrawable(true); | 260 mask->SetIsDrawable(true); |
247 mask->SetIsMask(true); | 261 mask->SetIsMask(true); |
248 | 262 |
(...skipping 26 matching lines...) Expand all Loading... | |
275 RunPixelTest(PIXEL_TEST_GL, | 289 RunPixelTest(PIXEL_TEST_GL, |
276 background, | 290 background, |
277 base::FilePath( | 291 base::FilePath( |
278 FILE_PATH_LITERAL("mask_of_replica_of_clipped_layer.png"))); | 292 FILE_PATH_LITERAL("mask_of_replica_of_clipped_layer.png"))); |
279 } | 293 } |
280 | 294 |
281 } // namespace | 295 } // namespace |
282 } // namespace cc | 296 } // namespace cc |
283 | 297 |
284 #endif // OS_ANDROID | 298 #endif // OS_ANDROID |
OLD | NEW |