add glyph atlas to map

This commit is contained in:
Konstantin Käfer
2014-03-12 16:20:52 +01:00
parent d9589573bc
commit be44b6b31f
6 changed files with 50 additions and 16 deletions

View File

@@ -6,16 +6,12 @@
#include <string>
#include <set>
#include <map>
#include <mutex>
#include <atomic>
namespace llmr {
class Glyph {
public:
uint32_t id = 0;
std::string bitmap;
uint16_t width = 0;
uint16_t height = 0;
};
class VectorTileGlyph;
class GlyphAtlas {
public:
@@ -34,17 +30,18 @@ public:
Rect<uint16_t> addGlyph(uint64_t tile_id, const std::string& face_name,
const Glyph& glyph, uint8_t buffer);
const VectorTileGlyph& glyph);
void removeGlyphs(uint64_t tile_id);
void bind();
private:
std::mutex mtx;
const uint16_t width = 0;
const uint16_t height = 0;
BinPack<uint16_t> bin;
std::map<std::string, std::map<uint32_t, GlyphValue>> index;
char *const data = NULL;
bool dirty = true;
char *const data = nullptr;
std::atomic<bool> dirty;
uint32_t texture = 0;
};

View File

@@ -5,6 +5,8 @@
#include <llmr/map/tile_data.hpp>
#include <llmr/map/transform.hpp>
#include <llmr/style/style.hpp>
#include <llmr/style/style.hpp>
#include <llmr/geometry/glyph_atlas.hpp>
#include <llmr/renderer/painter.hpp>
#include <llmr/util/noncopyable.hpp>
@@ -76,6 +78,7 @@ private:
Transform transform;
Style style;
Painter painter;
GlyphAtlas glyphAtlas;
int32_t min_zoom;
int32_t max_zoom;

View File

@@ -5,6 +5,7 @@
#include <llmr/util/vec.hpp>
#include <llmr/util/mat4.hpp>
#include <llmr/util/noncopyable.hpp>
#include <llmr/geometry/glyph_atlas.hpp>
#include <llmr/geometry/debug_font_buffer.hpp>
#include <llmr/geometry/vao.hpp>
#include <llmr/platform/platform.hpp>
@@ -25,6 +26,7 @@ class LayerDescription;
class BucketDescription;
class VectorTile;
class VectorTileLayer;
class VectorTileFace;
class FillVertexBuffer;
class LineVertexBuffer;
class PointVertexBuffer;
@@ -54,7 +56,7 @@ public:
};
public:
TileData(Tile::ID id, const Style& style);
TileData(Tile::ID id, const Style& style, GlyphAtlas& glyphAtlas);
~TileData();
// Start loading the tile.
@@ -74,6 +76,9 @@ public:
const std::string toString() const;
private:
void loadGlyphs(const std::map<std::string, const VectorTileFace>& faces);
public:
const Tile::ID id;
std::atomic<State> state;
@@ -94,10 +99,12 @@ public:
// Holds the buckets of this tile.
// They contain the location offsets in the buffers stored above
std::map<std::string, std::shared_ptr<Bucket>> buckets;
private:
// Source data
std::string data;
const Style& style;
GlyphAtlas& glyphAtlas;
platform::Request *req = nullptr;
};