diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 18:29:42 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-12-04 20:02:50 +0100 |
commit | abafb52f37beb5659efc2105ccd1568e1f754898 (patch) | |
tree | 6a60636d3497560ca61e5aae5f6d7061c4f18553 /src/mbgl/geometry/glyph_atlas.hpp | |
parent | bff6aeb4da41dee1f5f1cfa0be81b6c257257253 (diff) | |
download | qtlocation-mapboxgl-abafb52f37beb5659efc2105ccd1568e1f754898.tar.gz |
make most headers private
Diffstat (limited to 'src/mbgl/geometry/glyph_atlas.hpp')
-rw-r--r-- | src/mbgl/geometry/glyph_atlas.hpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp new file mode 100644 index 0000000000..7b3c223fe5 --- /dev/null +++ b/src/mbgl/geometry/glyph_atlas.hpp @@ -0,0 +1,54 @@ +#ifndef MBGL_GEOMETRY_GLYPH_ATLAS +#define MBGL_GEOMETRY_GLYPH_ATLAS + +#include <mbgl/geometry/binpack.hpp> +#include <mbgl/text/glyph_store.hpp> +#include <mbgl/util/noncopyable.hpp> + +#include <string> +#include <set> +#include <map> +#include <mutex> +#include <atomic> + +namespace mbgl { + +class GlyphAtlas : public util::noncopyable { +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; + }; + + Rect<uint16_t> addGlyph_impl(uint64_t tile_id, const std::string& face_name, + const SDFGlyph& glyph); +public: + GlyphAtlas(uint16_t width, uint16_t height); + + Rect<uint16_t> addGlyph(uint64_t tile_id, const std::string& face_name, + const SDFGlyph& glyph); + void addGlyphs(uint64_t tileid, std::u32string const& text, std::string const& stackname, + FontStack const& fontStack, GlyphPositions & face); + void removeGlyphs(uint64_t tile_id); + void bind(); + +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; + std::unique_ptr<char[]> data; + std::atomic<bool> dirty; + uint32_t texture = 0; +}; + +}; + +#endif |