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.h" | 6 #include "cc/layers/content_layer.h" |
7 #include "cc/layers/content_layer_client.h" | 7 #include "cc/layers/content_layer_client.h" |
8 #include "cc/layers/image_layer.h" | 8 #include "cc/layers/image_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 | 19 |
20 class MaskContentLayerClient : public cc::ContentLayerClient { | 20 class MaskContentLayerClient : public ContentLayerClient { |
21 public: | 21 public: |
22 MaskContentLayerClient() {} | 22 MaskContentLayerClient() {} |
23 virtual ~MaskContentLayerClient() {} | 23 virtual ~MaskContentLayerClient() {} |
24 | 24 |
25 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} | 25 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {} |
26 | 26 |
27 virtual void PaintContents(SkCanvas* canvas, | 27 virtual void PaintContents(SkCanvas* canvas, |
28 gfx::Rect rect, | 28 const gfx::Rect& rect, |
29 gfx::RectF* opaque_rect) OVERRIDE { | 29 gfx::RectF* opaque_rect) OVERRIDE { |
30 SkPaint paint; | 30 SkPaint paint; |
31 paint.setStyle(SkPaint::kStroke_Style); | 31 paint.setStyle(SkPaint::kStroke_Style); |
32 paint.setStrokeWidth(SkIntToScalar(2)); | 32 paint.setStrokeWidth(SkIntToScalar(2)); |
33 paint.setColor(SK_ColorWHITE); | 33 paint.setColor(SK_ColorWHITE); |
34 | 34 |
35 canvas->clear(SK_ColorTRANSPARENT); | 35 canvas->clear(SK_ColorTRANSPARENT); |
36 while (!rect.IsEmpty()) { | 36 gfx::Rect inset_rect(rect); |
37 rect.Inset(3, 3, 2, 2); | 37 while (!inset_rect.IsEmpty()) { |
| 38 inset_rect.Inset(3, 3, 2, 2); |
38 canvas->drawRect( | 39 canvas->drawRect( |
39 SkRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()), | 40 SkRect::MakeXYWH(inset_rect.x(), inset_rect.y(), |
| 41 inset_rect.width(), inset_rect.height()), |
40 paint); | 42 paint); |
41 rect.Inset(3, 3, 2, 2); | 43 inset_rect.Inset(3, 3, 2, 2); |
42 } | 44 } |
43 } | 45 } |
44 }; | 46 }; |
45 | 47 |
46 TEST_F(LayerTreeHostMasksPixelTest, MaskOfLayer) { | 48 TEST_F(LayerTreeHostMasksPixelTest, MaskOfLayer) { |
47 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 49 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
48 gfx::Rect(200, 200), SK_ColorWHITE); | 50 gfx::Rect(200, 200), SK_ColorWHITE); |
49 | 51 |
50 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 52 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
51 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 53 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 RunPixelTest(GL_WITH_BITMAP, | 272 RunPixelTest(GL_WITH_BITMAP, |
271 background, | 273 background, |
272 base::FilePath(FILE_PATH_LITERAL( | 274 base::FilePath(FILE_PATH_LITERAL( |
273 "mask_of_replica_of_clipped_layer.png"))); | 275 "mask_of_replica_of_clipped_layer.png"))); |
274 } | 276 } |
275 | 277 |
276 } // namespace | 278 } // namespace |
277 } // namespace cc | 279 } // namespace cc |
278 | 280 |
279 #endif // OS_ANDROID | 281 #endif // OS_ANDROID |
OLD | NEW |