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

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

Issue 2509983004: Revert "Change call-sites now that SkCanvas is not ref-counted" (Closed)
Patch Set: Created 4 years, 1 month 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "cc/layers/content_layer_client.h" 8 #include "cc/layers/content_layer_client.h"
9 #include "cc/layers/picture_image_layer.h" 9 #include "cc/layers/picture_image_layer.h"
10 #include "cc/layers/picture_layer.h" 10 #include "cc/layers/picture_layer.h"
(...skipping 22 matching lines...) Expand all
33 ~MaskContentLayerClient() override {} 33 ~MaskContentLayerClient() override {}
34 34
35 bool FillsBoundsCompletely() const override { return false; } 35 bool FillsBoundsCompletely() const override { return false; }
36 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } 36 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
37 37
38 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } 38 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); }
39 39
40 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 40 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
41 PaintingControlSetting picture_control) override { 41 PaintingControlSetting picture_control) override {
42 SkPictureRecorder recorder; 42 SkPictureRecorder recorder;
43 SkCanvas* canvas = 43 sk_sp<SkCanvas> canvas = sk_ref_sp(
44 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); 44 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))));
45 45
46 SkPaint paint; 46 SkPaint paint;
47 paint.setStyle(SkPaint::kStroke_Style); 47 paint.setStyle(SkPaint::kStroke_Style);
48 paint.setStrokeWidth(SkIntToScalar(2)); 48 paint.setStrokeWidth(SkIntToScalar(2));
49 paint.setColor(SK_ColorWHITE); 49 paint.setColor(SK_ColorWHITE);
50 50
51 canvas->clear(SK_ColorTRANSPARENT); 51 canvas->clear(SK_ColorTRANSPARENT);
52 gfx::Rect inset_rect(bounds_); 52 gfx::Rect inset_rect(bounds_);
53 while (!inset_rect.IsEmpty()) { 53 while (!inset_rect.IsEmpty()) {
54 inset_rect.Inset(3, 3, 2, 2); 54 inset_rect.Inset(3, 3, 2, 2);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SkColor color, 156 SkColor color,
157 bool vertical) 157 bool vertical)
158 : bounds_(bounds), color_(color), vertical_(vertical) {} 158 : bounds_(bounds), color_(color), vertical_(vertical) {}
159 ~CheckerContentLayerClient() override {} 159 ~CheckerContentLayerClient() override {}
160 bool FillsBoundsCompletely() const override { return false; } 160 bool FillsBoundsCompletely() const override { return false; }
161 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } 161 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
162 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } 162 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); }
163 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 163 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
164 PaintingControlSetting picture_control) override { 164 PaintingControlSetting picture_control) override {
165 SkPictureRecorder recorder; 165 SkPictureRecorder recorder;
166 SkCanvas* canvas = 166 sk_sp<SkCanvas> canvas = sk_ref_sp(
167 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); 167 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))));
168 168
169 SkPaint paint; 169 SkPaint paint;
170 paint.setStyle(SkPaint::kStroke_Style); 170 paint.setStyle(SkPaint::kStroke_Style);
171 paint.setStrokeWidth(SkIntToScalar(4)); 171 paint.setStrokeWidth(SkIntToScalar(4));
172 paint.setColor(color_); 172 paint.setColor(color_);
173 canvas->clear(SK_ColorTRANSPARENT); 173 canvas->clear(SK_ColorTRANSPARENT);
174 if (vertical_) { 174 if (vertical_) {
175 for (int i = 4; i < bounds_.width(); i += 16) { 175 for (int i = 4; i < bounds_.width(); i += 16) {
176 canvas->drawLine(i, 0, i, bounds_.height(), paint); 176 canvas->drawLine(i, 0, i, bounds_.height(), paint);
177 } 177 }
(...skipping 22 matching lines...) Expand all
200 public: 200 public:
201 explicit CircleContentLayerClient(const gfx::Size& bounds) 201 explicit CircleContentLayerClient(const gfx::Size& bounds)
202 : bounds_(bounds) {} 202 : bounds_(bounds) {}
203 ~CircleContentLayerClient() override {} 203 ~CircleContentLayerClient() override {}
204 bool FillsBoundsCompletely() const override { return false; } 204 bool FillsBoundsCompletely() const override { return false; }
205 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; } 205 size_t GetApproximateUnsharedMemoryUsage() const override { return 0; }
206 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); } 206 gfx::Rect PaintableRegion() override { return gfx::Rect(bounds_); }
207 scoped_refptr<DisplayItemList> PaintContentsToDisplayList( 207 scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
208 PaintingControlSetting picture_control) override { 208 PaintingControlSetting picture_control) override {
209 SkPictureRecorder recorder; 209 SkPictureRecorder recorder;
210 SkCanvas* canvas = 210 sk_sp<SkCanvas> canvas = sk_ref_sp(
211 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))); 211 recorder.beginRecording(gfx::RectToSkRect(gfx::Rect(bounds_))));
212 212
213 SkPaint paint; 213 SkPaint paint;
214 paint.setStyle(SkPaint::kFill_Style); 214 paint.setStyle(SkPaint::kFill_Style);
215 paint.setColor(SK_ColorWHITE); 215 paint.setColor(SK_ColorWHITE);
216 canvas->clear(SK_ColorTRANSPARENT); 216 canvas->clear(SK_ColorTRANSPARENT);
217 canvas->drawCircle(bounds_.width() / 2, 217 canvas->drawCircle(bounds_.width() / 2,
218 bounds_.height() / 2, 218 bounds_.height() / 2,
219 bounds_.width() / 4, 219 bounds_.width() / 4,
220 paint); 220 paint);
221 221
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 340
341 RunPixelResourceTest(background, 341 RunPixelResourceTest(background,
342 base::FilePath( 342 base::FilePath(
343 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); 343 FILE_PATH_LITERAL("mask_of_layer_with_blend.png")));
344 } 344 }
345 345
346 } // namespace 346 } // namespace
347 } // namespace cc 347 } // namespace cc
348 348
349 #endif // !defined(OS_ANDROID) 349 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « cc/test/solid_color_content_layer_client.cc ('k') | cc/trees/layer_tree_host_pixeltest_tiles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698