diff options
-rw-r--r-- | bench/ColorCodecBench.cpp | 3 | ||||
-rw-r--r-- | dm/DM.cpp | 8 | ||||
-rw-r--r-- | dm/DMSrcSink.cpp | 3 | ||||
-rw-r--r-- | gm/makecolorspace.cpp | 3 | ||||
-rw-r--r-- | samplecode/SampleCowboy.cpp | 9 | ||||
-rw-r--r-- | samplecode/SampleIdentityScale.cpp | 9 | ||||
-rw-r--r-- | samplecode/SampleSubpixelTranslate.cpp | 18 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 21 | ||||
-rw-r--r-- | tests/ColorSpaceTest.cpp | 18 | ||||
-rw-r--r-- | tests/GifTest.cpp | 8 | ||||
-rw-r--r-- | tests/ICCTest.cpp | 18 | ||||
-rw-r--r-- | tests/ImageIsOpaqueTest.cpp | 9 | ||||
-rw-r--r-- | tests/PDFJpegEmbedTest.cpp | 3 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 6 | ||||
-rw-r--r-- | tools/Resources.cpp | 35 | ||||
-rw-r--r-- | tools/Resources.h | 20 |
16 files changed, 88 insertions, 103 deletions
diff --git a/bench/ColorCodecBench.cpp b/bench/ColorCodecBench.cpp index 1239e1d4fe..c38a8a712b 100644 --- a/bench/ColorCodecBench.cpp +++ b/bench/ColorCodecBench.cpp @@ -74,8 +74,7 @@ void ColorCodecBench::onDelayedSetup() { matrix.set3x3(0.30f, 0.31f, 0.28f, 0.32f, 0.33f, 0.29f, 0.27f, 0.30f, 0.30f); fDstSpace = SkColorSpace::MakeRGB(gamma, matrix); } else { - sk_sp<SkData> dstData = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> dstData = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); SkASSERT(dstData); fDstSpace = SkColorSpace::MakeICC(dstData->data(), dstData->size()); } @@ -1357,12 +1357,8 @@ int main(int argc, char** argv) { SkTaskGroup::Enabler enabled(FLAGS_threads); gCreateTypefaceDelegate = &create_from_name; - { - SkString testResourcePath = GetResourcePath("images/color_wheel.png"); - SkFILEStream testResource(testResourcePath.c_str()); - if (!testResource.isValid()) { - info("Some resources are missing. Do you need to set --resourcePath?\n"); - } + if (nullptr == GetResourceAsData("images/color_wheel.png")) { + info("Some resources are missing. Do you need to set --resourcePath?\n"); } gather_gold(); gather_uninteresting_hashes(); diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 89a4b531e2..96817e0749 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1066,8 +1066,7 @@ Error ColorCodecSrc::draw(SkCanvas* canvas) const { } // Load the dst ICC profile. This particular dst is fairly similar to Adobe RGB. - sk_sp<SkData> dstData = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> dstData = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); if (!dstData) { return "Cannot read monitor profile. Is the resource path set correctly?"; } diff --git a/gm/makecolorspace.cpp b/gm/makecolorspace.cpp index c0002b3414..1435c04120 100644 --- a/gm/makecolorspace.cpp +++ b/gm/makecolorspace.cpp @@ -13,8 +13,7 @@ #include "SkImagePriv.h" sk_sp<SkImage> make_raster_image(const char* path, SkTransferFunctionBehavior behavior) { - SkString resourcePath = GetResourcePath(path); - sk_sp<SkData> resourceData = SkData::MakeFromFileName(resourcePath.c_str()); + sk_sp<SkData> resourceData = GetResourceAsData(path); std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(resourceData); SkBitmap bitmap; diff --git a/samplecode/SampleCowboy.cpp b/samplecode/SampleCowboy.cpp index b1eec87e50..bd8f7c909b 100644 --- a/samplecode/SampleCowboy.cpp +++ b/samplecode/SampleCowboy.cpp @@ -37,12 +37,13 @@ protected: }; void onOnceBeforeDraw() override { - fPath = GetResourcePath("Cowboy.svg"); - SkFILEStream svgStream(fPath.c_str()); - if (!svgStream.isValid()) { - SkDebugf("file not found: \"path\"\n", fPath.c_str()); + constexpr char path[] = "Cowboy.svg"; + auto data = GetResourceAsData(path); + if (!data) { + SkDebugf("file not found: \"%s\"\n", path); return; } + SkMemoryStream svgStream(std::move(data)); SkDOM xmlDom; if (!xmlDom.build(svgStream)) { diff --git a/samplecode/SampleIdentityScale.cpp b/samplecode/SampleIdentityScale.cpp index 2ec9112800..ad235416cd 100644 --- a/samplecode/SampleIdentityScale.cpp +++ b/samplecode/SampleIdentityScale.cpp @@ -25,11 +25,10 @@ class IdentityScaleView : public SampleView { public: IdentityScaleView(const char imageFilename[]) { - SkString resourcePath = GetResourcePath(imageFilename); - if (!decode_file(resourcePath.c_str(), &fBM)) { - fBM.allocN32Pixels(1, 1); - *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad - } + if (!DecodeDataToBitmap(GetResourceAsData(imageFilename), &fBM)) { + fBM.allocN32Pixels(1, 1); + *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad + } } protected: diff --git a/samplecode/SampleSubpixelTranslate.cpp b/samplecode/SampleSubpixelTranslate.cpp index 51b5ef6631..7ce1885892 100644 --- a/samplecode/SampleSubpixelTranslate.cpp +++ b/samplecode/SampleSubpixelTranslate.cpp @@ -24,15 +24,15 @@ public: SubpixelTranslateView(const char imageFilename[], float horizontalVelocity, float verticalVelocity) - : fHorizontalVelocity(horizontalVelocity), - fVerticalVelocity(verticalVelocity) { - SkString resourcePath = GetResourcePath(imageFilename); - if (!decode_file(resourcePath.c_str(), &fBM)) { - fBM.allocN32Pixels(1, 1); - *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad - } - fCurPos = SkPoint::Make(0,0); - fSize = 200; + : fHorizontalVelocity(horizontalVelocity) + , fVerticalVelocity(verticalVelocity) + { + if (!DecodeDataToBitmap(GetResourceAsData(imageFilename), &fBM)) { + fBM.allocN32Pixels(1, 1); + *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad + } + fCurPos = SkPoint::Make(0,0); + fSize = 200; } protected: diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index ab21e4a2c1..787e8549fc 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -846,9 +846,8 @@ private: // Test that the RawCodec works also for not asset stream. This will test the code path using // SkRawBufferedStream instead of SkRawAssetStream. DEF_TEST(Codec_raw_notseekable, r) { - const char* path = "images/dng_with_preview.dng"; - SkString fullPath(GetResourcePath(path)); - sk_sp<SkData> data(SkData::MakeFromFileName(fullPath.c_str())); + constexpr char path[] = "images/dng_with_preview.dng"; + sk_sp<SkData> data(GetResourceAsData(path)); if (!data) { SkDebugf("Missing resource '%s'\n", path); return; @@ -865,9 +864,8 @@ DEF_TEST(Codec_raw_notseekable, r) { // Test that even if webp_parse_header fails to peek enough, it will fall back to read() // + rewind() and succeed. DEF_TEST(Codec_webp_peek, r) { - const char* path = "images/baby_tux.webp"; - SkString fullPath(GetResourcePath(path)); - auto data = SkData::MakeFromFileName(fullPath.c_str()); + constexpr char path[] = "images/baby_tux.webp"; + auto data = GetResourceAsData(path); if (!data) { SkDebugf("Missing resource '%s'\n", path); return; @@ -1003,8 +1001,7 @@ static void check_color_xform(skiatest::Reporter* r, const char* path) { const int dstWidth = subsetWidth / opts.fSampleSize; const int dstHeight = subsetHeight / opts.fSampleSize; - sk_sp<SkData> data = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); sk_sp<SkColorSpace> colorSpace = SkColorSpace::MakeICC(data->data(), data->size()); SkImageInfo dstInfo = codec->getInfo().makeWH(dstWidth, dstHeight) .makeColorType(kN32_SkColorType) @@ -1386,12 +1383,14 @@ DEF_TEST(Codec_InvalidImages, r) { } static void test_invalid_header(skiatest::Reporter* r, const char* path) { - SkString resourcePath = GetResourcePath(path); - auto stream = SkFILEStream::Make(resourcePath.c_str()); + auto data = GetResourceAsData(path); + if (!data) { + return; + } + std::unique_ptr<SkStreamAsset> stream(new SkMemoryStream(std::move(data))); if (!stream) { return; } - std::unique_ptr<SkCodec> codec(SkCodec::MakeFromStream(std::move(stream))); REPORTER_ASSERT(r, !codec); } diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index 19e1044162..d180cda425 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -245,14 +245,13 @@ DEF_TEST(ColorSpace_Serialize, r) { test_serialize(r, SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named).get(), true); test_serialize(r, SkColorSpace::MakeSRGBLinear().get(), true); - sk_sp<SkData> monitorData = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> monitorData = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); - monitorData = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); + monitorData = GetResourceAsData("icc_profiles/HP_Z32x.icc"); test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); - monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); + monitorData = GetResourceAsData("icc_profiles/upperLeft.icc"); test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); - monitorData = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); + monitorData = GetResourceAsData("icc_profiles/upperRight.icc"); test_serialize(r, SkColorSpace::MakeICC(monitorData->data(), monitorData->size()).get(), false); SkColorSpaceTransferFn fn; @@ -270,14 +269,13 @@ DEF_TEST(ColorSpace_Serialize, r) { DEF_TEST(ColorSpace_Equals, r) { sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB(); sk_sp<SkColorSpace> adobe = SkColorSpace_Base::MakeNamed(SkColorSpace_Base::kAdobeRGB_Named); - sk_sp<SkData> data = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); sk_sp<SkColorSpace> z30 = SkColorSpace::MakeICC(data->data(), data->size()); - data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); + data = GetResourceAsData("icc_profiles/HP_Z32x.icc"); sk_sp<SkColorSpace> z32 = SkColorSpace::MakeICC(data->data(), data->size()); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperLeft.icc"); sk_sp<SkColorSpace> upperLeft = SkColorSpace::MakeICC(data->data(), data->size()); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperRight.icc"); sk_sp<SkColorSpace> upperRight = SkColorSpace::MakeICC(data->data(), data->size()); SkColorSpaceTransferFn fn; diff --git a/tests/GifTest.cpp b/tests/GifTest.cpp index 5219825f1b..0de5fc586d 100644 --- a/tests/GifTest.cpp +++ b/tests/GifTest.cpp @@ -225,12 +225,12 @@ DEF_TEST(Gif, reporter) { // Regression test for decoding a gif image with sampleSize of 4, which was // previously crashing. DEF_TEST(Gif_Sampled, r) { - auto stream = SkFILEStream::Make(GetResourcePath("images/test640x479.gif").c_str()); - REPORTER_ASSERT(r, stream); - if (!stream) { + auto data = GetResourceAsData("images/test640x479.gif"); + REPORTER_ASSERT(r, data); + if (!data) { return; } - + std::unique_ptr<SkStreamAsset> stream(new SkMemoryStream(std::move(data))); std::unique_ptr<SkAndroidCodec> codec(SkAndroidCodec::MakeFromStream(std::move(stream))); REPORTER_ASSERT(r, codec); if (!codec) { diff --git a/tests/ICCTest.cpp b/tests/ICCTest.cpp index 4bff6546ef..4933155148 100644 --- a/tests/ICCTest.cpp +++ b/tests/ICCTest.cpp @@ -39,8 +39,7 @@ DEF_TEST(ICC_ToXYZD50, r) { 0.74519f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; - sk_sp<SkData> data = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); sk_sp<SkICC> z30 = SkICC::Make(data->data(), data->size()); test_to_xyz_d50(r, z30.get(), true, z30Reference); @@ -49,15 +48,15 @@ DEF_TEST(ICC_ToXYZD50, r) { 0.75368f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, }; - data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); + data = GetResourceAsData("icc_profiles/HP_Z32x.icc"); sk_sp<SkICC> z32 = SkICC::Make(data->data(), data->size()); test_to_xyz_d50(r, z32.get(), true, z32Reference); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperLeft.icc"); sk_sp<SkICC> upperLeft = SkICC::Make(data->data(), data->size()); test_to_xyz_d50(r, upperLeft.get(), false, z32Reference); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperRight.icc"); sk_sp<SkICC> upperRight = SkICC::Make(data->data(), data->size()); test_to_xyz_d50(r, upperRight.get(), false, z32Reference); } @@ -82,20 +81,19 @@ DEF_TEST(ICC_IsNumericalTransferFn, r) { referenceFn.fF = 0.0f; referenceFn.fG = 2.2f; - sk_sp<SkData> data = SkData::MakeFromFileName( - GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); sk_sp<SkICC> z30 = SkICC::Make(data->data(), data->size()); test_is_numerical_transfer_fn(r, z30.get(), true, referenceFn); - data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); + data = GetResourceAsData("icc_profiles/HP_Z32x.icc"); sk_sp<SkICC> z32 = SkICC::Make(data->data(), data->size()); test_is_numerical_transfer_fn(r, z32.get(), true, referenceFn); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperLeft.icc"); sk_sp<SkICC> upperLeft = SkICC::Make(data->data(), data->size()); test_is_numerical_transfer_fn(r, upperLeft.get(), false, referenceFn); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperRight.icc"); sk_sp<SkICC> upperRight = SkICC::Make(data->data(), data->size()); test_is_numerical_transfer_fn(r, upperRight.get(), false, referenceFn); } diff --git a/tests/ImageIsOpaqueTest.cpp b/tests/ImageIsOpaqueTest.cpp index 9b4837a76f..38f9b6ae90 100644 --- a/tests/ImageIsOpaqueTest.cpp +++ b/tests/ImageIsOpaqueTest.cpp @@ -40,14 +40,13 @@ static void test_flatten(skiatest::Reporter* reporter, const SkImageInfo& info) } DEF_TEST(ImageInfo_flattening, reporter) { - sk_sp<SkData> data = - SkData::MakeFromFileName(GetResourcePath("icc_profiles/HP_ZR30w.icc").c_str()); + sk_sp<SkData> data = GetResourceAsData("icc_profiles/HP_ZR30w.icc"); sk_sp<SkColorSpace> space0 = SkColorSpace::MakeICC(data->data(), data->size()); - data = SkData::MakeFromFileName( GetResourcePath("icc_profiles/HP_Z32x.icc").c_str()); + data = GetResourceAsData("icc_profiles/HP_Z32x.icc"); sk_sp<SkColorSpace> space1 = SkColorSpace::MakeICC(data->data(), data->size()); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperLeft.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperLeft.icc"); sk_sp<SkColorSpace> space2 = SkColorSpace::MakeICC(data->data(), data->size()); - data = SkData::MakeFromFileName(GetResourcePath("icc_profiles/upperRight.icc").c_str()); + data = GetResourceAsData("icc_profiles/upperRight.icc"); sk_sp<SkColorSpace> space3 = SkColorSpace::MakeICC(data->data(), data->size()); sk_sp<SkColorSpace> spaces[] = { diff --git a/tests/PDFJpegEmbedTest.cpp b/tests/PDFJpegEmbedTest.cpp index b62b166fc1..aaac2b9f18 100644 --- a/tests/PDFJpegEmbedTest.cpp +++ b/tests/PDFJpegEmbedTest.cpp @@ -32,8 +32,7 @@ static bool is_subset_of(SkData* smaller, SkData* larger) { static sk_sp<SkData> load_resource( skiatest::Reporter* r, const char* test, const char* filename) { - SkString path(GetResourcePath(filename)); - sk_sp<SkData> data(SkData::MakeFromFileName(path.c_str())); + sk_sp<SkData> data = GetResourceAsData(filename); if (!data) { INFOF(r, "\n%s: Resource '%s' can not be found.\n", test, filename); diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index 4cf605a2fc..2543870667 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -358,8 +358,8 @@ static void serialize_and_compare_typeface(sk_sp<SkTypeface> typeface, const cha static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { { // Load typeface from file to test CreateFromFile with index. - SkString filename = GetResourcePath("/fonts/test.ttc"); - sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFile(filename.c_str(), 1)); + auto data = GetResourceAsData("fonts/test.ttc"); + auto typeface = SkTypeface::MakeFromStream(new SkMemoryStream(std::move(data)), 1); if (!typeface) { INFOF(reporter, "Could not run fontstream test because test.ttc not found."); } else { @@ -369,7 +369,7 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { { // Load typeface as stream to create with axis settings. - std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf")); + std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("fonts/Distortable.ttf")); if (!distortable) { INFOF(reporter, "Could not run fontstream test because Distortable.ttf not found."); } else { diff --git a/tools/Resources.cpp b/tools/Resources.cpp index 948949bf04..6436a0ddb8 100644 --- a/tools/Resources.cpp +++ b/tools/Resources.cpp @@ -26,37 +26,26 @@ void SetResourcePath(const char* resource) { FLAGS_resourcePath.set(0, resource); } -bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) { - SkString resourcePath = GetResourcePath(resource); - sk_sp<SkData> resourceData(SkData::MakeFromFileName(resourcePath.c_str())); - std::unique_ptr<SkImageGenerator> gen(SkImageGenerator::MakeFromEncoded(resourceData)); - if (!gen) { - return false; - } - return dst->tryAllocPixels(gen->getInfo()) && + +bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst) { + std::unique_ptr<SkImageGenerator> gen(SkImageGenerator::MakeFromEncoded(std::move(data))); + return gen && dst->tryAllocPixels(gen->getInfo()) && gen->getPixels(gen->getInfo().makeColorSpace(nullptr), dst->getPixels(), dst->rowBytes(), nullptr); } -sk_sp<SkImage> GetResourceAsImage(const char* resource) { - SkString path = GetResourcePath(resource); - sk_sp<SkData> resourceData(SkData::MakeFromFileName(path.c_str())); - return SkImage::MakeFromEncoded(resourceData); -} - std::unique_ptr<SkStreamAsset> GetResourceAsStream(const char* resource) { - SkString resourcePath = GetResourcePath(resource); - auto stream = SkFILEStream::Make(resourcePath.c_str()); - if (!stream) { - SkDebugf("Resource %s not found.\n", resource); - return nullptr; - } - return std::move(stream); + auto data = GetResourceAsData(resource); + return data ? std::unique_ptr<SkStreamAsset>(new SkMemoryStream(std::move(data))) + : nullptr; } sk_sp<SkData> GetResourceAsData(const char* resource) { - SkString resourcePath = GetResourcePath(resource); - return SkData::MakeFromFileName(resourcePath.c_str()); + auto data = SkData::MakeFromFileName(GetResourcePath(resource).c_str()); + if (!data) { + SkDebugf("Resource \"%s\" not found.\n", resource); + } + return data; } sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource) { diff --git a/tools/Resources.h b/tools/Resources.h index 01eaa3f214..7d5909371b 100644 --- a/tools/Resources.h +++ b/tools/Resources.h @@ -8,22 +8,32 @@ #ifndef Resources_DEFINED #define Resources_DEFINED -#include "SkRefCnt.h" +#include "SkImage.h" #include "SkString.h" class SkBitmap; class SkData; -class SkImage; class SkStreamAsset; class SkTypeface; SkString GetResourcePath(const char* resource = ""); + void SetResourcePath(const char* ); -bool GetResourceAsBitmap(const char* resource, SkBitmap* dst); -sk_sp<SkImage> GetResourceAsImage(const char* resource); -std::unique_ptr<SkStreamAsset> GetResourceAsStream(const char* resource); +bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst); + sk_sp<SkData> GetResourceAsData(const char* resource); + +inline bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) { + return DecodeDataToBitmap(GetResourceAsData(resource), dst); +} + +inline sk_sp<SkImage> GetResourceAsImage(const char* resource) { + return SkImage::MakeFromEncoded(GetResourceAsData(resource)); +} + +std::unique_ptr<SkStreamAsset> GetResourceAsStream(const char* resource); + sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource); #endif // Resources_DEFINED |