blob: 7d5909371bfdddc1c7e331a156cf37f1581b9fa5 [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
bungeman13b9c952016-05-12 10:09:30 -070037sk_sp<SkTypeface> MakeResourceAsTypeface(const char* resource);
halcanary30b83d42014-10-26 05:23:53 -070038
tfarinabcbc1782014-06-18 14:32:48 -070039#endif // Resources_DEFINED