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

port labeling, symbol sorting, and reparsing overscaled tiles #1666

Merged
merged 41 commits into from
Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
19ddaae
remove in-shader label flipping
ansis Mar 31, 2015
7b29c5b
port some of the text shaping changes
ansis Mar 31, 2015
9309f59
split generating symbol quads from collision code
ansis Mar 31, 2015
128ed1f
start porting symbol bucket changes
ansis Mar 31, 2015
8fd42f3
start porting CollisionTile and CollisionFeature
ansis Apr 1, 2015
dda1b77
port collision box debug rendering
ansis Apr 1, 2015
fd526ae
port the remained of CollisionTile
ansis Apr 1, 2015
e1059e7
port SymbolBucket::placeFeatures
ansis Apr 1, 2015
dea7b32
remove old collision and rotation range code
ansis Apr 1, 2015
c200053
don't add upside-down glyphs to buffers
ansis Apr 1, 2015
1d50485
port bboxifyLabel from -js
ansis Apr 2, 2015
c49e1ac
port getAnchors from -js
ansis Apr 2, 2015
2767a9b
port checkMaxAngle from -js
ansis Apr 2, 2015
07b8504
port clipLines from -js
ansis Apr 2, 2015
7b02800
remove old symbol collision types
ansis Apr 2, 2015
02d2dde
fix quad offsets by subtracting buffer
ansis Apr 2, 2015
1dcd1cf
remove tests for deleted rotation_range
ansis Apr 2, 2015
68ae21d
fix android and Release builds
ansis Apr 2, 2015
466febd
don't create infinitely many boxes for zero or negative height symbols
ansis Apr 2, 2015
148294d
Merge branch 'master' into new-labelling
ansis Apr 3, 2015
34a5bf6
fix bboxify where first box should be placed after anchor
ansis Apr 6, 2015
7ac0166
port line icon angle fix
ansis Apr 9, 2015
4d63162
Merge master @ 353e5661de
friedbunny Apr 27, 2015
7abd795
Merge branch 'master' into new-labelling
ansis May 19, 2015
d41bfa2
redo placement when map rotates
ansis May 20, 2015
0bd39ae
place symbols with correct angle on initial load
ansis May 20, 2015
8962442
make collision debug boxes toggleable
ansis May 28, 2015
1e044a1
Reparse tiles when zoom level > source maxzoom
ansis May 28, 2015
4cd95a9
fix clipping lines for labeling
ansis May 28, 2015
fd19eb7
fix shaped icon box sizes
ansis May 28, 2015
ff6a5ce
Merge remote-tracking branch 'origin/master' into new-labelling
ansis May 29, 2015
520eddb
use floats when resampling lines to match -js
ansis May 29, 2015
36212ea
sort overlapping symbols in the y direction
ansis May 29, 2015
2ae2cad
fix assertion. only include glyphs with metrics
ansis May 29, 2015
93fc67b
re-add sprite atlas pollution fix
ansis May 29, 2015
956ad85
update test suite
ansis May 29, 2015
4e74867
use source zoom level for tile loading errors
ansis Jun 2, 2015
3dfa317
fix android compile errors
ansis Jun 2, 2015
1f5fb1d
fix hangs caused by redoPlacement
ansis Jun 2, 2015
2bd7e45
fix collision box clipping
ansis Jun 3, 2015
9c03b39
Merge remote-tracking branch 'origin/master' into HEAD
ansis Jun 3, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ Some styles in JSON format are included at `./styles`. See the [style spec](http
- Press `X` to reset the transform
- Press `N` to reset north
- Press `Tab` to toggle debug information
- Press 'C' to toggle symbol collision debug boxes
- Press `Esc` to quit

## Mobile
Expand Down
3 changes: 3 additions & 0 deletions include/mbgl/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class Map : private util::noncopyable {
void setDebug(bool value);
void toggleDebug();
bool getDebug() const;
void setCollisionDebug(bool value);
void toggleCollisionDebug();
bool getCollisionDebug() const;
bool isFullyLoaded() const;

private:
Expand Down
3 changes: 3 additions & 0 deletions platform/default/glfw_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
case GLFW_KEY_TAB:
view->map->toggleDebug();
break;
case GLFW_KEY_C:
view->map->toggleCollisionDebug();
break;
case GLFW_KEY_X:
if (!mods)
view->map->resetPosition();
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/geometry/anchor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ struct Anchor {
: x(x_), y(y_), angle(angle_), scale(scale_) {}
explicit Anchor(float x_, float y_, float angle_, float scale_, int segment_)
: x(x_), y(y_), angle(angle_), scale(scale_), segment(segment_) {}

};

typedef std::vector<Anchor> Anchors;

}

#endif
#endif
27 changes: 27 additions & 0 deletions src/mbgl/geometry/collision_box_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <mbgl/geometry/collision_box_buffer.hpp>
#include <mbgl/platform/gl.hpp>
#include <mbgl/util/math.hpp>

#include <cmath>

namespace mbgl {

size_t CollisionBoxVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, float maxzoom, float placementZoom) {
const size_t idx = index();
void *data = addElement();

int16_t *shorts = static_cast<int16_t *>(data);
shorts[0] /* pos */ = x;
shorts[1] /* pos */ = y;
shorts[2] /* offset */ = std::round(ox); // use 1/64 pixels for placement
shorts[3] /* offset */ = std::round(oy);

uint8_t *ubytes = static_cast<uint8_t *>(data);
// a_data1
ubytes[8] = maxzoom * 10;
ubytes[9] = placementZoom * 10;

return idx;
}

}
23 changes: 23 additions & 0 deletions src/mbgl/geometry/collision_box_buffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef MBGL_GEOMETRY_COLLISIONBOX_BUFFER
#define MBGL_GEOMETRY_COLLISIONBOX_BUFFER

