add Make factory to SkMemoryStream (simplify call-sites)

Bug: skia:6888
Change-Id: Ia4e432673ed089a91229697c8dde0489f220000d
Reviewed-on: https://skia-review.googlesource.com/26884
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index 01fd82a..1862117 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -263,6 +263,11 @@
 
     ~SkFILEStream() override;
 
+    static std::unique_ptr<SkFILEStream> Make(const char path[]) {
+        SkFILEStream* stream = new SkFILEStream(path);
+        return stream->isValid() ? std::unique_ptr<SkFILEStream>(stream) : nullptr;
+    }
+
     /** Returns true if the current path could be opened. */
     bool isValid() const { return fFILE != nullptr; }
 
@@ -308,6 +313,15 @@
     /** Creates the stream to read from the specified data */
     SkMemoryStream(sk_sp<SkData>);
 
+    /** Returns a stream with a copy of the input data. */
+    static std::unique_ptr<SkMemoryStream> MakeCopy(const void* data, size_t length);
+
+    /** Returns a stream with a bare pointer reference to the input data. */
+    static std::unique_ptr<SkMemoryStream> MakeDirect(const void* data, size_t length);
+
+    /** Returns a stream with a shared reference to the input data. */
+    static std::unique_ptr<SkMemoryStream> Make(sk_sp<SkData> data);
+
     /** Resets the stream to the specified data and length,
         just like the constructor.
         if copyData is true, the stream makes a private copy of the data