summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <ansis@mapbox.com>2018-02-14 15:17:48 -0500
committerAnsis Brammanis <ansis@mapbox.com>2018-02-14 16:57:05 -0500
commit88032a785519b4e80dff47a6de732657121cf4fe (patch)
tree0b28dd000aa754b7e3a9fd38464cd34824ba238d
parent8a283b030629abb00367929d047731c3974bc3d6 (diff)
downloadqtlocation-mapboxgl-upstream/fix-empty-string-label.tar.gz
[core] don't hide icons if text is an empty stringupstream/fix-empty-string-label
m---------mapbox-gl-js0
-rw-r--r--src/mbgl/layout/symbol_instance.cpp8
-rw-r--r--src/mbgl/layout/symbol_instance.hpp4
-rw-r--r--src/mbgl/layout/symbol_layout.cpp9
-rw-r--r--src/mbgl/text/placement.cpp12
-rw-r--r--test/text/cross_tile_symbol_index.test.cpp2
6 files changed, 22 insertions, 13 deletions
diff --git a/mapbox-gl-js b/mapbox-gl-js
-Subproject f13c86ea356c384fdab31855b9152f5bf5ef97b
+Subproject eb90e09f7148d56c636412912e5de6214934b32
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp
index 6e152349ca..c7f6269d4b 100644
--- a/src/mbgl/layout/symbol_instance.cpp
+++ b/src/mbgl/layout/symbol_instance.cpp
@@ -12,6 +12,8 @@ SymbolInstance::SymbolInstance(Anchor& anchor_,
const SymbolLayoutProperties::Evaluated& layout,
const float layoutTextSize,
const uint32_t index_,
+ const bool hasText_,
+ const bool hasIcon_,
const float textBoxScale,
const float textPadding,
const SymbolPlacementType textPlacement,
@@ -27,8 +29,10 @@ SymbolInstance::SymbolInstance(Anchor& anchor_,
anchor(anchor_),
line(line_),
index(index_),
- hasText(shapedTextOrientations.first || shapedTextOrientations.second),
- hasIcon(shapedIcon),
+ hasText(hasText_),
+ hasIcon(hasIcon_),
+ hasTextData(shapedTextOrientations.first || shapedTextOrientations.second),
+ hasIconData(shapedIcon),
// Create the collision features that will be used to check whether this symbol instance can be placed
textCollisionFeature(line_, anchor, shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature, overscaling),
diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp
index 827a5dbbdb..e896cde392 100644
--- a/src/mbgl/layout/symbol_instance.hpp
+++ b/src/mbgl/layout/symbol_instance.hpp
@@ -20,6 +20,8 @@ public:
const style::SymbolLayoutProperties::Evaluated&,
const float layoutTextSize,
const uint32_t index,
+ const bool hasText,
+ const bool hasIcon,
const float textBoxScale,
const float textPadding,
style::SymbolPlacementType textPlacement,
@@ -38,6 +40,8 @@ public:
uint32_t index;
bool hasText;
bool hasIcon;
+ bool hasTextData;
+ bool hasIconData;
SymbolQuads horizontalGlyphQuads;
SymbolQuads verticalGlyphQuads;
optional<SymbolQuad> iconQuad;
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index a41a98fcaf..26332df4a0 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -323,6 +323,7 @@ void SymbolLayout::addFeature(const std::size_t index,
symbolInstances.emplace_back(anchor, line, shapedTextOrientations, shapedIcon,
layout.evaluate(zoom, feature), layoutTextSize,
symbolInstances.size(),
+ bool(feature.text), bool(feature.icon),
textBoxScale, textPadding, textPlacement, textOffset,
iconBoxScale, iconPadding, iconOffset,
glyphPositionMap, indexedFeature, index, feature.text.value_or(std::u16string()), overscaling);
@@ -428,14 +429,14 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(const bool showCollisionBoxes)
for (SymbolInstance &symbolInstance : bucket->symbolInstances) {
- const bool hasText = symbolInstance.hasText;
- const bool hasIcon = symbolInstance.hasIcon;
+ const bool hasTextData = symbolInstance.hasTextData;
+ const bool hasIconData = symbolInstance.hasIconData;
const auto& feature = features.at(symbolInstance.featureIndex);
// Insert final placement into collision tree and add glyphs/icons to buffers
- if (hasText) {
+ if (hasTextData) {
const Range<float> sizeData = bucket->textSizeBinder->getVertexSizeData(feature);
bucket->text.placedSymbols.emplace_back(symbolInstance.anchor.point, symbolInstance.anchor.segment, sizeData.min, sizeData.max,
symbolInstance.textOffset, symbolInstance.writingModes, symbolInstance.line, CalculateTileDistances(symbolInstance.line, symbolInstance.anchor));
@@ -474,7 +475,7 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(const bool showCollisionBoxes)
}
}
- if (hasIcon) {
+ if (hasIconData) {
if (symbolInstance.iconQuad) {
const Range<float> sizeData = bucket->iconSizeBinder->getVertexSizeData(feature);
bucket->icon.placedSymbols.emplace_back(symbolInstance.anchor.point, symbolInstance.anchor.segment, sizeData.min, sizeData.max,
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 400fe79ac5..f8fed7f01a 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -108,8 +108,8 @@ void Placement::placeLayerBucket(
continue;
}
- bool placeText = false;
- bool placeIcon = false;
+ bool placeText = symbolInstance.hasText;
+ bool placeIcon = symbolInstance.hasIcon;
bool offscreen = true;
if (symbolInstance.placedTextIndex) {
@@ -149,11 +149,11 @@ void Placement::placeLayerBucket(
placeIcon = placeText && placeIcon;
}
- if (placeText) {
+ if (placeText && symbolInstance.hasTextData) {
collisionIndex.insertFeature(symbolInstance.textCollisionFeature, bucket.layout.get<style::TextIgnorePlacement>());
}
- if (placeIcon) {
+ if (placeIcon && symbolInstance.hasIconData) {
collisionIndex.insertFeature(symbolInstance.iconCollisionFeature, bucket.layout.get<style::IconIgnorePlacement>());
}
@@ -249,7 +249,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
seenCrossTileIDs.insert(symbolInstance.crossTileID);
- if (symbolInstance.hasText) {
+ if (symbolInstance.hasTextData) {
auto opacityVertex = SymbolOpacityAttributes::vertex(opacityState.text.placed, opacityState.text.opacity);
for (size_t i = 0; i < symbolInstance.horizontalGlyphQuads.size() * 4; i++) {
bucket.text.opacityVertices.emplace_back(opacityVertex);
@@ -264,7 +264,7 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
bucket.text.placedSymbols[*symbolInstance.placedVerticalTextIndex].hidden = opacityState.isHidden();
}
}
- if (symbolInstance.hasIcon) {
+ if (symbolInstance.hasIconData) {
auto opacityVertex = SymbolOpacityAttributes::vertex(opacityState.icon.placed, opacityState.icon.opacity);
if (symbolInstance.iconQuad) {
bucket.icon.opacityVertices.emplace_back(opacityVertex);
diff --git a/test/text/cross_tile_symbol_index.test.cpp b/test/text/cross_tile_symbol_index.test.cpp
index 794c2b59a1..dd2494bb53 100644
--- a/test/text/cross_tile_symbol_index.test.cpp
+++ b/test/text/cross_tile_symbol_index.test.cpp
@@ -11,7 +11,7 @@ SymbolInstance makeSymbolInstance(float x, float y, std::u16string key) {
style::SymbolLayoutProperties::Evaluated layout_;
IndexedSubfeature subfeature(0, "", "", 0);
Anchor anchor(x, y, 0, 0);
- return {anchor, line, shaping, {}, layout_, 0, 0, 0, 0, style::SymbolPlacementType::Point, {{0, 0}}, 0, 0, {{0, 0}}, gpm, subfeature, 0, key, 0 };
+ return {anchor, line, shaping, {}, layout_, 0, 0, true, false, 0, 0, style::SymbolPlacementType::Point, {{0, 0}}, 0, 0, {{0, 0}}, gpm, subfeature, 0, key, 0 };
}