#include <mbgl/geometry/buffer.hpp>
#include <array>

namespace mbgl {

class CollisionBoxVertexBuffer : public Buffer <
12,
GL_ARRAY_BUFFER,
32768
> {
public:
typedef int16_t vertex_type;

size_t add(int16_t x, int16_t y, float ex, float ey, float maxzoom, float placementZoom);
};


}

#endif
7 changes: 1 addition & 6 deletions src/mbgl/geometry/icon_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

namespace mbgl {

const double IconVertexBuffer::angleFactor = 128.0 / M_PI;

size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom) {
size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float minzoom, float maxzoom, float labelminzoom) {
const size_t idx = index();
void *data = addElement();

Expand All @@ -23,13 +21,10 @@ size_t IconVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, int16_t t
ubytes[8] /* tex */ = tx / 4;
ubytes[9] /* tex */ = ty / 4;
ubytes[10] /* labelminzoom */ = labelminzoom * 10;
ubytes[11] /* angle */ = (int16_t)std::round(angle * angleFactor) % 256;

// a_data2
ubytes[12] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
ubytes[13] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
ubytes[14] /* rangeend */ = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256;
ubytes[15] /* rangestart */ = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256;

return idx;
}
Expand Down
4 changes: 1 addition & 3 deletions src/mbgl/geometry/icon_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ namespace mbgl {
16
> {
public:
static const double angleFactor;

size_t add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom);
size_t add(int16_t x, int16_t y, float ox, float oy, int16_t tx, int16_t ty, float minzoom, float maxzoom, float labelminzoom);

};

Expand Down
63 changes: 0 additions & 63 deletions src/mbgl/geometry/resample.cpp

This file was deleted.

13 changes: 0 additions & 13 deletions src/mbgl/geometry/resample.hpp

This file was deleted.

7 changes: 1 addition & 6 deletions src/mbgl/geometry/text_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

namespace mbgl {

const double TextVertexBuffer::angleFactor = 128.0 / M_PI;

size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom) {
size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float minzoom, float maxzoom, float labelminzoom) {
const size_t idx = index();
void *data = addElement();

Expand All @@ -23,13 +21,10 @@ size_t TextVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, uint16_t
ubytes[8] /* tex */ = tx / 4;
ubytes[9] /* tex */ = ty / 4;
ubytes[10] /* labelminzoom */ = labelminzoom * 10;
ubytes[11] /* angle */ = (int16_t)std::round(angle * angleFactor) % 256;

// a_data2
ubytes[12] /* minzoom */ = minzoom * 10; // 1/10 zoom levels: z16 == 160.
ubytes[13] /* maxzoom */ = std::fmin(maxzoom, 25) * 10; // 1/10 zoom levels: z16 == 160.
ubytes[14] /* rangeend */ = util::max((int16_t)std::round(range[0] * angleFactor), (int16_t)0) % 256;
ubytes[15] /* rangestart */ = util::min((int16_t)std::round(range[1] * angleFactor), (int16_t)255) % 256;

return idx;
}
Expand Down
4 changes: 1 addition & 3 deletions src/mbgl/geometry/text_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ class TextVertexBuffer : public Buffer <
public:
typedef int16_t vertex_type;

static const double angleFactor;

