Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] don't hide icons if text is an empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Feb 14, 2018
1 parent 8a283b0 commit 88032a7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion mapbox-gl-js
Submodule mapbox-gl-js updated 60 files
+3 −0 .circleci/deploy.sh
+2 −1 bench/README.md
+23 −8 bench/index.html
+2 −2 package.json
+12 −12 src/data/bucket/symbol_bucket.js
+3 −5 src/data/feature_index.js
+9 −2 src/geo/transform.js
+1 −1 src/source/geojson_source.js
+1 −1 src/source/query_features.js
+1 −1 src/source/tile.js
+42 −6 src/style-spec/reference/v8.json
+5 −0 src/style/pauseable_placement.js
+17 −16 src/style/style.js
+17 −13 src/symbol/placement.js
+1 −1 src/ui/hash.js
+21 −0 src/ui/map.js
+13 −3 src/util/ajax.js
+37 −22 test/integration/lib/render.js
+2 −1 test/integration/package.json
+13 −0 test/integration/query-tests/regressions/mapbox-gl-js#6075/expected.json
+51 −0 test/integration/query-tests/regressions/mapbox-gl-js#6075/style.json
+ test/integration/render-tests/heatmap-color/default/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-color/default/style.json
+ test/integration/render-tests/heatmap-color/expression/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-color/expression/style.json
+ test/integration/render-tests/heatmap-intensity/default/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-intensity/default/style.json
+ test/integration/render-tests/heatmap-intensity/function/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-intensity/function/style.json
+ test/integration/render-tests/heatmap-intensity/literal/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-intensity/literal/style.json
+ test/integration/render-tests/heatmap-opacity/default/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-opacity/default/style.json
+ test/integration/render-tests/heatmap-opacity/function/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-opacity/function/style.json
+ test/integration/render-tests/heatmap-opacity/literal/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-opacity/literal/style.json
+ test/integration/render-tests/heatmap-radius/antimeridian/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-radius/antimeridian/style.json
+ test/integration/render-tests/heatmap-radius/data-expression/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-radius/data-expression/style.json
+ test/integration/render-tests/heatmap-radius/default/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-radius/default/style.json
+ test/integration/render-tests/heatmap-radius/function/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-radius/function/style.json
+ test/integration/render-tests/heatmap-radius/literal/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-radius/literal/style.json
+ test/integration/render-tests/heatmap-radius/pitch30/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-radius/pitch30/style.json
+ test/integration/render-tests/heatmap-weight/default/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-weight/default/style.json
+ test/integration/render-tests/heatmap-weight/identity-property-function/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-weight/identity-property-function/style.json
+ test/integration/render-tests/heatmap-weight/literal/expected-half-float.png
+2 −1 test/integration/render-tests/heatmap-weight/literal/style.json
+ test/integration/render-tests/regressions/mapbox-gl-js#6160/expected.png
+73 −0 test/integration/render-tests/regressions/mapbox-gl-js#6160/style.json
+1 −3 test/unit/style/style.test.js
+48 −0 test/unit/ui/map.test.js
+61 −106 yarn.lock
8 changes: 6 additions & 2 deletions src/mbgl/layout/symbol_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions src/mbgl/layout/symbol_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SymbolInstance {
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,
Expand All @@ -38,6 +40,8 @@ class SymbolInstance {
uint32_t index;
bool hasText;
bool hasIcon;
bool hasTextData;
bool hasIconData;
SymbolQuads horizontalGlyphQuads;
SymbolQuads verticalGlyphQuads;
optional<SymbolQuad> iconQuad;
Expand Down
9 changes: 5 additions & 4 deletions src/mbgl/layout/symbol_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/mbgl/text/placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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>());
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/text/cross_tile_symbol_index.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}


Expand Down

0 comments on commit 88032a7

Please sign in to comment.