summaryrefslogtreecommitdiff
path: root/src/mbgl/map/tile_data.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/map/tile_data.cpp')
-rw-r--r--src/mbgl/map/tile_data.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/mbgl/map/tile_data.cpp b/src/mbgl/map/tile_data.cpp
index 9d48041239..53d36dfe8b 100644
--- a/src/mbgl/map/tile_data.cpp
+++ b/src/mbgl/map/tile_data.cpp
@@ -1,5 +1,6 @@
#include <mbgl/map/tile_data.hpp>
#include <mbgl/map/map.hpp>
+#include <mbgl/map/environment.hpp>
#include <mbgl/style/style_source.hpp>
#include <mbgl/util/token.hpp>
@@ -10,12 +11,12 @@
using namespace mbgl;
-TileData::TileData(Tile::ID const& id_, const SourceInfo& source_, FileSource& fileSource_)
+TileData::TileData(Tile::ID const& id_, const SourceInfo& source_, Environment& env_)
: id(id_),
name(id),
state(State::initial),
source(source_),
- fileSource(fileSource_),
+ env(env_),
debugBucket(debugFontBuffer) {
// Initialize tile debug coordinates
debugFontBuffer.addText(name.c_str(), 50, 200, 5);
@@ -23,7 +24,7 @@ TileData::TileData(Tile::ID const& id_, const SourceInfo& source_, FileSource& f
TileData::~TileData() {
if (req) {
- fileSource.cancel(req);
+ env.cancelRequest(req);
}
}
@@ -31,8 +32,7 @@ const std::string TileData::toString() const {
return std::string { "[tile " } + name + "]";
}
-void TileData::request(uv::worker &worker, uv_loop_t &loop,
- float pixelRatio, std::function<void()> callback) {
+void TileData::request(uv::worker &worker, float pixelRatio, std::function<void()> callback) {
if (source.tiles.empty())
return;
@@ -53,9 +53,8 @@ void TileData::request(uv::worker &worker, uv_loop_t &loop,
state = State::loading;
- // Note: Somehow this feels slower than the change to request_http()
std::weak_ptr<TileData> weak_tile = shared_from_this();
- req = fileSource.request({ Resource::Kind::Tile, url }, &loop, [weak_tile, url, callback, &worker](const Response &res) {
+ req = env.request({ Resource::Kind::Tile, url }, [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
@@ -84,7 +83,7 @@ void TileData::cancel() {
state = State::obsolete;
}
if (req) {
- fileSource.cancel(req);
+ env.cancelRequest(req);
req = nullptr;
}
}