blob: e76a91b61d91488bce1a5926201b18ebd70d72b5 (
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
|
#ifndef MBGL_GEOMETRY_LINE_ATLAS
#define MBGL_GEOMETRY_LINE_ATLAS
#include <mbgl/platform/gl.hpp>
#include <vector>
#include <map>
#include <memory>
namespace mbgl {
typedef struct {
float width;
float height;
float y;
} LinePatternPos;
class LineAtlas {
public:
LineAtlas(GLsizei width, GLsizei height);
~LineAtlas();
// Binds the atlas texture to the GPU, and uploads data if it is out of date.
void bind();
// Uploads the texture to the GPU to be available when we need it. This is a lazy operation;
// the texture is only bound when the data is out of date (=dirty).
void upload();
LinePatternPos getDashPosition(const std::vector<float>&, bool);
LinePatternPos addDash(const std::vector<float> &dasharray, bool round);
const GLsizei width;
const GLsizei height;
private:
const std::unique_ptr<GLbyte[]> data;
bool dirty;
GLuint texture = 0;
int nextRow = 0;
std::map<size_t, LinePatternPos> positions;
};
} // namespace mbgl
#endif
|