diff options
43 files changed, 91 insertions, 117 deletions
diff --git a/include/mbgl/util/immutable.hpp b/include/mbgl/util/immutable.hpp index 1d6ff4079a..2cdce8772d 100644 --- a/include/mbgl/util/immutable.hpp +++ b/include/mbgl/util/immutable.hpp @@ -107,18 +107,9 @@ private: std::shared_ptr<const T> ptr; template <class S> friend class Immutable; - template <class S> friend class EnableImmutableFromThis; template <class S, class U> friend Immutable<S> staticImmutableCast(const Immutable<U>&); }; -template <class T> -class EnableImmutableFromThis : public std::enable_shared_from_this<const T> { -public: - Immutable<T> immutableFromThis() const { - return Immutable<T>(this->shared_from_this()); - } -}; - template <class S, class U> Immutable<S> staticImmutableCast(const Immutable<U>& u) { return Immutable<S>(std::static_pointer_cast<const S>(u.ptr)); diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp index b0b8bae6cc..68f36f2d3a 100644 --- a/src/mbgl/annotation/annotation_source.cpp +++ b/src/mbgl/annotation/annotation_source.cpp @@ -1,6 +1,5 @@ #include <mbgl/annotation/annotation_source.hpp> #include <mbgl/annotation/annotation_manager.hpp> -#include <mbgl/annotation/render_annotation_source.hpp> namespace mbgl { @@ -22,8 +21,4 @@ optional<std::string> AnnotationSource::Impl::getAttribution() const { return {}; } -std::unique_ptr<RenderSource> AnnotationSource::Impl::createRenderSource() const { - return std::make_unique<RenderAnnotationSource>(staticImmutableCast<AnnotationSource::Impl>(immutableFromThis())); -} - } // namespace mbgl diff --git a/src/mbgl/annotation/annotation_source.hpp b/src/mbgl/annotation/annotation_source.hpp index 56d91f5501..0728f3207e 100644 --- a/src/mbgl/annotation/annotation_source.hpp +++ b/src/mbgl/annotation/annotation_source.hpp @@ -23,7 +23,6 @@ public: Impl(); optional<std::string> getAttribution() const final; - std::unique_ptr<RenderSource> createRenderSource() const final; }; } // namespace mbgl diff --git a/src/mbgl/renderer/render_background_layer.hpp b/src/mbgl/renderer/render_background_layer.hpp index c2ac44af8b..7eabf47345 100644 --- a/src/mbgl/renderer/render_background_layer.hpp +++ b/src/mbgl/renderer/render_background_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/background_layer.hpp> +#include <mbgl/style/layers/background_layer_impl.hpp> #include <mbgl/style/layers/background_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_circle_layer.hpp b/src/mbgl/renderer/render_circle_layer.hpp index d059db9343..2b517912c9 100644 --- a/src/mbgl/renderer/render_circle_layer.hpp +++ b/src/mbgl/renderer/render_circle_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/circle_layer.hpp> +#include <mbgl/style/layers/circle_layer_impl.hpp> #include <mbgl/style/layers/circle_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_custom_layer.hpp b/src/mbgl/renderer/render_custom_layer.hpp index 64cd02ac7b..d448433092 100644 --- a/src/mbgl/renderer/render_custom_layer.hpp +++ b/src/mbgl/renderer/render_custom_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/custom_layer.hpp> +#include <mbgl/style/layers/custom_layer_impl.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/render_fill_extrusion_layer.hpp index ef6858a680..f6166495c6 100644 --- a/src/mbgl/renderer/render_fill_extrusion_layer.hpp +++ b/src/mbgl/renderer/render_fill_extrusion_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/fill_extrusion_layer.hpp> +#include <mbgl/style/layers/fill_extrusion_layer_impl.hpp> #include <mbgl/style/layers/fill_extrusion_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_fill_layer.hpp b/src/mbgl/renderer/render_fill_layer.hpp index 7402094a1c..d26ca10b44 100644 --- a/src/mbgl/renderer/render_fill_layer.hpp +++ b/src/mbgl/renderer/render_fill_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/fill_layer.hpp> +#include <mbgl/style/layers/fill_layer_impl.hpp> #include <mbgl/style/layers/fill_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index 2f30b2ce21..ca4999e606 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -1,8 +1,43 @@ #include <mbgl/renderer/render_layer.hpp> +#include <mbgl/renderer/render_background_layer.hpp> +#include <mbgl/renderer/render_circle_layer.hpp> +#include <mbgl/renderer/render_custom_layer.hpp> +#include <mbgl/renderer/render_fill_extrusion_layer.hpp> +#include <mbgl/renderer/render_fill_layer.hpp> +#include <mbgl/renderer/render_line_layer.hpp> +#include <mbgl/renderer/render_raster_layer.hpp> +#include <mbgl/renderer/render_symbol_layer.hpp> #include <mbgl/style/types.hpp> namespace mbgl { +using namespace style; + +std::unique_ptr<RenderLayer> RenderLayer::create(Immutable<Layer::Impl> impl) { + switch (impl->type) { + case LayerType::Fill: + return std::make_unique<RenderFillLayer>(staticImmutableCast<FillLayer::Impl>(impl)); + case LayerType::Line: + return std::make_unique<RenderLineLayer>(staticImmutableCast<LineLayer::Impl>(impl)); + case LayerType::Circle: + return std::make_unique<RenderCircleLayer>(staticImmutableCast<CircleLayer::Impl>(impl)); + case LayerType::Symbol: + return std::make_unique<RenderSymbolLayer>(staticImmutableCast<SymbolLayer::Impl>(impl)); + case LayerType::Raster: + return std::make_unique<RenderRasterLayer>(staticImmutableCast<RasterLayer::Impl>(impl)); + case LayerType::Background: + return std::make_unique<RenderBackgroundLayer>(staticImmutableCast<BackgroundLayer::Impl>(impl)); + case LayerType::Custom: + return std::make_unique<RenderCustomLayer>(staticImmutableCast<CustomLayer::Impl>(impl)); + case LayerType::FillExtrusion: + return std::make_unique<RenderFillExtrusionLayer>(staticImmutableCast<FillExtrusionLayer::Impl>(impl)); + } + + // Not reachable, but placate GCC. + assert(false); + return nullptr; +} + RenderLayer::RenderLayer(style::LayerType type_, Immutable<style::Layer::Impl> baseImpl_) : type(type_), baseImpl(baseImpl_) { diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index f1999a7257..e6a2d26fde 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -22,6 +22,8 @@ protected: const style::LayerType type; public: + static std::unique_ptr<RenderLayer> create(Immutable<style::Layer::Impl>); + virtual ~RenderLayer() = default; // Partially evaluate paint properties based on a set of classes. diff --git a/src/mbgl/renderer/render_line_layer.hpp b/src/mbgl/renderer/render_line_layer.hpp index ddb2608fff..0276e6a6d9 100644 --- a/src/mbgl/renderer/render_line_layer.hpp +++ b/src/mbgl/renderer/render_line_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/line_layer.hpp> +#include <mbgl/style/layers/line_layer_impl.hpp> #include <mbgl/style/layers/line_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_raster_layer.hpp b/src/mbgl/renderer/render_raster_layer.hpp index c822262e91..50c213aa26 100644 --- a/src/mbgl/renderer/render_raster_layer.hpp +++ b/src/mbgl/renderer/render_raster_layer.hpp @@ -1,7 +1,7 @@ #pragma once #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/style/layers/raster_layer.hpp> +#include <mbgl/style/layers/raster_layer_impl.hpp> #include <mbgl/style/layers/raster_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/renderer/render_source.cpp b/src/mbgl/renderer/render_source.cpp index 9eca54795a..4b411aa703 100644 --- a/src/mbgl/renderer/render_source.cpp +++ b/src/mbgl/renderer/render_source.cpp @@ -1,9 +1,35 @@ #include <mbgl/renderer/render_source.hpp> #include <mbgl/renderer/render_source_observer.hpp> +#include <mbgl/renderer/sources/render_geojson_source.hpp> +#include <mbgl/renderer/sources/render_raster_source.hpp> +#include <mbgl/renderer/sources/render_vector_source.hpp> +#include <mbgl/annotation/render_annotation_source.hpp> #include <mbgl/tile/tile.hpp> namespace mbgl { +using namespace style; + +std::unique_ptr<RenderSource> RenderSource::create(Immutable<Source::Impl> impl) { + switch (impl->type) { + case SourceType::Vector: + return std::make_unique<RenderVectorSource>(staticImmutableCast<VectorSource::Impl>(impl)); + case SourceType::Raster: + return std::make_unique<RenderRasterSource>(staticImmutableCast<RasterSource::Impl>(impl)); + case SourceType::GeoJSON: + return std::make_unique<RenderGeoJSONSource>(staticImmutableCast<GeoJSONSource::Impl>(impl)); + case SourceType::Video: + assert(false); + return nullptr; + case SourceType::Annotations: + return std::make_unique<RenderAnnotationSource>(staticImmutableCast<AnnotationSource::Impl>(impl)); + } + + // Not reachable, but placate GCC. + assert(false); + return nullptr; +} + static RenderSourceObserver nullObserver; RenderSource::RenderSource(Immutable<style::Source::Impl> impl) diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp index 178ee92f93..994d600613 100644 --- a/src/mbgl/renderer/render_source.hpp +++ b/src/mbgl/renderer/render_source.hpp @@ -29,7 +29,8 @@ class ClipIDGenerator; class RenderSource : protected TileObserver { public: - RenderSource(Immutable<style::Source::Impl>); + static std::unique_ptr<RenderSource> create(Immutable<style::Source::Impl>); + ~RenderSource() override = default; virtual bool isLoaded() const = 0; @@ -77,6 +78,7 @@ public: bool enabled = false; protected: + RenderSource(Immutable<style::Source::Impl>); RenderSourceObserver* observer; void onTileChanged(Tile&) final; diff --git a/src/mbgl/renderer/render_symbol_layer.hpp b/src/mbgl/renderer/render_symbol_layer.hpp index 07b4e96125..ba1b047663 100644 --- a/src/mbgl/renderer/render_symbol_layer.hpp +++ b/src/mbgl/renderer/render_symbol_layer.hpp @@ -3,7 +3,7 @@ #include <mbgl/text/glyph.hpp> #include <mbgl/renderer/render_layer.hpp> #include <mbgl/sprite/sprite_atlas.hpp> -#include <mbgl/style/layers/symbol_layer.hpp> +#include <mbgl/style/layers/symbol_layer_impl.hpp> #include <mbgl/style/layers/symbol_layer_properties.hpp> namespace mbgl { diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp index fe7259a11a..569ef65906 100644 --- a/src/mbgl/style/layer_impl.hpp +++ b/src/mbgl/style/layer_impl.hpp @@ -27,7 +27,7 @@ namespace style { * Members that are public in `FooLayer::Impl` are part of the internal API for "foo" layers. * Members that are private in `FooLayer::Impl` are internal to "foo" layers. */ -class Layer::Impl : public EnableImmutableFromThis<Layer::Impl> { +class Layer::Impl { public: Impl(LayerType, std::string layerID, std::string sourceID); virtual ~Impl() = default; @@ -37,8 +37,6 @@ public: // Utility function for automatic layer grouping. virtual void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const = 0; - virtual std::unique_ptr<RenderLayer> createRenderLayer() const = 0; - const LayerType type; std::string id; std::string source; diff --git a/src/mbgl/style/layers/background_layer_impl.cpp b/src/mbgl/style/layers/background_layer_impl.cpp index 07249ec5a4..4b4f44a8d8 100644 --- a/src/mbgl/style/layers/background_layer_impl.cpp +++ b/src/mbgl/style/layers/background_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/background_layer_impl.hpp> -#include <mbgl/renderer/render_background_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> BackgroundLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderBackgroundLayer>(staticImmutableCast<BackgroundLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/background_layer_impl.hpp b/src/mbgl/style/layers/background_layer_impl.hpp index 41eee7bdf3..8f17eb6d34 100644 --- a/src/mbgl/style/layers/background_layer_impl.hpp +++ b/src/mbgl/style/layers/background_layer_impl.hpp @@ -13,8 +13,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - BackgroundPaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp index 8df79507bf..cdb371bd58 100644 --- a/src/mbgl/style/layers/circle_layer_impl.cpp +++ b/src/mbgl/style/layers/circle_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/circle_layer_impl.hpp> -#include <mbgl/renderer/render_circle_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> CircleLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderCircleLayer>(staticImmutableCast<CircleLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp index 94fa24b811..707f7e6103 100644 --- a/src/mbgl/style/layers/circle_layer_impl.hpp +++ b/src/mbgl/style/layers/circle_layer_impl.hpp @@ -13,8 +13,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - CirclePaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp index e459b57171..f5ad2bb087 100644 --- a/src/mbgl/style/layers/custom_layer_impl.cpp +++ b/src/mbgl/style/layers/custom_layer_impl.cpp @@ -1,15 +1,10 @@ #include <mbgl/style/layers/custom_layer_impl.hpp> -#include <mbgl/renderer/render_custom_layer.hpp> #include <mbgl/map/transform_state.hpp> #include <mbgl/util/logging.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> CustomLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderCustomLayer>(staticImmutableCast<CustomLayer::Impl>(immutableFromThis())); -} - CustomLayer::Impl::Impl(const std::string& id_, CustomLayerInitializeFunction initializeFn_, CustomLayerRenderFunction renderFn_, diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp index f921f47d59..26a75f5834 100644 --- a/src/mbgl/style/layers/custom_layer_impl.hpp +++ b/src/mbgl/style/layers/custom_layer_impl.hpp @@ -24,8 +24,6 @@ public: private: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const final; - CustomLayerInitializeFunction initializeFn = nullptr; CustomLayerRenderFunction renderFn = nullptr; CustomLayerDeinitializeFunction deinitializeFn = nullptr; diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp index 9530e45b7f..07df4cd331 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/fill_extrusion_layer_impl.hpp> -#include <mbgl/renderer/render_fill_extrusion_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> FillExtrusionLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderFillExtrusionLayer>(staticImmutableCast<FillExtrusionLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp index 167d28e973..edc481767e 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp +++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp @@ -13,8 +13,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - FillExtrusionPaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp index 3bddedbdfb..38672c5bfe 100644 --- a/src/mbgl/style/layers/fill_layer_impl.cpp +++ b/src/mbgl/style/layers/fill_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/fill_layer_impl.hpp> -#include <mbgl/renderer/render_fill_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> FillLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderFillLayer>(staticImmutableCast<FillLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp index 0e911c86cf..0ae146f859 100644 --- a/src/mbgl/style/layers/fill_layer_impl.hpp +++ b/src/mbgl/style/layers/fill_layer_impl.hpp @@ -13,8 +13,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - FillPaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/layers/line_layer_impl.cpp b/src/mbgl/style/layers/line_layer_impl.cpp index 0158ba7a96..16a164eb9d 100644 --- a/src/mbgl/style/layers/line_layer_impl.cpp +++ b/src/mbgl/style/layers/line_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/line_layer_impl.hpp> -#include <mbgl/renderer/render_line_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> LineLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderLineLayer>(staticImmutableCast<LineLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp index 70d357c592..decbf8451e 100644 --- a/src/mbgl/style/layers/line_layer_impl.hpp +++ b/src/mbgl/style/layers/line_layer_impl.hpp @@ -13,8 +13,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - LineLayoutProperties layout; LinePaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/layers/raster_layer_impl.cpp b/src/mbgl/style/layers/raster_layer_impl.cpp index f7e908a5cf..1c2204c5d7 100644 --- a/src/mbgl/style/layers/raster_layer_impl.cpp +++ b/src/mbgl/style/layers/raster_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/raster_layer_impl.hpp> -#include <mbgl/renderer/render_raster_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> RasterLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderRasterLayer>(staticImmutableCast<RasterLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp index 451619807a..fbdbd9379b 100644 --- a/src/mbgl/style/layers/raster_layer_impl.hpp +++ b/src/mbgl/style/layers/raster_layer_impl.hpp @@ -13,8 +13,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - RasterPaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp index 220a17fd36..3f0ab9b8fb 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.cpp +++ b/src/mbgl/style/layers/symbol_layer_impl.cpp @@ -1,12 +1,7 @@ #include <mbgl/style/layers/symbol_layer_impl.hpp> -#include <mbgl/renderer/render_symbol_layer.hpp> namespace mbgl { namespace style { -std::unique_ptr<RenderLayer> SymbolLayer::Impl::createRenderLayer() const { - return std::make_unique<RenderSymbolLayer>(staticImmutableCast<SymbolLayer::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp index 4937ee8721..5e04834583 100644 --- a/src/mbgl/style/layers/symbol_layer_impl.hpp +++ b/src/mbgl/style/layers/symbol_layer_impl.hpp @@ -14,8 +14,6 @@ public: void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override; - std::unique_ptr<RenderLayer> createRenderLayer() const override; - SymbolLayoutProperties layout; SymbolPaintProperties::Cascading cascading; }; diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp index 3620ec4e50..52d5036fae 100644 --- a/src/mbgl/style/source_impl.hpp +++ b/src/mbgl/style/source_impl.hpp @@ -13,12 +13,11 @@ namespace style { class SourceObserver; -class Source::Impl : public EnableImmutableFromThis<Source::Impl> { +class Source::Impl { public: virtual ~Impl() = default; virtual optional<std::string> getAttribution() const = 0; - virtual std::unique_ptr<RenderSource> createRenderSource() const = 0; const SourceType type; const std::string id; diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 17d05aaa5a..be347af2ab 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -1,6 +1,6 @@ #include <mbgl/style/sources/geojson_source_impl.hpp> -#include <mbgl/renderer/sources/render_geojson_source.hpp> -#include <mbgl/util/constants.cpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/tile/tile_id.hpp> #include <mapbox/geojsonvt.hpp> #include <supercluster.hpp> @@ -79,9 +79,5 @@ optional<std::string> GeoJSONSource::Impl::getAttribution() const { return {}; } -std::unique_ptr<RenderSource> GeoJSONSource::Impl::createRenderSource() const { - return std::make_unique<RenderGeoJSONSource>(staticImmutableCast<GeoJSONSource::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index 65580700e7..192ef653dc 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -26,7 +26,6 @@ public: GeoJSONData* getData() const; optional<std::string> getAttribution() const final; - std::unique_ptr<RenderSource> createRenderSource() const final; private: GeoJSONOptions options; diff --git a/src/mbgl/style/sources/raster_source_impl.cpp b/src/mbgl/style/sources/raster_source_impl.cpp index 1d684524c7..50dae1f07e 100644 --- a/src/mbgl/style/sources/raster_source_impl.cpp +++ b/src/mbgl/style/sources/raster_source_impl.cpp @@ -1,5 +1,4 @@ #include <mbgl/style/sources/raster_source_impl.hpp> -#include <mbgl/renderer/sources/render_raster_source.hpp> namespace mbgl { namespace style { @@ -30,9 +29,5 @@ optional<std::string> RasterSource::Impl::getAttribution() const { return tileset->attribution; } -std::unique_ptr<RenderSource> RasterSource::Impl::createRenderSource() const { - return std::make_unique<RenderRasterSource>(staticImmutableCast<RasterSource::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/sources/raster_source_impl.hpp b/src/mbgl/style/sources/raster_source_impl.hpp index 0a58953ab7..c41d5485b2 100644 --- a/src/mbgl/style/sources/raster_source_impl.hpp +++ b/src/mbgl/style/sources/raster_source_impl.hpp @@ -15,7 +15,6 @@ public: uint16_t getTileSize() const; optional<std::string> getAttribution() const final; - std::unique_ptr<RenderSource> createRenderSource() const final; private: uint16_t tileSize; diff --git a/src/mbgl/style/sources/vector_source_impl.cpp b/src/mbgl/style/sources/vector_source_impl.cpp index aab62acf3f..b06f0557bf 100644 --- a/src/mbgl/style/sources/vector_source_impl.cpp +++ b/src/mbgl/style/sources/vector_source_impl.cpp @@ -1,5 +1,4 @@ #include <mbgl/style/sources/vector_source_impl.hpp> -#include <mbgl/renderer/sources/render_vector_source.hpp> namespace mbgl { namespace style { @@ -24,9 +23,5 @@ optional<std::string> VectorSource::Impl::getAttribution() const { return tileset->attribution; } -std::unique_ptr<RenderSource> VectorSource::Impl::createRenderSource() const { - return std::make_unique<RenderVectorSource>(staticImmutableCast<VectorSource::Impl>(immutableFromThis())); -} - } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/sources/vector_source_impl.hpp b/src/mbgl/style/sources/vector_source_impl.hpp index 602d0e5bbb..5e559b9266 100644 --- a/src/mbgl/style/sources/vector_source_impl.hpp +++ b/src/mbgl/style/sources/vector_source_impl.hpp @@ -14,7 +14,6 @@ public: optional<Tileset> getTileset() const; optional<std::string> getAttribution() const final; - std::unique_ptr<RenderSource> createRenderSource() const final; private: optional<Tileset> tileset; diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 2042bc1225..6af876d740 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -388,7 +388,7 @@ void Style::update(const UpdateParameters& parameters) { // Create render sources for newly added sources. for (const auto& entry : sourceDiff.added) { - std::unique_ptr<RenderSource> renderSource = entry.second->createRenderSource(); + std::unique_ptr<RenderSource> renderSource = RenderSource::create(entry.second); renderSource->setObserver(this); renderSources.emplace(entry.first, std::move(renderSource)); } @@ -415,7 +415,7 @@ void Style::update(const UpdateParameters& parameters) { // Create render layers for newly added layers. for (const auto& entry : layerDiff.added) { - renderLayers.emplace(entry.first, entry.second->createRenderLayer()); + renderLayers.emplace(entry.first, RenderLayer::create(entry.second)); } // Update render layers for changed layers. diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index 788534531d..121960fb81 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -246,7 +246,7 @@ static std::vector<std::unique_ptr<RenderLayer>> toRenderLayers(const std::vecto std::vector<std::unique_ptr<RenderLayer>> renderLayers; renderLayers.reserve(layers.size()); for (auto& layer : layers) { - renderLayers.push_back(layer->createRenderLayer()); + renderLayers.push_back(RenderLayer::create(layer)); renderLayers.back()->cascade(CascadeParameters { { ClassID::Default }, diff --git a/test/renderer/group_by_layout.test.cpp b/test/renderer/group_by_layout.test.cpp index 9c8e09e222..958f1bdf24 100644 --- a/test/renderer/group_by_layout.test.cpp +++ b/test/renderer/group_by_layout.test.cpp @@ -13,7 +13,7 @@ static std::vector<std::unique_ptr<RenderLayer>> toRenderLayers(const std::vecto std::vector<std::unique_ptr<RenderLayer>> result; result.reserve(layers.size()); for (auto& layer : layers) { - result.push_back(layer->baseImpl->createRenderLayer()); + result.push_back(RenderLayer::create(layer->baseImpl)); } return result; } diff --git a/test/style/source.test.cpp b/test/style/source.test.cpp index ad28db7c19..0473286c8b 100644 --- a/test/style/source.test.cpp +++ b/test/style/source.test.cpp @@ -148,7 +148,7 @@ TEST(Source, RasterTileEmpty) { FAIL() << "Should never be called"; }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -179,7 +179,7 @@ TEST(Source, VectorTileEmpty) { FAIL() << "Should never be called"; }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -210,7 +210,7 @@ TEST(Source, RasterTileFail) { test.end(); }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -241,7 +241,7 @@ TEST(Source, VectorTileFail) { test.end(); }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -271,7 +271,7 @@ TEST(Source, RasterTileCorrupt) { test.end(); }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -305,7 +305,7 @@ TEST(Source, VectorTileCorrupt) { test.end(); }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -334,7 +334,7 @@ TEST(Source, RasterTileCancel) { FAIL() << "Should never be called"; }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -363,7 +363,7 @@ TEST(Source, VectorTileCancel) { FAIL() << "Should never be called"; }; - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->setObserver(&test.renderSourceObserver); renderSource->updateTiles(test.tileParameters); @@ -401,7 +401,7 @@ TEST(Source, RasterTileAttribution) { source.setObserver(&test.styleObserver); source.loadDescription(test.fileSource); - auto renderSource = source.baseImpl->createRenderSource(); + auto renderSource = RenderSource::create(source.baseImpl); renderSource->updateTiles(test.tileParameters); test.run(); |