blob: 966ac6f35c7225f92096d22dbb408d080635f8aa [file] [log] [blame]
tfarinabcbc1782014-06-18 14:32:48 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef Resources_DEFINED
9#define Resources_DEFINED
10
Mike Reed0933bc92017-12-09 01:27:41 +000011#include "SkImage.h"
tfarinabcbc1782014-06-18 14:32:48 -070012#include "SkString.h"
13
halcanary30b83d42014-10-26 05:23:53 -070014class SkBitmap;
Mike Reed463c8482016-12-21 12:01:12 -050015class SkData;
bungeman3ffa1262015-04-30 17:12:58 -040016class SkStreamAsset;
17class SkTypeface;
halcanary30b83d42014-10-26 05:23:53 -070018
tfarinabcbc1782014-06-18 14:32:48 -070019SkString GetResourcePath(const char* resource = "");
Mike Reed0933bc92017-12-09 01:27:41 +000020
caryclark936b7342014-07-11 12:14:51 -070021void SetResourcePath(const char* );
tfarinabcbc1782014-06-18 14:32:48 -070022
Mike Reed0933bc92017-12-09 01:27:41 +000023bool DecodeDataToBitmap(sk_sp<SkData> data, SkBitmap* dst);
24
Mike Reedcca23002017-12-08 21:09:12 +000025sk_sp<SkData> GetResourceAsData(const char* resource);
Mike Reed0933bc92017-12-09 01:27:41 +000026
27inline bool GetResourceAsBitmap(const char* resource, SkBitmap* dst) {
28 return DecodeDataToBitmap(GetResourceAsData(resource), dst);
29}
30
31inline sk_sp<SkImage> GetResourceAsImage(const char* resource) {
32 return SkImage::MakeFromEncoded(GetResourceAsData(resource));
33}
34
35std::unique_ptr<SkStreamAsset> GetResourceAsStream(const char* resource);
36
Mike Reed271d1d92018-09-03 21:10:10 -040037sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource, int ttcIndex = 0);
halcanary30b83d42014-10-26 05:23:53 -070038
tfarinabcbc1782014-06-18 14:32:48 -070039#endif // Resources_DEFINED