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/paint/paint_image.h" |
9 #include "cc/test/layer_tree_pixel_resource_test.h" | 10 #include "cc/test/layer_tree_pixel_resource_test.h" |
10 #include "cc/test/pixel_comparator.h" | 11 #include "cc/test/pixel_comparator.h" |
11 #include "third_party/skia/include/core/SkImage.h" | 12 #include "third_party/skia/include/core/SkImage.h" |
12 #include "third_party/skia/include/core/SkSurface.h" | 13 #include "third_party/skia/include/core/SkSurface.h" |
13 | 14 |
14 #if !defined(OS_ANDROID) | 15 #if !defined(OS_ANDROID) |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 namespace { | 18 namespace { |
18 | 19 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 canvas->clear(SK_ColorTRANSPARENT); | 139 canvas->clear(SK_ColorTRANSPARENT); |
139 for (int i = 0; i < kCSSTestColorsCount; ++i) { | 140 for (int i = 0; i < kCSSTestColorsCount; ++i) { |
140 SkPaint paint; | 141 SkPaint paint; |
141 paint.setColor(kCSSTestColors[i]); | 142 paint.setColor(kCSSTestColors[i]); |
142 canvas->drawRect( | 143 canvas->drawRect( |
143 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); | 144 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); |
144 } | 145 } |
145 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); | 146 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); |
146 layer->SetIsDrawable(true); | 147 layer->SetIsDrawable(true); |
147 layer->SetBounds(gfx::Size(width, height)); | 148 layer->SetBounds(gfx::Size(width, height)); |
148 layer->SetImage(backing_store->makeImageSnapshot()); | 149 layer->SetImage(PaintImage(backing_store->makeImageSnapshot())); |
149 return layer; | 150 return layer; |
150 } | 151 } |
151 | 152 |
152 void SetupMaskLayer(scoped_refptr<Layer> layer) { | 153 void SetupMaskLayer(scoped_refptr<Layer> layer) { |
153 const int kMaskOffset = 2; | 154 const int kMaskOffset = 2; |
154 gfx::Size bounds = layer->bounds(); | 155 gfx::Size bounds = layer->bounds(); |
155 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); |
156 mask->SetIsDrawable(true); | 157 mask->SetIsDrawable(true); |
157 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); | 158 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); |
158 mask->SetBounds(bounds); | 159 mask->SetBounds(bounds); |
159 | 160 |
160 sk_sp<SkSurface> surface = | 161 sk_sp<SkSurface> surface = |
161 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); | 162 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); |
162 SkCanvas* canvas = surface->getCanvas(); | 163 SkCanvas* canvas = surface->getCanvas(); |
163 SkPaint paint; | 164 SkPaint paint; |
164 paint.setColor(SK_ColorWHITE); | 165 paint.setColor(SK_ColorWHITE); |
165 canvas->clear(SK_ColorTRANSPARENT); | 166 canvas->clear(SK_ColorTRANSPARENT); |
166 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, | 167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, |
167 bounds.width() - kMaskOffset * 2, | 168 bounds.width() - kMaskOffset * 2, |
168 bounds.height() - kMaskOffset * 2), | 169 bounds.height() - kMaskOffset * 2), |
169 paint); | 170 paint); |
170 mask->SetImage(surface->makeImageSnapshot()); | 171 mask->SetImage(PaintImage(surface->makeImageSnapshot())); |
171 layer->SetMaskLayer(mask.get()); | 172 layer->SetMaskLayer(mask.get()); |
172 } | 173 } |
173 | 174 |
174 void SetupColorMatrix(scoped_refptr<Layer> layer) { | 175 void SetupColorMatrix(scoped_refptr<Layer> layer) { |
175 FilterOperations filter_operations; | 176 FilterOperations filter_operations; |
176 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); | 177 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); |
177 layer->SetFilters(filter_operations); | 178 layer->SetFilters(filter_operations); |
178 } | 179 } |
179 | 180 |
180 void CreateBlendingColorLayers(int lane_width, | 181 void CreateBlendingColorLayers(int lane_width, |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 RunBlendingWithRenderPass( | 501 RunBlendingWithRenderPass( |
501 GL_ZERO_COPY_RECT_DRAW, | 502 GL_ZERO_COPY_RECT_DRAW, |
502 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 503 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
503 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); | 504 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); |
504 } | 505 } |
505 | 506 |
506 } // namespace | 507 } // namespace |
507 } // namespace cc | 508 } // namespace cc |
508 | 509 |
509 #endif // OS_ANDROID | 510 #endif // OS_ANDROID |
OLD | NEW |