| 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 <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" |
| 11 #include "cc/layers/solid_color_layer.h" | 11 #include "cc/layers/solid_color_layer.h" |
| 12 #include "cc/paint/drawing_display_item.h" | 12 #include "cc/paint/drawing_display_item.h" |
| 13 #include "cc/paint/paint_flags.h" | 13 #include "cc/paint/paint_flags.h" |
| 14 #include "cc/paint/paint_image.h" |
| 14 #include "cc/paint/paint_recorder.h" | 15 #include "cc/paint/paint_recorder.h" |
| 15 #include "cc/test/layer_tree_pixel_resource_test.h" | 16 #include "cc/test/layer_tree_pixel_resource_test.h" |
| 16 #include "cc/test/pixel_comparator.h" | 17 #include "cc/test/pixel_comparator.h" |
| 17 #include "cc/test/solid_color_content_layer_client.h" | 18 #include "cc/test/solid_color_content_layer_client.h" |
| 18 #include "third_party/skia/include/core/SkImage.h" | 19 #include "third_party/skia/include/core/SkImage.h" |
| 19 | 20 |
| 20 #if !defined(OS_ANDROID) | 21 #if !defined(OS_ANDROID) |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 namespace { | 24 namespace { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 mask->SetBounds(mask_bounds); | 103 mask->SetBounds(mask_bounds); |
| 103 | 104 |
| 104 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(200, 200); | 105 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(200, 200); |
| 105 SkCanvas* canvas = surface->getCanvas(); | 106 SkCanvas* canvas = surface->getCanvas(); |
| 106 canvas->scale(SkIntToScalar(4), SkIntToScalar(4)); | 107 canvas->scale(SkIntToScalar(4), SkIntToScalar(4)); |
| 107 MaskContentLayerClient client(mask_bounds); | 108 MaskContentLayerClient client(mask_bounds); |
| 108 scoped_refptr<DisplayItemList> mask_display_list = | 109 scoped_refptr<DisplayItemList> mask_display_list = |
| 109 client.PaintContentsToDisplayList( | 110 client.PaintContentsToDisplayList( |
| 110 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 111 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
| 111 mask_display_list->Raster(canvas, nullptr); | 112 mask_display_list->Raster(canvas, nullptr); |
| 112 mask->SetImage(surface->makeImageSnapshot()); | 113 mask->SetImage(PaintImage(surface->makeImageSnapshot())); |
| 113 | 114 |
| 114 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( | 115 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( |
| 115 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); | 116 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK); |
| 116 green->SetMaskLayer(mask.get()); | 117 green->SetMaskLayer(mask.get()); |
| 117 background->AddChild(green); | 118 background->AddChild(green); |
| 118 | 119 |
| 119 RunPixelResourceTest( | 120 RunPixelResourceTest( |
| 120 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); | 121 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); |
| 121 } | 122 } |
| 122 | 123 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 335 |
| 335 RunPixelResourceTest(background, | 336 RunPixelResourceTest(background, |
| 336 base::FilePath( | 337 base::FilePath( |
| 337 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 338 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
| 338 } | 339 } |
| 339 | 340 |
| 340 } // namespace | 341 } // namespace |
| 341 } // namespace cc | 342 } // namespace cc |
| 342 | 343 |
| 343 #endif // !defined(OS_ANDROID) | 344 #endif // !defined(OS_ANDROID) |
| OLD | NEW |