summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2016-01-29 00:19:40 -0800
committerAnsis Brammanis <brammanis@gmail.com>2016-02-02 16:17:30 -0800
commit2cfc6248486cb3ed2c18bd6722fdfb841c68626b (patch)
treebf18e1ad4e84984fde99f9b17c588bf68293b3f8
parent4e0d1070f623811513e6800e4ac906d69958d66a (diff)
downloadqtlocation-mapboxgl-2cfc6248486cb3ed2c18bd6722fdfb841c68626b.tar.gz
[core] make symbol sort order more deterministic
-rw-r--r--package.json2
-rw-r--r--src/mbgl/renderer/symbol_bucket.cpp13
-rw-r--r--src/mbgl/renderer/symbol_bucket.hpp3
3 files changed, 11 insertions, 7 deletions
diff --git a/package.json b/package.json
index 50d5a393d1..742808bbaa 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
],
"devDependencies": {
"aws-sdk": "^2.2.21",
- "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#67fe48d058c23dbb4a8ac36ce0270185da3045a8",
+ "mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#7ebad0438ea47721235434f56eb0dba2db66ddb5",
"node-gyp": "^3.2.1",
"request": "^2.67.0",
"tape": "^4.2.2"
diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp
index 36d285909b..e4fccc22e9 100644
--- a/src/mbgl/renderer/symbol_bucket.cpp
+++ b/src/mbgl/renderer/symbol_bucket.cpp
@@ -31,12 +31,13 @@ namespace mbgl {
SymbolInstance::SymbolInstance(Anchor& anchor, const std::vector<Coordinate>& line,
const Shaping& shapedText, const PositionedIcon& shapedIcon,
- const SymbolLayoutProperties& layout, const bool addToBuffers,
+ const SymbolLayoutProperties& layout, const bool addToBuffers, const uint32_t index_,
const float textBoxScale, const float textPadding, const float textAlongLine,
const float iconBoxScale, const float iconPadding, const float iconAlongLine,
const GlyphPositions& face) :
x(anchor.x),
y(anchor.y),
+ index(index_),
hasText(shapedText),
hasIcon(shapedIcon),
@@ -333,7 +334,7 @@ void SymbolBucket::addFeature(const std::vector<std::vector<Coordinate>> &lines,
// TODO remove the `&& false` when is #1673 implemented
const bool addToBuffers = (mode == MapMode::Still) || inside || (mayOverlap && false);
- symbolInstances.emplace_back(anchor, line, shapedText, shapedIcon, layout, addToBuffers,
+ symbolInstances.emplace_back(anchor, line, shapedText, shapedIcon, layout, addToBuffers, symbolInstances.size(),
textBoxScale, textPadding, textAlongLine,
iconBoxScale, iconPadding, iconAlongLine,
face);
@@ -382,9 +383,11 @@ void SymbolBucket::placeFeatures(CollisionTile& collisionTile) {
const float cos = std::cos(collisionTile.config.angle);
std::sort(symbolInstances.begin(), symbolInstances.end(), [sin, cos](SymbolInstance &a, SymbolInstance &b) {
- const float aRotated = sin * a.x + cos * a.y;
- const float bRotated = sin * b.x + cos * b.y;
- return aRotated < bRotated;
+ const int32_t aRotated = sin * a.x + cos * a.y;
+ const int32_t bRotated = sin * b.x + cos * b.y;
+ return aRotated != bRotated ?
+ aRotated < bRotated :
+ a.index > b.index;
});
}
diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp
index 7ea5fa05d7..5728cfa28c 100644
--- a/src/mbgl/renderer/symbol_bucket.hpp
+++ b/src/mbgl/renderer/symbol_bucket.hpp
@@ -46,12 +46,13 @@ class SymbolInstance {
public:
explicit SymbolInstance(Anchor& anchor, const std::vector<Coordinate>& line,
const Shaping& shapedText, const PositionedIcon& shapedIcon,
- const SymbolLayoutProperties& layout, const bool inside,
+ const SymbolLayoutProperties& layout, const bool inside, const uint32_t index,
const float textBoxScale, const float textPadding, const float textAlongLine,
const float iconBoxScale, const float iconPadding, const float iconAlongLine,
const GlyphPositions& face);
float x;
float y;
+ uint32_t index;
bool hasText;
bool hasIcon;
SymbolQuads glyphQuads;