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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "cc/layers/picture_image_layer.h" | 7 #include "cc/layers/picture_image_layer.h" |
8 #include "cc/layers/solid_color_layer.h" | 8 #include "cc/layers/solid_color_layer.h" |
9 #include "cc/test/layer_tree_pixel_resource_test.h" | 9 #include "cc/test/layer_tree_pixel_resource_test.h" |
10 #include "cc/test/pixel_comparator.h" | 10 #include "cc/test/pixel_comparator.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 } | 124 } |
125 | 125 |
126 RunPixelResourceTest( | 126 RunPixelResourceTest( |
127 root, base::FilePath(FILE_PATH_LITERAL("blending_transparent.png"))); | 127 root, base::FilePath(FILE_PATH_LITERAL("blending_transparent.png"))); |
128 } | 128 } |
129 | 129 |
130 scoped_refptr<Layer> CreateColorfulBackdropLayer(int width, int height) { | 130 scoped_refptr<Layer> CreateColorfulBackdropLayer(int width, int height) { |
131 // Draw the backdrop with horizontal lanes. | 131 // Draw the backdrop with horizontal lanes. |
132 const int kLaneWidth = width; | 132 const int kLaneWidth = width; |
133 const int kLaneHeight = height / kCSSTestColorsCount; | 133 const int kLaneHeight = height / kCSSTestColorsCount; |
134 skia::RefPtr<SkSurface> backing_store = | 134 sk_sp<SkSurface> backing_store = |
135 skia::AdoptRef(SkSurface::NewRasterN32Premul(width, height)); | 135 SkSurface::MakeRasterN32Premul(width, height); |
136 SkCanvas* canvas = backing_store->getCanvas(); | 136 SkCanvas* canvas = backing_store->getCanvas(); |
137 canvas->clear(SK_ColorTRANSPARENT); | 137 canvas->clear(SK_ColorTRANSPARENT); |
138 for (int i = 0; i < kCSSTestColorsCount; ++i) { | 138 for (int i = 0; i < kCSSTestColorsCount; ++i) { |
139 SkPaint paint; | 139 SkPaint paint; |
140 paint.setColor(kCSSTestColors[i]); | 140 paint.setColor(kCSSTestColors[i]); |
141 canvas->drawRect( | 141 canvas->drawRect( |
142 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); | 142 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); |
143 } | 143 } |
144 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); | 144 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); |
145 layer->SetIsDrawable(true); | 145 layer->SetIsDrawable(true); |
146 layer->SetBounds(gfx::Size(width, height)); | 146 layer->SetBounds(gfx::Size(width, height)); |
147 skia::RefPtr<const SkImage> image = | 147 skia::RefPtr<const SkImage> image = |
148 skia::AdoptRef(backing_store->newImageSnapshot()); | 148 skia::AdoptRef(backing_store->newImageSnapshot()); |
149 layer->SetImage(std::move(image)); | 149 layer->SetImage(std::move(image)); |
150 return layer; | 150 return layer; |
151 } | 151 } |
152 | 152 |
153 void SetupMaskLayer(scoped_refptr<Layer> layer) { | 153 void SetupMaskLayer(scoped_refptr<Layer> layer) { |
154 const int kMaskOffset = 2; | 154 const int kMaskOffset = 2; |
155 gfx::Size bounds = layer->bounds(); | 155 gfx::Size bounds = layer->bounds(); |
156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); |
157 mask->SetIsDrawable(true); | 157 mask->SetIsDrawable(true); |
158 mask->SetIsMask(true); | 158 mask->SetIsMask(true); |
159 mask->SetBounds(bounds); | 159 mask->SetBounds(bounds); |
160 | 160 |
161 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 161 sk_sp<SkSurface> surface = |
162 SkSurface::NewRasterN32Premul(bounds.width(), bounds.height())); | 162 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); |
163 SkCanvas* canvas = surface->getCanvas(); | 163 SkCanvas* canvas = surface->getCanvas(); |
164 SkPaint paint; | 164 SkPaint paint; |
165 paint.setColor(SK_ColorWHITE); | 165 paint.setColor(SK_ColorWHITE); |
166 canvas->clear(SK_ColorTRANSPARENT); | 166 canvas->clear(SK_ColorTRANSPARENT); |
167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, | 167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, |
168 bounds.width() - kMaskOffset * 2, | 168 bounds.width() - kMaskOffset * 2, |
169 bounds.height() - kMaskOffset * 2), | 169 bounds.height() - kMaskOffset * 2), |
170 paint); | 170 paint); |
171 skia::RefPtr<const SkImage> image = | 171 skia::RefPtr<const SkImage> image = |
172 skia::AdoptRef(surface->newImageSnapshot()); | 172 skia::AdoptRef(surface->newImageSnapshot()); |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 RunBlendingWithRenderPass( | 496 RunBlendingWithRenderPass( |
497 GL_ZERO_COPY_RECT_DRAW, | 497 GL_ZERO_COPY_RECT_DRAW, |
498 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 498 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
499 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); | 499 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); |
500 } | 500 } |
501 | 501 |
502 } // namespace | 502 } // namespace |
503 } // namespace cc | 503 } // namespace cc |
504 | 504 |
505 #endif // OS_ANDROID | 505 #endif // OS_ANDROID |
OLD | NEW |