| 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/paint/paint_image.h" |
| 10 #include "cc/test/layer_tree_pixel_resource_test.h" | 10 #include "cc/test/layer_tree_pixel_resource_test.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 canvas->clear(SK_ColorTRANSPARENT); | 139 canvas->clear(SK_ColorTRANSPARENT); |
| 140 for (int i = 0; i < kCSSTestColorsCount; ++i) { | 140 for (int i = 0; i < kCSSTestColorsCount; ++i) { |
| 141 SkPaint paint; | 141 SkPaint paint; |
| 142 paint.setColor(kCSSTestColors[i]); | 142 paint.setColor(kCSSTestColors[i]); |
| 143 canvas->drawRect( | 143 canvas->drawRect( |
| 144 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); | 144 SkRect::MakeXYWH(0, i * kLaneHeight, kLaneWidth, kLaneHeight), paint); |
| 145 } | 145 } |
| 146 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); | 146 scoped_refptr<PictureImageLayer> layer = PictureImageLayer::Create(); |
| 147 layer->SetIsDrawable(true); | 147 layer->SetIsDrawable(true); |
| 148 layer->SetBounds(gfx::Size(width, height)); | 148 layer->SetBounds(gfx::Size(width, height)); |
| 149 layer->SetImage(PaintImage(PaintImage::GetNextId(), | 149 layer->SetImage(PaintImage(backing_store->makeImageSnapshot())); |
| 150 backing_store->makeImageSnapshot())); | |
| 151 return layer; | 150 return layer; |
| 152 } | 151 } |
| 153 | 152 |
| 154 void SetupMaskLayer(scoped_refptr<Layer> layer) { | 153 void SetupMaskLayer(scoped_refptr<Layer> layer) { |
| 155 const int kMaskOffset = 2; | 154 const int kMaskOffset = 2; |
| 156 gfx::Size bounds = layer->bounds(); | 155 gfx::Size bounds = layer->bounds(); |
| 157 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); | 156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); |
| 158 mask->SetIsDrawable(true); | 157 mask->SetIsDrawable(true); |
| 159 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); | 158 mask->SetLayerMaskType(Layer::LayerMaskType::MULTI_TEXTURE_MASK); |
| 160 mask->SetBounds(bounds); | 159 mask->SetBounds(bounds); |
| 161 | 160 |
| 162 sk_sp<SkSurface> surface = | 161 sk_sp<SkSurface> surface = |
| 163 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); | 162 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); |
| 164 SkCanvas* canvas = surface->getCanvas(); | 163 SkCanvas* canvas = surface->getCanvas(); |
| 165 SkPaint paint; | 164 SkPaint paint; |
| 166 paint.setColor(SK_ColorWHITE); | 165 paint.setColor(SK_ColorWHITE); |
| 167 canvas->clear(SK_ColorTRANSPARENT); | 166 canvas->clear(SK_ColorTRANSPARENT); |
| 168 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, | 167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, |
| 169 bounds.width() - kMaskOffset * 2, | 168 bounds.width() - kMaskOffset * 2, |
| 170 bounds.height() - kMaskOffset * 2), | 169 bounds.height() - kMaskOffset * 2), |
| 171 paint); | 170 paint); |
| 172 mask->SetImage( | 171 mask->SetImage(PaintImage(surface->makeImageSnapshot())); |
| 173 PaintImage(PaintImage::GetNextId(), surface->makeImageSnapshot())); | |
| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 RunBlendingWithRenderPass( | 501 RunBlendingWithRenderPass( |
| 504 GL_ZERO_COPY_RECT_DRAW, | 502 GL_ZERO_COPY_RECT_DRAW, |
| 505 FILE_PATH_LITERAL("blending_render_pass_mask.png"), | 503 FILE_PATH_LITERAL("blending_render_pass_mask.png"), |
| 506 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); | 504 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); |
| 507 } | 505 } |
| 508 | 506 |
| 509 } // namespace | 507 } // namespace |
| 510 } // namespace cc | 508 } // namespace cc |
| 511 | 509 |
| 512 #endif // OS_ANDROID | 510 #endif // OS_ANDROID |
| OLD | NEW |