SkFontData to use smart pointers.

The SkFontData type is not exposed externally, so any method which uses
it can be updated to use smart pointers without affecting external
users. Updating this first will make updating the public API much
easier.

This also updates SkStreamAsset* SkStream::NewFromFile(const char*) to
std::unique_ptr<SkStreamAsset> SkStream::MakeFromFile(const char*). It
appears that no one outside Skia is currently using SkStream::NewfromFile
so this is a good time to update it as well.

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

Committed: https://skia.googlesource.com/skia/+/d8c2476a8b1e1e1a1771b17e8dd4db8645914f8c
Review-Url: https://codereview.chromium.org/2339273002
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index 044c2fd..341433b 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -22,11 +22,6 @@
 
 #include "png.h"
 
-static SkStreamAsset* resource(const char path[]) {
-    SkString fullPath = GetResourcePath(path);
-    return SkStream::NewFromFile(fullPath.c_str());
-}
-
 static void md5(const SkBitmap& bm, SkMD5::Digest* digest) {
     SkAutoLockPixels autoLockPixels(bm);
     SkASSERT(bm.getPixels());
@@ -199,9 +194,8 @@
                   bool supportsSubsetDecoding,
                   bool supportsIncomplete = true) {
 
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
         return;
     }
 
@@ -329,9 +323,8 @@
     // SkAndroidCodec tests
     if (supportsScanlineDecoding || supportsSubsetDecoding) {
 
-        SkAutoTDelete<SkStream> stream(resource(path));
+        SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
         if (!stream) {
-            SkDebugf("Missing resource '%s'\n", path);
             return;
         }
 
@@ -356,7 +349,7 @@
 
     if (!isIncomplete) {
         // Test SkCodecImageGenerator
-        SkAutoTDelete<SkStream> stream(resource(path));
+        SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
         sk_sp<SkData> fullData(SkData::MakeFromStream(stream, stream->getLength()));
         SkAutoTDelete<SkImageGenerator> gen(
                 SkCodecImageGenerator::NewFromEncodedCodec(fullData.get()));
@@ -449,9 +442,10 @@
 // Test interlaced PNG in stripes, similar to DM's kStripe_Mode
 DEF_TEST(Codec_stripes, r) {
     const char * path = "plane_interlaced.png";
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
+    REPORTER_ASSERT(r, stream);
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
+        return;
     }
 
     SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
@@ -582,9 +576,8 @@
 
 static void test_dimensions(skiatest::Reporter* r, const char path[]) {
     // Create the codec from the resource file
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
         return;
     }
     SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
@@ -647,9 +640,8 @@
 }
 
 static void test_invalid(skiatest::Reporter* r, const char path[]) {
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
         return;
     }
     SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
@@ -673,9 +665,8 @@
 }
 
 static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) {
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
         return;
     }
     SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release()));
@@ -965,9 +956,8 @@
 // Test that SkCodec now supports an image with these bits set.
 DEF_TEST(Codec_wbmp, r) {
     const char* path = "mandrill.wbmp";
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
         return;
     }
 
@@ -1016,9 +1006,8 @@
 
 DEF_TEST(Codec_jpeg_rewind, r) {
     const char* path = "mandrill_512_q075.jpg";
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     if (!stream) {
-        SkDebugf("Missing resource '%s'\n", path);
         return;
     }
     SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release()));
@@ -1044,7 +1033,7 @@
 }
 
 static void check_color_xform(skiatest::Reporter* r, const char* path) {
-    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(resource(path)));
+    SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(GetResourceAsStream(path)));
 
     SkAndroidCodec::AndroidOptions opts;
     opts.fSampleSize = 3;
@@ -1130,7 +1119,7 @@
 
 DEF_TEST(Codec_PngRoundTrip, r) {
     const char* path = "mandrill_512_q075.jpg";
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
 
     SkColorType colorTypesOpaque[] = {
@@ -1142,12 +1131,12 @@
     }
 
     path = "grayscale.jpg";
-    stream.reset(resource(path));
+    stream.reset(GetResourceAsStream(path));
     codec.reset(SkCodec::NewFromStream(stream.release()));
     check_round_trip(r, codec.get(), codec->getInfo());
 
     path = "yellow_rose.png";
-    stream.reset(resource(path));
+    stream.reset(GetResourceAsStream(path));
     codec.reset(SkCodec::NewFromStream(stream.release()));
 
     SkColorType colorTypesWithAlpha[] = {
@@ -1167,7 +1156,7 @@
     }
 
     path = "index8.png";
-    stream.reset(resource(path));
+    stream.reset(GetResourceAsStream(path));
     codec.reset(SkCodec::NewFromStream(stream.release()));
 
     for (SkAlphaType alphaType : alphaTypes) {
@@ -1179,7 +1168,7 @@
 
 static void test_conversion_possible(skiatest::Reporter* r, const char* path,
                                      bool testScanlineDecoder) {
-    SkAutoTDelete<SkStream> stream(resource(path));
+    SkAutoTDelete<SkStream> stream(GetResourceAsStream(path));
     SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release()));
     SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType);