| 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 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 bool FillsBoundsCompletely() const OVERRIDE { return false; } | 27 virtual bool FillsBoundsCompletely() const OVERRIDE { return false; } |
| 28 | 28 |
| 29 virtual void PaintContents(SkCanvas* canvas, | 29 virtual void PaintContents( |
| 30 const gfx::Rect& rect, | 30 SkCanvas* canvas, |
| 31 gfx::RectF* opaque_rect) OVERRIDE { | 31 const gfx::Rect& rect, |
| 32 gfx::RectF* opaque_rect, |
| 33 ContentLayerClient::GraphicsContextStatus gc_status) OVERRIDE { |
| 32 SkPaint paint; | 34 SkPaint paint; |
| 33 paint.setStyle(SkPaint::kStroke_Style); | 35 paint.setStyle(SkPaint::kStroke_Style); |
| 34 paint.setStrokeWidth(SkIntToScalar(2)); | 36 paint.setStrokeWidth(SkIntToScalar(2)); |
| 35 paint.setColor(SK_ColorWHITE); | 37 paint.setColor(SK_ColorWHITE); |
| 36 | 38 |
| 37 canvas->clear(SK_ColorTRANSPARENT); | 39 canvas->clear(SK_ColorTRANSPARENT); |
| 38 gfx::Rect inset_rect(rect); | 40 gfx::Rect inset_rect(rect); |
| 39 while (!inset_rect.IsEmpty()) { | 41 while (!inset_rect.IsEmpty()) { |
| 40 inset_rect.Inset(3, 3, 2, 2); | 42 inset_rect.Inset(3, 3, 2, 2); |
| 41 canvas->drawRect( | 43 canvas->drawRect( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 mask->SetIsMask(true); | 79 mask->SetIsMask(true); |
| 78 mask->SetBounds(gfx::Size(100, 100)); | 80 mask->SetBounds(gfx::Size(100, 100)); |
| 79 | 81 |
| 80 SkBitmap bitmap; | 82 SkBitmap bitmap; |
| 81 bitmap.allocN32Pixels(400, 400); | 83 bitmap.allocN32Pixels(400, 400); |
| 82 SkCanvas canvas(bitmap); | 84 SkCanvas canvas(bitmap); |
| 83 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); | 85 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); |
| 84 MaskContentLayerClient client; | 86 MaskContentLayerClient client; |
| 85 client.PaintContents(&canvas, | 87 client.PaintContents(&canvas, |
| 86 gfx::Rect(100, 100), | 88 gfx::Rect(100, 100), |
| 87 NULL); | 89 NULL, |
| 90 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); |
| 88 mask->SetBitmap(bitmap); | 91 mask->SetBitmap(bitmap); |
| 89 | 92 |
| 90 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 93 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
| 91 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); | 94 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); |
| 92 green->SetMaskLayer(mask.get()); | 95 green->SetMaskLayer(mask.get()); |
| 93 background->AddChild(green); | 96 background->AddChild(green); |
| 94 | 97 |
| 95 this->impl_side_painting_ = false; | 98 this->impl_side_painting_ = false; |
| 96 RunPixelTest(GL_WITH_BITMAP, | 99 RunPixelTest(GL_WITH_BITMAP, |
| 97 background, | 100 background, |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 RunPixelTest(GL_WITH_BITMAP, | 276 RunPixelTest(GL_WITH_BITMAP, |
| 274 background, | 277 background, |
| 275 base::FilePath(FILE_PATH_LITERAL( | 278 base::FilePath(FILE_PATH_LITERAL( |
| 276 "mask_of_replica_of_clipped_layer.png"))); | 279 "mask_of_replica_of_clipped_layer.png"))); |
| 277 } | 280 } |
| 278 | 281 |
| 279 } // namespace | 282 } // namespace |
| 280 } // namespace cc | 283 } // namespace cc |
| 281 | 284 |
| 282 #endif // OS_ANDROID | 285 #endif // OS_ANDROID |
| OLD | NEW |