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

Side by Side Diff: gm/multipicturedraw.cpp

Issue 1817383002: switch surface to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « gm/mipmap.cpp ('k') | gm/ninepatchstretch.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "SkColorFilter.h" 10 #include "SkColorFilter.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 canvas->restore(); 234 canvas->restore();
235 235
236 pic = make_sub_picture(pic.get()); 236 pic = make_sub_picture(pic.get());
237 237
238 canvas->translate(0, 1.5f * kTriSide / kRoot3); 238 canvas->translate(0, 1.5f * kTriSide / kRoot3);
239 } 239 }
240 240
241 return recorder.finishRecordingAsPicture(); 241 return recorder.finishRecordingAsPicture();
242 } 242 }
243 243
244 static SkSurface* create_compat_surface(SkCanvas* canvas, int width, int height) { 244 static sk_sp<SkSurface> create_compat_surface(SkCanvas* canvas, int width, int h eight) {
245 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); 245 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height);
246 246
247 SkSurface* surface = canvas->newSurface(info); 247 auto surface = canvas->makeSurface(info);
248 if (nullptr == surface) { 248 if (nullptr == surface) {
249 // picture canvas returns nullptr so fall back to raster 249 // picture canvas returns nullptr so fall back to raster
250 surface = SkSurface::NewRaster(info); 250 surface = SkSurface::MakeRaster(info);
251 } 251 }
252
253 return surface; 252 return surface;
254 } 253 }
255 254
256 // This class stores the information required to compose all the result 255 // This class stores the information required to compose all the result
257 // fragments potentially generated by the MultiPictureDraw object 256 // fragments potentially generated by the MultiPictureDraw object
258 class ComposeStep { 257 class ComposeStep {
259 public: 258 public:
260 ComposeStep() : fSurf(nullptr), fX(0.0f), fY(0.0f), fPaint(nullptr) { } 259 ComposeStep() : fX(0.0f), fY(0.0f), fPaint(nullptr) { }
261 ~ComposeStep() { 260 ~ComposeStep() {
262 SkSafeUnref(fSurf);
263 delete fPaint; 261 delete fPaint;
264 } 262 }
265 263
266 SkSurface* fSurf; 264 sk_sp<SkSurface> fSurf;
267 SkScalar fX; 265 SkScalar fX;
268 SkScalar fY; 266 SkScalar fY;
269 SkPaint* fPaint; 267 SkPaint* fPaint;
270 }; 268 };
271 269
272 typedef void (*PFContentMtd)(SkCanvas* canvas, const SkPicture* pictures[kNumPic tures]); 270 typedef void (*PFContentMtd)(SkCanvas* canvas, const SkPicture* pictures[kNumPic tures]);
273 271
274 // Just a single picture with no clip 272 // Just a single picture with no clip
275 static void no_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) { 273 static void no_clip(SkCanvas* canvas, const SkPicture* pictures[kNumPictures]) {
276 canvas->drawPicture(pictures[0]); 274 canvas->drawPicture(pictures[0]);
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 MultiPictureDraw::kTiled_Layout);) 563 MultiPictureDraw::kTiled_Layout);)
566 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content, 564 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kPathClipMulti_Content,
567 MultiPictureDraw::kTiled_Layout);) 565 MultiPictureDraw::kTiled_Layout);)
568 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Conte nt, 566 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kInvPathClipMulti_Conte nt,
569 MultiPictureDraw::kTiled_Layout);) 567 MultiPictureDraw::kTiled_Layout);)
570 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content, 568 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kSierpinski_Content,
571 MultiPictureDraw::kTiled_Layout);) 569 MultiPictureDraw::kTiled_Layout);)
572 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content, 570 DEF_GM(return new MultiPictureDraw(MultiPictureDraw::kBigLayer_Content,
573 MultiPictureDraw::kTiled_Layout);) 571 MultiPictureDraw::kTiled_Layout);)
574 } 572 }
OLDNEW
« no previous file with comments | « gm/mipmap.cpp ('k') | gm/ninepatchstretch.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698