summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-03-12 17:46:52 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-03-13 10:55:49 -0700
commit6325f1e25a47f1d8afa35aee0db1327c21466b67 (patch)
tree168dde4d488d7411ecc8affd89c9605a467cfb16 /src
parent96682a02af35295f0f241b52a4d44a6059b04485 (diff)
downloadqtlocation-mapboxgl-6325f1e25a47f1d8afa35aee0db1327c21466b67.tar.gz
Index glyph use by tile pointer value, not tile ID
There can be multiple tiles with the same ID, but from different sources. Fixes #957
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/glyph_atlas.cpp14
-rw-r--r--src/mbgl/geometry/glyph_atlas.hpp10
-rw-r--r--src/mbgl/map/tile_parser.cpp2
-rw-r--r--src/mbgl/map/vector_tile_data.cpp2
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp9
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp2
6 files changed, 21 insertions, 18 deletions
diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp
index 6fcb4ecf87..f690004b52 100644
--- a/src/mbgl/geometry/glyph_atlas.cpp
+++ b/src/mbgl/geometry/glyph_atlas.cpp
@@ -18,7 +18,7 @@ GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_)
dirty(true) {
}
-void GlyphAtlas::addGlyphs(uint64_t tileID,
+void GlyphAtlas::addGlyphs(uintptr_t tileUID,
const std::u32string& text,
const std::string& stackName,
const FontStack& fontStack,
@@ -36,12 +36,12 @@ void GlyphAtlas::addGlyphs(uint64_t tileID,
}
const SDFGlyph& sdf = sdf_it->second;
- Rect<uint16_t> rect = addGlyph(tileID, stackName, sdf);
+ Rect<uint16_t> rect = addGlyph(tileUID, stackName, sdf);
face.emplace(chr, Glyph{rect, sdf.metrics});
}
}
-Rect<uint16_t> GlyphAtlas::addGlyph(uint64_t tileID,
+Rect<uint16_t> GlyphAtlas::addGlyph(uintptr_t tileUID,
const std::string& stackName,
const SDFGlyph& glyph)
{
@@ -54,7 +54,7 @@ Rect<uint16_t> GlyphAtlas::addGlyph(uint64_t tileID,
// The glyph is already in this texture.
if (it != face.end()) {
GlyphValue& value = it->second;
- value.ids.insert(tileID);
+ value.ids.insert(tileUID);
return value.rect;
}
@@ -85,7 +85,7 @@ Rect<uint16_t> GlyphAtlas::addGlyph(uint64_t tileID,
assert(rect.x + rect.w <= width);
assert(rect.y + rect.h <= height);
- face.emplace(glyph.id, GlyphValue { rect, tileID });
+ face.emplace(glyph.id, GlyphValue { rect, tileUID });
// Copy the bitmap
char *target = data.get();
@@ -103,14 +103,14 @@ Rect<uint16_t> GlyphAtlas::addGlyph(uint64_t tileID,
return rect;
}
-void GlyphAtlas::removeGlyphs(uint64_t tile_id) {
+void GlyphAtlas::removeGlyphs(uintptr_t tileUID) {
std::lock_guard<std::mutex> lock(mtx);
for (auto& faces : index) {
std::map<uint32_t, GlyphValue>& face = faces.second;
for (auto it = face.begin(); it != face.end(); /* we advance in the body */) {
GlyphValue& value = it->second;
- value.ids.erase(tile_id);
+ value.ids.erase(tileUID);
if (!value.ids.size()) {
const Rect<uint16_t>& rect = value.rect;
diff --git a/src/mbgl/geometry/glyph_atlas.hpp b/src/mbgl/geometry/glyph_atlas.hpp
index 19550ea4df..a25c735a8e 100644
--- a/src/mbgl/geometry/glyph_atlas.hpp
+++ b/src/mbgl/geometry/glyph_atlas.hpp
@@ -17,12 +17,12 @@ class GlyphAtlas : public util::noncopyable {
public:
GlyphAtlas(uint16_t width, uint16_t height);
- void addGlyphs(uint64_t tileID,
+ void addGlyphs(uintptr_t tileUID,
const std::u32string& text,
const std::string& stackName,
const FontStack&,
GlyphPositions&);
- void removeGlyphs(uint64_t tile_id);
+ void removeGlyphs(uintptr_t tileUID);
void bind();
@@ -31,13 +31,13 @@ public:
private:
struct GlyphValue {
- GlyphValue(const Rect<uint16_t>& rect_, uint64_t id)
+ GlyphValue(const Rect<uint16_t>& rect_, uintptr_t id)
: rect(rect_), ids({ id }) {}
Rect<uint16_t> rect;
- std::set<uint64_t> ids;
+ std::set<uintptr_t> ids;
};
- Rect<uint16_t> addGlyph(uint64_t tileID,
+ Rect<uint16_t> addGlyph(uintptr_t tileID,
const std::string& stackName,
const SDFGlyph&);
diff --git a/src/mbgl/map/tile_parser.cpp b/src/mbgl/map/tile_parser.cpp
index c50c394e2c..0540c7d7d3 100644
--- a/src/mbgl/map/tile_parser.cpp
+++ b/src/mbgl/map/tile_parser.cpp
@@ -256,7 +256,7 @@ std::unique_ptr<Bucket> TileParser::createSymbolBucket(const GeometryTileLayer&
auto symbol = parseStyleLayoutSymbol(bucket_desc, tile.id.z);
auto bucket = util::make_unique<SymbolBucket>(std::move(symbol), *collision);
bucket->addFeatures(
- layer, bucket_desc.filter, tile.id, spriteAtlas, *sprite, glyphAtlas, glyphStore);
+ layer, bucket_desc.filter, reinterpret_cast<uintptr_t>(&tile), spriteAtlas, *sprite, glyphAtlas, glyphStore);
return obsolete() ? nullptr : std::move(bucket);
}
}
diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp
index 66fed0706b..e165863bec 100644
--- a/src/mbgl/map/vector_tile_data.cpp
+++ b/src/mbgl/map/vector_tile_data.cpp
@@ -25,7 +25,7 @@ VectorTileData::VectorTileData(Tile::ID const& id_,
}
VectorTileData::~VectorTileData() {
- glyphAtlas.removeGlyphs(id.to_uint64());
+ glyphAtlas.removeGlyphs(reinterpret_cast<uintptr_t>(this));
}
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 7e587e7eed..2c28d72196 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -124,8 +124,11 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const GeometryTileLayer
void SymbolBucket::addFeatures(const GeometryTileLayer& layer,
const FilterExpression& filter,
- const Tile::ID &id, SpriteAtlas &spriteAtlas, Sprite &sprite,
- GlyphAtlas & glyphAtlas, GlyphStore &glyphStore) {
+ uintptr_t tileUID,
+ SpriteAtlas& spriteAtlas,
+ Sprite& sprite,
+ GlyphAtlas& glyphAtlas,
+ GlyphStore& glyphStore) {
auto &layout = *styleLayout;
const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore, sprite);
@@ -193,7 +196,7 @@ void SymbolBucket::addFeatures(const GeometryTileLayer& layer,
// Add the glyphs we need for this label to the glyph atlas.
if (shaping.size()) {
- glyphAtlas.addGlyphs(id.to_uint64(), feature.label, layout.text.font, fontStack, face);
+ glyphAtlas.addGlyphs(tileUID, feature.label, layout.text.font, fontStack, face);
}
}
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 26cf22c546..b7291c186c 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -67,7 +67,7 @@ public:
void addFeatures(const GeometryTileLayer&,
const FilterExpression&,
- const Tile::ID&,
+ uintptr_t tileUID,
SpriteAtlas&,
Sprite&,
GlyphAtlas&,