Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_masks.cc

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "cc/layers/content_layer_client.h" 8 #include "cc/layers/content_layer_client.h"
9 #include "cc/layers/picture_image_layer.h" 9 #include "cc/layers/picture_image_layer.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { 74 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) {
75 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 75 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
76 gfx::Rect(100, 100), SK_ColorWHITE); 76 gfx::Rect(100, 100), SK_ColorWHITE);
77 77
78 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 78 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
79 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 79 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
80 background->AddChild(green); 80 background->AddChild(green);
81 81
82 gfx::Size mask_bounds(50, 50); 82 gfx::Size mask_bounds(50, 50);
83 MaskContentLayerClient client(mask_bounds); 83 MaskContentLayerClient client(mask_bounds);
84 scoped_refptr<PictureLayer> mask = 84 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
85 PictureLayer::Create(layer_settings(), &client);
86 mask->SetBounds(mask_bounds); 85 mask->SetBounds(mask_bounds);
87 mask->SetIsDrawable(true); 86 mask->SetIsDrawable(true);
88 mask->SetIsMask(true); 87 mask->SetIsMask(true);
89 green->SetMaskLayer(mask.get()); 88 green->SetMaskLayer(mask.get());
90 89
91 RunPixelResourceTest(background, 90 RunPixelResourceTest(background,
92 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); 91 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png")));
93 } 92 }
94 93
95 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { 94 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) {
96 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 95 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
97 gfx::Rect(100, 100), SK_ColorWHITE); 96 gfx::Rect(100, 100), SK_ColorWHITE);
98 97
99 gfx::Size mask_bounds(50, 50); 98 gfx::Size mask_bounds(50, 50);
100 99
101 scoped_refptr<PictureImageLayer> mask = 100 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
102 PictureImageLayer::Create(layer_settings());
103 mask->SetIsDrawable(true); 101 mask->SetIsDrawable(true);
104 mask->SetIsMask(true); 102 mask->SetIsMask(true);
105 mask->SetBounds(mask_bounds); 103 mask->SetBounds(mask_bounds);
106 104
107 skia::RefPtr<SkSurface> surface = 105 skia::RefPtr<SkSurface> surface =
108 skia::AdoptRef(SkSurface::NewRasterN32Premul(200, 200)); 106 skia::AdoptRef(SkSurface::NewRasterN32Premul(200, 200));
109 SkCanvas* canvas = surface->getCanvas(); 107 SkCanvas* canvas = surface->getCanvas();
110 canvas->scale(SkIntToScalar(4), SkIntToScalar(4)); 108 canvas->scale(SkIntToScalar(4), SkIntToScalar(4));
111 MaskContentLayerClient client(mask_bounds); 109 MaskContentLayerClient client(mask_bounds);
112 scoped_refptr<DisplayItemList> mask_display_list = 110 scoped_refptr<DisplayItemList> mask_display_list =
(...skipping 11 matching lines...) Expand all
124 122
125 RunPixelResourceTest( 123 RunPixelResourceTest(
126 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); 124 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png")));
127 } 125 }
128 126
129 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { 127 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
130 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 128 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
131 gfx::Rect(100, 100), SK_ColorWHITE); 129 gfx::Rect(100, 100), SK_ColorWHITE);
132 130
133 // Clip to the top half of the green layer. 131 // Clip to the top half of the green layer.
134 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 132 scoped_refptr<Layer> clip = Layer::Create();
135 clip->SetPosition(gfx::PointF()); 133 clip->SetPosition(gfx::PointF());
136 clip->SetBounds(gfx::Size(100, 50)); 134 clip->SetBounds(gfx::Size(100, 50));
137 clip->SetMasksToBounds(true); 135 clip->SetMasksToBounds(true);
138 background->AddChild(clip); 136 background->AddChild(clip);
139 137
140 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 138 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
141 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 139 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
142 clip->AddChild(green); 140 clip->AddChild(green);
143 141
144 gfx::Size mask_bounds(50, 50); 142 gfx::Size mask_bounds(50, 50);
145 MaskContentLayerClient client(mask_bounds); 143 MaskContentLayerClient client(mask_bounds);
146 scoped_refptr<PictureLayer> mask = 144 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
147 PictureLayer::Create(layer_settings(), &client);
148 mask->SetBounds(mask_bounds); 145 mask->SetBounds(mask_bounds);
149 mask->SetIsDrawable(true); 146 mask->SetIsDrawable(true);
150 mask->SetIsMask(true); 147 mask->SetIsMask(true);
151 green->SetMaskLayer(mask.get()); 148 green->SetMaskLayer(mask.get());
152 149
153 RunPixelResourceTest( 150 RunPixelResourceTest(
154 background, 151 background,
155 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); 152 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png")));
156 } 153 }
157 154
158 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) { 155 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) {
159 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 156 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
160 gfx::Rect(100, 100), SK_ColorWHITE); 157 gfx::Rect(100, 100), SK_ColorWHITE);
161 158
162 gfx::Size mask_bounds(50, 50); 159 gfx::Size mask_bounds(50, 50);
163 MaskContentLayerClient client(mask_bounds); 160 MaskContentLayerClient client(mask_bounds);
164 scoped_refptr<PictureLayer> mask = 161 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
165 PictureLayer::Create(layer_settings(), &client);
166 mask->SetBounds(mask_bounds); 162 mask->SetBounds(mask_bounds);
167 mask->SetIsDrawable(true); 163 mask->SetIsDrawable(true);
168 mask->SetIsMask(true); 164 mask->SetIsMask(true);
169 165
170 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 166 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
171 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 167 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
172 background->AddChild(green); 168 background->AddChild(green);
173 green->SetMaskLayer(mask.get()); 169 green->SetMaskLayer(mask.get());
174 170
175 gfx::Transform replica_transform; 171 gfx::Transform replica_transform;
176 replica_transform.Rotate(-90.0); 172 replica_transform.Rotate(-90.0);
177 173
178 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 174 scoped_refptr<Layer> replica = Layer::Create();
179 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); 175 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
180 replica->SetPosition(gfx::PointF(50.f, 50.f)); 176 replica->SetPosition(gfx::PointF(50.f, 50.f));
181 replica->SetTransform(replica_transform); 177 replica->SetTransform(replica_transform);
182 green->SetReplicaLayer(replica.get()); 178 green->SetReplicaLayer(replica.get());
183 179
184 RunPixelResourceTest( 180 RunPixelResourceTest(
185 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); 181 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png")));
186 } 182 }
187 183
188 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { 184 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) {
189 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 185 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
190 gfx::Rect(100, 100), SK_ColorWHITE); 186 gfx::Rect(100, 100), SK_ColorWHITE);
191 187
192 gfx::Size mask_bounds(50, 50); 188 gfx::Size mask_bounds(50, 50);
193 MaskContentLayerClient client(mask_bounds); 189 MaskContentLayerClient client(mask_bounds);
194 scoped_refptr<PictureLayer> mask = 190 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
195 PictureLayer::Create(layer_settings(), &client);
196 mask->SetBounds(mask_bounds); 191 mask->SetBounds(mask_bounds);
197 mask->SetIsDrawable(true); 192 mask->SetIsDrawable(true);
198 mask->SetIsMask(true); 193 mask->SetIsMask(true);
199 194
200 // Clip to the bottom half of the green layer, and the left half of the 195 // Clip to the bottom half of the green layer, and the left half of the
201 // replica. 196 // replica.
202 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 197 scoped_refptr<Layer> clip = Layer::Create();
203 clip->SetPosition(gfx::PointF(0.f, 25.f)); 198 clip->SetPosition(gfx::PointF(0.f, 25.f));
204 clip->SetBounds(gfx::Size(75, 75)); 199 clip->SetBounds(gfx::Size(75, 75));
205 clip->SetMasksToBounds(true); 200 clip->SetMasksToBounds(true);
206 background->AddChild(clip); 201 background->AddChild(clip);
207 202
208 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 203 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
209 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 204 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
210 clip->AddChild(green); 205 clip->AddChild(green);
211 green->SetMaskLayer(mask.get()); 206 green->SetMaskLayer(mask.get());
212 207
213 gfx::Transform replica_transform; 208 gfx::Transform replica_transform;
214 replica_transform.Rotate(-90.0); 209 replica_transform.Rotate(-90.0);
215 210
216 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 211 scoped_refptr<Layer> replica = Layer::Create();
217 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f)); 212 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
218 replica->SetPosition(gfx::PointF(50.f, 50.f)); 213 replica->SetPosition(gfx::PointF(50.f, 50.f));
219 replica->SetTransform(replica_transform); 214 replica->SetTransform(replica_transform);
220 green->SetReplicaLayer(replica.get()); 215 green->SetReplicaLayer(replica.get());
221 216
222 RunPixelResourceTest(background, 217 RunPixelResourceTest(background,
223 base::FilePath(FILE_PATH_LITERAL( 218 base::FilePath(FILE_PATH_LITERAL(
224 "mask_with_replica_of_clipped_layer.png"))); 219 "mask_with_replica_of_clipped_layer.png")));
225 } 220 }
226 221
227 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) { 222 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) {
228 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 223 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
229 gfx::Rect(100, 100), SK_ColorWHITE); 224 gfx::Rect(100, 100), SK_ColorWHITE);
230 225
231 gfx::Size mask_bounds(50, 50); 226 gfx::Size mask_bounds(50, 50);
232 MaskContentLayerClient client(mask_bounds); 227 MaskContentLayerClient client(mask_bounds);
233 scoped_refptr<PictureLayer> mask = 228 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
234 PictureLayer::Create(layer_settings(), &client);
235 mask->SetBounds(mask_bounds); 229 mask->SetBounds(mask_bounds);
236 mask->SetIsDrawable(true); 230 mask->SetIsDrawable(true);
237 mask->SetIsMask(true); 231 mask->SetIsMask(true);
238 232
239 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 233 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
240 gfx::Rect(25, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 234 gfx::Rect(25, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
241 background->AddChild(green); 235 background->AddChild(green);
242 236
243 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 237 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
244 gfx::Rect(-25, 25, 25, 25), kCSSOrange); 238 gfx::Rect(-25, 25, 25, 25), kCSSOrange);
245 green->AddChild(orange); 239 green->AddChild(orange);
246 240
247 gfx::Transform replica_transform; 241 gfx::Transform replica_transform;
248 replica_transform.Rotate(180.0); 242 replica_transform.Rotate(180.0);
249 replica_transform.Translate(50.0, 0.0); 243 replica_transform.Translate(50.0, 0.0);
250 244
251 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 245 scoped_refptr<Layer> replica = Layer::Create();
252 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 246 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
253 replica->SetPosition(gfx::PointF()); 247 replica->SetPosition(gfx::PointF());
254 replica->SetTransform(replica_transform); 248 replica->SetTransform(replica_transform);
255 replica->SetMaskLayer(mask.get()); 249 replica->SetMaskLayer(mask.get());
256 green->SetReplicaLayer(replica.get()); 250 green->SetReplicaLayer(replica.get());
257 251
258 RunPixelResourceTest( 252 RunPixelResourceTest(
259 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); 253 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png")));
260 } 254 }
261 255
262 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { 256 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
263 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 257 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
264 gfx::Rect(100, 100), SK_ColorWHITE); 258 gfx::Rect(100, 100), SK_ColorWHITE);
265 259
266 gfx::Size mask_bounds(50, 50); 260 gfx::Size mask_bounds(50, 50);
267 MaskContentLayerClient client(mask_bounds); 261 MaskContentLayerClient client(mask_bounds);
268 scoped_refptr<PictureLayer> mask = 262 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
269 PictureLayer::Create(layer_settings(), &client);
270 mask->SetBounds(mask_bounds); 263 mask->SetBounds(mask_bounds);
271 mask->SetIsDrawable(true); 264 mask->SetIsDrawable(true);
272 mask->SetIsMask(true); 265 mask->SetIsMask(true);
273 266
274 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. 267 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica.
275 scoped_refptr<Layer> clip = Layer::Create(layer_settings()); 268 scoped_refptr<Layer> clip = Layer::Create();
276 clip->SetPosition(gfx::PointF(0.f, 12.f)); 269 clip->SetPosition(gfx::PointF(0.f, 12.f));
277 clip->SetBounds(gfx::Size(100, 75)); 270 clip->SetBounds(gfx::Size(100, 75));
278 clip->SetMasksToBounds(true); 271 clip->SetMasksToBounds(true);
279 background->AddChild(clip); 272 background->AddChild(clip);
280 273
281 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 274 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
282 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK); 275 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
283 clip->AddChild(green); 276 clip->AddChild(green);
284 277
285 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 278 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
286 gfx::Rect(-25, 25, 25, 25), kCSSOrange); 279 gfx::Rect(-25, 25, 25, 25), kCSSOrange);
287 green->AddChild(orange); 280 green->AddChild(orange);
288 281
289 gfx::Transform replica_transform; 282 gfx::Transform replica_transform;
290 replica_transform.Rotate(180.0); 283 replica_transform.Rotate(180.0);
291 replica_transform.Translate(50.0, 0.0); 284 replica_transform.Translate(50.0, 0.0);
292 285
293 scoped_refptr<Layer> replica = Layer::Create(layer_settings()); 286 scoped_refptr<Layer> replica = Layer::Create();
294 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 287 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
295 replica->SetPosition(gfx::PointF()); 288 replica->SetPosition(gfx::PointF());
296 replica->SetTransform(replica_transform); 289 replica->SetTransform(replica_transform);
297 replica->SetMaskLayer(mask.get()); 290 replica->SetMaskLayer(mask.get());
298 green->SetReplicaLayer(replica.get()); 291 green->SetReplicaLayer(replica.get());
299 292
300 RunPixelResourceTest(background, 293 RunPixelResourceTest(background,
301 base::FilePath(FILE_PATH_LITERAL( 294 base::FilePath(FILE_PATH_LITERAL(
302 "mask_of_replica_of_clipped_layer.png"))); 295 "mask_of_replica_of_clipped_layer.png")));
303 } 296 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 GL_ZERO_COPY_RECT_DRAW, 391 GL_ZERO_COPY_RECT_DRAW,
399 GL_ZERO_COPY_EXTERNAL_DRAW)); 392 GL_ZERO_COPY_EXTERNAL_DRAW));
400 393
401 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, 394 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
402 MaskOfLayerWithBackgroundFilter) { 395 MaskOfLayerWithBackgroundFilter) {
403 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 396 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
404 gfx::Rect(100, 100), SK_ColorWHITE); 397 gfx::Rect(100, 100), SK_ColorWHITE);
405 398
406 gfx::Size picture_bounds(100, 100); 399 gfx::Size picture_bounds(100, 100);
407 CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true); 400 CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true);
408 scoped_refptr<PictureLayer> picture = 401 scoped_refptr<PictureLayer> picture = PictureLayer::Create(&picture_client);
409 PictureLayer::Create(layer_settings(), &picture_client);
410 picture->SetBounds(picture_bounds); 402 picture->SetBounds(picture_bounds);
411 picture->SetIsDrawable(true); 403 picture->SetIsDrawable(true);
412 404
413 scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer( 405 scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer(
414 gfx::Rect(100, 100), SK_ColorTRANSPARENT); 406 gfx::Rect(100, 100), SK_ColorTRANSPARENT);
415 background->AddChild(picture); 407 background->AddChild(picture);
416 background->AddChild(blur); 408 background->AddChild(blur);
417 409
418 FilterOperations filters; 410 FilterOperations filters;
419 filters.Append(FilterOperation::CreateGrayscaleFilter(1.0)); 411 filters.Append(FilterOperation::CreateGrayscaleFilter(1.0));
420 blur->SetBackgroundFilters(filters); 412 blur->SetBackgroundFilters(filters);
421 413
422 gfx::Size mask_bounds(100, 100); 414 gfx::Size mask_bounds(100, 100);
423 CircleContentLayerClient mask_client(mask_bounds); 415 CircleContentLayerClient mask_client(mask_bounds);
424 scoped_refptr<PictureLayer> mask = 416 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client);
425 PictureLayer::Create(layer_settings(), &mask_client);
426 mask->SetBounds(mask_bounds); 417 mask->SetBounds(mask_bounds);
427 mask->SetIsDrawable(true); 418 mask->SetIsDrawable(true);
428 mask->SetIsMask(true); 419 mask->SetIsMask(true);
429 blur->SetMaskLayer(mask.get()); 420 blur->SetMaskLayer(mask.get());
430 421
431 float percentage_pixels_large_error = 2.5f; // 2.5%, ~250px / (100*100) 422 float percentage_pixels_large_error = 2.5f; // 2.5%, ~250px / (100*100)
432 float percentage_pixels_small_error = 0.0f; 423 float percentage_pixels_small_error = 0.0f;
433 float average_error_allowed_in_bad_pixels = 100.0f; 424 float average_error_allowed_in_bad_pixels = 100.0f;
434 int large_error_allowed = 256; 425 int large_error_allowed = 256;
435 int small_error_allowed = 0; 426 int small_error_allowed = 0;
(...skipping 12 matching lines...) Expand all
448 439
449 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, 440 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
450 MaskOfLayerWithBlend) { 441 MaskOfLayerWithBlend) {
451 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 442 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
452 gfx::Rect(128, 128), SK_ColorWHITE); 443 gfx::Rect(128, 128), SK_ColorWHITE);
453 444
454 gfx::Size picture_bounds(128, 128); 445 gfx::Size picture_bounds(128, 128);
455 CheckerContentLayerClient picture_client_vertical( 446 CheckerContentLayerClient picture_client_vertical(
456 picture_bounds, SK_ColorGREEN, true); 447 picture_bounds, SK_ColorGREEN, true);
457 scoped_refptr<PictureLayer> picture_vertical = 448 scoped_refptr<PictureLayer> picture_vertical =
458 PictureLayer::Create(layer_settings(), &picture_client_vertical); 449 PictureLayer::Create(&picture_client_vertical);
459 picture_vertical->SetBounds(picture_bounds); 450 picture_vertical->SetBounds(picture_bounds);
460 picture_vertical->SetIsDrawable(true); 451 picture_vertical->SetIsDrawable(true);
461 452
462 CheckerContentLayerClient picture_client_horizontal( 453 CheckerContentLayerClient picture_client_horizontal(
463 picture_bounds, SK_ColorMAGENTA, false); 454 picture_bounds, SK_ColorMAGENTA, false);
464 scoped_refptr<PictureLayer> picture_horizontal = 455 scoped_refptr<PictureLayer> picture_horizontal =
465 PictureLayer::Create(layer_settings(), &picture_client_horizontal); 456 PictureLayer::Create(&picture_client_horizontal);
466 picture_horizontal->SetBounds(picture_bounds); 457 picture_horizontal->SetBounds(picture_bounds);
467 picture_horizontal->SetIsDrawable(true); 458 picture_horizontal->SetIsDrawable(true);
468 picture_horizontal->SetContentsOpaque(false); 459 picture_horizontal->SetContentsOpaque(false);
469 picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode); 460 picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode);
470 461
471 background->AddChild(picture_vertical); 462 background->AddChild(picture_vertical);
472 background->AddChild(picture_horizontal); 463 background->AddChild(picture_horizontal);
473 464
474 gfx::Size mask_bounds(128, 128); 465 gfx::Size mask_bounds(128, 128);
475 CircleContentLayerClient mask_client(mask_bounds); 466 CircleContentLayerClient mask_client(mask_bounds);
476 scoped_refptr<PictureLayer> mask = 467 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client);
477 PictureLayer::Create(layer_settings(), &mask_client);
478 mask->SetBounds(mask_bounds); 468 mask->SetBounds(mask_bounds);
479 mask->SetIsDrawable(true); 469 mask->SetIsDrawable(true);
480 mask->SetIsMask(true); 470 mask->SetIsMask(true);
481 picture_horizontal->SetMaskLayer(mask.get()); 471 picture_horizontal->SetMaskLayer(mask.get());
482 472
483 float percentage_pixels_large_error = 0.04f; // 0.04%, ~6px / (128*128) 473 float percentage_pixels_large_error = 0.04f; // 0.04%, ~6px / (128*128)
484 float percentage_pixels_small_error = 0.0f; 474 float percentage_pixels_small_error = 0.0f;
485 float average_error_allowed_in_bad_pixels = 256.0f; 475 float average_error_allowed_in_bad_pixels = 256.0f;
486 int large_error_allowed = 256; 476 int large_error_allowed = 256;
487 int small_error_allowed = 0; 477 int small_error_allowed = 0;
488 pixel_comparator_.reset(new FuzzyPixelComparator( 478 pixel_comparator_.reset(new FuzzyPixelComparator(
489 true, // discard_alpha 479 true, // discard_alpha
490 percentage_pixels_large_error, 480 percentage_pixels_large_error,
491 percentage_pixels_small_error, 481 percentage_pixels_small_error,
492 average_error_allowed_in_bad_pixels, 482 average_error_allowed_in_bad_pixels,
493 large_error_allowed, 483 large_error_allowed,
494 small_error_allowed)); 484 small_error_allowed));
495 485
496 RunPixelResourceTest(background, 486 RunPixelResourceTest(background,
497 base::FilePath( 487 base::FilePath(
498 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); 488 FILE_PATH_LITERAL("mask_of_layer_with_blend.png")));
499 } 489 }
500 490
501 } // namespace 491 } // namespace
502 } // namespace cc 492 } // namespace cc
503 493
504 #endif // !defined(OS_ANDROID) 494 #endif // !defined(OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698