return pictures as sk_sp

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1811703002

Review URL: https://codereview.chromium.org/1811703002
diff --git a/tools/VisualBench/VisualBenchmarkStream.cpp b/tools/VisualBench/VisualBenchmarkStream.cpp
index e0d02f2..b15ac7e 100644
--- a/tools/VisualBench/VisualBenchmarkStream.cpp
+++ b/tools/VisualBench/VisualBenchmarkStream.cpp
@@ -104,25 +104,24 @@
     this->next();
 }
 
-bool VisualBenchmarkStream::ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+sk_sp<SkPicture> VisualBenchmarkStream::ReadPicture(const char path[]) {
     // Not strictly necessary, as it will be checked again later,
     // but helps to avoid a lot of pointless work if we're going to skip it.
     if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
-        return false;
+        return nullptr;
     }
 
     SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
     if (stream.get() == nullptr) {
         SkDebugf("Could not read %s.\n", path);
-        return false;
+        return nullptr;
     }
 
-    pic->reset(SkPicture::CreateFromStream(stream.get()));
-    if (pic->get() == nullptr) {
+    auto pic = SkPicture::MakeFromStream(stream.get());
+    if (!pic) {
         SkDebugf("Could not read %s as an SkPicture.\n", path);
-        return false;
     }
-    return true;
+    return pic;
 }
 
 Benchmark* VisualBenchmarkStream::next() {
@@ -175,8 +174,8 @@
     // Render skps
     while (fCurrentSKP < fSKPs.count()) {
         const SkString& path = fSKPs[fCurrentSKP++];
-        SkAutoTUnref<SkPicture> pic;
-        if (!ReadPicture(path.c_str(), &pic)) {
+        sk_sp<SkPicture> pic = ReadPicture(path.c_str());
+        if (!pic) {
             continue;
         }
 
diff --git a/tools/VisualBench/VisualBenchmarkStream.h b/tools/VisualBench/VisualBenchmarkStream.h
index b1fd0f0..71b6c97 100644
--- a/tools/VisualBench/VisualBenchmarkStream.h
+++ b/tools/VisualBench/VisualBenchmarkStream.h
@@ -20,7 +20,7 @@
 public:
     VisualBenchmarkStream(const SkSurfaceProps&, bool justSKP = false);
 
-    static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic);
+    static sk_sp<SkPicture> ReadPicture(const char* path);
 
     Benchmark* next();
     Benchmark* current() { return fBenchmark.get(); }
diff --git a/tools/dump_record.cpp b/tools/dump_record.cpp
index 96b8937..52f8f8c 100644
--- a/tools/dump_record.cpp
+++ b/tools/dump_record.cpp
@@ -49,7 +49,7 @@
             SkDebugf("Could not read %s.\n", FLAGS_skps[i]);
             return 1;
         }
-        SkAutoTUnref<SkPicture> src(SkPicture::CreateFromStream(stream));
+        sk_sp<SkPicture> src(SkPicture::MakeFromStream(stream));
         if (!src) {
             SkDebugf("Could not read %s as an SkPicture.\n", FLAGS_skps[i]);
             return 1;
@@ -79,7 +79,7 @@
                          0,
                          nullptr,
                          nullptr);
-            SkAutoTUnref<SkPicture> dst(r.endRecording());
+            sk_sp<SkPicture> dst(r.finishRecordingAsPicture());
             SkFILEWStream ostream(FLAGS_write[0]);
             dst->serialize(&ostream);
         }
diff --git a/tools/get_images_from_skps.cpp b/tools/get_images_from_skps.cpp
index 7d0854d..e6bb6e2 100644
--- a/tools/get_images_from_skps.cpp
+++ b/tools/get_images_from_skps.cpp
@@ -90,7 +90,7 @@
     for (SkString file; iter.next(&file); ) {
         SkAutoTDelete<SkStream> stream =
                 SkStream::NewFromFile(SkOSPath::Join(inputs, file.c_str()).c_str());
-        SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(stream));
+        sk_sp<SkPicture> picture(SkPicture::MakeFromStream(stream));
 
         SkDynamicMemoryWStream scratch;
         Sniffer sniff;
diff --git a/tools/gpuveto.cpp b/tools/gpuveto.cpp
index f2e103e..41ca0c8 100644
--- a/tools/gpuveto.cpp
+++ b/tools/gpuveto.cpp
@@ -41,8 +41,8 @@
         return kError;
     }
 
