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" |
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 // TODO(enne): these time out on Windows. http://crbug.com/435632 |
| 16 #if !defined(OS_WIN) |
| 17 |
15 namespace cc { | 18 namespace cc { |
16 namespace { | 19 namespace { |
17 | 20 |
18 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest; | 21 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest; |
19 | 22 |
20 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest); | 23 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest); |
21 | 24 |
22 class MaskContentLayerClient : public ContentLayerClient { | 25 class MaskContentLayerClient : public ContentLayerClient { |
23 public: | 26 public: |
24 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} | 27 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} |
(...skipping 25 matching lines...) Expand all Loading... |
50 const gfx::Rect& clip, | 53 const gfx::Rect& clip, |
51 PaintingControlSetting picture_control) override { | 54 PaintingControlSetting picture_control) override { |
52 NOTIMPLEMENTED(); | 55 NOTIMPLEMENTED(); |
53 return DisplayItemList::Create(); | 56 return DisplayItemList::Create(); |
54 } | 57 } |
55 | 58 |
56 private: | 59 private: |
57 gfx::Size bounds_; | 60 gfx::Size bounds_; |
58 }; | 61 }; |
59 | 62 |
60 // TODO(enne): these time out on Windows. http://crbug.com/435632 | |
61 #if !defined(OS_WIN) | |
62 | |
63 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { | 63 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { |
64 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 64 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
65 gfx::Rect(200, 200), SK_ColorWHITE); | 65 gfx::Rect(200, 200), SK_ColorWHITE); |
66 | 66 |
67 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 67 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
68 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 68 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
69 background->AddChild(green); | 69 background->AddChild(green); |
70 | 70 |
71 gfx::Size mask_bounds(100, 100); | 71 gfx::Size mask_bounds(100, 100); |
72 MaskContentLayerClient client(mask_bounds); | 72 MaskContentLayerClient client(mask_bounds); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 replica->SetPosition(gfx::Point()); | 273 replica->SetPosition(gfx::Point()); |
274 replica->SetTransform(replica_transform); | 274 replica->SetTransform(replica_transform); |
275 replica->SetMaskLayer(mask.get()); | 275 replica->SetMaskLayer(mask.get()); |
276 green->SetReplicaLayer(replica.get()); | 276 green->SetReplicaLayer(replica.get()); |
277 | 277 |
278 RunPixelResourceTest(background, | 278 RunPixelResourceTest(background, |
279 base::FilePath(FILE_PATH_LITERAL( | 279 base::FilePath(FILE_PATH_LITERAL( |
280 "mask_of_replica_of_clipped_layer.png"))); | 280 "mask_of_replica_of_clipped_layer.png"))); |
281 } | 281 } |
282 | 282 |
283 #endif // !defined(OS_WIN) | |
284 | |
285 class CheckerContentLayerClient : public ContentLayerClient { | 283 class CheckerContentLayerClient : public ContentLayerClient { |
286 public: | 284 public: |
287 CheckerContentLayerClient(const gfx::Size& bounds, | 285 CheckerContentLayerClient(const gfx::Size& bounds, |
288 SkColor color, | 286 SkColor color, |
289 bool vertical) | 287 bool vertical) |
290 : bounds_(bounds), color_(color), vertical_(vertical) {} | 288 : bounds_(bounds), color_(color), vertical_(vertical) {} |
291 ~CheckerContentLayerClient() override {} | 289 ~CheckerContentLayerClient() override {} |
292 bool FillsBoundsCompletely() const override { return false; } | 290 bool FillsBoundsCompletely() const override { return false; } |
293 void PaintContents(SkCanvas* canvas, | 291 void PaintContents(SkCanvas* canvas, |
294 const gfx::Rect& rect, | 292 const gfx::Rect& rect, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 gfx::Size mask_bounds(256, 256); | 388 gfx::Size mask_bounds(256, 256); |
391 CircleContentLayerClient mask_client(mask_bounds); | 389 CircleContentLayerClient mask_client(mask_bounds); |
392 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); | 390 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); |
393 mask->SetBounds(mask_bounds); | 391 mask->SetBounds(mask_bounds); |
394 mask->SetIsDrawable(true); | 392 mask->SetIsDrawable(true); |
395 mask->SetIsMask(true); | 393 mask->SetIsMask(true); |
396 blur->SetMaskLayer(mask.get()); | 394 blur->SetMaskLayer(mask.get()); |
397 | 395 |
398 float percentage_pixels_large_error = 2.5f; // 2.5%, ~1600px / (256*256) | 396 float percentage_pixels_large_error = 2.5f; // 2.5%, ~1600px / (256*256) |
399 float percentage_pixels_small_error = 0.0f; | 397 float percentage_pixels_small_error = 0.0f; |
400 float average_error_allowed_in_bad_pixels = 60.0f; | 398 float average_error_allowed_in_bad_pixels = 100.0f; |
401 int large_error_allowed = 100; | 399 int large_error_allowed = 256; |
402 int small_error_allowed = 0; | 400 int small_error_allowed = 0; |
403 pixel_comparator_.reset(new FuzzyPixelComparator( | 401 pixel_comparator_.reset(new FuzzyPixelComparator( |
404 true, // discard_alpha | 402 true, // discard_alpha |
405 percentage_pixels_large_error, | 403 percentage_pixels_large_error, |
406 percentage_pixels_small_error, | 404 percentage_pixels_small_error, |
407 average_error_allowed_in_bad_pixels, | 405 average_error_allowed_in_bad_pixels, |
408 large_error_allowed, | 406 large_error_allowed, |
409 small_error_allowed)); | 407 small_error_allowed)); |
410 | 408 |
411 RunPixelResourceTest(background, | 409 RunPixelResourceTest(background, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 small_error_allowed)); | 458 small_error_allowed)); |
461 | 459 |
462 RunPixelResourceTest(background, | 460 RunPixelResourceTest(background, |
463 base::FilePath( | 461 base::FilePath( |
464 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 462 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
465 } | 463 } |
466 | 464 |
467 } // namespace | 465 } // namespace |
468 } // namespace cc | 466 } // namespace cc |
469 | 467 |
470 #endif // OS_ANDROID | 468 #endif // !defined(OS_WIN) |
| 469 #endif // !defined(OS_ANDROID) |
OLD | NEW |