blob: 81bdd1bdb046edc0a7ab54d1fe69e6ce10b805a4 [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 Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkImage.h"
12#include "include/core/SkString.h"
tfarinabcbc1782014-06-18 14:32:48 -070013
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