summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mbgl/style/source_impl.cpp4
-rw-r--r--src/mbgl/style/source_impl.hpp2
-rw-r--r--src/mbgl/style/source_observer.hpp4
-rw-r--r--src/mbgl/style/style.cpp6
-rw-r--r--src/mbgl/style/style.hpp2
-rw-r--r--src/mbgl/tile/geometry_tile.cpp6
-rw-r--r--src/mbgl/tile/raster_tile.cpp4
-rw-r--r--src/mbgl/tile/tile_observer.hpp7
-rw-r--r--test/src/mbgl/test/stub_style_observer.hpp6
-rw-r--r--test/style/source.cpp8
10 files changed, 28 insertions, 21 deletions
diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp
index 45cc27ef1f..e124cde583 100644
--- a/src/mbgl/style/source_impl.cpp
+++ b/src/mbgl/style/source_impl.cpp
@@ -258,8 +258,8 @@ void Source::Impl::setObserver(SourceObserver* observer_) {
observer = observer_;
}
-void Source::Impl::onTileLoaded(Tile& tile, bool isNewTile) {
- observer->onTileLoaded(base, tile.id, isNewTile);
+void Source::Impl::onTileLoaded(Tile& tile, TileLoadState loadState) {
+ observer->onTileLoaded(base, tile.id, loadState);
}
void Source::Impl::onTileError(Tile& tile, std::exception_ptr error) {
diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp
index fa278b3623..5a54f4781a 100644
--- a/src/mbgl/style/source_impl.hpp
+++ b/src/mbgl/style/source_impl.hpp
@@ -88,7 +88,7 @@ protected:
private:
// TileObserver implementation.
- void onTileLoaded(Tile&, bool isNewTile) override;
+ void onTileLoaded(Tile&, TileLoadState) override;
void onTileError(Tile&, std::exception_ptr) override;
void onTileUpdated(Tile&) override;
diff --git a/src/mbgl/style/source_observer.hpp b/src/mbgl/style/source_observer.hpp
index 8c353e4d82..6e0b226c3b 100644
--- a/src/mbgl/style/source_observer.hpp
+++ b/src/mbgl/style/source_observer.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <mbgl/tile/tile_observer.hpp>
+
#include <exception>
namespace mbgl {
@@ -17,7 +19,7 @@ public:
virtual void onSourceLoaded(Source&) {}
virtual void onSourceError(Source&, std::exception_ptr) {}
- virtual void onTileLoaded(Source&, const OverscaledTileID&, bool /* isNewTile */) {}
+ virtual void onTileLoaded(Source&, const OverscaledTileID&, TileLoadState) {}
virtual void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) {}
virtual void onTileUpdated(Source&, const OverscaledTileID&) {}
};
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 42636194e3..fba12b6127 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -469,12 +469,12 @@ void Style::onSourceError(Source& source, std::exception_ptr error) {
observer->onResourceError(error);
}
-void Style::onTileLoaded(Source& source, const OverscaledTileID& tileID, bool isNewTile) {
- if (isNewTile) {
+void Style::onTileLoaded(Source& source, const OverscaledTileID& tileID, TileLoadState loadState) {
+ if (loadState == TileLoadState::First) {
shouldReparsePartialTiles = true;
}
- observer->onTileLoaded(source, tileID, isNewTile);
+ observer->onTileLoaded(source, tileID, loadState);
observer->onUpdate(Update::Repaint);
}
diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp
index ef1b427538..61f2563c87 100644
--- a/src/mbgl/style/style.hpp
+++ b/src/mbgl/style/style.hpp
@@ -130,7 +130,7 @@ private:
// SourceObserver implementation.
void onSourceLoaded(Source&) override;
void onSourceError(Source&, std::exception_ptr) override;
- void onTileLoaded(Source&, const OverscaledTileID&, bool isNewTile) override;
+ void onTileLoaded(Source&, const OverscaledTileID&, TileLoadState) override;
void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) override;
void onTileUpdated(Source&, const OverscaledTileID&) override;
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index ef5b2eb280..f74f813e48 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -69,7 +69,7 @@ void GeometryTile::setData(std::unique_ptr<const GeometryTileData> data_) {
featureIndex.reset();
data.reset();
redoPlacement();
- observer->onTileLoaded(*this, true);
+ observer->onTileLoaded(*this, TileLoadState::First);
return;
}
@@ -124,7 +124,7 @@ void GeometryTile::tileLoaded(TileParseResult result, PlacementConfig config) {
}
redoPlacement();
- observer->onTileLoaded(*this, true);
+ observer->onTileLoaded(*this, TileLoadState::First);
} else {
availableData = DataAvailability::All;
observer->onTileError(*this, result.get<std::exception_ptr>());
@@ -161,7 +161,7 @@ bool GeometryTile::parsePending() {
}
redoPlacement();
- observer->onTileLoaded(*this, false);
+ observer->onTileLoaded(*this, TileLoadState::Subsequent);
} else {
availableData = DataAvailability::All;
observer->onTileError(*this, result.get<std::exception_ptr>());
diff --git a/src/mbgl/tile/raster_tile.cpp b/src/mbgl/tile/raster_tile.cpp
index 2460aac8f9..9230c3d79d 100644
--- a/src/mbgl/tile/raster_tile.cpp
+++ b/src/mbgl/tile/raster_tile.cpp
@@ -36,7 +36,7 @@ void RasterTile::setData(std::shared_ptr<const std::string> data,
workRequest.reset();
availableData = DataAvailability::All;
bucket.reset();
- observer->onTileLoaded(*this, true);
+ observer->onTileLoaded(*this, TileLoadState::First);
return;
}
@@ -48,7 +48,7 @@ void RasterTile::setData(std::shared_ptr<const std::string> data,
if (result.is<std::unique_ptr<Bucket>>()) {
bucket = std::move(result.get<std::unique_ptr<Bucket>>());
- observer->onTileLoaded(*this, true);
+ observer->onTileLoaded(*this, TileLoadState::First);
} else {
bucket.reset();
observer->onTileError(*this, result.get<std::exception_ptr>());
diff --git a/src/mbgl/tile/tile_observer.hpp b/src/mbgl/tile/tile_observer.hpp
index ef412f0fb3..94243cb1fa 100644
--- a/src/mbgl/tile/tile_observer.hpp
+++ b/src/mbgl/tile/tile_observer.hpp
@@ -6,11 +6,16 @@ namespace mbgl {
class Tile;
+enum class TileLoadState : bool {
+ First = true,
+ Subsequent = false,
+};
+
class TileObserver {
public:
virtual ~TileObserver() = default;
- virtual void onTileLoaded(Tile&, bool /*isNewTile*/) {}
+ virtual void onTileLoaded(Tile&, TileLoadState) {}
virtual void onTileError(Tile&, std::exception_ptr) {}
virtual void onTileUpdated(Tile&) {}
};
diff --git a/test/src/mbgl/test/stub_style_observer.hpp b/test/src/mbgl/test/stub_style_observer.hpp
index 879b06d6b8..4de3430fcc 100644
--- a/test/src/mbgl/test/stub_style_observer.hpp
+++ b/test/src/mbgl/test/stub_style_observer.hpp
@@ -34,8 +34,8 @@ public:
if (sourceError) sourceError(source, error);
}
- void onTileLoaded(Source& source, const OverscaledTileID& tileID, bool isNewTile) override {
- if (tileLoaded) tileLoaded(source, tileID, isNewTile);
+ void onTileLoaded(Source& source, const OverscaledTileID& tileID, TileLoadState loadState) override {
+ if (tileLoaded) tileLoaded(source, tileID, loadState);
}
void
@@ -57,7 +57,7 @@ public:
std::function<void (std::exception_ptr)> spriteError;
std::function<void (Source&)> sourceLoaded;
std::function<void (Source&, std::exception_ptr)> sourceError;
- std::function<void (Source&, const OverscaledTileID&, bool isNewTile)> tileLoaded;
+ std::function<void (Source&, const OverscaledTileID&, TileLoadState)> tileLoaded;
std::function<void (Source&, const OverscaledTileID&, std::exception_ptr)> tileError;
std::function<void (Source&, const OverscaledTileID&)> tileUpdated;
std::function<void (std::exception_ptr)> resourceError;
diff --git a/test/style/source.cpp b/test/style/source.cpp
index bffe89a8c3..a33467dedb 100644
--- a/test/style/source.cpp
+++ b/test/style/source.cpp
@@ -123,7 +123,7 @@ TEST(Source, RasterTileEmpty) {
return response;
};
- test.observer.tileLoaded = [&] (Source& source, const OverscaledTileID&, bool) {
+ test.observer.tileLoaded = [&] (Source& source, const OverscaledTileID&, TileLoadState) {
EXPECT_EQ("source", source.getID());
test.end();
};
@@ -152,7 +152,7 @@ TEST(Source, VectorTileEmpty) {
return response;
};
- test.observer.tileLoaded = [&] (Source& source, const OverscaledTileID&, bool) {
+ test.observer.tileLoaded = [&] (Source& source, const OverscaledTileID&, TileLoadState) {
EXPECT_EQ("source", source.getID());
test.end();
};
@@ -298,7 +298,7 @@ TEST(Source, RasterTileCancel) {
return optional<Response>();
};
- test.observer.tileLoaded = [&] (Source&, const OverscaledTileID&, bool) {
+ test.observer.tileLoaded = [&] (Source&, const OverscaledTileID&, TileLoadState) {
FAIL() << "Should never be called";
};
@@ -325,7 +325,7 @@ TEST(Source, VectorTileCancel) {
return optional<Response>();
};
- test.observer.tileLoaded = [&] (Source&, const OverscaledTileID&, bool) {
+ test.observer.tileLoaded = [&] (Source&, const OverscaledTileID&, TileLoadState) {
FAIL() << "Should never be called";
};