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

Side by Side Diff: gm/image_shader.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/image_pict.cpp ('k') | gm/imagealphathreshold.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 2015 Google Inc. 2 * Copyright 2015 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 "SkData.h" 10 #include "SkData.h"
11 #include "SkImage.h" 11 #include "SkImage.h"
12 #include "SkPictureRecorder.h" 12 #include "SkPictureRecorder.h"
13 #include "SkSurface.h" 13 #include "SkSurface.h"
14 14
15 static void draw_something(SkCanvas* canvas, const SkRect& bounds) { 15 static void draw_something(SkCanvas* canvas, const SkRect& bounds) {
16 SkPaint paint; 16 SkPaint paint;
17 paint.setAntiAlias(true); 17 paint.setAntiAlias(true);
18 paint.setColor(SK_ColorRED); 18 paint.setColor(SK_ColorRED);
19 paint.setStyle(SkPaint::kStroke_Style); 19 paint.setStyle(SkPaint::kStroke_Style);
20 paint.setStrokeWidth(10); 20 paint.setStrokeWidth(10);
21 canvas->drawRect(bounds, paint); 21 canvas->drawRect(bounds, paint);
22 paint.setStyle(SkPaint::kFill_Style); 22 paint.setStyle(SkPaint::kFill_Style);
23 paint.setColor(SK_ColorBLUE); 23 paint.setColor(SK_ColorBLUE);
24 canvas->drawOval(bounds, paint); 24 canvas->drawOval(bounds, paint);
25 } 25 }
26 26
27 typedef sk_sp<SkImage> (*ImageMakerProc)(GrContext*, SkPicture*, const SkImageIn fo&); 27 typedef sk_sp<SkImage> (*ImageMakerProc)(GrContext*, SkPicture*, const SkImageIn fo&);
28 28
29 static sk_sp<SkImage> make_raster(GrContext*, SkPicture* pic, const SkImageInfo& info) { 29 static sk_sp<SkImage> make_raster(GrContext*, SkPicture* pic, const SkImageInfo& info) {
30 SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info)); 30 auto surface(SkSurface::MakeRaster(info));
31 surface->getCanvas()->clear(0); 31 surface->getCanvas()->clear(0);
32 surface->getCanvas()->drawPicture(pic); 32 surface->getCanvas()->drawPicture(pic);
33 return surface->makeImageSnapshot(); 33 return surface->makeImageSnapshot();
34 } 34 }
35 35
36 static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImage Info& info) { 36 static sk_sp<SkImage> make_texture(GrContext* ctx, SkPicture* pic, const SkImage Info& info) {
37 if (!ctx) { 37 if (!ctx) {
38 return nullptr; 38 return nullptr;
39 } 39 }
40 SkAutoTUnref<SkSurface> surface(SkSurface::NewRenderTarget(ctx, SkBudgeted:: kNo, 40 auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info));
41 info, 0));
42 surface->getCanvas()->clear(0); 41 surface->getCanvas()->clear(0);
43 surface->getCanvas()->drawPicture(pic); 42 surface->getCanvas()->drawPicture(pic);
44 return surface->makeImageSnapshot(); 43 return surface->makeImageSnapshot();
45 } 44 }
46 45
47 static sk_sp<SkImage> make_pict_gen(GrContext*, SkPicture* pic, const SkImageInf o& info) { 46 static sk_sp<SkImage> make_pict_gen(GrContext*, SkPicture* pic, const SkImageInf o& info) {
48 return SkImage::MakeFromPicture(sk_ref_sp(pic), info.dimensions(), nullptr, nullptr); 47 return SkImage::MakeFromPicture(sk_ref_sp(pic), info.dimensions(), nullptr, nullptr);
49 } 48 }
50 49
51 static sk_sp<SkImage> make_encode_gen(GrContext* ctx, SkPicture* pic, const SkIm ageInfo& info) { 50 static sk_sp<SkImage> make_encode_gen(GrContext* ctx, SkPicture* pic, const SkIm ageInfo& info) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 118 }
120 canvas->translate(120, 0); 119 canvas->translate(120, 0);
121 } 120 }
122 } 121 }
123 122
124 private: 123 private:
125 typedef skiagm::GM INHERITED; 124 typedef skiagm::GM INHERITED;
126 }; 125 };
127 DEF_GM( return new ImageShaderGM; ) 126 DEF_GM( return new ImageShaderGM; )
128 127
OLDNEW
« no previous file with comments | « gm/image_pict.cpp ('k') | gm/imagealphathreshold.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698