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_resource_test.h" | 10 #include "cc/test/layer_tree_pixel_resource_test.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { | 60 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { |
61 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 61 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
62 gfx::Rect(100, 100), SK_ColorWHITE); | 62 gfx::Rect(100, 100), SK_ColorWHITE); |
63 | 63 |
64 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 64 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
65 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 65 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
66 background->AddChild(green); | 66 background->AddChild(green); |
67 | 67 |
68 gfx::Size mask_bounds(50, 50); | 68 gfx::Size mask_bounds(50, 50); |
69 MaskContentLayerClient client(mask_bounds); | 69 MaskContentLayerClient client(mask_bounds); |
70 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 70 scoped_refptr<PictureLayer> mask = |
| 71 PictureLayer::Create(layer_settings(), &client); |
71 mask->SetBounds(mask_bounds); | 72 mask->SetBounds(mask_bounds); |
72 mask->SetIsDrawable(true); | 73 mask->SetIsDrawable(true); |
73 mask->SetIsMask(true); | 74 mask->SetIsMask(true); |
74 green->SetMaskLayer(mask.get()); | 75 green->SetMaskLayer(mask.get()); |
75 | 76 |
76 RunPixelResourceTest(background, | 77 RunPixelResourceTest(background, |
77 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); | 78 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); |
78 } | 79 } |
79 | 80 |
80 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { | 81 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { |
81 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 82 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
82 gfx::Rect(100, 100), SK_ColorWHITE); | 83 gfx::Rect(100, 100), SK_ColorWHITE); |
83 | 84 |
84 gfx::Size mask_bounds(50, 50); | 85 gfx::Size mask_bounds(50, 50); |
85 | 86 |
86 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 87 scoped_refptr<PictureImageLayer> mask = |
| 88 PictureImageLayer::Create(layer_settings()); |
87 mask->SetIsDrawable(true); | 89 mask->SetIsDrawable(true); |
88 mask->SetIsMask(true); | 90 mask->SetIsMask(true); |
89 mask->SetBounds(mask_bounds); | 91 mask->SetBounds(mask_bounds); |
90 | 92 |
91 SkBitmap bitmap; | 93 SkBitmap bitmap; |
92 bitmap.allocN32Pixels(200, 200); | 94 bitmap.allocN32Pixels(200, 200); |
93 SkCanvas canvas(bitmap); | 95 SkCanvas canvas(bitmap); |
94 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); | 96 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); |
95 MaskContentLayerClient client(mask_bounds); | 97 MaskContentLayerClient client(mask_bounds); |
96 client.PaintContents(&canvas, gfx::Rect(mask_bounds), | 98 client.PaintContents(&canvas, gfx::Rect(mask_bounds), |
97 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 99 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
98 mask->SetBitmap(bitmap); | 100 mask->SetBitmap(bitmap); |
99 | 101 |
100 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 102 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
101 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 103 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
102 green->SetMaskLayer(mask.get()); | 104 green->SetMaskLayer(mask.get()); |
103 background->AddChild(green); | 105 background->AddChild(green); |
104 | 106 |
105 RunPixelResourceTest( | 107 RunPixelResourceTest( |
106 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); | 108 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); |
107 } | 109 } |
108 | 110 |
109 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { | 111 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { |
110 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 112 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
111 gfx::Rect(100, 100), SK_ColorWHITE); | 113 gfx::Rect(100, 100), SK_ColorWHITE); |
112 | 114 |
113 // Clip to the top half of the green layer. | 115 // Clip to the top half of the green layer. |
114 scoped_refptr<Layer> clip = Layer::Create(); | 116 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); |
115 clip->SetPosition(gfx::Point(0, 0)); | 117 clip->SetPosition(gfx::Point(0, 0)); |
116 clip->SetBounds(gfx::Size(100, 50)); | 118 clip->SetBounds(gfx::Size(100, 50)); |
117 clip->SetMasksToBounds(true); | 119 clip->SetMasksToBounds(true); |
118 background->AddChild(clip); | 120 background->AddChild(clip); |
119 | 121 |
120 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 122 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
121 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 123 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
122 clip->AddChild(green); | 124 clip->AddChild(green); |
123 | 125 |
124 gfx::Size mask_bounds(50, 50); | 126 gfx::Size mask_bounds(50, 50); |
125 MaskContentLayerClient client(mask_bounds); | 127 MaskContentLayerClient client(mask_bounds); |
126 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 128 scoped_refptr<PictureLayer> mask = |
| 129 PictureLayer::Create(layer_settings(), &client); |
127 mask->SetBounds(mask_bounds); | 130 mask->SetBounds(mask_bounds); |
128 mask->SetIsDrawable(true); | 131 mask->SetIsDrawable(true); |
129 mask->SetIsMask(true); | 132 mask->SetIsMask(true); |
130 green->SetMaskLayer(mask.get()); | 133 green->SetMaskLayer(mask.get()); |
131 | 134 |
132 RunPixelResourceTest( | 135 RunPixelResourceTest( |
133 background, | 136 background, |
134 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); | 137 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); |
135 } | 138 } |
136 | 139 |
137 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) { | 140 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) { |
138 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 141 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
139 gfx::Rect(100, 100), SK_ColorWHITE); | 142 gfx::Rect(100, 100), SK_ColorWHITE); |
140 | 143 |
141 gfx::Size mask_bounds(50, 50); | 144 gfx::Size mask_bounds(50, 50); |
142 MaskContentLayerClient client(mask_bounds); | 145 MaskContentLayerClient client(mask_bounds); |
143 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 146 scoped_refptr<PictureLayer> mask = |
| 147 PictureLayer::Create(layer_settings(), &client); |
144 mask->SetBounds(mask_bounds); | 148 mask->SetBounds(mask_bounds); |
145 mask->SetIsDrawable(true); | 149 mask->SetIsDrawable(true); |
146 mask->SetIsMask(true); | 150 mask->SetIsMask(true); |
147 | 151 |
148 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 152 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
149 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 153 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
150 background->AddChild(green); | 154 background->AddChild(green); |
151 green->SetMaskLayer(mask.get()); | 155 green->SetMaskLayer(mask.get()); |
152 | 156 |
153 gfx::Transform replica_transform; | 157 gfx::Transform replica_transform; |
154 replica_transform.Rotate(-90.0); | 158 replica_transform.Rotate(-90.0); |
155 | 159 |
156 scoped_refptr<Layer> replica = Layer::Create(); | 160 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); |
157 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); | 161 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); |
158 replica->SetPosition(gfx::Point(50, 50)); | 162 replica->SetPosition(gfx::Point(50, 50)); |
159 replica->SetTransform(replica_transform); | 163 replica->SetTransform(replica_transform); |
160 green->SetReplicaLayer(replica.get()); | 164 green->SetReplicaLayer(replica.get()); |
161 | 165 |
162 RunPixelResourceTest( | 166 RunPixelResourceTest( |
163 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); | 167 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); |
164 } | 168 } |
165 | 169 |
166 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { | 170 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { |
167 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 171 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
168 gfx::Rect(100, 100), SK_ColorWHITE); | 172 gfx::Rect(100, 100), SK_ColorWHITE); |
169 | 173 |
170 gfx::Size mask_bounds(50, 50); | 174 gfx::Size mask_bounds(50, 50); |
171 MaskContentLayerClient client(mask_bounds); | 175 MaskContentLayerClient client(mask_bounds); |
172 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 176 scoped_refptr<PictureLayer> mask = |
| 177 PictureLayer::Create(layer_settings(), &client); |
173 mask->SetBounds(mask_bounds); | 178 mask->SetBounds(mask_bounds); |
174 mask->SetIsDrawable(true); | 179 mask->SetIsDrawable(true); |
175 mask->SetIsMask(true); | 180 mask->SetIsMask(true); |
176 | 181 |
177 // Clip to the bottom half of the green layer, and the left half of the | 182 // Clip to the bottom half of the green layer, and the left half of the |
178 // replica. | 183 // replica. |
179 scoped_refptr<Layer> clip = Layer::Create(); | 184 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); |
180 clip->SetPosition(gfx::Point(0, 25)); | 185 clip->SetPosition(gfx::Point(0, 25)); |
181 clip->SetBounds(gfx::Size(75, 75)); | 186 clip->SetBounds(gfx::Size(75, 75)); |
182 clip->SetMasksToBounds(true); | 187 clip->SetMasksToBounds(true); |
183 background->AddChild(clip); | 188 background->AddChild(clip); |
184 | 189 |
185 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 190 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
186 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 191 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
187 clip->AddChild(green); | 192 clip->AddChild(green); |
188 green->SetMaskLayer(mask.get()); | 193 green->SetMaskLayer(mask.get()); |
189 | 194 |
190 gfx::Transform replica_transform; | 195 gfx::Transform replica_transform; |
191 replica_transform.Rotate(-90.0); | 196 replica_transform.Rotate(-90.0); |
192 | 197 |
193 scoped_refptr<Layer> replica = Layer::Create(); | 198 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); |
194 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); | 199 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); |
195 replica->SetPosition(gfx::Point(50, 50)); | 200 replica->SetPosition(gfx::Point(50, 50)); |
196 replica->SetTransform(replica_transform); | 201 replica->SetTransform(replica_transform); |
197 green->SetReplicaLayer(replica.get()); | 202 green->SetReplicaLayer(replica.get()); |
198 | 203 |
199 RunPixelResourceTest(background, | 204 RunPixelResourceTest(background, |
200 base::FilePath(FILE_PATH_LITERAL( | 205 base::FilePath(FILE_PATH_LITERAL( |
201 "mask_with_replica_of_clipped_layer.png"))); | 206 "mask_with_replica_of_clipped_layer.png"))); |
202 } | 207 } |
203 | 208 |
204 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) { | 209 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) { |
205 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 210 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
206 gfx::Rect(100, 100), SK_ColorWHITE); | 211 gfx::Rect(100, 100), SK_ColorWHITE); |
207 | 212 |
208 gfx::Size mask_bounds(50, 50); | 213 gfx::Size mask_bounds(50, 50); |
209 MaskContentLayerClient client(mask_bounds); | 214 MaskContentLayerClient client(mask_bounds); |
210 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 215 scoped_refptr<PictureLayer> mask = |
| 216 PictureLayer::Create(layer_settings(), &client); |
211 mask->SetBounds(mask_bounds); | 217 mask->SetBounds(mask_bounds); |
212 mask->SetIsDrawable(true); | 218 mask->SetIsDrawable(true); |
213 mask->SetIsMask(true); | 219 mask->SetIsMask(true); |
214 | 220 |
215 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 221 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
216 gfx::Rect(25, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 222 gfx::Rect(25, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
217 background->AddChild(green); | 223 background->AddChild(green); |
218 | 224 |
219 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( | 225 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( |
220 gfx::Rect(-25, 25, 25, 25), kCSSOrange); | 226 gfx::Rect(-25, 25, 25, 25), kCSSOrange); |
221 green->AddChild(orange); | 227 green->AddChild(orange); |
222 | 228 |
223 gfx::Transform replica_transform; | 229 gfx::Transform replica_transform; |
224 replica_transform.Rotate(180.0); | 230 replica_transform.Rotate(180.0); |
225 replica_transform.Translate(50.0, 0.0); | 231 replica_transform.Translate(50.0, 0.0); |
226 | 232 |
227 scoped_refptr<Layer> replica = Layer::Create(); | 233 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); |
228 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); | 234 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); |
229 replica->SetPosition(gfx::Point()); | 235 replica->SetPosition(gfx::Point()); |
230 replica->SetTransform(replica_transform); | 236 replica->SetTransform(replica_transform); |
231 replica->SetMaskLayer(mask.get()); | 237 replica->SetMaskLayer(mask.get()); |
232 green->SetReplicaLayer(replica.get()); | 238 green->SetReplicaLayer(replica.get()); |
233 | 239 |
234 RunPixelResourceTest( | 240 RunPixelResourceTest( |
235 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); | 241 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); |
236 } | 242 } |
237 | 243 |
238 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { | 244 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { |
239 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 245 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
240 gfx::Rect(100, 100), SK_ColorWHITE); | 246 gfx::Rect(100, 100), SK_ColorWHITE); |
241 | 247 |
242 gfx::Size mask_bounds(50, 50); | 248 gfx::Size mask_bounds(50, 50); |
243 MaskContentLayerClient client(mask_bounds); | 249 MaskContentLayerClient client(mask_bounds); |
244 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); | 250 scoped_refptr<PictureLayer> mask = |
| 251 PictureLayer::Create(layer_settings(), &client); |
245 mask->SetBounds(mask_bounds); | 252 mask->SetBounds(mask_bounds); |
246 mask->SetIsDrawable(true); | 253 mask->SetIsDrawable(true); |
247 mask->SetIsMask(true); | 254 mask->SetIsMask(true); |
248 | 255 |
249 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. | 256 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. |
250 scoped_refptr<Layer> clip = Layer::Create(); | 257 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); |
251 clip->SetPosition(gfx::Point(0, 12)); | 258 clip->SetPosition(gfx::Point(0, 12)); |
252 clip->SetBounds(gfx::Size(100, 75)); | 259 clip->SetBounds(gfx::Size(100, 75)); |
253 clip->SetMasksToBounds(true); | 260 clip->SetMasksToBounds(true); |
254 background->AddChild(clip); | 261 background->AddChild(clip); |
255 | 262 |
256 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 263 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
257 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 264 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
258 clip->AddChild(green); | 265 clip->AddChild(green); |
259 | 266 |
260 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( | 267 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( |
261 gfx::Rect(-25, 25, 25, 25), kCSSOrange); | 268 gfx::Rect(-25, 25, 25, 25), kCSSOrange); |
262 green->AddChild(orange); | 269 green->AddChild(orange); |
263 | 270 |
264 gfx::Transform replica_transform; | 271 gfx::Transform replica_transform; |
265 replica_transform.Rotate(180.0); | 272 replica_transform.Rotate(180.0); |
266 replica_transform.Translate(50.0, 0.0); | 273 replica_transform.Translate(50.0, 0.0); |
267 | 274 |
268 scoped_refptr<Layer> replica = Layer::Create(); | 275 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); |
269 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); | 276 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); |
270 replica->SetPosition(gfx::Point()); | 277 replica->SetPosition(gfx::Point()); |
271 replica->SetTransform(replica_transform); | 278 replica->SetTransform(replica_transform); |
272 replica->SetMaskLayer(mask.get()); | 279 replica->SetMaskLayer(mask.get()); |
273 green->SetReplicaLayer(replica.get()); | 280 green->SetReplicaLayer(replica.get()); |
274 | 281 |
275 RunPixelResourceTest(background, | 282 RunPixelResourceTest(background, |
276 base::FilePath(FILE_PATH_LITERAL( | 283 base::FilePath(FILE_PATH_LITERAL( |
277 "mask_of_replica_of_clipped_layer.png"))); | 284 "mask_of_replica_of_clipped_layer.png"))); |
278 } | 285 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 GL_ZERO_COPY_EXTERNAL_DRAW, | 369 GL_ZERO_COPY_EXTERNAL_DRAW, |
363 GL_ASYNC_UPLOAD_2D_DRAW)); | 370 GL_ASYNC_UPLOAD_2D_DRAW)); |
364 | 371 |
365 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, | 372 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, |
366 MaskOfLayerWithBackgroundFilter) { | 373 MaskOfLayerWithBackgroundFilter) { |
367 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 374 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
368 gfx::Rect(100, 100), SK_ColorWHITE); | 375 gfx::Rect(100, 100), SK_ColorWHITE); |
369 | 376 |
370 gfx::Size picture_bounds(100, 100); | 377 gfx::Size picture_bounds(100, 100); |
371 CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true); | 378 CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true); |
372 scoped_refptr<PictureLayer> picture = PictureLayer::Create(&picture_client); | 379 scoped_refptr<PictureLayer> picture = |
| 380 PictureLayer::Create(layer_settings(), &picture_client); |
373 picture->SetBounds(picture_bounds); | 381 picture->SetBounds(picture_bounds); |
374 picture->SetIsDrawable(true); | 382 picture->SetIsDrawable(true); |
375 | 383 |
376 scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer( | 384 scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer( |
377 gfx::Rect(100, 100), SK_ColorTRANSPARENT); | 385 gfx::Rect(100, 100), SK_ColorTRANSPARENT); |
378 background->AddChild(picture); | 386 background->AddChild(picture); |
379 background->AddChild(blur); | 387 background->AddChild(blur); |
380 | 388 |
381 FilterOperations filters; | 389 FilterOperations filters; |
382 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); | 390 filters.Append(FilterOperation::CreateBlurFilter(1.5f)); |
383 blur->SetBackgroundFilters(filters); | 391 blur->SetBackgroundFilters(filters); |
384 | 392 |
385 gfx::Size mask_bounds(100, 100); | 393 gfx::Size mask_bounds(100, 100); |
386 CircleContentLayerClient mask_client(mask_bounds); | 394 CircleContentLayerClient mask_client(mask_bounds); |
387 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); | 395 scoped_refptr<PictureLayer> mask = |
| 396 PictureLayer::Create(layer_settings(), &mask_client); |
388 mask->SetBounds(mask_bounds); | 397 mask->SetBounds(mask_bounds); |
389 mask->SetIsDrawable(true); | 398 mask->SetIsDrawable(true); |
390 mask->SetIsMask(true); | 399 mask->SetIsMask(true); |
391 blur->SetMaskLayer(mask.get()); | 400 blur->SetMaskLayer(mask.get()); |
392 | 401 |
393 float percentage_pixels_large_error = 2.5f; // 2.5%, ~250px / (100*100) | 402 float percentage_pixels_large_error = 2.5f; // 2.5%, ~250px / (100*100) |
394 float percentage_pixels_small_error = 0.0f; | 403 float percentage_pixels_small_error = 0.0f; |
395 float average_error_allowed_in_bad_pixels = 100.0f; | 404 float average_error_allowed_in_bad_pixels = 100.0f; |
396 int large_error_allowed = 256; | 405 int large_error_allowed = 256; |
397 int small_error_allowed = 0; | 406 int small_error_allowed = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
410 | 419 |
411 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, | 420 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, |
412 MaskOfLayerWithBlend) { | 421 MaskOfLayerWithBlend) { |
413 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 422 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
414 gfx::Rect(128, 128), SK_ColorWHITE); | 423 gfx::Rect(128, 128), SK_ColorWHITE); |
415 | 424 |
416 gfx::Size picture_bounds(128, 128); | 425 gfx::Size picture_bounds(128, 128); |
417 CheckerContentLayerClient picture_client_vertical( | 426 CheckerContentLayerClient picture_client_vertical( |
418 picture_bounds, SK_ColorGREEN, true); | 427 picture_bounds, SK_ColorGREEN, true); |
419 scoped_refptr<PictureLayer> picture_vertical = | 428 scoped_refptr<PictureLayer> picture_vertical = |
420 PictureLayer::Create(&picture_client_vertical); | 429 PictureLayer::Create(layer_settings(), &picture_client_vertical); |
421 picture_vertical->SetBounds(picture_bounds); | 430 picture_vertical->SetBounds(picture_bounds); |
422 picture_vertical->SetIsDrawable(true); | 431 picture_vertical->SetIsDrawable(true); |
423 | 432 |
424 CheckerContentLayerClient picture_client_horizontal( | 433 CheckerContentLayerClient picture_client_horizontal( |
425 picture_bounds, SK_ColorMAGENTA, false); | 434 picture_bounds, SK_ColorMAGENTA, false); |
426 scoped_refptr<PictureLayer> picture_horizontal = | 435 scoped_refptr<PictureLayer> picture_horizontal = |
427 PictureLayer::Create(&picture_client_horizontal); | 436 PictureLayer::Create(layer_settings(), &picture_client_horizontal); |
428 picture_horizontal->SetBounds(picture_bounds); | 437 picture_horizontal->SetBounds(picture_bounds); |
429 picture_horizontal->SetIsDrawable(true); | 438 picture_horizontal->SetIsDrawable(true); |
430 picture_horizontal->SetContentsOpaque(false); | 439 picture_horizontal->SetContentsOpaque(false); |
431 picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode); | 440 picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode); |
432 | 441 |
433 background->AddChild(picture_vertical); | 442 background->AddChild(picture_vertical); |
434 background->AddChild(picture_horizontal); | 443 background->AddChild(picture_horizontal); |
435 | 444 |
436 gfx::Size mask_bounds(128, 128); | 445 gfx::Size mask_bounds(128, 128); |
437 CircleContentLayerClient mask_client(mask_bounds); | 446 CircleContentLayerClient mask_client(mask_bounds); |
438 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); | 447 scoped_refptr<PictureLayer> mask = |
| 448 PictureLayer::Create(layer_settings(), &mask_client); |
439 mask->SetBounds(mask_bounds); | 449 mask->SetBounds(mask_bounds); |
440 mask->SetIsDrawable(true); | 450 mask->SetIsDrawable(true); |
441 mask->SetIsMask(true); | 451 mask->SetIsMask(true); |
442 picture_horizontal->SetMaskLayer(mask.get()); | 452 picture_horizontal->SetMaskLayer(mask.get()); |
443 | 453 |
444 float percentage_pixels_large_error = 0.04f; // 0.04%, ~6px / (128*128) | 454 float percentage_pixels_large_error = 0.04f; // 0.04%, ~6px / (128*128) |
445 float percentage_pixels_small_error = 0.0f; | 455 float percentage_pixels_small_error = 0.0f; |
446 float average_error_allowed_in_bad_pixels = 256.0f; | 456 float average_error_allowed_in_bad_pixels = 256.0f; |
447 int large_error_allowed = 256; | 457 int large_error_allowed = 256; |
448 int small_error_allowed = 0; | 458 int small_error_allowed = 0; |
449 pixel_comparator_.reset(new FuzzyPixelComparator( | 459 pixel_comparator_.reset(new FuzzyPixelComparator( |
450 true, // discard_alpha | 460 true, // discard_alpha |
451 percentage_pixels_large_error, | 461 percentage_pixels_large_error, |
452 percentage_pixels_small_error, | 462 percentage_pixels_small_error, |
453 average_error_allowed_in_bad_pixels, | 463 average_error_allowed_in_bad_pixels, |
454 large_error_allowed, | 464 large_error_allowed, |
455 small_error_allowed)); | 465 small_error_allowed)); |
456 | 466 |
457 RunPixelResourceTest(background, | 467 RunPixelResourceTest(background, |
458 base::FilePath( | 468 base::FilePath( |
459 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 469 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
460 } | 470 } |
461 | 471 |
462 } // namespace | 472 } // namespace |
463 } // namespace cc | 473 } // namespace cc |
464 | 474 |
465 #endif // !defined(OS_ANDROID) | 475 #endif // !defined(OS_ANDROID) |
OLD | NEW |