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 "cc/layers/picture_image_layer.h" | 5 #include "cc/layers/picture_image_layer.h" |
6 #include "cc/layers/solid_color_layer.h" | 6 #include "cc/layers/solid_color_layer.h" |
7 #include "cc/test/layer_tree_pixel_resource_test.h" | 7 #include "cc/test/layer_tree_pixel_resource_test.h" |
8 #include "cc/test/pixel_comparator.h" | 8 #include "cc/test/pixel_comparator.h" |
9 #include "third_party/skia/include/core/SkImage.h" | 9 #include "third_party/skia/include/core/SkImage.h" |
10 #include "third_party/skia/include/core/SkSurface.h" | 10 #include "third_party/skia/include/core/SkSurface.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 paint.setColor(kCSSTestColors[i]); | 138 paint.setColor(kCSSTestColors[i]); |
139 canvas->drawRect( | 139 canvas->drawRect( |
140 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); | 140 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); |
141 } | 141 } |
142 scoped_refptr<PictureImageLayer> layer = | 142 scoped_refptr<PictureImageLayer> layer = |
143 PictureImageLayer::Create(layer_settings()); | 143 PictureImageLayer::Create(layer_settings()); |
144 layer->SetIsDrawable(true); | 144 layer->SetIsDrawable(true); |
145 layer->SetBounds(gfx::Size(width, height)); | 145 layer->SetBounds(gfx::Size(width, height)); |
146 skia::RefPtr<const SkImage> image = | 146 skia::RefPtr<const SkImage> image = |
147 skia::AdoptRef(backing_store->newImageSnapshot()); | 147 skia::AdoptRef(backing_store->newImageSnapshot()); |
148 layer->SetImage(image.Pass()); | 148 layer->SetImage(std::move(image)); |
149 return layer; | 149 return layer; |
150 } | 150 } |
151 | 151 |
152 void SetupMaskLayer(scoped_refptr<Layer> layer) { | 152 void SetupMaskLayer(scoped_refptr<Layer> layer) { |
153 const int kMaskOffset = 2; | 153 const int kMaskOffset = 2; |
154 gfx::Size bounds = layer->bounds(); | 154 gfx::Size bounds = layer->bounds(); |
155 scoped_refptr<PictureImageLayer> mask = | 155 scoped_refptr<PictureImageLayer> mask = |
156 PictureImageLayer::Create(layer_settings()); | 156 PictureImageLayer::Create(layer_settings()); |
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 skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
162 SkSurface::NewRasterN32Premul(bounds.width(), bounds.height())); | 162 SkSurface::NewRasterN32Premul(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()); |
173 mask->SetImage(image.Pass()); | 173 mask->SetImage(std::move(image)); |
174 layer->SetMaskLayer(mask.get()); | 174 layer->SetMaskLayer(mask.get()); |
175 } | 175 } |
176 | 176 |
177 void SetupColorMatrix(scoped_refptr<Layer> layer) { | 177 void SetupColorMatrix(scoped_refptr<Layer> layer) { |
178 FilterOperations filter_operations; | 178 FilterOperations filter_operations; |
179 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); | 179 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); |
180 layer->SetFilters(filter_operations); | 180 layer->SetFilters(filter_operations); |
181 } | 181 } |
182 | 182 |
183 void CreateBlendingColorLayers(int lane_width, | 183 void CreateBlendingColorLayers(int lane_width, |
(...skipping 312 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 |