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

Unified Diff: samplecode/SamplePictFile.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 | « samplecode/SampleHT.cpp ('k') | samplecode/SampleTiling.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SamplePictFile.cpp
diff --git a/samplecode/SamplePictFile.cpp b/samplecode/SamplePictFile.cpp
index 9203cbad7778fa2610a70d1958dde7dd33e2e8f4..ae107969013fe0d4582ce209ddddfefa3c4e7cdc 100644
--- a/samplecode/SamplePictFile.cpp
+++ b/samplecode/SamplePictFile.cpp
@@ -117,7 +117,7 @@ protected:
#endif
if (!*picture) {
- *picture = LoadPicture(fFilename.c_str(), fBBox);
+ *picture = LoadPicture(fFilename.c_str(), fBBox).release();
}
if (*picture) {
SkCounterDrawFilter filter(fCount);
@@ -149,8 +149,8 @@ private:
SkSize fTileSize;
int fCount;
- SkPicture* LoadPicture(const char path[], BBoxType bbox) {
- SkAutoTUnref<SkPicture> pic;
+ sk_sp<SkPicture> LoadPicture(const char path[], BBoxType bbox) {
+ sk_sp<SkPicture> pic;
SkBitmap bm;
if (SkImageDecoder::DecodeFile(path, &bm)) {
@@ -160,11 +160,11 @@ private:
SkIntToScalar(bm.height()),
nullptr, 0);
can->drawBitmap(bm, 0, 0, nullptr);
- pic.reset(recorder.endRecording());
+ pic = recorder.finishRecordingAsPicture();
} else {
SkFILEStream stream(path);
if (stream.isValid()) {
- pic.reset(SkPicture::CreateFromStream(&stream));
+ pic = SkPicture::MakeFromStream(&stream);
} else {
SkDebugf("coun't load picture at \"path\"\n", path);
}
@@ -174,7 +174,7 @@ private:
pic->playback(recorder.beginRecording(pic->cullRect().width(),
pic->cullRect().height(),
nullptr, 0));
- SkAutoTUnref<SkPicture> p2(recorder.endRecording());
+ sk_sp<SkPicture> p2(recorder.finishRecordingAsPicture());
SkString path2(path);
path2.append(".new.skp");
@@ -191,7 +191,7 @@ private:
switch (bbox) {
case kNo_BBoxType:
// no bbox playback necessary
- return pic.release();
+ return std::move(pic);
case kRTree_BBoxType:
factory.reset(new SkRTreeFactory);
break;
@@ -203,7 +203,7 @@ private:
pic->playback(recorder.beginRecording(pic->cullRect().width(),
pic->cullRect().height(),
factory.get(), 0));
- return recorder.endRecording();
+ return recorder.finishRecordingAsPicture();
}
typedef SampleView INHERITED;
« no previous file with comments | « samplecode/SampleHT.cpp ('k') | samplecode/SampleTiling.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698