summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-11-25 16:35:27 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-11-26 15:13:14 -0800
commit23b61f808cca8d926c11bbb738f384522e41dbbd (patch)
treefb93d18c0454628b6f320ca08562cfabfc488a66 /src
parent9af3b033bf41cd32635172864d58dc169168f9e6 (diff)
downloadqtlocation-mapboxgl-23b61f808cca8d926c11bbb738f384522e41dbbd.tar.gz
Eliminate remaining uses of Map in TileData
Diffstat (limited to 'src')
-rw-r--r--src/map/map.cpp2
-rw-r--r--src/map/raster_tile_data.cpp4
-rw-r--r--src/map/source.cpp20
-rw-r--r--src/map/tile_data.cpp20
-rw-r--r--src/map/vector_tile_data.cpp8
5 files changed, 29 insertions, 25 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp
index f2822f3967..eb0a48d8d6 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -645,7 +645,7 @@ void Map::updateTiles() {
source->source->update(*this, getWorker(),
style, glyphAtlas, *glyphStore,
spriteAtlas, getSprite(),
- *texturepool, *fileSource);
+ *texturepool, *fileSource, [this](){ update(); });
}
}
diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp
index 04e89d9e37..b2d0cf6a6b 100644
--- a/src/map/raster_tile_data.cpp
+++ b/src/map/raster_tile_data.cpp
@@ -5,8 +5,8 @@
using namespace mbgl;
-RasterTileData::RasterTileData(Tile::ID const& id_, Map &map_, Texturepool& texturepool, const util::ptr<SourceInfo> &source_)
- : TileData(id_, map_, source_),
+RasterTileData::RasterTileData(Tile::ID const& id_, Texturepool& texturepool, const util::ptr<SourceInfo> &source_)
+ : TileData(id_, source_),
bucket(texturepool, properties) {
}
diff --git a/src/map/source.cpp b/src/map/source.cpp
index 0348e02513..d617d2cdee 100644
--- a/src/map/source.cpp
+++ b/src/map/source.cpp
@@ -65,12 +65,14 @@ bool Source::update(Map& map, uv::worker& worker,
util::ptr<Style> style,
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
- Texturepool& texturepool, FileSource& fileSource) {
+ Texturepool& texturepool, FileSource& fileSource,
+ std::function<void ()> callback) {
if (loaded && map.getTime() > updated) {
return updateTiles(map, worker, style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
- texturepool, fileSource);
+ texturepool, fileSource,
+ callback);
} else {
return false;
}
@@ -171,7 +173,8 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
FileSource& fileSource, Texturepool& texturepool,
- const Tile::ID& id) {
+ const Tile::ID& id,
+ std::function<void ()> callback) {
const TileData::State state = hasTile(id);
if (state != TileData::State::invalid) {
@@ -199,17 +202,17 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
if (!new_tile.data) {
// If we don't find working tile data, we're just going to load it.
if (info->type == SourceType::Vector) {
- new_tile.data = std::make_shared<VectorTileData>(normalized_id, map, style,
+ new_tile.data = std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
texturepool, info);
} else if (info->type == SourceType::Raster) {
- new_tile.data = std::make_shared<RasterTileData>(normalized_id, map, texturepool, info);
+ new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturepool, info);
} else {
throw std::runtime_error("source type not implemented");
}
- new_tile.data->request(worker, fileSource);
+ new_tile.data->request(worker, fileSource, map.getState().getPixelRatio(), callback);
tile_data.emplace(new_tile.data->id, new_tile.data);
}
@@ -299,7 +302,8 @@ bool Source::findLoadedParent(const Tile::ID& id, int32_t minCoveringZoom, std::
bool Source::updateTiles(Map& map, uv::worker& worker, util::ptr<Style> style,
GlyphAtlas& glyphAtlas, GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas, util::ptr<Sprite> sprite,
- Texturepool& texturepool, FileSource& fileSource) {
+ Texturepool& texturepool, FileSource& fileSource,
+ std::function<void ()> callback) {
bool changed = false;
int32_t zoom = std::floor(getZoom(map.getState()));
@@ -320,7 +324,7 @@ bool Source::updateTiles(Map& map, uv::worker& worker, util::ptr<Style> style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
fileSource, texturepool,
- id);
+ id, callback);
if (state != TileData::State::parsed) {
// The tile we require is not yet loaded. Try to find a parent or
diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp
index 3be8b3788b..1cbcf00825 100644
--- a/src/map/tile_data.cpp
+++ b/src/map/tile_data.cpp
@@ -9,10 +9,9 @@
using namespace mbgl;
-TileData::TileData(Tile::ID const& id_, Map &map_, const util::ptr<SourceInfo> &source_)
+TileData::TileData(Tile::ID const& id_, const util::ptr<SourceInfo> &source_)
: id(id_),
state(State::initial),
- map(map_),
source(source_),
debugBucket(debugFontBuffer) {
// Initialize tile debug coordinates
@@ -28,7 +27,8 @@ const std::string TileData::toString() const {
return util::sprintf<32>("[tile %d/%d/%d]", id.z, id.x, id.y);
}
-void TileData::request(uv::worker& worker, FileSource& fileSource) {
+void TileData::request(uv::worker& worker, FileSource& fileSource,
+ float pixelRatio, std::function<void ()> callback) {
if (source->tiles.empty())
return;
@@ -43,7 +43,7 @@ void TileData::request(uv::worker& worker, FileSource& fileSource) {
prefix[1] = "0123456789abcdef"[id.y % 16];
return prefix;
}
- if (token == "ratio") return (map.getState().getPixelRatio() > 1.0 ? "@2x" : "");
+ if (token == "ratio") return pixelRatio > 1.0 ? "@2x" : "";
return "";
});
@@ -52,7 +52,7 @@ void TileData::request(uv::worker& worker, FileSource& fileSource) {
// Note: Somehow this feels slower than the change to request_http()
std::weak_ptr<TileData> weak_tile = shared_from_this();
req = fileSource.request(ResourceType::Tile, url);
- req->onload([weak_tile, url, &worker](const Response &res) {
+ req->onload([weak_tile, url, callback, &worker](const Response &res) {
util::ptr<TileData> tile = weak_tile.lock();
if (!tile || tile->state == State::obsolete) {
// noop. Tile is obsolete and we're now just waiting for the refcount
@@ -69,7 +69,7 @@ void TileData::request(uv::worker& worker, FileSource& fileSource) {
tile->data = res.data;
// Schedule tile parsing in another thread
- tile->reparse(worker);
+ tile->reparse(worker, callback);
} else {
#if defined(DEBUG)
fprintf(stderr, "[%s] tile loading failed: %ld, %s\n", url.c_str(), res.code, res.message.c_str());
@@ -88,17 +88,17 @@ void TileData::cancel() {
}
}
-void TileData::reparse(uv::worker& worker)
+void TileData::reparse(uv::worker& worker, std::function<void()> callback)
{
// We're creating a new work request. The work request deletes itself after it executed
// the after work handler
new uv::work<util::ptr<TileData>>(
worker,
- [](util::ptr<TileData> &tile) {
+ [](util::ptr<TileData>& tile) {
tile->parse();
},
- [](util::ptr<TileData> &tile) {
- tile->map.update();
+ [callback](util::ptr<TileData>&) {
+ callback();
},
shared_from_this());
}
diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp
index e662379abb..8193f7e8a5 100644
--- a/src/map/vector_tile_data.cpp
+++ b/src/map/vector_tile_data.cpp
@@ -8,20 +8,20 @@
using namespace mbgl;
-VectorTileData::VectorTileData(Tile::ID const& id_, Map &map_,
- util::ptr<Style> style_,
+VectorTileData::VectorTileData(Tile::ID const& id_,
+ float mapMaxZoom, util::ptr<Style> style_,
GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_,
Texturepool& texturepool_,
const util::ptr<SourceInfo> &source_)
- : TileData(id_, map_, source_),
+ : TileData(id_, source_),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),
spriteAtlas(spriteAtlas_),
sprite(sprite_),
texturepool(texturepool_),
style(style_),
- depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) {
+ depth(id.z >= source->max_zoom ? mapMaxZoom - id.z : 1) {
}
VectorTileData::~VectorTileData() {