From fce5dd5f6afd4864456197a5cfec20a5e8cd0e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Fri, 27 May 2016 16:55:59 +0200 Subject: [core] TileData objects now store whether an optional load attempt was performed --- src/mbgl/tile/file_based_tile_source_impl.hpp | 2 ++ src/mbgl/tile/tile_data.cpp | 5 +++++ src/mbgl/tile/tile_data.hpp | 10 ++++++++++ 3 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/mbgl/tile/file_based_tile_source_impl.hpp b/src/mbgl/tile/file_based_tile_source_impl.hpp index 4a11728332..b8a69e3f60 100644 --- a/src/mbgl/tile/file_based_tile_source_impl.hpp +++ b/src/mbgl/tile/file_based_tile_source_impl.hpp @@ -40,6 +40,8 @@ void FileBasedTileSource::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 diff --git a/src/mbgl/tile/tile_data.cpp b/src/mbgl/tile/tile_data.cpp index a5822b2c17..a64de4d1eb 100644 --- a/src/mbgl/tile/tile_data.cpp +++ b/src/mbgl/tile/tile_data.cpp @@ -24,6 +24,11 @@ void TileData::setTileSource(std::unique_ptr 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"); diff --git a/src/mbgl/tile/tile_data.hpp b/src/mbgl/tile/tile_data.hpp index c3877d0d63..d22e871185 100644 --- a/src/mbgl/tile/tile_data.hpp +++ b/src/mbgl/tile/tile_data.hpp @@ -50,6 +50,14 @@ public: const TransformState&, const optional>& 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; protected: + bool triedOptional = false; + enum class DataAvailability : uint8_t { // Still waiting for data to load or parse. None, -- cgit v1.2.1