diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-11-20 21:05:45 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-11-29 11:12:55 +0200 |
commit | 6419cd0ab2ba877bbae51ae7590ddba47765dac7 (patch) | |
tree | b167f864db677365d281423e1df755f7fd383989 /test | |
parent | ab5572b0bc3d386893592b842ad58b356b227a5d (diff) | |
download | qtlocation-mapboxgl-6419cd0ab2ba877bbae51ae7590ddba47765dac7.tar.gz |
[core] Calculate GeoJSON tile geometries in a background thread
Call `mapbox::geojsonvt::GeoJSONVT::getTile()` in a background
thread, so that the rendering thread is not blocked.
Diffstat (limited to 'test')
-rw-r--r-- | test/tile/geojson_tile.test.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/test/tile/geojson_tile.test.cpp b/test/tile/geojson_tile.test.cpp index cc2dbfced8..d4bf1e0752 100644 --- a/test/tile/geojson_tile.test.cpp +++ b/test/tile/geojson_tile.test.cpp @@ -4,15 +4,16 @@ #include <mbgl/tile/geojson_tile.hpp> #include <mbgl/tile/tile_loader_impl.hpp> -#include <mbgl/util/run_loop.hpp> +#include <mbgl/annotation/annotation_manager.hpp> #include <mbgl/map/transform.hpp> +#include <mbgl/renderer/image_manager.hpp> #include <mbgl/renderer/tile_parameters.hpp> -#include <mbgl/style/style.hpp> #include <mbgl/style/layers/circle_layer.hpp> #include <mbgl/style/layers/circle_layer_impl.hpp> -#include <mbgl/annotation/annotation_manager.hpp> -#include <mbgl/renderer/image_manager.hpp> +#include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/style/style.hpp> #include <mbgl/text/glyph_manager.hpp> +#include <mbgl/util/run_loop.hpp> #include <memory> @@ -43,6 +44,29 @@ public: }; }; +namespace { + +class FakeGeoJSONData : public GeoJSONData { +public: + FakeGeoJSONData(TileFeatures features_) : features(std::move(features_)) {} + + void getTile(const CanonicalTileID&, const std::function<void(TileFeatures)>& fn) final { + assert(fn); + fn(features); + } + + Features getChildren(const std::uint32_t) final { return {}; } + + Features getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) final { return {}; } + + std::uint8_t getClusterExpansionZoom(std::uint32_t) final { return 0; } + +private: + TileFeatures features; +}; + +} // namespace + TEST(GeoJSONTile, Issue7648) { GeoJSONTileTest test; @@ -50,8 +74,8 @@ TEST(GeoJSONTile, Issue7648) { mapbox::feature::feature_collection<int16_t> features; features.push_back(mapbox::feature::feature<int16_t> { mapbox::geometry::point<int16_t>(0, 0) }); - - GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features); + auto data = std::make_shared<FakeGeoJSONData>(std::move(features)); + GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, data); Immutable<LayerProperties> layerProperties = makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl)); StubTileObserver observer; observer.tileChanged = [&] (const Tile&) { @@ -68,7 +92,7 @@ TEST(GeoJSONTile, Issue7648) { test.loop.runOnce(); } - tile.updateData(features); + tile.updateData(data); while (!tile.isComplete()) { test.loop.runOnce(); } @@ -83,8 +107,8 @@ TEST(GeoJSONTile, Issue9927) { mapbox::feature::feature_collection<int16_t> features; features.push_back(mapbox::feature::feature<int16_t> { mapbox::geometry::point<int16_t>(0, 0) }); - - GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, features); + auto data = std::make_shared<FakeGeoJSONData>(std::move(features)); + GeoJSONTile tile(OverscaledTileID(0, 0, 0), "source", test.tileParameters, data); Immutable<LayerProperties> layerProperties = makeMutable<CircleLayerProperties>(staticImmutableCast<CircleLayer::Impl>(layer.baseImpl)); std::vector<Immutable<LayerProperties>> layers { layerProperties }; |