[core] remove TileData::State::loaded
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>>()) {
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user