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

Side by Side Diff: gm/verylargebitmap.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/transparency.cpp ('k') | gm/xfermodes3.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 2012 Google Inc. 2 * Copyright 2012 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkGradientShader.h" 10 #include "SkGradientShader.h"
11 #include "SkPath.h" 11 #include "SkPath.h"
12 #include "SkPictureRecorder.h" 12 #include "SkPictureRecorder.h"
13 #include "SkSurface.h" 13 #include "SkSurface.h"
14 14
15 static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) { 15 static void draw(SkCanvas* canvas, int width, int height, SkColor colors[2]) {
16 const SkPoint center = { SkIntToScalar(width)/2, SkIntToScalar(height)/2 }; 16 const SkPoint center = { SkIntToScalar(width)/2, SkIntToScalar(height)/2 };
17 const SkScalar radius = 40; 17 const SkScalar radius = 40;
18 SkPaint paint; 18 SkPaint paint;
19 paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, nullptr , 2, 19 paint.setShader(SkGradientShader::MakeRadial(center, radius, colors, nullptr , 2,
20 SkShader::kMirror_TileMode)); 20 SkShader::kMirror_TileMode));
21 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 21 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
22 canvas->drawPaint(paint); 22 canvas->drawPaint(paint);
23 } 23 }
24 24
25 static sk_sp<SkImage> make_raster_image(int width, int height, SkColor colors[2] ) { 25 static sk_sp<SkImage> make_raster_image(int width, int height, SkColor colors[2] ) {
26 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(width, height) ); 26 auto surface(SkSurface::MakeRasterN32Premul(width, height));
27 draw(surface->getCanvas(), width, height, colors); 27 draw(surface->getCanvas(), width, height, colors);
28 return surface->makeImageSnapshot(); 28 return surface->makeImageSnapshot();
29 } 29 }
30 30
31 static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2 ]) { 31 static sk_sp<SkImage> make_picture_image(int width, int height, SkColor colors[2 ]) {
32 SkPictureRecorder recorder; 32 SkPictureRecorder recorder;
33 draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height, colors); 33 draw(recorder.beginRecording(SkRect::MakeIWH(width, height)), width, height, colors);
34 return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(), 34 return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
35 SkISize::Make(width, height), nullptr, nullp tr); 35 SkISize::Make(width, height), nullptr, nullp tr);
36 } 36 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // since it has a 64K limit on x,y coordinates... (but gpu should succee d) 114 // since it has a 64K limit on x,y coordinates... (but gpu should succee d)
115 show_image(canvas, veryBig, small, colors, fProc); 115 show_image(canvas, veryBig, small, colors, fProc);
116 } 116 }
117 117
118 private: 118 private:
119 typedef skiagm::GM INHERITED; 119 typedef skiagm::GM INHERITED;
120 }; 120 };
121 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); ) 121 DEF_GM( return new VeryLargeBitmapGM(make_raster_image, "bitmap"); )
122 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); ) 122 DEF_GM( return new VeryLargeBitmapGM(make_picture_image, "_picture_image"); )
123 123
OLDNEW
« no previous file with comments | « gm/transparency.cpp ('k') | gm/xfermodes3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698