1#ifndef ATLAS_H
2#define ATLAS_H
3
4#include "drawqueue.h"
5#include "framebuffer.h"
6#include <map>
7#include <vector>
8
9class Atlas {
10public:
11 void init();
12 void terminate();
13 void reload();
14
15 Point cache(uint64_t hash, const Size& size, bool& draw);
16 Point cacheFont(const TexturePtr& fontTexture);
17
18 TexturePtr get(int location) { return m_atlas[location]->getTexture(); }
19 void bind();
20 void release();
21
22 std::string getStats(); // not thread safe!
23
24private:
25 void reset();
26 void resetAtlas(int location);
27 bool findSpace(int location, int index);
28 inline int calculateIndex(const Size& size);
29
30 FrameBufferPtr m_atlas[2];
31 std::map<uint64_t, Point> m_cache;
32 std::list<Point> m_locations[2][7];
33 size_t m_size;
34 bool m_doReset = false;
35};
36
37extern Atlas g_atlas;
38
39#endif