summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-01-20 12:03:36 +0100
committerKonstantin Käfer <mail@kkaefer.com>2014-01-20 12:03:36 +0100
commit209dd913f9518388b93bb1900717f3c97bd54451 (patch)
tree843e5bec44b479ec08ef354f289ac58fd381bc4d /src
parent381daf9cae1013ad38a0094447de6fc34432ebaf (diff)
downloadqtlocation-mapboxgl-209dd913f9518388b93bb1900717f3c97bd54451.tar.gz
tile => Tile
Diffstat (limited to 'src')
-rw-r--r--src/map/map.cpp56
-rw-r--r--src/map/tile.cpp26
-rw-r--r--src/renderer/painter.cpp8
3 files changed, 45 insertions, 45 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 81ba185de0..768a4fc164 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -96,22 +96,22 @@ void Map::update() {
}
-tile::ptr Map::hasTile(const tile_id& id) {
- for (tile::ptr& tile : tiles) {
+Tile::Ptr Map::hasTile(const Tile::ID& id) {
+ for (Tile::Ptr& tile : tiles) {
if (tile->id == id) {
return tile;
}
}
- return tile::ptr();
+ return Tile::Ptr();
}
-tile::ptr Map::addTile(const tile_id& id) {
- tile::ptr tile = hasTile(id);
+Tile::Ptr Map::addTile(const Tile::ID& id) {
+ Tile::Ptr tile = hasTile(id);
if (!tile.get()) {
// We couldn't find the tile in the list. Create a new one.
- tile = std::make_shared<class tile>(id);
+ tile = std::make_shared<Tile>(id);
assert(tile);
// std::cerr << "init " << id.z << "/" << id.x << "/" << id.y << std::endl;
// std::cerr << "add " << tile->toString() << std::endl;
@@ -130,14 +130,14 @@ tile::ptr Map::addTile(const tile_id& id) {
*
* @return boolean Whether the children found completely cover the tile.
*/
-bool Map::findLoadedChildren(const tile_id& id, int32_t maxCoveringZoom, std::forward_list<tile_id>& retain) {
+bool Map::findLoadedChildren(const Tile::ID& id, int32_t maxCoveringZoom, std::forward_list<Tile::ID>& retain) {
bool complete = true;
int32_t z = id.z;
- auto ids = tile::children(id, z + 1);
- for (const tile_id& child_id : ids) {
- const tile::ptr& tile = hasTile(child_id);
- if (tile && tile->state == tile::ready) {
+ auto ids = Tile::children(id, z + 1);
+ for (const Tile::ID& child_id : ids) {
+ const Tile::Ptr& tile = hasTile(child_id);
+ if (tile && tile->state == Tile::ready) {
assert(tile);
retain.emplace_front(tile->id);
} else {
@@ -160,11 +160,11 @@ bool Map::findLoadedChildren(const tile_id& id, int32_t maxCoveringZoom, std::fo
*
* @return boolean Whether a parent was found.
*/
-bool Map::findLoadedParent(const tile_id& id, int32_t minCoveringZoom, std::forward_list<tile_id>& retain) {
+bool Map::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::forward_list<Tile::ID>& retain) {
for (int32_t z = id.z - 1; z >= minCoveringZoom; z--) {
- const tile_id parent_id = tile::parent(id, z);
- const tile::ptr tile = hasTile(parent_id);
- if (tile && tile->state == tile::ready) {
+ const Tile::ID parent_id = Tile::parent(id, z);
+ const Tile::Ptr tile = hasTile(parent_id);
+ if (tile && tile->state == Tile::ready) {
assert(tile);
retain.emplace_front(tile->id);
return true;
@@ -201,7 +201,7 @@ void Map::updateTiles() {
// TODO: Discard tiles that are outside the viewport
- std::forward_list<tile_id> required;
+ std::forward_list<Tile::ID> required;
for (int32_t y = tl.y; y < br.y; y++) {
for (int32_t x = tl.x; x < br.x; x++) {
required.emplace_front(x, y, zoom);
@@ -211,14 +211,14 @@ void Map::updateTiles() {
// Retain is a list of tiles that we shouldn't delete, even if they are not
// the most ideal tile for the current viewport. This may include tiles like
// parent or child tiles that are *already* loaded.
- std::forward_list<tile_id> retain(required);
+ std::forward_list<Tile::ID> retain(required);
// Add existing child/parent tiles if the actual tile is not yet loaded
- for (const tile_id& id : required) {
- tile::ptr tile = addTile(id);
+ for (const Tile::ID& id : required) {
+ Tile::Ptr tile = addTile(id);
assert(tile);
- if (tile->state != tile::ready) {
+ if (tile->state != Tile::ready) {
// The tile we require is not yet loaded. Try to find a parent or
// child tile that we already have.
@@ -233,16 +233,16 @@ void Map::updateTiles() {
}
}
- if (tile->state == tile::initial) {
+ if (tile->state == Tile::initial) {
// If the tile is new, we have to make sure to load it.
- tile->state = tile::loading;
+ tile->state = Tile::loading;
platform::request(this, tile);
}
}
// Remove tiles that we definitely don't need, i.e. tiles that are not on
// the required list.
- tiles.remove_if([&retain](const tile::ptr& tile) {
+ tiles.remove_if([&retain](const Tile::Ptr& tile) {
assert(tile);
bool obsolete = std::find(retain.begin(), retain.end(), tile->id) == retain.end();
if (obsolete) {
@@ -254,7 +254,7 @@ void Map::updateTiles() {
// Sort tiles by zoom level, front to back.
// We're painting front-to-back, so we want to draw more detailed tiles first
// before filling in other parts with lower zoom levels.
- tiles.sort([](const tile::ptr& a, const tile::ptr& b) {
+ tiles.sort([](const Tile::Ptr& a, const Tile::Ptr& b) {
return a->id.z > b->id.z;
});
}
@@ -264,9 +264,9 @@ bool Map::render() {
painter.clear();
- for (tile::ptr& tile : tiles) {
+ for (Tile::Ptr& tile : tiles) {
assert(tile);
- if (tile->state == tile::ready) {
+ if (tile->state == Tile::ready) {
painter.render(tile);
}
}
@@ -274,12 +274,12 @@ bool Map::render() {
return transform.needsAnimation();
}
-void Map::tileLoaded(tile::ptr tile) {
+void Map::tileLoaded(Tile::Ptr tile) {
// std::cerr << "loaded " << tile->toString() << std::endl;
update();
}
-void Map::tileFailed(tile::ptr tile) {
+void Map::tileFailed(Tile::Ptr tile) {
// fprintf(stderr, "[%8zx] tile failed to load %d/%d/%d\n",
// std::hash<std::thread::id>()(std::this_thread::get_id()),
// tile->z, tile->x, tile->y);
diff --git a/src/map/tile.cpp b/src/map/tile.cpp
index 3a2c5ce0be..59cf2e4c61 100644
--- a/src/map/tile.cpp
+++ b/src/map/tile.cpp
@@ -12,9 +12,9 @@
using namespace llmr;
-tile_id tile::parent(const tile_id& id, int32_t z) {
+Tile::ID Tile::parent(const ID& id, int32_t z) {
assert(z < id.z);
- tile_id pos(id);
+ ID pos(id);
while (pos.z > z) {
pos.z--;
pos.x = floor(pos.x / 2);
@@ -24,11 +24,11 @@ tile_id tile::parent(const tile_id& id, int32_t z) {
}
-std::forward_list<tile_id> tile::children(const tile_id& id, int32_t z) {
+std::forward_list<Tile::ID> Tile::children(const ID& id, int32_t z) {
assert(z > id.z);
int32_t factor = pow(2, z - id.z);
- std::forward_list<tile_id> children;
+ std::forward_list<ID> children;
for (int32_t y = id.y * factor, y_max = (id.y + 1) * factor; y < y_max; y++) {
for (int32_t x = id.x * factor, x_max = (id.x + 1) * factor; x < x_max; x++) {
children.emplace_front(x, y, z);
@@ -38,7 +38,7 @@ std::forward_list<tile_id> tile::children(const tile_id& id, int32_t z) {
}
-tile::tile(tile_id id)
+Tile::Tile(ID id)
: id(id),
state(initial),
data(0),
@@ -50,25 +50,25 @@ tile::tile(tile_id id)
debugFontVertex.addText(coord, 50, 200, 5);
}
-tile::~tile() {
+Tile::~Tile() {
// fprintf(stderr, "[%p] deleting tile %d/%d/%d\n", this, id.z, id.x, id.y);
if (this->data) {
free(this->data);
}
}
-const std::string tile::toString() const {
+const std::string Tile::toString() const {
return util::sprintf("[tile %d/%d/%d]", id.z, id.x, id.y);
}
-void tile::setData(uint8_t *data, uint32_t bytes) {
+void Tile::setData(uint8_t *data, uint32_t bytes) {
this->data = (uint8_t *)malloc(bytes);
this->bytes = bytes;
memcpy(this->data, data, bytes);
}
-void tile::cancel() {
+void Tile::cancel() {
// TODO: thread safety
if (state != obsolete) {
state = obsolete;
@@ -77,7 +77,7 @@ void tile::cancel() {
}
}
-bool tile::parse() {
+bool Tile::parse() {
if (state == obsolete) {
return false;
}
@@ -112,7 +112,7 @@ bool tile::parse() {
return true;
}
-void tile::parseLayer(const uint8_t *data, uint32_t bytes) {
+void Tile::parseLayer(const uint8_t *data, uint32_t bytes) {
pbf layer(data, bytes);
std::string name;
while (layer.next()) {
@@ -128,7 +128,7 @@ void tile::parseLayer(const uint8_t *data, uint32_t bytes) {
}
}
-void tile::parseFeature(const uint8_t *data, uint32_t bytes) {
+void Tile::parseFeature(const uint8_t *data, uint32_t bytes) {
pbf feature(data, bytes);
while (feature.next()) {
if (feature.tag == 1) {
@@ -151,7 +151,7 @@ void tile::parseFeature(const uint8_t *data, uint32_t bytes) {
}
}
-void tile::loadGeometry(const uint8_t *data, uint32_t bytes) {
+void Tile::loadGeometry(const uint8_t *data, uint32_t bytes) {
geometry geometry(data, bytes);
geometry::command cmd;
diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp
index b0c49d8024..c0e0ce7c91 100644
--- a/src/renderer/painter.cpp
+++ b/src/renderer/painter.cpp
@@ -83,7 +83,7 @@ void Painter::teardown() {
}
-void Painter::changeMatrix(const tile::ptr& tile) {
+void Painter::changeMatrix(const Tile::Ptr& tile) {
// Initialize projection matrix
float projMatrix[16];
mat4::ortho(projMatrix, 0, transform.width, transform.height, 0, 1, 10);
@@ -135,8 +135,8 @@ void Painter::clear() {
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
-void Painter::render(const tile::ptr& tile) {
- if (tile->state != tile::ready) {
+void Painter::render(const Tile::Ptr& tile) {
+ if (tile->state != Tile::ready) {
return;
}
@@ -164,7 +164,7 @@ void Painter::render(const tile::ptr& tile) {
}
}
-void Painter::renderDebug(const tile::ptr& tile) {
+void Painter::renderDebug(const Tile::Ptr& tile) {
// draw tile outline
switchShader(lineShader);
glUniformMatrix4fv(lineShader->u_matrix, 1, GL_FALSE, matrix);