blob: 32fa16de12befddbd834c3b7b821bea849134eab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#ifndef MBGL_STYLE_SPRITE
#define MBGL_STYLE_SPRITE
#include <mbgl/annotation/sprite_parser.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/ptr.hpp>
#include <mbgl/storage/request.hpp>
#include <cstdint>
#include <atomic>
#include <iosfwd>
#include <string>
#include <unordered_map>
namespace mbgl {
class Request;
class Sprite : private util::noncopyable {
public:
struct Data {
std::string image;
std::string json;
};
class Observer {
public:
virtual ~Observer() = default;
virtual void onSpriteLoaded(const Sprites& sprites) = 0;
virtual void onSpriteLoadingFailed(std::exception_ptr error) = 0;
};
Sprite(const std::string& baseUrl, float pixelRatio);
~Sprite();
inline bool isLoaded() const {
return loaded;
}
const float pixelRatio;
void setObserver(Observer* observer);
private:
void emitSpriteLoadedIfComplete();
void emitSpriteLoadingFailed(const std::string& message);
struct Loader;
std::unique_ptr<Loader> loader;
bool loaded = false;
Observer* observer = nullptr;
};
} // namespace mbgl
#endif
|