[core] TileData objects now store whether an optional load attempt was performed
This commit is contained in:
@@ -40,6 +40,8 @@ void FileBasedTileSource<T, I>::loadOptional() {
|
||||
request = fileSource.request(resource, [this](Response res) {
|
||||
request.reset();
|
||||
|
||||
T::tileData.setTriedOptional();
|
||||
|
||||
if (res.error && res.error->reason == Response::Error::Reason::NotFound) {
|
||||
// When the optional request could not be satisfied, don't treat it as an error.
|
||||
// Instead, we make sure that the next request knows that there has been an optional
|
||||
|
||||
@@ -24,6 +24,11 @@ void TileData::setTileSource(std::unique_ptr<TileSource> tileSource_) {
|
||||
tileSource = std::move(tileSource_);
|
||||
}
|
||||
|
||||
void TileData::setTriedOptional() {
|
||||
triedOptional = true;
|
||||
observer->onNeedsRepaint();
|
||||
}
|
||||
|
||||
void TileData::dumpDebugLogs() const {
|
||||
Log::Info(Event::General, "TileData::id: %s", util::toString(id).c_str());
|
||||
Log::Info(Event::General, "TileData::renderable: %s", isRenderable() ? "yes" : "no");
|
||||
|
||||
@@ -50,6 +50,14 @@ public:
|
||||
const TransformState&,
|
||||
const optional<std::vector<std::string>>& layerIDs);
|
||||
|
||||
void setTriedOptional();
|
||||
|
||||
// Returns true when the tile source has received a first response, regardless of whether a load
|
||||
// error occurred or actual data was loaded.
|
||||
bool hasTriedOptional() const {
|
||||
return triedOptional;
|
||||
}
|
||||
|
||||
// Tile data considered "Renderable" can be used for rendering. Data in
|
||||
// partial state is still waiting for network resources but can also
|
||||
// be rendered, although layers will be missing.
|
||||
@@ -74,6 +82,8 @@ public:
|
||||
std::unique_ptr<DebugBucket> debugBucket;
|
||||
|
||||
protected:
|
||||
bool triedOptional = false;
|
||||
|
||||
enum class DataAvailability : uint8_t {
|
||||
// Still waiting for data to load or parse.
|
||||
None,
|
||||
|
||||
@@ -29,11 +29,17 @@ struct MockBucket {};
|
||||
|
||||
struct MockTileData {
|
||||
MockTileData(const mbgl::OverscaledTileID& tileID_) : tileID(tileID_) {}
|
||||
bool isRenderable() {
|
||||
|
||||
bool hasTriedOptional() const {
|
||||
return triedOptional;
|
||||
}
|
||||
|
||||
bool isRenderable() const {
|
||||
return renderable;
|
||||
}
|
||||
|
||||
bool renderable = false;
|
||||
bool triedOptional = false;
|
||||
const mbgl::OverscaledTileID tileID;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user