summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2017-06-20 16:45:06 -0400
committerAnsis Brammanis <brammanis@gmail.com>2017-06-20 16:45:06 -0400
commit40c0f734d70fb47af1cf3572546f625d2cb78600 (patch)
treef467e543a7e16fbd64d09e0ae5bf5ab76b3736d6
parent383b7792a5f5bc5e2e882f6f7f78418cd6f9c7ae (diff)
downloadqtlocation-mapboxgl-40c0f734d70fb47af1cf3572546f625d2cb78600.tar.gz
use real line and some shader stuff
-rw-r--r--src/mbgl/layout/symbol_instance.cpp13
-rw-r--r--src/mbgl/layout/symbol_instance.hpp3
-rw-r--r--src/mbgl/layout/symbol_layout.cpp4
-rw-r--r--src/mbgl/layout/symbol_projection.cpp8
-rw-r--r--src/mbgl/renderer/buckets/symbol_bucket.hpp6
-rw-r--r--src/mbgl/renderer/painters/painter_symbol.cpp5
-rw-r--r--src/mbgl/shaders/symbol_sdf.cpp12
7 files changed, 29 insertions, 22 deletions
diff --git a/src/mbgl/layout/symbol_instance.cpp b/src/mbgl/layout/symbol_instance.cpp
index ffb70c7ca2..d28da6b43e 100644
--- a/src/mbgl/layout/symbol_instance.cpp
+++ b/src/mbgl/layout/symbol_instance.cpp
@@ -6,7 +6,7 @@ namespace mbgl {
using namespace style;
SymbolInstance::SymbolInstance(Anchor& anchor,
- const GeometryCoordinates& line,
+ GeometryCoordinates line_,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
optional<PositionedIcon> shapedIcon,
const SymbolLayoutProperties::Evaluated& layout,
@@ -23,26 +23,27 @@ SymbolInstance::SymbolInstance(Anchor& anchor,
const IndexedSubfeature& indexedFeature,
const std::size_t featureIndex_) :
point(anchor.point),
+ line(line_),
index(index_),
hasText(shapedTextOrientations.first || shapedTextOrientations.second),
hasIcon(shapedIcon),
// Create the collision features that will be used to check whether this symbol instance can be placed
- textCollisionFeature(line, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature),
- iconCollisionFeature(line, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature),
+ textCollisionFeature(line_, anchor, shapedTextOrientations.second ?: shapedTextOrientations.first, textBoxScale, textPadding, textPlacement, indexedFeature),
+ iconCollisionFeature(line_, anchor, shapedIcon, iconBoxScale, iconPadding, iconPlacement, indexedFeature),
featureIndex(featureIndex_) {
// Create the quads used for rendering the icon and glyphs.
if (addToBuffers) {
if (shapedIcon) {
- iconQuad = getIconQuad(anchor, *shapedIcon, line, layout, layoutTextSize, iconPlacement, shapedTextOrientations.first);
+ iconQuad = getIconQuad(anchor, *shapedIcon, line_, layout, layoutTextSize, iconPlacement, shapedTextOrientations.first);
}
if (shapedTextOrientations.first) {
- auto quads = getGlyphQuads(anchor, shapedTextOrientations.first, textBoxScale, line, layout, textPlacement, positions);
+ auto quads = getGlyphQuads(anchor, shapedTextOrientations.first, textBoxScale, line_, layout, textPlacement, positions);
glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end());
}
if (shapedTextOrientations.second) {
- auto quads = getGlyphQuads(anchor, shapedTextOrientations.second, textBoxScale, line, layout, textPlacement, positions);
+ auto quads = getGlyphQuads(anchor, shapedTextOrientations.second, textBoxScale, line_, layout, textPlacement, positions);
glyphQuads.insert(glyphQuads.end(), quads.begin(), quads.end());
}
}
diff --git a/src/mbgl/layout/symbol_instance.hpp b/src/mbgl/layout/symbol_instance.hpp
index f199d929df..859fa20a02 100644
--- a/src/mbgl/layout/symbol_instance.hpp
+++ b/src/mbgl/layout/symbol_instance.hpp
@@ -13,7 +13,7 @@ class IndexedSubfeature;
class SymbolInstance {
public:
SymbolInstance(Anchor& anchor,
- const GeometryCoordinates& line,
+ GeometryCoordinates line,
const std::pair<Shaping, Shaping>& shapedTextOrientations,
optional<PositionedIcon> shapedIcon,
const style::SymbolLayoutProperties::Evaluated&,
@@ -31,6 +31,7 @@ public:
const std::size_t featureIndex);
Point<float> point;
+ GeometryCoordinates line;
uint32_t index;
bool hasText;
bool hasIcon;
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp
index c59f1040a1..9bc1f65226 100644
--- a/src/mbgl/layout/symbol_layout.cpp
+++ b/src/mbgl/layout/symbol_layout.cpp
@@ -505,7 +505,7 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
bucket->text, *bucket->textSizeBinder, symbol, feature, placementZoom,
keepUpright, textPlacement, collisionTile.config.angle, symbolInstance.writingModes, symbolInstance.point);
}
- PlacedSymbol placedSymbol(symbolInstance.point, 0, 0, 0, 0, 0, placementZoom, false);
+ PlacedSymbol placedSymbol(symbolInstance.point, symbolInstance.index, 16, 16, 0, 0, placementZoom, false, symbolInstance.line);
bucket->text.placedSymbols.emplace_back(std::move(placedSymbol));
}
}
@@ -517,7 +517,7 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile)
addSymbol(
bucket->icon, *bucket->iconSizeBinder, *symbolInstance.iconQuad, feature, placementZoom,
keepUpright, iconPlacement, collisionTile.config.angle, symbolInstance.writingModes, symbolInstance.point);
- PlacedSymbol placedSymbol(symbolInstance.point, 0, 0, 0, 0, 0, placementZoom, false);
+ PlacedSymbol placedSymbol(symbolInstance.point, 0, 0, 0, 0, 0, placementZoom, false, symbolInstance.line);
bucket->icon.placedSymbols.emplace_back(std::move(placedSymbol));
}
}
diff --git a/src/mbgl/layout/symbol_projection.cpp b/src/mbgl/layout/symbol_projection.cpp
index 652e04151e..64d5a3b451 100644
--- a/src/mbgl/layout/symbol_projection.cpp
+++ b/src/mbgl/layout/symbol_projection.cpp
@@ -83,7 +83,7 @@ namespace mbgl {
};
optional<PlacedGlyph> placeGlyphAlongLine(const float offsetX, const float lineOffsetX, const float lineOffsetY, const bool flip,
- Point<float> anchorPoint, const uint16_t anchorSegment, const std::vector<Point<float>>& line, const mat4& labelPlaneMatrix) {
+ Point<float> anchorPoint, const uint16_t anchorSegment, const GeometryCoordinates& line, const mat4& labelPlaneMatrix) {
const float combinedOffsetX = flip ?
offsetX - lineOffsetX :
@@ -116,7 +116,7 @@ namespace mbgl {
if (currentIndex < 0 || currentIndex >= static_cast<int32_t>(line.size())) return {};
prev = current;
- current = project(line.at(currentIndex), labelPlaneMatrix);
+ current = project(convertPoint<float>(line.at(currentIndex)), labelPlaneMatrix);
distanceToPrev += currentSegmentDistance;
currentSegmentDistance = util::dist<float>(prev, current);
@@ -191,8 +191,8 @@ namespace mbgl {
bool flip = false;
if (values.keepUpright) {
if (false) {
- const Point<float> a = project(placedSymbol.line.at(placedSymbol.segment), posMatrix);
- const Point<float> b = project(placedSymbol.line.at(placedSymbol.segment + 1), posMatrix);
+ const Point<float> a = project(convertPoint<float>(placedSymbol.line.at(placedSymbol.segment)), posMatrix);
+ const Point<float> b = project(convertPoint<float>(placedSymbol.line.at(placedSymbol.segment + 1)), posMatrix);
flip = placedSymbol.vertical ? b.y > a.y : b.x < a.x;
}
}
diff --git a/src/mbgl/renderer/buckets/symbol_bucket.hpp b/src/mbgl/renderer/buckets/symbol_bucket.hpp
index 1534dbcf8f..e0bf830088 100644
--- a/src/mbgl/renderer/buckets/symbol_bucket.hpp
+++ b/src/mbgl/renderer/buckets/symbol_bucket.hpp
@@ -18,9 +18,9 @@ namespace mbgl {
class PlacedSymbol {
public:
PlacedSymbol(Point<float> anchorPoint_, uint16_t segment_, float lowerSize_, float upperSize_,
- float lineOffsetX_, float lineOffsetY_, float placementZoom_, bool vertical_) :
+ float lineOffsetX_, float lineOffsetY_, float placementZoom_, bool vertical_, GeometryCoordinates line_) :
anchorPoint(anchorPoint_), segment(segment_), lowerSize(lowerSize_), upperSize(upperSize_),
- lineOffsetX(lineOffsetX_), lineOffsetY(lineOffsetY_), placementZoom(placementZoom_), vertical(vertical_) {}
+ lineOffsetX(lineOffsetX_), lineOffsetY(lineOffsetY_), placementZoom(placementZoom_), vertical(vertical_), line(line_) {}
Point<float> anchorPoint;
uint16_t segment;
float lowerSize;
@@ -30,7 +30,7 @@ public:
float placementZoom;
bool vertical;
std::vector<float> glyphOffsets;
- std::vector<Point<float>> line;
+ GeometryCoordinates line;
};
class SymbolBucket : public Bucket {
diff --git a/src/mbgl/renderer/painters/painter_symbol.cpp b/src/mbgl/renderer/painters/painter_symbol.cpp
index c31f2c29ea..3db33cdd32 100644
--- a/src/mbgl/renderer/painters/painter_symbol.cpp
+++ b/src/mbgl/renderer/painters/painter_symbol.cpp
@@ -128,6 +128,11 @@ void Painter::renderSymbol(PaintParameters& parameters,
const bool alongLine = bucket.layout.get<SymbolPlacement>() == SymbolPlacementType::Line &&
bucket.layout.get<TextRotationAlignment>() == AlignmentType::Map;
+ if (alongLine) {
+ reprojectLineLabels(bucket, tile.matrix, true, values, tile, state, frameHistory);
+ context.updateVertexBuffer(std::move(bucket.text.dynamicVertices), *bucket.text.dynamicVertexBuffer);
+ }
+
const Size texsize = geometryTile.glyphAtlasTexture->size;
if (values.hasHalo) {
diff --git a/src/mbgl/shaders/symbol_sdf.cpp b/src/mbgl/shaders/symbol_sdf.cpp
index 64f21ae02f..17ba69c202 100644
--- a/src/mbgl/shaders/symbol_sdf.cpp
+++ b/src/mbgl/shaders/symbol_sdf.cpp
@@ -151,15 +151,15 @@ void main() {
vec2 a_tex = a_data.xy;
- highp vec2 label_data = unpack_float(a_data[2]);
- highp float a_labelminzoom = label_data[0];
+ //highp vec2 label_data = unpack_float(a_data[2]);
+ //highp float a_labelminzoom = label_data[0];
//highp float a_lineangle = (label_data[1] / 256.0 * 2.0 * PI);
highp vec2 a_angle_zoom = unpack_float(a_projected_pos[2]);
highp float a_lineangle = a_angle_zoom[0] / 256.0 * 2.0 * PI;
- a_lineangle += 1.0;
- highp vec2 a_zoom = unpack_float(a_data[3]);
- highp float a_minzoom = a_zoom[0];
- highp float a_maxzoom = a_zoom[1];
+ highp float a_labelminzoom = a_angle_zoom[1];
+ //highp vec2 a_zoom = unpack_float(a_data[3]);
+ highp float a_minzoom = 0.0;//a_zoom[0];
+ highp float a_maxzoom = 250.0;//a_zoom[1];
// In order to accommodate placing labels around corners in
// symbol-placement: line, each glyph in a label could have multiple