-    SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream));
-    if (nullptr == picture.get()) {
+    sk_sp<SkPicture> picture(SkPicture::MakeFromStream(&inputStream));
+    if (nullptr == picture) {
         if (!FLAGS_quiet) {
             SkDebugf("Could not read the SkPicture\n");
         }
@@ -55,7 +55,7 @@
     picture->playback(recorder.beginRecording(picture->cullRect().width(), 
                                               picture->cullRect().height(), 
                                               nullptr, 0));
-    SkAutoTUnref<SkPicture> recorded(recorder.endRecording());
+    sk_sp<SkPicture> recorded(recorder.finishRecordingAsPicture());
 
     if (recorded->suitableForGpuRasterization(nullptr)) {
         SkDebugf("suitable\n");
diff --git a/tools/kilobench/kilobench.cpp b/tools/kilobench/kilobench.cpp
index 1f92d53..06cb33f 100644
--- a/tools/kilobench/kilobench.cpp
+++ b/tools/kilobench/kilobench.cpp
@@ -104,33 +104,28 @@
     }
 
 private:
-    static bool ReadPicture(const char* path, SkAutoTUnref<SkPicture>* pic) {
+    static sk_sp<SkPicture> ReadPicture(const char path[]) {
         // Not strictly necessary, as it will be checked again later,
         // but helps to avoid a lot of pointless work if we're going to skip it.
         if (SkCommandLineFlags::ShouldSkip(FLAGS_match, path)) {
-            return false;
+            return nullptr;
         }
 
         SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
         if (stream.get() == nullptr) {
             SkDebugf("Could not read %s.\n", path);
-            return false;
+            return nullptr;
         }
 
-        pic->reset(SkPicture::CreateFromStream(stream.get()));
-        if (pic->get() == nullptr) {
-            SkDebugf("Could not read %s as an SkPicture.\n", path);
-            return false;
-        }
-        return true;
+        return SkPicture::MakeFromStream(stream.get());
     }
 
     Benchmark* innerNext() {
         // Render skps
         while (fCurrentSKP < fSKPs.count()) {
             const SkString& path = fSKPs[fCurrentSKP++];
-            SkAutoTUnref<SkPicture> pic;
-            if (!ReadPicture(path.c_str(), &pic)) {
+            auto pic = ReadPicture(path.c_str());
+            if (!pic) {
                 continue;
             }
 
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index c526406..0edea25 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -38,13 +38,12 @@
 DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end");
 DEFINE_bool2(quiet, q, false, "Silence all non-error related output");
 
-static SkPicture* load_picture(const char path[]) {
+static sk_sp<SkPicture> load_picture(const char path[]) {
     SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(path));
-    SkPicture* pic = nullptr;
     if (stream.get()) {
-        pic = SkPicture::CreateFromStream(stream.get());
+        return SkPicture::MakeFromStream(stream.get());
     }
-    return pic;
+    return nullptr;
 }
 
 static void call_canvas(lua_State* L, SkLuaCanvas* canvas,
@@ -143,7 +142,7 @@
                 SkDebugf("scraping %s %s\n", path, moduloStr.c_str());
             }
 
-            SkAutoTUnref<SkPicture> pic(load_picture(path));
+            auto pic(load_picture(path));
             if (pic.get()) {
                 SkAutoTUnref<SkLuaCanvas> canvas(
                                     new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()), 
diff --git a/tools/pinspect.cpp b/tools/pinspect.cpp
index 419b2ab..1cbc2e1 100644
--- a/tools/pinspect.cpp
+++ b/tools/pinspect.cpp
@@ -14,7 +14,7 @@
 #include "SkString.h"
 #include "SkDumpCanvas.h"
 
-static SkPicture* inspect(const char path[]) {
+static sk_sp<SkPicture> inspect(const char path[]) {
     SkFILEStream stream(path);
     if (!stream.isValid()) {
         printf("-- Can't open '%s'\n", path);
@@ -33,7 +33,7 @@
     }
 
     stream.rewind();
-    SkPicture* pic = SkPicture::CreateFromStream(&stream);
+    auto pic = SkPicture::MakeFromStream(&stream);
     if (nullptr == pic) {
         SkDebugf("Could not create SkPicture: %s\n", path);
         return nullptr;
@@ -71,9 +71,9 @@
     }
 
     for (; index < argc; ++index) {
-        SkAutoTUnref<SkPicture> pic(inspect(argv[index]));
+        auto pic(inspect(argv[index]));
         if (doDumpOps) {
-            dumpOps(pic);
+            dumpOps(pic.get());
         }
         if (index < argc - 1) {
             printf("\n");
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index e0aad15..8627dd6 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -131,7 +131,7 @@
 
     fDebugCanvas->draw(canvas);
 
-    SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+    sk_sp<SkPicture> picture(recorder.finishRecordingAsPicture());
 
     SkDynamicMemoryWStream outStream;
 
@@ -215,8 +215,8 @@
 
 bool Request::initPictureFromStream(SkStream* stream) {
     // parse picture from stream
-    fPicture.reset(SkPicture::CreateFromStream(stream));
-    if (!fPicture.get()) {
+    fPicture = SkPicture::MakeFromStream(stream);
+    if (!fPicture) {
         fprintf(stderr, "Could not create picture from stream.\n");
         return false;
     }
diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h
index 52ebf25..eecfe33 100644
--- a/tools/skiaserve/Request.h
+++ b/tools/skiaserve/Request.h
@@ -68,7 +68,7 @@
     SkIRect getBounds();
     GrContext* getContext();
     
-    SkAutoTUnref<SkPicture> fPicture;
+    sk_sp<SkPicture> fPicture;
     GrContextFactory* fContextFactory;
     SkAutoTUnref<SkSurface> fSurface;
     bool fGPUEnabled;
diff --git a/tools/skpmaker.cpp b/tools/skpmaker.cpp
index 8fa969a..99e6adf 100644
--- a/tools/skpmaker.cpp
+++ b/tools/skpmaker.cpp
@@ -41,9 +41,8 @@
     paint.setColor(color);
     r.inset(border, border);
     canvas->drawRect(r, paint);
-    SkAutoTUnref<SkPicture> pict(recorder.endRecording());
     SkFILEWStream stream(writePath);
-    pict->serialize(&stream);
+    recorder.finishRecordingAsPicture()->serialize(&stream);
 }
 
 int tool_main(int argc, char** argv);