diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2020-04-29 22:33:41 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2020-05-26 20:35:03 +0300 |
commit | e45dcfe6705c61201077ea66c74d065a5b961a16 (patch) | |
tree | 52dc65c2e9fba258a9a4d8dab731c585476ab397 | |
parent | 57972231e864cf4af18f12664dbb4a838e9e99db (diff) | |
download | qtlocation-mapboxgl-e45dcfe6705c61201077ea66c74d065a5b961a16.tar.gz |
[core] Introduce `SourceTypeInfo::TileSet`
A flag, which specifies whether the source operates with the loaded tile set.
-rw-r--r-- | include/mbgl/style/source.hpp | 12 | ||||
-rw-r--r-- | include/mbgl/style/sources/raster_source.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/style/sources/vector_source.hpp | 2 | ||||
-rw-r--r-- | platform/default/src/mbgl/storage/offline_download.cpp | 32 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_source.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/renderer/tile_pyramid.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/sources/custom_geometry_source_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/sources/image_source_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/sources/raster_dem_source_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/sources/raster_source.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/sources/raster_source_impl.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/style/sources/vector_source_impl.cpp | 3 |
13 files changed, 43 insertions, 32 deletions
diff --git a/include/mbgl/style/source.hpp b/include/mbgl/style/source.hpp index 3727d944f8..ceec12149a 100644 --- a/include/mbgl/style/source.hpp +++ b/include/mbgl/style/source.hpp @@ -40,11 +40,15 @@ struct SourceTypeInfo { /** * @brief specifies whether the source supports tile prefetching; */ - const bool supportsTilePrefetch; + const enum class TilePrefetch : bool { No, Yes } tilePrefetch; + + /** + * @brief specifies whether the source operates with the loaded tile set; + */ + const enum class TileSet : bool { No, Yes } tileSet; /** * @brief specifies source's tile kind; - * */ const optional<TileKind> tileKind; }; @@ -88,13 +92,13 @@ public: virtual void loadDescription(FileSource&) = 0; - virtual void setSourceData(SourceData){}; + virtual void setSourceData(SourceData) {} virtual SourceDataResult getSourceData() const { return {}; } virtual const variant<std::string, Tileset>* getURLOrTileset() const { return nullptr; } - virtual void setSourceParameters(SourceParameters){}; + virtual void setSourceParameters(SourceParameters) {} virtual void invalidateTile(const CanonicalTileID&) {} virtual void invalidateRegion(const LatLngBounds&) {} diff --git a/include/mbgl/style/sources/raster_source.hpp b/include/mbgl/style/sources/raster_source.hpp index d84a9576c1..e49436b971 100644 --- a/include/mbgl/style/sources/raster_source.hpp +++ b/include/mbgl/style/sources/raster_source.hpp @@ -32,7 +32,7 @@ public: Value serialize() const override; protected: - RasterSource(Immutable<Impl>&&, variant<std::string, Tileset> urlOrTileset_); + RasterSource(Immutable<Impl>, variant<std::string, Tileset> urlOrTileset_); Mutable<Source::Impl> createMutable() const noexcept override; virtual Mutable<Source::Impl> createMutable(Tileset tileset) const noexcept; diff --git a/include/mbgl/style/sources/vector_source.hpp b/include/mbgl/style/sources/vector_source.hpp index 27fd78cce5..d284062e1f 100644 --- a/include/mbgl/style/sources/vector_source.hpp +++ b/include/mbgl/style/sources/vector_source.hpp @@ -38,9 +38,9 @@ protected: private: const variant<std::string, Tileset> urlOrTileset; std::unique_ptr<AsyncRequest> req; - mapbox::base::WeakPtrFactory<Source> weakFactory {this}; optional<float> maxZoom; optional<float> minZoom; + mapbox::base::WeakPtrFactory<Source> weakFactory{this}; }; } // namespace style diff --git a/platform/default/src/mbgl/storage/offline_download.cpp b/platform/default/src/mbgl/storage/offline_download.cpp index a144bf1900..a2c0db10a4 100644 --- a/platform/default/src/mbgl/storage/offline_download.cpp +++ b/platform/default/src/mbgl/storage/offline_download.cpp @@ -217,22 +217,22 @@ void OfflineDownload::activateDownload() { sourceResource.setPriority(Resource::Priority::Low); sourceResource.setUsage(Resource::Usage::Offline); - ensureResource(std::move(sourceResource), - [=, source = std::make_shared<std::unique_ptr<Source>>(std::move(source))]( - const Response& sourceResponse) { - style::conversion::Error error; - optional<Tileset> tileset = - style::conversion::convertJSON<Tileset>(*sourceResponse.data, error); - if (tileset) { - util::mapbox::canonicalizeTileset(*tileset, url, **source); - queueTiles(**source, *tileset); - - requiredSourceURLs.erase(url); - if (requiredSourceURLs.empty()) { - status.requiredResourceCountIsPrecise = true; - } - } - }); + ensureResource( + std::move(sourceResource), + [=, source = std::shared_ptr<Source>(std::move(source))](const Response& sourceResponse) { + style::conversion::Error error; + optional<Tileset> tileset = + style::conversion::convertJSON<Tileset>(*sourceResponse.data, error); + if (tileset) { + util::mapbox::canonicalizeTileset(*tileset, url, *source); + queueTiles(*source, *tileset); + + requiredSourceURLs.erase(url); + if (requiredSourceURLs.empty()) { + status.requiredResourceCountIsPrecise = true; + } + } + }); } }; diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp index 712ad73651..b4737efce8 100644 --- a/src/mbgl/annotation/annotation_source.cpp +++ b/src/mbgl/annotation/annotation_source.cpp @@ -33,7 +33,8 @@ Mutable<Source::Impl> AnnotationSource::createMutable() const noexcept { } const SourceTypeInfo* AnnotationSource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"annotations", false, nullopt}; + const static SourceTypeInfo typeInfo{ + "annotations", SourceTypeInfo::TilePrefetch::No, SourceTypeInfo::TileSet::No, nullopt}; return &typeInfo; } diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp index 60aabafd58..00ba200e34 100644 --- a/src/mbgl/renderer/tile_pyramid.cpp +++ b/src/mbgl/renderer/tile_pyramid.cpp @@ -101,7 +101,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l } // Only attempt prefetching in continuous mode. - if (parameters.mode == MapMode::Continuous && sourceImpl.getTypeInfo()->supportsTilePrefetch) { + if (parameters.mode == MapMode::Continuous && mbgl::underlying_type(sourceImpl.getTypeInfo()->tilePrefetch)) { // Request lower zoom level tiles (if configured to do so) in an attempt // to show something on the screen faster at the cost of a little of bandwidth. const uint8_t prefetchZoomDelta = diff --git a/src/mbgl/style/sources/custom_geometry_source_impl.cpp b/src/mbgl/style/sources/custom_geometry_source_impl.cpp index 59f25a3d2d..913d1873ff 100644 --- a/src/mbgl/style/sources/custom_geometry_source_impl.cpp +++ b/src/mbgl/style/sources/custom_geometry_source_impl.cpp @@ -34,7 +34,8 @@ optional<ActorRef<CustomTileLoader>> CustomGeometrySource::Impl::getTileLoader() } const SourceTypeInfo* CustomGeometrySource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"customvector", true, nullopt}; + const static SourceTypeInfo typeInfo{ + "customvector", SourceTypeInfo::TilePrefetch::Yes, SourceTypeInfo::TileSet::No, nullopt}; return &typeInfo; } diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 7193af0f1b..b47c0c5ab9 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -142,7 +142,8 @@ optional<std::string> GeoJSONSource::Impl::getAttribution() const { } const SourceTypeInfo* GeoJSONSource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"geojson", false, TileKind::Geometry}; + const static SourceTypeInfo typeInfo{ + "geojson", SourceTypeInfo::TilePrefetch::No, SourceTypeInfo::TileSet::No, TileKind::Geometry}; return &typeInfo; } diff --git a/src/mbgl/style/sources/image_source_impl.cpp b/src/mbgl/style/sources/image_source_impl.cpp index 41255b3bb0..6b16f96d55 100644 --- a/src/mbgl/style/sources/image_source_impl.cpp +++ b/src/mbgl/style/sources/image_source_impl.cpp @@ -27,7 +27,8 @@ optional<std::string> ImageSource::Impl::getAttribution() const { } const SourceTypeInfo* ImageSource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"image", true, nullopt}; + const static SourceTypeInfo typeInfo{ + "image", SourceTypeInfo::TilePrefetch::No, SourceTypeInfo::TileSet::No, nullopt}; return &typeInfo; } diff --git a/src/mbgl/style/sources/raster_dem_source_impl.cpp b/src/mbgl/style/sources/raster_dem_source_impl.cpp index 487c451d83..98c53f1623 100644 --- a/src/mbgl/style/sources/raster_dem_source_impl.cpp +++ b/src/mbgl/style/sources/raster_dem_source_impl.cpp @@ -8,7 +8,8 @@ RasterDEMSource::Impl::Impl(std::string id_, uint16_t tileSize_) : RasterSource: RasterDEMSource::Impl::Impl(const Impl& other, Tileset tileset_) : RasterSource::Impl(other, std::move(tileset_)) {} const SourceTypeInfo* RasterDEMSource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"raster-dem", true, TileKind::RasterDEM}; + const static SourceTypeInfo typeInfo{ + "raster-dem", SourceTypeInfo::TilePrefetch::Yes, SourceTypeInfo::TileSet::Yes, TileKind::RasterDEM}; return &typeInfo; } diff --git a/src/mbgl/style/sources/raster_source.cpp b/src/mbgl/style/sources/raster_source.cpp index 6684b8a52e..75c5acf24e 100644 --- a/src/mbgl/style/sources/raster_source.cpp +++ b/src/mbgl/style/sources/raster_source.cpp @@ -16,7 +16,7 @@ namespace style { RasterSource::RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset_, uint16_t tileSize) : Source(makeMutable<Impl>(std::move(id), tileSize)), urlOrTileset(std::move(urlOrTileset_)) {} -RasterSource::RasterSource(Immutable<Impl>&& impl, variant<std::string, Tileset> urlOrTileset_) +RasterSource::RasterSource(Immutable<Impl> impl, variant<std::string, Tileset> urlOrTileset_) : Source(std::move(impl)), urlOrTileset(std::move(urlOrTileset_)) {} RasterSource::~RasterSource() = default; @@ -31,7 +31,7 @@ const variant<std::string, Tileset>* RasterSource::getURLOrTileset() const { optional<std::string> RasterSource::getURL() const { if (urlOrTileset.is<Tileset>()) { - return {}; + return nullopt; } return urlOrTileset.get<std::string>(); diff --git a/src/mbgl/style/sources/raster_source_impl.cpp b/src/mbgl/style/sources/raster_source_impl.cpp index b18a34412b..2bb4027fa3 100644 --- a/src/mbgl/style/sources/raster_source_impl.cpp +++ b/src/mbgl/style/sources/raster_source_impl.cpp @@ -20,7 +20,8 @@ optional<std::string> RasterSource::Impl::getAttribution() const { } const SourceTypeInfo* RasterSource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"raster", true, TileKind::Raster}; + const static SourceTypeInfo typeInfo{ + "raster", SourceTypeInfo::TilePrefetch::Yes, SourceTypeInfo::TileSet::Yes, TileKind::Raster}; return &typeInfo; } diff --git a/src/mbgl/style/sources/vector_source_impl.cpp b/src/mbgl/style/sources/vector_source_impl.cpp index 172673be8a..9c28ce409a 100644 --- a/src/mbgl/style/sources/vector_source_impl.cpp +++ b/src/mbgl/style/sources/vector_source_impl.cpp @@ -15,7 +15,8 @@ optional<std::string> VectorSource::Impl::getAttribution() const { } const SourceTypeInfo* VectorSource::Impl::staticTypeInfo() noexcept { - const static SourceTypeInfo typeInfo{"vector", true, TileKind::Geometry}; + const static SourceTypeInfo typeInfo{ + "vector", SourceTypeInfo::TilePrefetch::Yes, SourceTypeInfo::TileSet::Yes, TileKind::Geometry}; return &typeInfo; } |