Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_blending.cc

Issue 1869753003: Replace many skia::RefPtr with sk_sp<> in cc/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fmalita review - deconstify sk_sp<>s Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 layer->SetImage(skia::SharePtr(backing_store->makeImageSnapshot()));
f(malita) 2016/04/21 15:45:47 nit: in this particular case I think they're funct
tomhudson 2016/04/25 20:20:51 I don't understand - AdoptRef *does not* increment
f(malita) 2016/04/27 14:00:41 Yes (functionally), but the increment is front-loa
148 skia::AdoptRef(backing_store->newImageSnapshot());
149 layer->SetImage(std::move(image));
150 return layer; 148 return layer;
151 } 149 }
152 150
153 void SetupMaskLayer(scoped_refptr<Layer> layer) { 151 void SetupMaskLayer(scoped_refptr<Layer> layer) {
154 const int kMaskOffset = 2; 152 const int kMaskOffset = 2;
155 gfx::Size bounds = layer->bounds(); 153 gfx::Size bounds = layer->bounds();
156 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); 154 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
157 mask->SetIsDrawable(true); 155 mask->SetIsDrawable(true);
158 mask->SetIsMask(true); 156 mask->SetIsMask(true);
159 mask->SetBounds(bounds); 157 mask->SetBounds(bounds);
160 158
161 sk_sp<SkSurface> surface = 159 sk_sp<SkSurface> surface =
162 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height()); 160 SkSurface::MakeRasterN32Premul(bounds.width(), bounds.height());
163 SkCanvas* canvas = surface->getCanvas(); 161 SkCanvas* canvas = surface->getCanvas();
164 SkPaint paint; 162 SkPaint paint;
165 paint.setColor(SK_ColorWHITE); 163 paint.setColor(SK_ColorWHITE);
166 canvas->clear(SK_ColorTRANSPARENT); 164 canvas->clear(SK_ColorTRANSPARENT);
167 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset, 165 canvas->drawRect(SkRect::MakeXYWH(kMaskOffset, kMaskOffset,
168 bounds.width() - kMaskOffset * 2, 166 bounds.width() - kMaskOffset * 2,
169 bounds.height() - kMaskOffset * 2), 167 bounds.height() - kMaskOffset * 2),
170 paint); 168 paint);
171 skia::RefPtr<const SkImage> image = 169 mask->SetImage(skia::SharePtr(surface->makeImageSnapshot()));
f(malita) 2016/04/21 15:45:47 nit: ditto
172 skia::AdoptRef(surface->newImageSnapshot());
173 mask->SetImage(std::move(image));
174 layer->SetMaskLayer(mask.get()); 170 layer->SetMaskLayer(mask.get());
175 } 171 }
176 172
177 void SetupColorMatrix(scoped_refptr<Layer> layer) { 173 void SetupColorMatrix(scoped_refptr<Layer> layer) {
178 FilterOperations filter_operations; 174 FilterOperations filter_operations;
179 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f)); 175 filter_operations.Append(FilterOperation::CreateSepiaFilter(.001f));
180 layer->SetFilters(filter_operations); 176 layer->SetFilters(filter_operations);
181 } 177 }
182 178
183 void CreateBlendingColorLayers(int lane_width, 179 void CreateBlendingColorLayers(int lane_width,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 RunBlendingWithRenderPass( 492 RunBlendingWithRenderPass(
497 GL_ZERO_COPY_RECT_DRAW, 493 GL_ZERO_COPY_RECT_DRAW,
498 FILE_PATH_LITERAL("blending_render_pass_mask.png"), 494 FILE_PATH_LITERAL("blending_render_pass_mask.png"),
499 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders); 495 kUseMasks | kUseAntialiasing | kUseColorMatrix | kForceShaders);
500 } 496 }
501 497
502 } // namespace 498 } // namespace
503 } // namespace cc 499 } // namespace cc
504 500
505 #endif // OS_ANDROID 501 #endif // OS_ANDROID
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698