diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-05-25 19:54:30 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-05-25 21:51:25 +0200 |
commit | c52a0c65f473a82d9aed05f402bc4e82fcd24fb9 (patch) | |
tree | 7db828b32ded3179de5ab6efe285c2475000b95d /src/mbgl | |
parent | 95dc8ff3e1e890a1074f75fe9b8116217975e448 (diff) | |
download | qtlocation-mapboxgl-c52a0c65f473a82d9aed05f402bc4e82fcd24fb9.tar.gz |
[core] remove TileData::State::loaded
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/source/source.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/tile/raster_tile_data.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/tile/tile_data.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/tile/tile_data.hpp | 12 | ||||
-rw-r--r-- | src/mbgl/tile/vector_tile_data.cpp | 11 |
5 files changed, 11 insertions, 28 deletions
diff --git a/src/mbgl/source/source.cpp b/src/mbgl/source/source.cpp index ac05963ce0..9043bd1935 100644 --- a/src/mbgl/source/source.cpp +++ b/src/mbgl/source/source.cpp @@ -63,7 +63,7 @@ bool Source::isLoaded() const { if (!loaded) return false; for (const auto& pair : tileDataMap) { - if (pair.second->getState() != TileData::State::parsed) { + if (!pair.second->isComplete()) { return false; } } diff --git a/src/mbgl/tile/raster_tile_data.cpp b/src/mbgl/tile/raster_tile_data.cpp index 6280c2a972..b47c3fed24 100644 --- a/src/mbgl/tile/raster_tile_data.cpp +++ b/src/mbgl/tile/raster_tile_data.cpp @@ -18,8 +18,6 @@ RasterTileData::RasterTileData(const OverscaledTileID& id_, : TileData(id_), texturePool(texturePool_), worker(worker_) { - state = State::loading; - const Resource resource = Resource::tile(urlTemplate, pixelRatio, id.canonical.x, id.canonical.y, id.canonical.z); req = fileSource.request(resource, [callback, this](Response res) { @@ -39,17 +37,9 @@ RasterTileData::RasterTileData(const OverscaledTileID& id_, modified = res.modified; expires = res.expires; - // Only overwrite the state when we didn't have a previous tile. - if (state == State::loading) { - state = State::loaded; - } - workRequest.reset(); workRequest = worker.parseRasterTile(std::make_unique<RasterBucket>(texturePool), res.data, [this, callback] (RasterTileParseResult result) { workRequest.reset(); - if (state != State::loaded) { - return; - } std::exception_ptr error; if (result.is<std::unique_ptr<Bucket>>()) { diff --git a/src/mbgl/tile/tile_data.cpp b/src/mbgl/tile/tile_data.cpp index 2198d26741..0e4237fc25 100644 --- a/src/mbgl/tile/tile_data.cpp +++ b/src/mbgl/tile/tile_data.cpp @@ -6,16 +6,14 @@ namespace mbgl { TileData::TileData(const OverscaledTileID& id_) : id(id_), - state(State::initial) { + state(State::loading) { } TileData::~TileData() = default; const char* TileData::StateToString(const State state) { switch (state) { - case TileData::State::initial: return "initial"; case TileData::State::loading : return "loading"; - case TileData::State::loaded : return "loaded"; case TileData::State::obsolete : return "obsolete"; case TileData::State::parsed : return "parsed"; case TileData::State::partial : return "partial"; diff --git a/src/mbgl/tile/tile_data.hpp b/src/mbgl/tile/tile_data.hpp index e223c12e05..8c93f787fb 100644 --- a/src/mbgl/tile/tile_data.hpp +++ b/src/mbgl/tile/tile_data.hpp @@ -24,16 +24,10 @@ class TransformState; class TileData : private util::noncopyable { public: - // initial: - // Initial state, only used when the TileData object is created. - // // loading: // A request to the FileSource was made for the actual tile data and TileData // is waiting for it to arrive. // - // loaded: - // The actual tile data has arrived and the tile can be parsed. - // // partial: // TileData is partially parsed, some buckets are still waiting for dependencies // to arrive, but it is good for rendering. Partial tiles can also be re-parsed, @@ -47,9 +41,7 @@ public: // The TileData can go to obsolete from any state, due to parsing or loading error, // request cancellation or because the tile is no longer in use. enum class State { - initial, loading, - loaded, partial, parsed, obsolete @@ -82,6 +74,10 @@ public: return state == State::partial || state == State::parsed; } + bool isComplete() const { + return state == State::parsed; + } + State getState() const { return state; } diff --git a/src/mbgl/tile/vector_tile_data.cpp b/src/mbgl/tile/vector_tile_data.cpp index 220290cbf9..29aac5af30 100644 --- a/src/mbgl/tile/vector_tile_data.cpp +++ b/src/mbgl/tile/vector_tile_data.cpp @@ -29,7 +29,6 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_, mode_), monitor(std::move(monitor_)) { - state = State::loading; tileRequest = monitor->monitorTile([callback, this](std::exception_ptr err, std::unique_ptr<GeometryTile> tile, optional<Timestamp> modified_, @@ -51,9 +50,9 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_, return; } - if (state == State::loading) { - state = State::loaded; - } else if (isRenderable()) { + // Mark the tile as pending again if it was complete before to prevent signaling a complete + // state despite pending parse operations. + if (isComplete()) { state = State::partial; } @@ -80,7 +79,7 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_, // existing buckets in case we got a refresh parse. buckets = std::move(resultBuckets.buckets); - if (state == State::parsed) { + if (isComplete()) { featureIndex = std::move(resultBuckets.featureIndex); geometryTile = std::move(resultBuckets.geometryTile); } @@ -127,7 +126,7 @@ bool VectorTileData::parsePending(std::function<void(std::exception_ptr)> callba // place again in case the configuration has changed. placedConfig = config; - if (state == State::parsed) { + if (isComplete()) { featureIndex = std::move(resultBuckets.featureIndex); geometryTile = std::move(resultBuckets.geometryTile); } |