[core] rename TileData::State to DataAvailability and make it private
This commit is contained in:
@@ -11,17 +11,20 @@
|
||||
using namespace mbgl;
|
||||
|
||||
DebugBucket::DebugBucket(const OverscaledTileID& id,
|
||||
const TileData::State state_,
|
||||
const bool renderable_,
|
||||
const bool complete_,
|
||||
optional<Timestamp> modified_,
|
||||
optional<Timestamp> expires_,
|
||||
MapDebugOptions debugMode_)
|
||||
: state(state_),
|
||||
: renderable(renderable_),
|
||||
complete(complete_),
|
||||
modified(std::move(modified_)),
|
||||
expires(std::move(expires_)),
|
||||
debugMode(debugMode_) {
|
||||
double baseline = 200;
|
||||
if (debugMode & MapDebugOptions::ParseStatus) {
|
||||
const std::string text = util::toString(id) + " - " + TileData::StateToString(state);
|
||||
const std::string text = util::toString(id) + " - " +
|
||||
(complete ? "complete" : renderable ? "renderable" : "pending");
|
||||
fontBuffer.addText(text.c_str(), 50, baseline, 5);
|
||||
baseline += 200;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ class GLObjectStore;
|
||||
|
||||
class DebugBucket : private util::noncopyable {
|
||||
public:
|
||||
DebugBucket(const OverscaledTileID& id, TileData::State,
|
||||
DebugBucket(const OverscaledTileID& id,
|
||||
bool renderable,
|
||||
bool complete,
|
||||
optional<Timestamp> modified,
|
||||
optional<Timestamp> expires,
|
||||
MapDebugOptions);
|
||||
@@ -24,7 +26,8 @@ public:
|
||||
void drawLines(PlainShader&, gl::GLObjectStore&);
|
||||
void drawPoints(PlainShader&, gl::GLObjectStore&);
|
||||
|
||||
const TileData::State state;
|
||||
const bool renderable;
|
||||
const bool complete;
|
||||
const optional<Timestamp> modified;
|
||||
const optional<Timestamp> expires;
|
||||
const MapDebugOptions debugMode;
|
||||
|
||||
@@ -29,11 +29,14 @@ void Painter::renderDebugText(TileData& tileData, const mat4 &matrix) {
|
||||
|
||||
config.depthTest = GL_FALSE;
|
||||
|
||||
if (!tileData.debugBucket || tileData.debugBucket->state != tileData.getState()
|
||||
|| !(tileData.debugBucket->modified == tileData.modified)
|
||||
|| !(tileData.debugBucket->expires == tileData.expires)
|
||||
|| tileData.debugBucket->debugMode != frame.debugOptions) {
|
||||
tileData.debugBucket = std::make_unique<DebugBucket>(tileData.id, tileData.getState(), tileData.modified, tileData.expires, frame.debugOptions);
|
||||
if (!tileData.debugBucket || tileData.debugBucket->renderable != tileData.isRenderable() ||
|
||||
tileData.debugBucket->complete != tileData.isComplete() ||
|
||||
!(tileData.debugBucket->modified == tileData.modified) ||
|
||||
!(tileData.debugBucket->expires == tileData.expires) ||
|
||||
tileData.debugBucket->debugMode != frame.debugOptions) {
|
||||
tileData.debugBucket = std::make_unique<DebugBucket>(
|
||||
tileData.id, tileData.isRenderable(), tileData.isComplete(), tileData.modified,
|
||||
tileData.expires, frame.debugOptions);
|
||||
}
|
||||
|
||||
config.program = plainShader->getID();
|
||||
|
||||
@@ -307,8 +307,7 @@ bool Source::update(const StyleUpdateParameters& parameters) {
|
||||
for (auto& pair : tileDataMap) {
|
||||
const auto& dataTileID = pair.first;
|
||||
auto tileData = pair.second.get();
|
||||
if (parameters.shouldReparsePartialTiles &&
|
||||
tileData->getState() == TileData::State::partial) {
|
||||
if (parameters.shouldReparsePartialTiles && tileData->isIncomplete()) {
|
||||
auto callback = std::bind(&Source::tileLoadingCallback, this, dataTileID,
|
||||
std::placeholders::_1, false);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/style/filter.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <atomic>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ RasterTileData::RasterTileData(const OverscaledTileID& id_,
|
||||
modified = res.modified;
|
||||
expires = res.expires;
|
||||
} else if (res.noContent) {
|
||||
state = State::parsed;
|
||||
availableData = DataAvailability::All;
|
||||
modified = res.modified;
|
||||
expires = res.expires;
|
||||
workRequest.reset();
|
||||
@@ -43,14 +43,14 @@ RasterTileData::RasterTileData(const OverscaledTileID& id_,
|
||||
|
||||
std::exception_ptr error;
|
||||
if (result.is<std::unique_ptr<Bucket>>()) {
|
||||
state = State::parsed;
|
||||
bucket = std::move(result.get<std::unique_ptr<Bucket>>());
|
||||
} else {
|
||||
error = result.get<std::exception_ptr>();
|
||||
state = State::parsed;
|
||||
bucket.reset();
|
||||
}
|
||||
|
||||
availableData = DataAvailability::All;
|
||||
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,24 +5,15 @@
|
||||
namespace mbgl {
|
||||
|
||||
TileData::TileData(const OverscaledTileID& id_)
|
||||
: id(id_),
|
||||
state(State::loading) {
|
||||
: id(id_) {
|
||||
}
|
||||
|
||||
TileData::~TileData() = default;
|
||||
|
||||
const char* TileData::StateToString(const State state) {
|
||||
switch (state) {
|
||||
case TileData::State::loading : return "loading";
|
||||
case TileData::State::parsed : return "parsed";
|
||||
case TileData::State::partial : return "partial";
|
||||
default: return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
void TileData::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "TileData::id: %s", util::toString(id).c_str());
|
||||
Log::Info(Event::General, "TileData::state: %s", TileData::StateToString(state));
|
||||
Log::Info(Event::General, "TileData::renderable: %s", isRenderable() ? "yes" : "no");
|
||||
Log::Info(Event::General, "TileData::complete: %s", isComplete() ? "yes" : "no");
|
||||
}
|
||||
|
||||
void TileData::queryRenderedFeatures(
|
||||
|
||||
@@ -23,26 +23,6 @@ class TransformState;
|
||||
|
||||
class TileData : private util::noncopyable {
|
||||
public:
|
||||
// loading:
|
||||
// A request to the FileSource was made for the actual tile data and TileData
|
||||
// is waiting for it to arrive.
|
||||
//
|
||||
// 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,
|
||||
// but might remain in the same state if dependencies are still missing.
|
||||
//
|
||||
// parsed:
|
||||
// TileData is fully parsed and its contents won't change from this point. This
|
||||
// is the only state which is safe to cache this object.
|
||||
enum class State {
|
||||
loading,
|
||||
partial,
|
||||
parsed,
|
||||
};
|
||||
|
||||
static const char* StateToString(State);
|
||||
|
||||
TileData(const OverscaledTileID&);
|
||||
virtual ~TileData();
|
||||
|
||||
@@ -65,15 +45,14 @@ public:
|
||||
// partial state is still waiting for network resources but can also
|
||||
// be rendered, although layers will be missing.
|
||||
bool isRenderable() const {
|
||||
return state == State::partial || state == State::parsed;
|
||||
return availableData != DataAvailability::None;
|
||||
}
|
||||
|
||||
bool isComplete() const {
|
||||
return state == State::parsed;
|
||||
return availableData == DataAvailability::All;
|
||||
}
|
||||
|
||||
State getState() const {
|
||||
return state;
|
||||
bool isIncomplete() const {
|
||||
return availableData == DataAvailability::Some;
|
||||
}
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
@@ -86,7 +65,20 @@ public:
|
||||
std::unique_ptr<DebugBucket> debugBucket;
|
||||
|
||||
protected:
|
||||
State state;
|
||||
enum class DataAvailability : uint8_t {
|
||||
// Still waiting for data to load or parse.
|
||||
None,
|
||||
|
||||
// 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,
|
||||
// but might remain in the same state if dependencies are still missing.
|
||||
Some,
|
||||
|
||||
// TileData is fully parsed, and all buckets are available if they exist.
|
||||
All,
|
||||
};
|
||||
|
||||
DataAvailability availableData = DataAvailability::None;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <list>
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -44,7 +44,7 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_,
|
||||
if (!tile) {
|
||||
// This is a 404 response. We're treating these as empty tiles.
|
||||
workRequest.reset();
|
||||
state = State::parsed;
|
||||
availableData = DataAvailability::All;
|
||||
buckets.clear();
|
||||
callback(err);
|
||||
return;
|
||||
@@ -52,8 +52,8 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_,
|
||||
|
||||
// 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;
|
||||
if (availableData == DataAvailability::All) {
|
||||
availableData = DataAvailability::Some;
|
||||
}
|
||||
|
||||
// Kick off a fresh parse of this tile. This happens when the tile is new, or
|
||||
@@ -66,7 +66,8 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_,
|
||||
std::exception_ptr error;
|
||||
if (result.is<TileParseResultData>()) {
|
||||
auto& resultBuckets = result.get<TileParseResultData>();
|
||||
state = resultBuckets.complete ? State::parsed : State::partial;
|
||||
availableData =
|
||||
resultBuckets.complete ? DataAvailability::All : DataAvailability::Some;
|
||||
|
||||
// Persist the configuration we just placed so that we can later check whether we need to
|
||||
// place again in case the configuration has changed.
|
||||
@@ -84,7 +85,7 @@ VectorTileData::VectorTileData(const OverscaledTileID& id_,
|
||||
} else {
|
||||
// This is triggered when parsing fails (e.g. due to an invalid vector tile)
|
||||
error = result.get<std::exception_ptr>();
|
||||
state = State::parsed;
|
||||
availableData = DataAvailability::All;
|
||||
}
|
||||
|
||||
callback(error);
|
||||
@@ -109,7 +110,8 @@ bool VectorTileData::parsePending(std::function<void(std::exception_ptr)> callba
|
||||
std::exception_ptr error;
|
||||
if (result.is<TileParseResultData>()) {
|
||||
auto& resultBuckets = result.get<TileParseResultData>();
|
||||
state = resultBuckets.complete ? State::parsed : State::partial;
|
||||
availableData =
|
||||
resultBuckets.complete ? DataAvailability::All : DataAvailability::Some;
|
||||
|
||||
// Move over all buckets we received in this parse request, potentially overwriting
|
||||
// existing buckets in case we got a refresh parse.
|
||||
@@ -128,7 +130,7 @@ bool VectorTileData::parsePending(std::function<void(std::exception_ptr)> callba
|
||||
|
||||
} else {
|
||||
error = result.get<std::exception_ptr>();
|
||||
state = State::parsed;
|
||||
availableData = DataAvailability::All;
|
||||
}
|
||||
|
||||
callback(error);
|
||||
|
||||
Reference in New Issue
Block a user