size_t add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float angle, float minzoom, std::array<float, 2> range, float maxzoom, float labelminzoom);
size_t add(int16_t x, int16_t y, float ox, float oy, uint16_t tx, uint16_t ty, float minzoom, float maxzoom, float labelminzoom);
};


Expand Down
8 changes: 4 additions & 4 deletions src/mbgl/map/annotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ AnnotationManager::addPointAnnotations(const std::vector<LatLng>& points,
uint32_t y = p.y * z2;

for (int8_t z = maxZoom; z >= 0; z--) {
affectedTiles.emplace_back(z, x, y);
affectedTiles.emplace_back(z, x, y, z);
TileID tileID = affectedTiles.back();

// calculate tile coordinate
Expand Down Expand Up @@ -213,7 +213,7 @@ std::vector<TileID> AnnotationManager::removeAnnotations(const AnnotationIDs& id
p = projectPoint(latLng);
x = z2s[z] * p.x;
y = z2s[z] * p.y;
TileID tid(z, x, y);
TileID tid(z, x, y, z);
// erase annotation from tile's list
auto& tileAnnotations = tiles[tid].first;
tileAnnotations.erase(annotationID);
Expand Down Expand Up @@ -244,8 +244,8 @@ std::vector<uint32_t> AnnotationManager::getAnnotationsInBounds(const LatLngBoun
const vec2<double> nePoint = projectPoint(queryBounds.ne);

// tiles number y from top down
const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2);
const TileID seTile(z, nePoint.x * z2, swPoint.y * z2);
const TileID nwTile(z, swPoint.x * z2, nePoint.y * z2, z);
const TileID seTile(z, nePoint.x * z2, swPoint.y * z2, z);

std::vector<uint32_t> matchingAnnotations;

Expand Down
10 changes: 6 additions & 4 deletions src/mbgl/map/live_tile_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ using namespace mbgl;

LiveTileData::LiveTileData(const TileID& id_,
AnnotationManager& annotationManager_,
float mapMaxZoom,
Style& style_,
GlyphAtlas& glyphAtlas_,
GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_,
util::ptr<Sprite> sprite_,
const SourceInfo& source_)
: VectorTileData::VectorTileData(id_, mapMaxZoom, style_, glyphAtlas_, glyphStore_,
spriteAtlas_, sprite_, source_),
const SourceInfo& source_,
float overscaling_,
float angle_,
bool collisionDebug_)
: VectorTileData::VectorTileData(id_, style_, glyphAtlas_, glyphStore_,
spriteAtlas_, sprite_, source_, overscaling_, angle_, collisionDebug_),
annotationManager(annotationManager_) {
// live features are always ready
setState(State::loaded);
Expand Down
6 changes: 4 additions & 2 deletions src/mbgl/map/live_tile_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ class LiveTileData : public VectorTileData {
public:
LiveTileData(const TileID&,
AnnotationManager&,
float mapMaxZoom,
Style&,
GlyphAtlas&,
GlyphStore&,
SpriteAtlas&,
util::ptr<Sprite>,
const SourceInfo&);
const SourceInfo&,
float overscaling_,
float angle_,
bool collisionDebug_);
~LiveTileData();

void parse() override;
Expand Down
14 changes: 14 additions & 0 deletions src/mbgl/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ bool Map::getDebug() const {
return data->getDebug();
}

void Map::setCollisionDebug(bool value) {
data->setCollisionDebug(value);
update();
}

void Map::toggleCollisionDebug() {
data->toggleCollisionDebug();
update();
}

bool Map::getCollisionDebug() const {
return data->getCollisionDebug();
}

bool Map::isFullyLoaded() const {
return data->getFullyLoaded();
}
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/map/map_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ std::vector<std::string> MapData::getClasses() const {
return classes;
}

}
}
11 changes: 11 additions & 0 deletions src/mbgl/map/map_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ class MapData {
debug = value;
}

inline bool getCollisionDebug() const {
return collisionDebug;
}
inline bool toggleCollisionDebug() {
return collisionDebug ^= 1u;
}
inline void setCollisionDebug(bool value) {
collisionDebug = value;
}

inline bool getFullyLoaded() const {
return loaded;
}
Expand Down Expand Up @@ -88,6 +98,7 @@ class MapData {

std::vector<std::string> classes;
std::atomic<uint8_t> debug { false };
std::atomic<uint8_t> collisionDebug { false };
std::atomic<bool> loaded { false };
std::atomic<Duration> animationTime;
std::atomic<Duration> defaultTransitionDuration;
Expand Down
Loading