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

Unified Diff: gm/image.cpp

Issue 1811703002: return pictures as sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rely on RVO in picturerecorder 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/filterfastbounds.cpp ('k') | gm/image_pict.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/image.cpp
diff --git a/gm/image.cpp b/gm/image.cpp
index d54f1cf203ced34d9997090a41d54aa05d4346fd..b32e430e91497dcd76eb62520f5c5ef44adb03e5 100644
--- a/gm/image.cpp
+++ b/gm/image.cpp
@@ -246,8 +246,8 @@ static sk_sp<SkImage> make_raster(const SkImageInfo& info, GrContext*, void (*dr
static sk_sp<SkImage> make_picture(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
SkPictureRecorder recorder;
draw(recorder.beginRecording(SkRect::MakeIWH(info.width(), info.height())));
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
- return SkImage::MakeFromPicture(sk_ref_sp(pict.get()), info.dimensions(), nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ info.dimensions(), nullptr, nullptr);
}
static sk_sp<SkImage> make_codec(const SkImageInfo& info, GrContext*, void (*draw)(SkCanvas*)) {
@@ -343,8 +343,8 @@ static SkImageGenerator* gen_raster(const SkImageInfo& info) {
static SkImageGenerator* gen_picture(const SkImageInfo& info) {
SkPictureRecorder recorder;
draw_opaque_contents(recorder.beginRecording(SkRect::MakeIWH(info.width(), info.height())));
- SkAutoTUnref<SkPicture> pict(recorder.endRecording());
- return SkImageGenerator::NewFromPicture(info.dimensions(), pict, nullptr, nullptr);
+ sk_sp<SkPicture> pict(recorder.finishRecordingAsPicture());
+ return SkImageGenerator::NewFromPicture(info.dimensions(), pict.get(), nullptr, nullptr);
}
static SkImageGenerator* gen_png(const SkImageInfo& info) {
@@ -476,9 +476,8 @@ DEF_SIMPLE_GM(new_texture_image, canvas, 225, 60) {
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(kSize), SkIntToScalar(kSize));
render_image(canvas);
- SkAutoTUnref<SkPicture> picture(recorder.endRecording());
- return SkImage::MakeFromPicture(sk_ref_sp(picture.get()), SkISize::Make(kSize, kSize),
- nullptr, nullptr);
+ return SkImage::MakeFromPicture(recorder.finishRecordingAsPicture(),
+ SkISize::Make(kSize, kSize), nullptr, nullptr);
},
// Create a texture image
[context, render_image]() -> sk_sp<SkImage> {
« no previous file with comments | « gm/filterfastbounds.cpp ('k') | gm/image_pict.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698