blob: 07011d324e1e49d0fae98e0f1204f8e28502d51c (
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
|
#ifndef MBGL_GEOMETRY_GLYPH_ATLAS
#define MBGL_GEOMETRY_GLYPH_ATLAS
#include <mbgl/geometry/binpack.hpp>
#include <mbgl/text/glyph_store.hpp>
#include <string>
#include <set>
#include <map>
#include <mutex>
#include <atomic>
namespace mbgl {
class GlyphAtlas {
public:
private:
struct GlyphValue {
GlyphValue(const Rect<uint16_t>& rect, uint64_t id)
: rect(rect), ids({ id }) {}
Rect<uint16_t> rect;
std::set<uint64_t> ids;
};
public:
GlyphAtlas(uint16_t width, uint16_t height);
~GlyphAtlas();
Rect<uint16_t> addGlyph(uint64_t tile_id, const std::string& face_name,
const SDFGlyph& glyph);
void removeGlyphs(uint64_t tile_id);
void bind();
void upload();
public:
const uint16_t width = 0;
const uint16_t height = 0;
private:
std::mutex mtx;
BinPack<uint16_t> bin;
std::map<std::string, std::map<uint32_t, GlyphValue>> index;
char *const data = nullptr;
std::atomic<bool> dirty;
uint32_t texture = 0;
};
};
#endif
|