change SkStreams to work with sk_sp<SkData> instead of SkData*

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2333713002

Review-Url: https://codereview.chromium.org/2333713002
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 4bfaeda..48ac577 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -291,11 +291,13 @@
     /** If copyData is true, the stream makes a private copy of the data. */
     SkMemoryStream(const void* data, size_t length, bool copyData = false);
 
+#ifdef SK_SUPPORT_LEGACY_STREAM_DATA
     /** Use the specified data as the memory for this stream.
      *  The stream will call ref() on the data (assuming it is not NULL).
      *  DEPRECATED
      */
     SkMemoryStream(SkData*);
+#endif
 
     /** Creates the stream to read from the specified data */
     SkMemoryStream(sk_sp<SkData>);
@@ -312,17 +314,24 @@
     */
     void setMemoryOwned(const void* data, size_t length);
 
+    sk_sp<SkData> asData() const { return fData; }
+    void setData(sk_sp<SkData>);
+#ifdef SK_SUPPORT_LEGACY_STREAM_DATA
     /** Return the stream's data in a SkData.
      *  The caller must call unref() when it is finished using the data.
      */
-    SkData* copyToData() const;
+    SkData* copyToData() const { return asData().release(); }
 
     /**
      *  Use the specified data as the memory for this stream.
      *  The stream will call ref() on the data (assuming it is not NULL).
      *  The function returns the data parameter as a convenience.
      */
-    SkData* setData(SkData*);
+    SkData* setData(SkData* data) {
+        this->setData(sk_ref_sp(data));
+        return data;
+    }
+#endif
 
     void skipToAlign4();
     const void* getAtPos();
@@ -404,11 +413,18 @@
     void copyTo(void* dst) const;
     void writeToStream(SkWStream* dst) const;
 
+    sk_sp<SkData> snapshotAsData() const;
+    // Return the contents as SkData, and then reset the stream.
+    sk_sp<SkData> detachAsData();
+#ifdef SK_SUPPORT_LEGACY_STREAM_DATA
     /**
      *  Return a copy of the data written so far. This call is responsible for
      *  calling unref() when they are finished with the data.
      */
-    SkData* copyToData() const;
+    SkData* copyToData() const {
+        return snapshotAsData().release();
+    }
+#endif
 
     /** Reset, returning a reader stream with the current content. */
     SkStreamAsset* detachAsStream();