diff options
author | Chris Loer <chris.loer@gmail.com> | 2016-11-09 18:23:49 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-17 14:33:03 -0800 |
commit | 40b0c8d0760f8a767ef4646607ac63251d86de8d (patch) | |
tree | 5840c35c21dcb593198093769db8c81be6ce3674 /src/mbgl/layout | |
parent | 5c7aeec5c7170f47a127391cfdb5e25b42ec8b58 (diff) | |
download | qtlocation-mapboxgl-40b0c8d0760f8a767ef4646607ac63251d86de8d.tar.gz |
[core] Use UTF-16 instead of UTF-32 for label features to avoid extra conversions and reduce in-memory size.
Continue to use uint32 as glyph ID to maintain Glyph PBF, even though we're only using 16 bits of that uint32.
Use std::codecvt instead of boost::unicode_iterator for UTF8->UTF16 conversions.
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/merge_lines.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_feature.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/layout/symbol_layout.hpp | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/mbgl/layout/merge_lines.cpp b/src/mbgl/layout/merge_lines.cpp index f4fdb82617..676cbc092d 100644 --- a/src/mbgl/layout/merge_lines.cpp +++ b/src/mbgl/layout/merge_lines.cpp @@ -47,10 +47,10 @@ enum class Side { }; size_t -getKey(const std::u32string& text, const GeometryCollection& geom, Side side) { +getKey(const std::u16string& text, const GeometryCollection& geom, Side side) { const GeometryCoordinate& coord = side == Side::Right ? geom[0].back() : geom[0].front(); - auto hash = std::hash<std::u32string>()(text); + auto hash = std::hash<std::u16string>()(text); boost::hash_combine(hash, coord.x); boost::hash_combine(hash, coord.y); return hash; diff --git a/src/mbgl/layout/symbol_feature.hpp b/src/mbgl/layout/symbol_feature.hpp index 99db4f9ac5..9e0eacaac5 100644 --- a/src/mbgl/layout/symbol_feature.hpp +++ b/src/mbgl/layout/symbol_feature.hpp @@ -10,7 +10,7 @@ namespace mbgl { class SymbolFeature { public: GeometryCollection geometry; - optional<std::u32string> text; + optional<std::u16string> text; optional<std::string> icon; std::size_t index; }; diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index d974e6a357..7f8e8d5f83 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -90,10 +90,10 @@ SymbolLayout::SymbolLayout(std::string bucketName_, u8string = platform::lowercase(u8string); } - ft.text = util::utf8_to_utf32::convert(u8string); + ft.text = util::utf8_to_utf16::convert( u8string ); // Loop through all characters of this text and collect unique codepoints. - for (char32_t chr : *ft.text) { + for (char16_t chr : *ft.text) { ranges.insert(getGlyphRange(chr)); } } @@ -309,7 +309,7 @@ void SymbolLayout::addFeature(const GeometryCollection &lines, } } -bool SymbolLayout::anchorIsTooClose(const std::u32string &text, const float repeatDistance, Anchor &anchor) { +bool SymbolLayout::anchorIsTooClose(const std::u16string &text, const float repeatDistance, Anchor &anchor) { if (compareText.find(text) == compareText.end()) { compareText.emplace(text, Anchors()); } else { diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp index 54acf84aaf..9a580900dd 100644 --- a/src/mbgl/layout/symbol_layout.hpp +++ b/src/mbgl/layout/symbol_layout.hpp @@ -64,8 +64,8 @@ private: const GlyphPositions& face, const size_t index); - bool anchorIsTooClose(const std::u32string& text, const float repeatDistance, Anchor&); - std::map<std::u32string, std::vector<Anchor>> compareText; + bool anchorIsTooClose(const std::u16string& text, const float repeatDistance, Anchor&); + std::map<std::u16string, std::vector<Anchor>> compareText; void addToDebugBuffers(CollisionTile&, SymbolBucket&); |