summaryrefslogtreecommitdiff
path: root/src/mbgl/layout
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2019-11-13 11:22:26 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2019-12-02 17:11:49 +0200
commit34a9bc08ceefd695240047061fed41c591d30171 (patch)
tree71343b52067ea3dc1326b4637b03d78ab5c19969 /src/mbgl/layout
parenta9c3b5a389a249a9ddb62250cdcb8f8edb2f7280 (diff)
downloadqtlocation-mapboxgl-34a9bc08ceefd695240047061fed41c591d30171.tar.gz
[core] Pass images and evaluated layout text size to shaping
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r--src/mbgl/layout/symbol_layout.cpp28
-rw-r--r--src/mbgl/layout/symbol_layout.hpp2
2 files changed, 24 insertions, 6 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index 54708d5549..c64a2d21d1 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -352,16 +352,22 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions
ShapedTextOrientations shapedTextOrientations;
optional<PositionedIcon> shapedIcon;
std::array<float, 2> textOffset{{0.0f, 0.0f}};
+ const float layoutTextSize = layout->evaluate<TextSize>(zoom + 1, feature);
+ const float layoutIconSize = layout->evaluate<IconSize>(zoom + 1, feature);
// if feature has text, shape the text
if (feature.formattedText) {
const float lineHeight = layout->get<TextLineHeight>() * util::ONE_EM;
const float spacing = util::i18n::allowsLetterSpacing(feature.formattedText->rawText()) ? layout->evaluate<TextLetterSpacing>(zoom, feature) * util::ONE_EM : 0.0f;
- auto applyShaping = [&] (const TaggedString& formattedText, WritingModeType writingMode, SymbolAnchorType textAnchor, TextJustifyType textJustify) {
+ auto applyShaping = [&](const TaggedString& formattedText,
+ WritingModeType writingMode,
+ SymbolAnchorType textAnchor,
+ TextJustifyType textJustify) {
const Shaping result = getShaping(
/* string */ formattedText,
- /* maxWidth: ems */ isPointPlacement ? layout->evaluate<TextMaxWidth>(zoom, feature) * util::ONE_EM : 0.0f,
+ /* maxWidth: ems */
+ isPointPlacement ? layout->evaluate<TextMaxWidth>(zoom, feature) * util::ONE_EM : 0.0f,
/* ems */ lineHeight,
textAnchor,
textJustify,
@@ -370,10 +376,13 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions
/* writingMode */ writingMode,
/* bidirectional algorithm object */ bidi,
/* glyphs */ glyphMap,
+ /* images */ imagePositions,
+ layoutTextSize,
allowVerticalPlacement);
return result;
};
+
const std::vector<style::TextVariableAnchorType> variableTextAnchor = layout->evaluate<TextVariableAnchor>(zoom, feature);
const SymbolAnchorType textAnchor = layout->evaluate<TextAnchor>(zoom, feature);
if (variableTextAnchor.empty()) {
@@ -475,7 +484,15 @@ void SymbolLayout::prepareSymbols(const GlyphMap& glyphMap, const GlyphPositions
// if either shapedText or icon position is present, add the feature
if (getDefaultHorizontalShaping(shapedTextOrientations) || shapedIcon) {
- addFeature(std::distance(features.begin(), it), feature, shapedTextOrientations, std::move(shapedIcon), glyphPositions, textOffset, iconType);
+ addFeature(std::distance(features.begin(), it),
+ feature,
+ shapedTextOrientations,
+ std::move(shapedIcon),
+ glyphPositions,
+ textOffset,
+ layoutTextSize,
+ layoutIconSize,
+ iconType);
}
feature.geometry.clear();
@@ -490,13 +507,12 @@ void SymbolLayout::addFeature(const std::size_t layoutFeatureIndex,
optional<PositionedIcon> shapedIcon,
const GlyphPositions& glyphPositions,
std::array<float, 2> textOffset,
+ float layoutTextSize,
+ float layoutIconSize,
const SymbolContent iconType) {
const float minScale = 0.5f;
const float glyphSize = 24.0f;
- const float layoutTextSize = layout->evaluate<TextSize>(zoom + 1, feature);
- const float layoutIconSize = layout->evaluate<IconSize>(zoom + 1, feature);
-
const std::array<float, 2> iconOffset = layout->evaluate<IconOffset>(zoom, feature);
// To reduce the number of labels that jump around when zooming we need
diff --git a/src/mbgl/layout/symbol_layout.hpp b/src/mbgl/layout/symbol_layout.hpp
index 2b99c2fa24..804bc39741 100644
--- a/src/mbgl/layout/symbol_layout.hpp
+++ b/src/mbgl/layout/symbol_layout.hpp
@@ -62,6 +62,8 @@ private:
optional<PositionedIcon> shapedIcon,
const GlyphPositions&,
std::array<float, 2> textOffset,
+ float layoutTextSize,
+ float layoutIconSize,
const SymbolContent iconType);
bool anchorIsTooClose(const std::u16string& text, const float repeatDistance, const Anchor&);