Chromium Code Reviews| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 sk_sp<const SkImage> image = backing_store->makeImageSnapshot(); |
| 148 skia::AdoptRef(backing_store->newImageSnapshot()); | 148 layer->SetImage(skia::SharePtr(image)); |
|
danakj
2016/04/14 19:37:33
move image
| |
| 149 layer->SetImage(std::move(image)); | |
| 150 return layer; | 149 return layer; |
| 151 } | 150 } |
| 152 | 151 |
| 153 void SetupMaskLayer(scoped_refptr<Layer> layer) { | 152 void SetupMaskLayer(scoped_refptr<Layer> layer) { |
| 154 const int kMaskOffset = 2; | 153 const int kMaskOffset = 2; |
| 155 gfx::Size bounds = layer->bounds(); | 154 gfx::Size bounds = layer->bounds(); |
| 156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 155 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); |
| 157 mask->SetIsDrawable(true); | 156 mask->SetIsDrawable(true); |
| 158 mask->SetIsMask(true); | 157 mask->SetIsMask(true); |
| 159 mask->SetBounds(bounds); | 158 mask->SetBounds(bounds); |
| 160 | 159 |
| 161 sk_sp<SkSurface> surface = | 160 sk_sp<SkSurface> surface = |
| 162 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); | 161 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); |
| 163 SkCanvas* canvas = surface->getCanvas(); | 162 SkCanvas* canvas = surface->getCanvas(); |
| 164 SkPaint paint; | 163 SkPaint paint; |
| 165 paint.setColor(SK_ColorWHITE); | 164 paint.setColor(SK_ColorWHITE); |
| 166 canvas->clear(SK_ColorTRANSPARENT); | 165 canvas->clear(SK_ColorTRANSPARENT); |
| 167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, | 166 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, |
| 168 bounds.width() - kMaskOffset * 2, | 167 bounds.width() - kMaskOffset * 2, |
| 169 bounds.height() - kMaskOffset * 2), | 168 bounds.height() - kMaskOffset * 2), |
| 170 paint); | 169 paint); |
| 171 skia::RefPtr<const SkImage> image = | 170 sk_sp<const SkImage> image = surface->makeImageSnapshot(); |
| 172 skia::AdoptRef(surface->newImageSnapshot()); | 171 mask->SetImage(skia::SharePtr(image)); |
|
danakj
2016/04/14 19:37:33
move image
| |
| 173 mask->SetImage(std::move(image)); | |
| 174 layer->SetMaskLayer(mask.get()); | 172 layer->SetMaskLayer(mask.get()); |
| 175 } | 173 } |
| 176 | 174 |
| 177 void SetupColorMatrix(scoped_refptr<Layer> layer) { | 175 void SetupColorMatrix(scoped_refptr<Layer> layer) { |
| 178 FilterOperations filter_operations; | 176 FilterOperations filter_operations; |
| 179 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); | 177 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); |
| 180 layer->SetFilters(filter_operations); | 178 layer->SetFilters(filter_operations); |
| 181 } | 179 } |
| 182 | 180 |
| 183 void CreateBlendingColorLayers(int lane_width, | 181 void CreateBlendingColorLayers(int lane_width, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 496 RunBlendingWithRenderPass( | 494 RunBlendingWithRenderPass( |
| 497 GL_ZERO_COPY_RECT_DRAW, | 495 GL_ZERO_COPY_RECT_DRAW, |
| 498 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 496 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
| 499 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); | 497 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); |
| 500 } | 498 } |
| 501 | 499 |
| 502 } // namespace | 500 } // namespace |
| 503 } // namespace cc | 501 } // namespace cc |
| 504 | 502 |
| 505 #endif // OS_ANDROID | 503 #endif // OS_ANDROID |
| OLD | NEW |