From 31d9dbefeaad90eaece85c013d355c624018db7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 30 May 2014 14:01:53 +0200 Subject: [PATCH] pass shaping directly instead of looking it up --- include/llmr/renderer/text_bucket.hpp | 4 ++-- src/map/tile_parser.cpp | 10 +++------- src/renderer/text_bucket.cpp | 28 +++------------------------ 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/include/llmr/renderer/text_bucket.hpp b/include/llmr/renderer/text_bucket.hpp index ad282bdd0..36c50ae7f 100644 --- a/include/llmr/renderer/text_bucket.hpp +++ b/include/llmr/renderer/text_bucket.hpp @@ -36,9 +36,9 @@ public: void addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, PlacementRange placementRange, float zoom); - void addFeature(const VectorTileFeature &feature, + void addFeature(const pbf &geometry, const GlyphPositions &face, - const std::map &shapings); + const Shaping &shaping); void drawGlyphs(TextShader &shader); diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index f23a5e673..e0e28e345 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -199,7 +199,6 @@ std::unique_ptr TileParser::createTextBucket(const VectorTileLayer& laye // Create a copy! const FontStack &fontStack = glyphStore.getFontStack(bucket_desc.geometry.font); - std::map shaping; GlyphPositions face; // Shape and place all labels. @@ -222,18 +221,15 @@ std::unique_ptr TileParser::createTextBucket(const VectorTileLayer& laye const std::u32string string = ucs4conv.convert(source_string); // Shape labels. - const Shaping shaped = fontStack.getShaping(string); - shaping.emplace(source_string, shaped); + const Shaping shaping = fontStack.getShaping(string); // Place labels. addGlyph(tile.id.to_uint64(), bucket_desc.geometry.font, string, fontStack, glyphAtlas, face); + + bucket->addFeature(feature.geometry, face, shaping); } } - // It looks like nearly the same interface through the rest - // of the stack. - addBucketFeatures(bucket, layer, bucket_desc, face, shaping); - return std::move(bucket); } diff --git a/src/renderer/text_bucket.cpp b/src/renderer/text_bucket.cpp index 5823607ac..da6de3817 100644 --- a/src/renderer/text_bucket.cpp +++ b/src/renderer/text_bucket.cpp @@ -99,37 +99,15 @@ void TextBucket::addGlyphs(const PlacedGlyphs &glyphs, float placementZoom, } }; -void TextBucket::addFeature(const VectorTileFeature &feature, +void TextBucket::addFeature(const pbf &geom_pbf, const GlyphPositions &face, - const std::map &shapings) { - auto it_prop = feature.properties.find(geom_desc.field); - if (it_prop == feature.properties.end()) { - // feature does not have the correct property - if (debug::labelTextMissingWarning) { - fprintf(stderr, "[WARNING] feature doesn't have property '%s' required for labelling\n", geom_desc.field.c_str()); - } - return; - } - const Value &value = it_prop->second; - - auto it_shaping = shapings.find(toString(value)); - if (it_shaping == shapings.end()) { - if (debug::shapingWarning) { - fprintf(stderr, "[WARNING] missing shaping for '%s'\n", toString(value).c_str()); - } - // we lack shaping information for this label - return; - } - const Shaping &shaping = it_shaping->second; - - // std::cerr << "we have shaping for " << value << std::endl; - + const Shaping &shaping) { // Decode all lines. std::vector line; Geometry::command cmd; Coordinate coord; - pbf geom = feature.geometry; + pbf geom(geom_pbf); Geometry geometry(geom); int32_t x, y; while ((cmd = geometry.next(x, y)) != Geometry::end) {