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" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 95 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
96 gfx::Rect(100, 100), SK_ColorWHITE); | 96 gfx::Rect(100, 100), SK_ColorWHITE); |
97 | 97 |
98 gfx::Size mask_bounds(50, 50); | 98 gfx::Size mask_bounds(50, 50); |
99 | 99 |
100 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 100 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); |
101 mask->SetIsDrawable(true); | 101 mask->SetIsDrawable(true); |
102 mask->SetIsMask(true); | 102 mask->SetIsMask(true); |
103 mask->SetBounds(mask_bounds); | 103 mask->SetBounds(mask_bounds); |
104 | 104 |
105 skia::RefPtr<SkSurface> surface = | 105 sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(200, 200); |
106 skia::AdoptRef(SkSurface::NewRasterN32Premul(200, 200)); | |
107 SkCanvas* canvas = surface->getCanvas(); | 106 SkCanvas* canvas = surface->getCanvas(); |
108 canvas->scale(SkIntToScalar(4), SkIntToScalar(4)); | 107 canvas->scale(SkIntToScalar(4), SkIntToScalar(4)); |
109 MaskContentLayerClient client(mask_bounds); | 108 MaskContentLayerClient client(mask_bounds); |
110 scoped_refptr<DisplayItemList> mask_display_list = | 109 scoped_refptr<DisplayItemList> mask_display_list = |
111 client.PaintContentsToDisplayList( | 110 client.PaintContentsToDisplayList( |
112 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); | 111 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); |
113 mask_display_list->Raster(canvas, nullptr, gfx::Rect(mask_bounds), 1.0f); | 112 mask_display_list->Raster(canvas, nullptr, gfx::Rect(mask_bounds), 1.0f); |
114 skia::RefPtr<const SkImage> image = | 113 skia::RefPtr<const SkImage> image = |
115 skia::AdoptRef(surface->newImageSnapshot()); | 114 skia::AdoptRef(surface->newImageSnapshot()); |
116 mask->SetImage(std::move(image)); | 115 mask->SetImage(std::move(image)); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 484 |
486 RunPixelResourceTest(background, | 485 RunPixelResourceTest(background, |
487 base::FilePath( | 486 base::FilePath( |
488 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); | 487 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); |
489 } | 488 } |
490 | 489 |
491 } // namespace | 490 } // namespace |
492 } // namespace cc | 491 } // namespace cc |
493 | 492 |
494 #endif // !defined(OS_ANDROID) | 493 #endif // !defined(OS_ANDROID) |
OLD | NEW |