diff options
author | Hal Canary <halcanary@google.com> | 2017-12-08 11:38:47 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-08 19:30:48 +0000 |
commit | 5093a539def3ae09df324018f2343827009b2e05 (patch) | |
tree | 0809099fad806dd9a8f00fe0e2dfcd8a958915af /tools/Resources.h | |
parent | 0b1b9c233a338ef26e7593c1423795c8ced53e1d (diff) |
resources: remove most uses of GetResourcePath()
Going forward, we will standardize on GetResourceAsData(), which will
make it easier to run tests in environments without access to the
filesystem.
Also: GetResourceAsData() complains when a resource is missing.
This is usually an error.
Change-Id: Iaf70b71b0ca5ed8cd1a5538a60ef185ae8736188
Reviewed-on: https://skia-review.googlesource.com/82642
Reviewed-by: Hal Canary <halcanary@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tools/Resources.h')
-rw-r--r-- | tools/Resources.h | 20 |
1 files changed, 15 insertions, 5 deletions
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 |