summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-11-22 15:37:09 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-11-26 22:11:28 +0200
commitff390189a8887b57780cc3bea3b7f30bbecc0fec (patch)
treefce4c858652596e6ce6331ef3a1a8e466391a8d4
parent6bb1e977eafc61af39d47df083bb3de13205fae9 (diff)
downloadqtlocation-mapboxgl-upstream/mikhail_render_layer_factory.tar.gz
[core][Android][Darwin] LayerManager creates RenderLayer instancesupstream/mikhail_render_layer_factory
`LayerManager` is now responsible for `RenderLayer` instances creation, so that there is a single entry point for creating of objects, which correspond to a certain layer type. The `LayerType type` field is dropped from `Layer::Impl`.
-rw-r--r--include/mbgl/style/layer.hpp30
-rw-r--r--include/mbgl/style/layers/background_layer.hpp14
-rw-r--r--include/mbgl/style/layers/circle_layer.hpp14
-rw-r--r--include/mbgl/style/layers/custom_layer.hpp12
-rw-r--r--include/mbgl/style/layers/fill_extrusion_layer.hpp14
-rw-r--r--include/mbgl/style/layers/fill_layer.hpp14
-rw-r--r--include/mbgl/style/layers/heatmap_layer.hpp14
-rw-r--r--include/mbgl/style/layers/hillshade_layer.hpp14
-rw-r--r--include/mbgl/style/layers/layer.hpp.ejs14
-rw-r--r--include/mbgl/style/layers/line_layer.hpp14
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp14
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp14
-rw-r--r--platform/android/src/style/layers/background_layer.hpp4
-rw-r--r--platform/android/src/style/layers/circle_layer.hpp4
-rw-r--r--platform/android/src/style/layers/custom_layer.hpp4
-rw-r--r--platform/android/src/style/layers/fill_extrusion_layer.hpp4
-rw-r--r--platform/android/src/style/layers/fill_layer.hpp4
-rw-r--r--platform/android/src/style/layers/heatmap_layer.hpp4
-rw-r--r--platform/android/src/style/layers/hillshade_layer.hpp4
-rw-r--r--platform/android/src/style/layers/layer.hpp2
-rw-r--r--platform/android/src/style/layers/layer.hpp.ejs4
-rw-r--r--platform/android/src/style/layers/layer_manager.cpp41
-rw-r--r--platform/android/src/style/layers/layer_manager.hpp19
-rw-r--r--platform/android/src/style/layers/line_layer.hpp4
-rw-r--r--platform/android/src/style/layers/raster_layer.hpp4
-rw-r--r--platform/android/src/style/layers/symbol_layer.hpp4
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLFillStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLHeatmapStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLHillshadeStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLLineStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer_Private.h4
-rw-r--r--platform/darwin/src/MGLStyleLayerManager.h12
-rw-r--r--platform/darwin/src/MGLStyleLayerManager.mm39
-rw-r--r--platform/darwin/src/MGLStyleLayer_Private.h2
-rw-r--r--platform/darwin/src/MGLStyleLayer_Private.h.ejs4
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer_Private.h4
-rw-r--r--platform/darwin/test/MGLBackgroundStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLCircleStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLFillStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLHeatmapStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLHillshadeStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLLineStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLRasterStyleLayerTests.mm2
-rw-r--r--platform/darwin/test/MGLStyleLayerTests.mm.ejs2
-rw-r--r--platform/darwin/test/MGLSymbolStyleLayerTests.mm2
-rw-r--r--platform/default/layer_manager.cpp62
-rw-r--r--platform/ios/ios.xcodeproj/project.pbxproj8
-rw-r--r--platform/macos/macos.xcodeproj/project.pbxproj8
-rw-r--r--src/mbgl/annotation/fill_annotation_impl.cpp1
-rw-r--r--src/mbgl/annotation/line_annotation_impl.cpp1
-rw-r--r--src/mbgl/renderer/group_by_layout.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_background_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_circle_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_custom_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_hillshade_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.cpp2
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp2
-rw-r--r--src/mbgl/renderer/render_layer.cpp46
-rw-r--r--src/mbgl/renderer/render_layer.hpp8
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp2
-rw-r--r--src/mbgl/renderer/style_diff.cpp3
-rw-r--r--src/mbgl/style/layer.cpp38
-rw-r--r--src/mbgl/style/layer_impl.cpp5
-rw-r--r--src/mbgl/style/layer_impl.hpp11
-rw-r--r--src/mbgl/style/layers/background_layer.cpp36
-rw-r--r--src/mbgl/style/layers/background_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp36
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/custom_layer.cpp20
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp36
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp36
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/heatmap_layer.cpp36
-rw-r--r--src/mbgl/style/layers/heatmap_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/heatmap_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/hillshade_layer.cpp36
-rw-r--r--src/mbgl/style/layers/hillshade_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs40
-rw-r--r--src/mbgl/style/layers/line_layer.cpp36
-rw-r--r--src/mbgl/style/layers/line_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/line_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp36
-rw-r--r--src/mbgl/style/layers/raster_layer_impl.hpp3
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp36
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.cpp2
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.hpp3
-rw-r--r--src/mbgl/tile/geometry_tile.cpp3
-rw-r--r--src/mbgl/tile/geometry_tile_worker.cpp2
-rw-r--r--test/gl/context.test.cpp2
-rw-r--r--test/renderer/group_by_layout.test.cpp2
-rw-r--r--test/style/conversion/layer.test.cpp2
-rw-r--r--test/style/style_layer.test.cpp10
107 files changed, 538 insertions, 531 deletions
diff --git a/include/mbgl/style/layer.hpp b/include/mbgl/style/layer.hpp
index 5c1b361419..9e73e994e6 100644
--- a/include/mbgl/style/layer.hpp
+++ b/include/mbgl/style/layer.hpp
@@ -74,8 +74,7 @@ public:
Layer& operator=(const Layer&) = delete;
virtual ~Layer();
- // Note: LayerType is deprecated, do not use it.
- LayerType getType() const;
+
std::string getID() const;
// Source
std::string getSourceID() const;
@@ -126,6 +125,10 @@ protected:
LayerObserver* observer;
};
+} // namespace style
+
+class RenderLayer;
+// TODO: The following classes shall not be here. Move layer factories and manager to a dedicated folder.
/**
* @brief The LayerFactory abstract class
@@ -136,17 +139,19 @@ class LayerFactory {
public:
virtual ~LayerFactory() = default;
/// Returns the layer type data.
- virtual const LayerTypeInfo* getTypeInfo() const noexcept = 0;
+ virtual const style::LayerTypeInfo* getTypeInfo() const noexcept = 0;
/// Returns a new Layer instance on success call; returns `nulltptr` otherwise.
- virtual std::unique_ptr<Layer> createLayer(const std::string& id, const conversion::Convertible& value) = 0;
+ virtual std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept = 0;
+ /// Returns a new RenderLayer instance on success call; returns `nulltptr` otherwise.
+ virtual std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept = 0;
protected:
- optional<std::string> getSource(const conversion::Convertible& value) const noexcept;
- bool initSourceLayerAndFilter(Layer*, const conversion::Convertible& value) const noexcept;
+ optional<std::string> getSource(const style::conversion::Convertible& value) const noexcept;
+ bool initSourceLayerAndFilter(style::Layer*, const style::conversion::Convertible& value) const noexcept;
};
/**
- * @brief A singleton class forwarding calls to the corresponding \c LayerFactory instance.
+ * @brief A singleton class responsible for creating layer instances.
*/
class LayerManager {
public:
@@ -157,13 +162,16 @@ public:
*/
static LayerManager* get() noexcept;
- virtual ~LayerManager() = default;
/// Returns a new Layer instance on success call; returns `nulltptr` otherwise.
- virtual std::unique_ptr<Layer> createLayer(const std::string& type, const std::string& id, const conversion::Convertible& value, conversion::Error& error) noexcept = 0;
+ std::unique_ptr<style::Layer> createLayer(const std::string& type, const std::string& id,
+ const style::conversion::Convertible& value, style::conversion::Error& error) noexcept;
+ /// Returns a new RenderLayer instance on success call; returns `nulltptr` otherwise.
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept;
protected:
- LayerManager() = default;
+ virtual ~LayerManager() = default;
+ virtual LayerFactory* getFactory(const std::string& type) noexcept = 0;
+ virtual LayerFactory* getFactory(const style::LayerTypeInfo*) noexcept = 0;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp
index e188a9ba2c..b471d8613e 100644
--- a/include/mbgl/style/layers/background_layer.hpp
+++ b/include/mbgl/style/layers/background_layer.hpp
@@ -56,15 +56,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class BackgroundLayerFactory : public LayerFactory {
-public:
- BackgroundLayerFactory();
- ~BackgroundLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class BackgroundLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp
index 4dacb905df..46951653b7 100644
--- a/include/mbgl/style/layers/circle_layer.hpp
+++ b/include/mbgl/style/layers/circle_layer.hpp
@@ -104,15 +104,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class CircleLayerFactory : public LayerFactory {
-public:
- CircleLayerFactory();
- ~CircleLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class CircleLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/custom_layer.hpp b/include/mbgl/style/layers/custom_layer.hpp
index 5021df6a60..d204a782f2 100644
--- a/include/mbgl/style/layers/custom_layer.hpp
+++ b/include/mbgl/style/layers/custom_layer.hpp
@@ -85,15 +85,13 @@ public:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
+} // namespace style
+
class CustomLayerFactory : public LayerFactory {
-public:
- CustomLayerFactory();
// LayerFactory overrides.
- ~CustomLayerFactory() override;
-
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/fill_extrusion_layer.hpp b/include/mbgl/style/layers/fill_extrusion_layer.hpp
index 0092e61f3b..059b8f8996 100644
--- a/include/mbgl/style/layers/fill_extrusion_layer.hpp
+++ b/include/mbgl/style/layers/fill_extrusion_layer.hpp
@@ -80,15 +80,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class FillExtrusionLayerFactory : public LayerFactory {
-public:
- FillExtrusionLayerFactory();
- ~FillExtrusionLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class FillExtrusionLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp
index 52bbd054ae..222142daf3 100644
--- a/include/mbgl/style/layers/fill_layer.hpp
+++ b/include/mbgl/style/layers/fill_layer.hpp
@@ -80,15 +80,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class FillLayerFactory : public LayerFactory {
-public:
- FillLayerFactory();
- ~FillLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class FillLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/heatmap_layer.hpp b/include/mbgl/style/layers/heatmap_layer.hpp
index d1760100ad..004d77c487 100644
--- a/include/mbgl/style/layers/heatmap_layer.hpp
+++ b/include/mbgl/style/layers/heatmap_layer.hpp
@@ -69,15 +69,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class HeatmapLayerFactory : public LayerFactory {
-public:
- HeatmapLayerFactory();
- ~HeatmapLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class HeatmapLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/hillshade_layer.hpp b/include/mbgl/style/layers/hillshade_layer.hpp
index 978670f8a9..f840386907 100644
--- a/include/mbgl/style/layers/hillshade_layer.hpp
+++ b/include/mbgl/style/layers/hillshade_layer.hpp
@@ -74,15 +74,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class HillshadeLayerFactory : public LayerFactory {
-public:
- HillshadeLayerFactory();
- ~HillshadeLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class HillshadeLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs
index 11d45b4b0c..84a8edd9de 100644
--- a/include/mbgl/style/layers/layer.hpp.ejs
+++ b/include/mbgl/style/layers/layer.hpp.ejs
@@ -72,15 +72,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class <%- camelize(type) %>LayerFactory : public LayerFactory {
-public:
- <%- camelize(type) %>LayerFactory();
- ~<%- camelize(type) %>LayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class <%- camelize(type) %>LayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp
index 0f5e2bb347..bbc0213c53 100644
--- a/include/mbgl/style/layers/line_layer.hpp
+++ b/include/mbgl/style/layers/line_layer.hpp
@@ -125,15 +125,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class LineLayerFactory : public LayerFactory {
-public:
- LineLayerFactory();
- ~LineLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class LineLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index 4b63570590..0def2faacd 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -86,15 +86,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class RasterLayerFactory : public LayerFactory {
-public:
- RasterLayerFactory();
- ~RasterLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class RasterLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index 62ea393b33..e17df295f3 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -274,15 +274,13 @@ protected:
Mutable<Layer::Impl> mutableBaseImpl() const final;
};
-class SymbolLayerFactory : public LayerFactory {
-public:
- SymbolLayerFactory();
- ~SymbolLayerFactory() override;
+} // namespace style
- // LayerFactory overrides.
- const LayerTypeInfo* getTypeInfo() const noexcept final;
- std::unique_ptr<style::Layer> createLayer(const std::string& id, const conversion::Convertible& value) final;
+class SymbolLayerFactory : public LayerFactory {
+protected:
+ const style::LayerTypeInfo* getTypeInfo() const noexcept final;
+ std::unique_ptr<style::Layer> createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept final;
+ std::unique_ptr<RenderLayer> createRenderLayer(Immutable<style::Layer::Impl>) noexcept final;
};
-} // namespace style
} // namespace mbgl
diff --git a/platform/android/src/style/layers/background_layer.hpp b/platform/android/src/style/layers/background_layer.hpp
index efe882d531..c1b25b41bd 100644
--- a/platform/android/src/style/layers/background_layer.hpp
+++ b/platform/android/src/style/layers/background_layer.hpp
@@ -39,7 +39,7 @@ public:
}; // class BackgroundLayer
-class BackgroundJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::BackgroundLayerFactory {
+class BackgroundJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::BackgroundLayerFactory {
public:
~BackgroundJavaLayerPeerFactory() override;
@@ -49,7 +49,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class BackgroundJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/circle_layer.hpp b/platform/android/src/style/layers/circle_layer.hpp
index 5c53f6c191..6db97127c0 100644
--- a/platform/android/src/style/layers/circle_layer.hpp
+++ b/platform/android/src/style/layers/circle_layer.hpp
@@ -65,7 +65,7 @@ public:
}; // class CircleLayer
-class CircleJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::CircleLayerFactory {
+class CircleJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::CircleLayerFactory {
public:
~CircleJavaLayerPeerFactory() override;
@@ -75,7 +75,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class CircleJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/custom_layer.hpp b/platform/android/src/style/layers/custom_layer.hpp
index ea4a3d79a5..814cfea3ca 100644
--- a/platform/android/src/style/layers/custom_layer.hpp
+++ b/platform/android/src/style/layers/custom_layer.hpp
@@ -25,7 +25,7 @@ public:
}; // class CustomLayer
-class CustomJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::CustomLayerFactory {
+class CustomJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::CustomLayerFactory {
public:
~CustomJavaLayerPeerFactory() override;
@@ -35,7 +35,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class CustomJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/fill_extrusion_layer.hpp b/platform/android/src/style/layers/fill_extrusion_layer.hpp
index ace8cd1357..fe7204985c 100644
--- a/platform/android/src/style/layers/fill_extrusion_layer.hpp
+++ b/platform/android/src/style/layers/fill_extrusion_layer.hpp
@@ -53,7 +53,7 @@ public:
}; // class FillExtrusionLayer
-class FillExtrusionJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::FillExtrusionLayerFactory {
+class FillExtrusionJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::FillExtrusionLayerFactory {
public:
~FillExtrusionJavaLayerPeerFactory() override;
@@ -63,7 +63,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class FillExtrusionJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/fill_layer.hpp b/platform/android/src/style/layers/fill_layer.hpp
index c7b469ac90..776f2c3a88 100644
--- a/platform/android/src/style/layers/fill_layer.hpp
+++ b/platform/android/src/style/layers/fill_layer.hpp
@@ -51,7 +51,7 @@ public:
}; // class FillLayer
-class FillJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::FillLayerFactory {
+class FillJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::FillLayerFactory {
public:
~FillJavaLayerPeerFactory() override;
@@ -61,7 +61,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class FillJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/heatmap_layer.hpp b/platform/android/src/style/layers/heatmap_layer.hpp
index 45c194b0f0..51966ec93e 100644
--- a/platform/android/src/style/layers/heatmap_layer.hpp
+++ b/platform/android/src/style/layers/heatmap_layer.hpp
@@ -43,7 +43,7 @@ public:
}; // class HeatmapLayer
-class HeatmapJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::HeatmapLayerFactory {
+class HeatmapJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::HeatmapLayerFactory {
public:
~HeatmapJavaLayerPeerFactory() override;
@@ -53,7 +53,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class HeatmapJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/hillshade_layer.hpp b/platform/android/src/style/layers/hillshade_layer.hpp
index db0ea736b4..b63f85e36c 100644
--- a/platform/android/src/style/layers/hillshade_layer.hpp
+++ b/platform/android/src/style/layers/hillshade_layer.hpp
@@ -47,7 +47,7 @@ public:
}; // class HillshadeLayer
-class HillshadeJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::HillshadeLayerFactory {
+class HillshadeJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::HillshadeLayerFactory {
public:
~HillshadeJavaLayerPeerFactory() override;
@@ -57,7 +57,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class HillshadeJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/layer.hpp b/platform/android/src/style/layers/layer.hpp
index 633630b891..c405bc17c1 100644
--- a/platform/android/src/style/layers/layer.hpp
+++ b/platform/android/src/style/layers/layer.hpp
@@ -117,7 +117,7 @@ public:
*
* @return style::LayerFactory* must not be \c nullptr.
*/
- virtual style::LayerFactory* getLayerFactory() = 0;
+ virtual LayerFactory* getLayerFactory() = 0;
};
diff --git a/platform/android/src/style/layers/layer.hpp.ejs b/platform/android/src/style/layers/layer.hpp.ejs
index 5791c16501..e82470e270 100644
--- a/platform/android/src/style/layers/layer.hpp.ejs
+++ b/platform/android/src/style/layers/layer.hpp.ejs
@@ -43,7 +43,7 @@ public:
}; // class <%- camelize(type) %>Layer
-class <%- camelize(type) %>JavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::<%- camelize(type) %>LayerFactory {
+class <%- camelize(type) %>JavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::<%- camelize(type) %>LayerFactory {
public:
~<%- camelize(type) %>JavaLayerPeerFactory() override;
@@ -53,7 +53,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class <%- camelize(type) %>JavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/layer_manager.cpp b/platform/android/src/style/layers/layer_manager.cpp
index 9ad62121e6..9f13fa0640 100644
--- a/platform/android/src/style/layers/layer_manager.cpp
+++ b/platform/android/src/style/layers/layer_manager.cpp
@@ -1,17 +1,6 @@
#include "layer_manager.hpp"
-#include <mbgl/style/layer.hpp>
#include <mbgl/style/layer_impl.hpp>
-#include <mbgl/style/layers/background_layer.hpp>
-#include <mbgl/style/layers/circle_layer.hpp>
-#include <mbgl/style/layers/fill_extrusion_layer.hpp>
-#include <mbgl/style/layers/fill_layer.hpp>
-#include <mbgl/style/layers/heatmap_layer.hpp>
-#include <mbgl/style/layers/hillshade_layer.hpp>
-#include <mbgl/style/layers/line_layer.hpp>
-#include <mbgl/style/layers/raster_layer.hpp>
-#include <mbgl/style/layers/symbol_layer.hpp>
-#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/style/conversion/constant.hpp>
#include <mbgl/style/conversion/filter.hpp>
@@ -49,14 +38,14 @@ LayerManagerAndroid::LayerManagerAndroid() {
LayerManagerAndroid::~LayerManagerAndroid() = default;
jni::Local<jni::Object<Layer>> LayerManagerAndroid::createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, mbgl::style::Layer& layer) {
- if (JavaLayerPeerFactory* factory = getPeerFactory(&layer)) {
+ if (JavaLayerPeerFactory* factory = getPeerFactory(layer.getTypeInfo())) {
return factory->createJavaLayerPeer(env, map, layer);
}
return jni::Local<jni::Object<Layer>>();
}
jni::Local<jni::Object<Layer>> LayerManagerAndroid::createJavaLayerPeer(jni::JNIEnv& env, mbgl::Map& map, std::unique_ptr<mbgl::style::Layer> layer) {
- if (JavaLayerPeerFactory* factory = getPeerFactory(layer.get())) {
+ if (JavaLayerPeerFactory* factory = getPeerFactory(layer->getTypeInfo())) {
return factory->createJavaLayerPeer(env, map, std::move(layer));
}
return jni::Local<jni::Object<Layer>>();
@@ -78,8 +67,7 @@ void LayerManagerAndroid::addLayerType(std::unique_ptr<JavaLayerPeerFactory> fac
factories.emplace_back(std::move(factory));
}
-JavaLayerPeerFactory* LayerManagerAndroid::getPeerFactory(mbgl::style::Layer* layer) {
- auto* typeInfo = layer->baseImpl->getTypeInfo();
+JavaLayerPeerFactory* LayerManagerAndroid::getPeerFactory(const mbgl::style::LayerTypeInfo* typeInfo) {
assert(typeInfo);
for (const auto& factory: factories) {
if (factory->getLayerFactory()->getTypeInfo() == typeInfo) {
@@ -90,20 +78,14 @@ JavaLayerPeerFactory* LayerManagerAndroid::getPeerFactory(mbgl::style::Layer* la
return nullptr;
}
-std::unique_ptr<style::Layer> LayerManagerAndroid::createLayer(const std::string& type,
- const std::string& id,
- const style::conversion::Convertible& value,
- style::conversion::Error& error) noexcept {
+LayerFactory* LayerManagerAndroid::getFactory(const std::string& type) noexcept {
auto search = typeToFactory.find(type);
- if (search != typeToFactory.end()) {
- auto layer = search->second->createLayer(id, value);
- if (!layer) {
- error.message = "Error parsing a layer of type: " + type;
- }
- return layer;
- }
- error.message = "Unsupported layer type: " + type;
- return nullptr;
+ return (search != typeToFactory.end()) ? search->second : nullptr;
+}
+
+LayerFactory* LayerManagerAndroid::getFactory(const mbgl::style::LayerTypeInfo* info) noexcept {
+ JavaLayerPeerFactory* peerFactory = getPeerFactory(info);
+ return (peerFactory != nullptr) ? peerFactory->getLayerFactory() : nullptr;
}
// static
@@ -114,11 +96,8 @@ LayerManagerAndroid* LayerManagerAndroid::get() noexcept {
} // namespace android
-namespace style {
-// static
LayerManager* LayerManager::get() noexcept {
return android::LayerManagerAndroid::get();
}
-} // style
} // namespace mbgl
diff --git a/platform/android/src/style/layers/layer_manager.hpp b/platform/android/src/style/layers/layer_manager.hpp
index 396521cc4a..1521645cce 100644
--- a/platform/android/src/style/layers/layer_manager.hpp
+++ b/platform/android/src/style/layers/layer_manager.hpp
@@ -3,6 +3,8 @@
#include <mbgl/map/map.hpp>
#include <mbgl/style/layer.hpp>
+#include <mbgl/renderer/render_layer.hpp>
+
#include "layer.hpp"
#include <jni/jni.hpp>
@@ -16,9 +18,9 @@ namespace android {
/**
* @brief A singleton class forwarding calls to the corresponding \c JavaLayerPeerFactory instance.
*/
-class LayerManagerAndroid : public mbgl::style::LayerManager {
+class LayerManagerAndroid final : public mbgl::LayerManager {
public:
- ~LayerManagerAndroid() override;
+ ~LayerManagerAndroid() final;
static LayerManagerAndroid* get() noexcept;
jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv&, mbgl::Map&, mbgl::style::Layer&);
@@ -29,13 +31,14 @@ public:
private:
LayerManagerAndroid();
void addLayerType(std::unique_ptr<JavaLayerPeerFactory>);
- JavaLayerPeerFactory* getPeerFactory(mbgl::style::Layer*);
- // mbgl:style::LayerManager overrides.
- std::unique_ptr<style::Layer> createLayer(const std::string& type, const std::string& id, const style::conversion::Convertible& value, style::conversion::Error& error) noexcept final;
+ JavaLayerPeerFactory* getPeerFactory(const mbgl::style::LayerTypeInfo*);
+ // mbgl::LayerManager overrides.
+ LayerFactory* getFactory(const std::string& type) noexcept final;
+ LayerFactory* getFactory(const mbgl::style::LayerTypeInfo* info) noexcept final;
std::vector<std::unique_ptr<JavaLayerPeerFactory>> factories;
- std::map<std::string, style::LayerFactory*> typeToFactory;
+ std::map<std::string, mbgl::LayerFactory*> typeToFactory;
};
-}
-}
+} // namespace android
+} // namespace mbgl
diff --git a/platform/android/src/style/layers/line_layer.hpp b/platform/android/src/style/layers/line_layer.hpp
index 4dbc855ca9..7c16822ef8 100644
--- a/platform/android/src/style/layers/line_layer.hpp
+++ b/platform/android/src/style/layers/line_layer.hpp
@@ -75,7 +75,7 @@ public:
}; // class LineLayer
-class LineJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::LineLayerFactory {
+class LineJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::LineLayerFactory {
public:
~LineJavaLayerPeerFactory() override;
@@ -85,7 +85,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class LineJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/raster_layer.hpp b/platform/android/src/style/layers/raster_layer.hpp
index 492b3562fc..6be6792776 100644
--- a/platform/android/src/style/layers/raster_layer.hpp
+++ b/platform/android/src/style/layers/raster_layer.hpp
@@ -55,7 +55,7 @@ public:
}; // class RasterLayer
-class RasterJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::RasterLayerFactory {
+class RasterJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::RasterLayerFactory {
public:
~RasterJavaLayerPeerFactory() override;
@@ -65,7 +65,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class RasterJavaLayerPeerFactory
diff --git a/platform/android/src/style/layers/symbol_layer.hpp b/platform/android/src/style/layers/symbol_layer.hpp
index 5df7ac3687..b38a659b06 100644
--- a/platform/android/src/style/layers/symbol_layer.hpp
+++ b/platform/android/src/style/layers/symbol_layer.hpp
@@ -153,7 +153,7 @@ public:
}; // class SymbolLayer
-class SymbolJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::style::SymbolLayerFactory {
+class SymbolJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::SymbolLayerFactory {
public:
~SymbolJavaLayerPeerFactory() override;
@@ -163,7 +163,7 @@ public:
void registerNative(jni::JNIEnv&) final;
- style::LayerFactory* getLayerFactory() final { return this; }
+ LayerFactory* getLayerFactory() final { return this; }
}; // class SymbolJavaLayerPeerFactory
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer_Private.h b/platform/darwin/src/MGLBackgroundStyleLayer_Private.h
index 07021669dc..a6295a7c5a 100644
--- a/platform/darwin/src/MGLBackgroundStyleLayer_Private.h
+++ b/platform/darwin/src/MGLBackgroundStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class BackgroundStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::BackgroundLayerFactory {
+class BackgroundStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::BackgroundLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLCircleStyleLayer_Private.h b/platform/darwin/src/MGLCircleStyleLayer_Private.h
index 3813a9a068..a023e2a88b 100644
--- a/platform/darwin/src/MGLCircleStyleLayer_Private.h
+++ b/platform/darwin/src/MGLCircleStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class CircleStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::CircleLayerFactory {
+class CircleStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::CircleLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h b/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h
index 2b9a53f59f..fdd99d74f4 100644
--- a/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h
+++ b/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class FillExtrusionStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::FillExtrusionLayerFactory {
+class FillExtrusionStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::FillExtrusionLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLFillStyleLayer_Private.h b/platform/darwin/src/MGLFillStyleLayer_Private.h
index f31d397434..28f24f056d 100644
--- a/platform/darwin/src/MGLFillStyleLayer_Private.h
+++ b/platform/darwin/src/MGLFillStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class FillStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::FillLayerFactory {
+class FillStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::FillLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLHeatmapStyleLayer_Private.h b/platform/darwin/src/MGLHeatmapStyleLayer_Private.h
index 16ad816be4..e81920ae39 100644
--- a/platform/darwin/src/MGLHeatmapStyleLayer_Private.h
+++ b/platform/darwin/src/MGLHeatmapStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class HeatmapStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::HeatmapLayerFactory {
+class HeatmapStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::HeatmapLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLHillshadeStyleLayer_Private.h b/platform/darwin/src/MGLHillshadeStyleLayer_Private.h
index 28958512d7..e92cc7f3ec 100644
--- a/platform/darwin/src/MGLHillshadeStyleLayer_Private.h
+++ b/platform/darwin/src/MGLHillshadeStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class HillshadeStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::HillshadeLayerFactory {
+class HillshadeStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::HillshadeLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLLineStyleLayer_Private.h b/platform/darwin/src/MGLLineStyleLayer_Private.h
index ba50ebbc0d..85dbffb8ca 100644
--- a/platform/darwin/src/MGLLineStyleLayer_Private.h
+++ b/platform/darwin/src/MGLLineStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class LineStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::LineLayerFactory {
+class LineStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::LineLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLOpenGLStyleLayer_Private.h b/platform/darwin/src/MGLOpenGLStyleLayer_Private.h
index 1188c50cd5..cce062b53d 100644
--- a/platform/darwin/src/MGLOpenGLStyleLayer_Private.h
+++ b/platform/darwin/src/MGLOpenGLStyleLayer_Private.h
@@ -6,9 +6,9 @@
namespace mbgl {
-class OpenGLStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::CustomLayerFactory {
+class OpenGLStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::CustomLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLRasterStyleLayer_Private.h b/platform/darwin/src/MGLRasterStyleLayer_Private.h
index 1070751a61..5388d64302 100644
--- a/platform/darwin/src/MGLRasterStyleLayer_Private.h
+++ b/platform/darwin/src/MGLRasterStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class RasterStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::RasterLayerFactory {
+class RasterStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::RasterLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLStyleLayerManager.h b/platform/darwin/src/MGLStyleLayerManager.h
index 0f7fab00ed..2fa34991a1 100644
--- a/platform/darwin/src/MGLStyleLayerManager.h
+++ b/platform/darwin/src/MGLStyleLayerManager.h
@@ -10,7 +10,7 @@
namespace mbgl {
-class LayerManagerDarwin : public style::LayerManager {
+class LayerManagerDarwin : public LayerManager {
public:
static LayerManagerDarwin* get() noexcept;
~LayerManagerDarwin();
@@ -20,11 +20,13 @@ public:
private:
LayerManagerDarwin();
void addLayerType(std::unique_ptr<LayerPeerFactory>);
- // LayerManager overrides.
- std::unique_ptr<style::Layer> createLayer(const std::string& type, const std::string& id, const style::conversion::Convertible& value, style::conversion::Error& error) noexcept final;
-
+ LayerPeerFactory* getPeerFactory(const style::LayerTypeInfo* typeInfo);
+ // mbgl::LayerManager overrides.
+ LayerFactory* getFactory(const std::string& type) noexcept final;
+ LayerFactory* getFactory(const mbgl::style::LayerTypeInfo* info) noexcept final;
+
std::vector<std::unique_ptr<LayerPeerFactory>> factories;
- std::map<std::string, style::LayerFactory*> typeToFactory;
+ std::map<std::string, LayerFactory*> typeToFactory;
};
} // namespace mbgl
diff --git a/platform/darwin/src/MGLStyleLayerManager.mm b/platform/darwin/src/MGLStyleLayerManager.mm
index 2cb919dd9d..90272851c3 100644
--- a/platform/darwin/src/MGLStyleLayerManager.mm
+++ b/platform/darwin/src/MGLStyleLayerManager.mm
@@ -31,14 +31,9 @@ LayerManagerDarwin::LayerManagerDarwin() {
LayerManagerDarwin::~LayerManagerDarwin() = default;
MGLStyleLayer* LayerManagerDarwin::createPeer(style::Layer* layer) {
- auto* typeInfo = layer->getTypeInfo();
- assert(typeInfo);
- for (const auto& factory: factories) {
- if (factory->getCoreLayerFactory()->getTypeInfo() == typeInfo) {
- return factory->createPeer(layer);
- }
+ if (auto* factory = getPeerFactory(layer->getTypeInfo())) {
+ return factory->createPeer(layer);
}
- assert(false);
return nullptr;
}
@@ -51,34 +46,36 @@ void LayerManagerDarwin::addLayerType(std::unique_ptr<LayerPeerFactory> factory)
factories.emplace_back(std::move(factory));
}
-std::unique_ptr<style::Layer> LayerManagerDarwin::createLayer(const std::string& type,
- const std::string& id,
- const style::conversion::Convertible& value,
- style::conversion::Error& error) noexcept {
- auto search = typeToFactory.find(type);
- if (search != typeToFactory.end()) {
- auto layer = search->second->createLayer(id, value);
- if (!layer) {
- error.message = "Error parsing a layer of type: " + type;
+LayerPeerFactory* LayerManagerDarwin::getPeerFactory(const mbgl::style::LayerTypeInfo* typeInfo) {
+ assert(typeInfo);
+ for (const auto& factory: factories) {
+ if (factory->getCoreLayerFactory()->getTypeInfo() == typeInfo) {
+ return factory.get();
}
- return layer;
}
- error.message = "Unsupported layer type: " + type;
+ assert(false);
return nullptr;
}
+LayerFactory* LayerManagerDarwin::getFactory(const std::string& type) noexcept {
+ auto search = typeToFactory.find(type);
+ return (search != typeToFactory.end()) ? search->second : nullptr;
+}
+
+LayerFactory* LayerManagerDarwin::getFactory(const mbgl::style::LayerTypeInfo* info) noexcept {
+ LayerPeerFactory* peerFactory = getPeerFactory(info);
+ return (peerFactory != nullptr) ? peerFactory->getCoreLayerFactory() : nullptr;
+}
+
// static
LayerManagerDarwin* LayerManagerDarwin::get() noexcept {
static LayerManagerDarwin impl;
return &impl;
}
-namespace style {
-
// static
LayerManager* LayerManager::get() noexcept {
return LayerManagerDarwin::get();
}
-} // namespace style
} // namespace mbgl
diff --git a/platform/darwin/src/MGLStyleLayer_Private.h b/platform/darwin/src/MGLStyleLayer_Private.h
index 0d6e4094bd..656f74ca42 100644
--- a/platform/darwin/src/MGLStyleLayer_Private.h
+++ b/platform/darwin/src/MGLStyleLayer_Private.h
@@ -90,7 +90,7 @@ public:
/**
Get the corresponding core layer factory.
*/
- virtual style::LayerFactory* getCoreLayerFactory() = 0;
+ virtual LayerFactory* getCoreLayerFactory() = 0;
/**
Creates an MGLStyleLayer instance with a raw pointer to the backing store.
*/
diff --git a/platform/darwin/src/MGLStyleLayer_Private.h.ejs b/platform/darwin/src/MGLStyleLayer_Private.h.ejs
index 245eeec29e..8cb8d6281a 100644
--- a/platform/darwin/src/MGLStyleLayer_Private.h.ejs
+++ b/platform/darwin/src/MGLStyleLayer_Private.h.ejs
@@ -15,9 +15,9 @@
namespace mbgl {
-class <%- camelize(type) %>StyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::<%- camelize(type) %>LayerFactory {
+class <%- camelize(type) %>StyleLayerPeerFactory : public LayerPeerFactory, public mbgl::<%- camelize(type) %>LayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/src/MGLSymbolStyleLayer_Private.h b/platform/darwin/src/MGLSymbolStyleLayer_Private.h
index 6ba7c7bfd0..5e5755ad67 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer_Private.h
+++ b/platform/darwin/src/MGLSymbolStyleLayer_Private.h
@@ -8,9 +8,9 @@
namespace mbgl {
-class SymbolStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::SymbolLayerFactory {
+class SymbolStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::SymbolLayerFactory {
// LayerPeerFactory overrides.
- style::LayerFactory* getCoreLayerFactory() final { return this; }
+ LayerFactory* getCoreLayerFactory() final { return this; }
virtual MGLStyleLayer* createPeer(style::Layer*) final;
};
diff --git a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
index d76cd8cd6d..600f81acfe 100644
--- a/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
+++ b/platform/darwin/test/MGLBackgroundStyleLayerTests.mm
@@ -22,7 +22,7 @@
- (void)testProperties {
MGLBackgroundStyleLayer *layer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"layerID"];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Background);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"background");
auto rawLayer = static_cast<mbgl::style::BackgroundLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLCircleStyleLayerTests.mm b/platform/darwin/test/MGLCircleStyleLayerTests.mm
index 213416109c..5f789f4faf 100644
--- a/platform/darwin/test/MGLCircleStyleLayerTests.mm
+++ b/platform/darwin/test/MGLCircleStyleLayerTests.mm
@@ -43,7 +43,7 @@
MGLCircleStyleLayer *layer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Circle);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"circle");
auto rawLayer = static_cast<mbgl::style::CircleLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm b/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm
index 7c4e147026..ecfa2134a0 100644
--- a/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm
+++ b/platform/darwin/test/MGLFillExtrusionStyleLayerTests.mm
@@ -43,7 +43,7 @@
MGLFillExtrusionStyleLayer *layer = [[MGLFillExtrusionStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::FillExtrusion);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"fill-extrusion");
auto rawLayer = static_cast<mbgl::style::FillExtrusionLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLFillStyleLayerTests.mm b/platform/darwin/test/MGLFillStyleLayerTests.mm
index b8c39918c5..3762c4095e 100644
--- a/platform/darwin/test/MGLFillStyleLayerTests.mm
+++ b/platform/darwin/test/MGLFillStyleLayerTests.mm
@@ -43,7 +43,7 @@
MGLFillStyleLayer *layer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Fill);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"fill");
auto rawLayer = static_cast<mbgl::style::FillLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
index bde8a5b1c8..98d314cb9f 100644
--- a/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
+++ b/platform/darwin/test/MGLHeatmapStyleLayerTests.mm
@@ -43,7 +43,7 @@
MGLHeatmapStyleLayer *layer = [[MGLHeatmapStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Heatmap);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"heatmap");
auto rawLayer = static_cast<mbgl::style::HeatmapLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLHillshadeStyleLayerTests.mm b/platform/darwin/test/MGLHillshadeStyleLayerTests.mm
index 5c8a45beab..a52f36e8c6 100644
--- a/platform/darwin/test/MGLHillshadeStyleLayerTests.mm
+++ b/platform/darwin/test/MGLHillshadeStyleLayerTests.mm
@@ -25,7 +25,7 @@
MGLHillshadeStyleLayer *layer = [[MGLHillshadeStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Hillshade);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"hillshade");
auto rawLayer = static_cast<mbgl::style::HillshadeLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLLineStyleLayerTests.mm b/platform/darwin/test/MGLLineStyleLayerTests.mm
index c8868635ef..f4fd714ad7 100644
--- a/platform/darwin/test/MGLLineStyleLayerTests.mm
+++ b/platform/darwin/test/MGLLineStyleLayerTests.mm
@@ -43,7 +43,7 @@
MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Line);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"line");
auto rawLayer = static_cast<mbgl::style::LineLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLRasterStyleLayerTests.mm b/platform/darwin/test/MGLRasterStyleLayerTests.mm
index f0ce055b3a..5168d2e0d4 100644
--- a/platform/darwin/test/MGLRasterStyleLayerTests.mm
+++ b/platform/darwin/test/MGLRasterStyleLayerTests.mm
@@ -25,7 +25,7 @@
MGLRasterStyleLayer *layer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Raster);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"raster");
auto rawLayer = static_cast<mbgl::style::RasterLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLStyleLayerTests.mm.ejs b/platform/darwin/test/MGLStyleLayerTests.mm.ejs
index 68d61072f8..ba878b8bbe 100644
--- a/platform/darwin/test/MGLStyleLayerTests.mm.ejs
+++ b/platform/darwin/test/MGLStyleLayerTests.mm.ejs
@@ -54,7 +54,7 @@
MGL<%- camelize(type) %>StyleLayer *layer = [[MGL<%- camelize(type) %>StyleLayer alloc] initWithIdentifier:@"layerID" source:source];
<% } -%>
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::<%- camelize(type) %>);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"<%- type %>");
auto rawLayer = static_cast<mbgl::style::<%- camelize(type) %>Layer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/darwin/test/MGLSymbolStyleLayerTests.mm b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
index daf63355e6..f02c5d496e 100644
--- a/platform/darwin/test/MGLSymbolStyleLayerTests.mm
+++ b/platform/darwin/test/MGLSymbolStyleLayerTests.mm
@@ -43,7 +43,7 @@
MGLSymbolStyleLayer *layer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"layerID" source:source];
XCTAssertNotEqual(layer.rawLayer, nullptr);
- XCTAssertEqual(layer.rawLayer->getType(), mbgl::style::LayerType::Symbol);
+ XCTAssertEqualObjects(@(layer.rawLayer->getTypeInfo()->type), @"symbol");
auto rawLayer = static_cast<mbgl::style::SymbolLayer*>(layer.rawLayer);
MGLTransition transitionTest = MGLTransitionMake(5, 4);
diff --git a/platform/default/layer_manager.cpp b/platform/default/layer_manager.cpp
index 0a27c0b512..60cd0855b8 100644
--- a/platform/default/layer_manager.cpp
+++ b/platform/default/layer_manager.cpp
@@ -1,37 +1,36 @@
-#include <mbgl/style/layer.hpp>
-#include <mbgl/style/layers/symbol_layer.hpp>
-#include <mbgl/style/layers/background_layer.hpp>
-#include <mbgl/style/layers/circle_layer.hpp>
-#include <mbgl/style/layers/custom_layer.hpp>
-#include <mbgl/style/layers/fill_extrusion_layer.hpp>
-#include <mbgl/style/layers/fill_layer.hpp>
-#include <mbgl/style/layers/heatmap_layer.hpp>
-#include <mbgl/style/layers/hillshade_layer.hpp>
-#include <mbgl/style/layers/line_layer.hpp>
-#include <mbgl/style/layers/raster_layer.hpp>
-#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/renderer/render_layer.hpp>
+#include <mbgl/renderer/layers/render_background_layer.hpp>
+#include <mbgl/renderer/layers/render_circle_layer.hpp>
+#include <mbgl/renderer/layers/render_custom_layer.hpp>
+#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp>
+#include <mbgl/renderer/layers/render_fill_layer.hpp>
+#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
+#include <mbgl/renderer/layers/render_line_layer.hpp>
+#include <mbgl/renderer/layers/render_raster_layer.hpp>
+#include <mbgl/renderer/layers/render_symbol_layer.hpp>
+#include <mbgl/renderer/layers/render_heatmap_layer.hpp>
#include <map>
#include <memory>
#include <vector>
namespace mbgl {
-namespace style {
-class LayerManagerBase : public LayerManager {
+class LayerManagerDefault final : public LayerManager {
public:
- LayerManagerBase();
+ LayerManagerDefault();
private:
void addLayerType(std::unique_ptr<LayerFactory>);
// LayerManager overrides.
- std::unique_ptr<Layer> createLayer(const std::string& type, const std::string& id, const conversion::Convertible& value, conversion::Error& error) noexcept final;
+ LayerFactory* getFactory(const std::string& type) noexcept final;
+ LayerFactory* getFactory(const style::LayerTypeInfo*) noexcept final;
std::vector<std::unique_ptr<LayerFactory>> factories;
std::map<std::string, LayerFactory*> typeToFactory;
};
-LayerManagerBase::LayerManagerBase() {
+LayerManagerDefault::LayerManagerDefault() {
addLayerType(std::make_unique<FillLayerFactory>());
addLayerType(std::make_unique<LineLayerFactory>());
addLayerType(std::make_unique<CircleLayerFactory>());
@@ -44,7 +43,7 @@ LayerManagerBase::LayerManagerBase() {
addLayerType(std::make_unique<CustomLayerFactory>());
}
-void LayerManagerBase::addLayerType(std::unique_ptr<LayerFactory> factory) {
+void LayerManagerDefault::addLayerType(std::unique_ptr<LayerFactory> factory) {
std::string type{factory->getTypeInfo()->type};
if (!type.empty()) {
typeToFactory.emplace(std::make_pair(std::move(type), factory.get()));
@@ -52,27 +51,26 @@ void LayerManagerBase::addLayerType(std::unique_ptr<LayerFactory> factory) {
factories.emplace_back(std::move(factory));
}
-std::unique_ptr<Layer> LayerManagerBase::createLayer(const std::string& type,
- const std::string& id,
- const conversion::Convertible& value,
- conversion::Error& error) noexcept {
- auto search = typeToFactory.find(type);
- if (search != typeToFactory.end()) {
- auto layer = search->second->createLayer(id, value);
- if (!layer) {
- error.message = "Error parsing a layer of type: " + type;
+LayerFactory* LayerManagerDefault::getFactory(const mbgl::style::LayerTypeInfo* typeInfo) noexcept {
+ assert(typeInfo);
+ for (const auto& factory: factories) {
+ if (factory->getTypeInfo() == typeInfo) {
+ return factory.get();
}
- return layer;
}
- error.message = "Unsupported layer type: " + type;
+ assert(false);
return nullptr;
}
+LayerFactory* LayerManagerDefault::getFactory(const std::string& type) noexcept {
+ auto search = typeToFactory.find(type);
+ return (search != typeToFactory.end()) ? search->second : nullptr;
+}
+
// static
LayerManager* LayerManager::get() noexcept {
- static LayerManagerBase impl;
- return &impl;
+ static LayerManagerDefault instance;
+ return &instance;
}
-} // namespace style
} // namespace mbgl
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj
index 1b2334c657..f0ddbb346d 100644
--- a/platform/ios/ios.xcodeproj/project.pbxproj
+++ b/platform/ios/ios.xcodeproj/project.pbxproj
@@ -3770,6 +3770,10 @@
"$(geometry_cflags)",
"$(geojson_cflags)",
);
+ OTHER_LDFLAGS = (
+ "$(mbgl_core_LINK_LIBRARIES)",
+ "$(mbgl_filesource_LINK_LIBRARIES)",
+ );
OTHER_SWIFT_FLAGS = "-warnings-as-errors";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -3797,6 +3801,10 @@
"$(geometry_cflags)",
"$(geojson_cflags)",
);
+ OTHER_LDFLAGS = (
+ "$(mbgl_core_LINK_LIBRARIES)",
+ "$(mbgl_filesource_LINK_LIBRARIES)",
+ );
OTHER_SWIFT_FLAGS = "-warnings-as-errors";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj
index 60ac8e6843..3cd807be7e 100644
--- a/platform/macos/macos.xcodeproj/project.pbxproj
+++ b/platform/macos/macos.xcodeproj/project.pbxproj
@@ -2144,6 +2144,10 @@
"$(geometry_cflags)",
"$(geojson_cflags)",
);
+ OTHER_LDFLAGS = (
+ "$(mbgl_core_LINK_LIBRARIES)",
+ "$(mbgl_filesource_LINK_LIBRARIES)",
+ );
OTHER_SWIFT_FLAGS = "-warnings-as-errors";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -2172,6 +2176,10 @@
"$(geometry_cflags)",
"$(geojson_cflags)",
);
+ OTHER_LDFLAGS = (
+ "$(mbgl_core_LINK_LIBRARIES)",
+ "$(mbgl_filesource_LINK_LIBRARIES)",
+ );
OTHER_SWIFT_FLAGS = "-warnings-as-errors";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test;
PRODUCT_NAME = "$(TARGET_NAME)";
diff --git a/src/mbgl/annotation/fill_annotation_impl.cpp b/src/mbgl/annotation/fill_annotation_impl.cpp
index 7ac1932f32..59b8133cf7 100644
--- a/src/mbgl/annotation/fill_annotation_impl.cpp
+++ b/src/mbgl/annotation/fill_annotation_impl.cpp
@@ -21,7 +21,6 @@ void FillAnnotationImpl::updateStyle(Style::Impl& style) const {
layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
}
- assert(layer->getType() == LayerType::Fill);
auto* fillLayer = static_cast<FillLayer*>(layer);
fillLayer->setFillOpacity(annotation.opacity);
fillLayer->setFillColor(annotation.color);
diff --git a/src/mbgl/annotation/line_annotation_impl.cpp b/src/mbgl/annotation/line_annotation_impl.cpp
index b4dc10049f..315a36954b 100644
--- a/src/mbgl/annotation/line_annotation_impl.cpp
+++ b/src/mbgl/annotation/line_annotation_impl.cpp
@@ -22,7 +22,6 @@ void LineAnnotationImpl::updateStyle(Style::Impl& style) const {
layer = style.addLayer(std::move(newLayer), AnnotationManager::PointLayerID);
}
- assert(layer->getType() == LayerType::Line);
LineLayer* lineLayer = static_cast<LineLayer*>(layer);
lineLayer->setLineOpacity(annotation.opacity);
lineLayer->setLineWidth(annotation.width);
diff --git a/src/mbgl/renderer/group_by_layout.cpp b/src/mbgl/renderer/group_by_layout.cpp
index 3b02727ff8..41a895902c 100644
--- a/src/mbgl/renderer/group_by_layout.cpp
+++ b/src/mbgl/renderer/group_by_layout.cpp
@@ -18,7 +18,7 @@ std::string layoutKey(const RenderLayer& layer) {
rapidjson::Writer<rapidjson::StringBuffer> writer(s);
writer.StartArray();
- writer.Uint(static_cast<uint32_t>(layer.type));
+ writer.Uint64(reinterpret_cast<uint64_t>(layer.baseImpl->getTypeInfo()));
writer.String(layer.baseImpl->source);
writer.String(layer.baseImpl->sourceLayer);
writer.Double(layer.baseImpl->minZoom);
diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp
index 3e510ef352..d7bf0dc6bd 100644
--- a/src/mbgl/renderer/layers/render_background_layer.cpp
+++ b/src/mbgl/renderer/layers/render_background_layer.cpp
@@ -14,7 +14,7 @@ namespace mbgl {
using namespace style;
RenderBackgroundLayer::RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Background, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp
index 46db06416d..b984c596d3 100644
--- a/src/mbgl/renderer/layers/render_circle_layer.cpp
+++ b/src/mbgl/renderer/layers/render_circle_layer.cpp
@@ -15,7 +15,7 @@ namespace mbgl {
using namespace style;
RenderCircleLayer::RenderCircleLayer(Immutable<style::CircleLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Circle, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp
index e80ceda6c7..9e65830faf 100644
--- a/src/mbgl/renderer/layers/render_custom_layer.cpp
+++ b/src/mbgl/renderer/layers/render_custom_layer.cpp
@@ -13,7 +13,7 @@ namespace mbgl {
using namespace style;
RenderCustomLayer::RenderCustomLayer(Immutable<style::CustomLayer::Impl> _impl)
- : RenderLayer(LayerType::Custom, _impl), host(_impl->host) {
+ : RenderLayer(std::move(_impl)), host(impl().host) {
assert(BackendScope::exists());
host->initialize();
}
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index 8f1b961d1a..91d58bf8d6 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
@@ -19,7 +19,7 @@ namespace mbgl {
using namespace style;
RenderFillExtrusionLayer::RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl> _impl)
- : RenderLayer(style::LayerType::FillExtrusion, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index 83be3ccd57..391c2d5b0f 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -17,7 +17,7 @@ namespace mbgl {
using namespace style;
RenderFillLayer::RenderFillLayer(Immutable<style::FillLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Fill, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index 4e5e890358..1842cdac93 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -17,7 +17,7 @@ namespace mbgl {
using namespace style;
RenderHeatmapLayer::RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Heatmap, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()), colorRamp({256, 1}) {
}
diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
index 835cb3f9f9..ba7e782f16 100644
--- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp
+++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
@@ -16,7 +16,7 @@ namespace mbgl {
using namespace style;
RenderHillshadeLayer::RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Hillshade, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index 94081b5f09..fcdbc0b47a 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -18,7 +18,7 @@ namespace mbgl {
using namespace style;
RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Line, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()),
colorRamp({256, 1}) {
}
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp
index 8e0651b65b..e0a7e427ad 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.cpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -14,7 +14,7 @@ namespace mbgl {
using namespace style;
RenderRasterLayer::RenderRasterLayer(Immutable<style::RasterLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Raster, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 2b3a7195c5..11ffd74b10 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -23,7 +23,7 @@ namespace mbgl {
using namespace style;
RenderSymbolLayer::RenderSymbolLayer(Immutable<style::SymbolLayer::Impl> _impl)
- : RenderLayer(style::LayerType::Symbol, _impl),
+ : RenderLayer(std::move(_impl)),
unevaluated(impl().paint.untransitioned()) {
}
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp
index 3e9a7caf24..033df02282 100644
--- a/src/mbgl/renderer/render_layer.cpp
+++ b/src/mbgl/renderer/render_layer.cpp
@@ -1,14 +1,4 @@
#include <mbgl/renderer/render_layer.hpp>
-#include <mbgl/renderer/layers/render_background_layer.hpp>
-#include <mbgl/renderer/layers/render_circle_layer.hpp>
-#include <mbgl/renderer/layers/render_custom_layer.hpp>
-#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp>
-#include <mbgl/renderer/layers/render_fill_layer.hpp>
-#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
-#include <mbgl/renderer/layers/render_line_layer.hpp>
-#include <mbgl/renderer/layers/render_raster_layer.hpp>
-#include <mbgl/renderer/layers/render_symbol_layer.hpp>
-#include <mbgl/renderer/layers/render_heatmap_layer.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/style/types.hpp>
@@ -19,42 +9,12 @@ 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::Hillshade:
- return std::make_unique<RenderHillshadeLayer>(staticImmutableCast<HillshadeLayer::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));
- case LayerType::Heatmap:
- return std::make_unique<RenderHeatmapLayer>(staticImmutableCast<HeatmapLayer::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_) {
+RenderLayer::RenderLayer(Immutable<style::Layer::Impl> baseImpl_)
+ : baseImpl(std::move(baseImpl_)) {
}
void RenderLayer::setImpl(Immutable<style::Layer::Impl> impl) {
- baseImpl = impl;
+ baseImpl = std::move(impl);
}
const std::string& RenderLayer::getID() const {
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index a92d8f5aff..4e0e1913b6 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -23,13 +23,9 @@ class TransformState;
class RenderLayer {
protected:
- RenderLayer(style::LayerType, Immutable<style::Layer::Impl>);
-
- const style::LayerType type;
+ RenderLayer(Immutable<style::Layer::Impl>);
public:
- static std::unique_ptr<RenderLayer> create(Immutable<style::Layer::Impl>);
-
virtual ~RenderLayer() = default;
// Begin transitions for any properties that have changed since the last frame.
@@ -93,8 +89,6 @@ public:
// TODO: Only for background layers.
virtual optional<Color> getSolidBackground() const;
- friend std::string layoutKey(const RenderLayer&);
-
protected:
// Checks whether the current hardware can render this layer. If it can't, we'll show a warning
// in the console to inform the developer.
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 32fcd57332..c4c4851345 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -164,7 +164,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
// Create render layers for newly added layers.
for (const auto& entry : layerDiff.added) {
- renderLayers.emplace(entry.first, RenderLayer::create(entry.second));
+ renderLayers.emplace(entry.first, LayerManager::get()->createRenderLayer(entry.second));
}
// Update render layers for changed layers.
diff --git a/src/mbgl/renderer/style_diff.cpp b/src/mbgl/renderer/style_diff.cpp
index 0017280310..270c4483cd 100644
--- a/src/mbgl/renderer/style_diff.cpp
+++ b/src/mbgl/renderer/style_diff.cpp
@@ -62,8 +62,7 @@ SourceDifference diffSources(const Immutable<std::vector<ImmutableSource>>& a,
LayerDifference diffLayers(const Immutable<std::vector<ImmutableLayer>>& a,
const Immutable<std::vector<ImmutableLayer>>& b) {
return diff(a, b, [] (const ImmutableLayer& lhs, const ImmutableLayer& rhs) {
- return std::tie(lhs->id, lhs->type)
- == std::tie(rhs->id, rhs->type);
+ return (lhs->id == rhs->id) && (lhs->getTypeInfo() == rhs->getTypeInfo());
});
}
diff --git a/src/mbgl/style/layer.cpp b/src/mbgl/style/layer.cpp
index 56b825760b..abe6444701 100644
--- a/src/mbgl/style/layer.cpp
+++ b/src/mbgl/style/layer.cpp
@@ -5,6 +5,8 @@
#include <mbgl/style/conversion/filter.hpp>
#include <mbgl/style/conversion_impl.hpp>
+#include <mbgl/renderer/render_layer.hpp>
+
namespace mbgl {
namespace style {
@@ -17,10 +19,6 @@ Layer::Layer(Immutable<Impl> impl)
Layer::~Layer() = default;
-LayerType Layer::getType() const {
- return baseImpl->type;
-}
-
std::string Layer::getID() const {
return baseImpl->id;
}
@@ -111,7 +109,9 @@ const LayerTypeInfo* Layer::getTypeInfo() const noexcept {
return baseImpl->getTypeInfo();
}
-optional<std::string> LayerFactory::getSource(const conversion::Convertible& value) const noexcept {
+} // namespace style
+
+optional<std::string> LayerFactory::getSource(const style::conversion::Convertible& value) const noexcept {
auto sourceValue = objectMember(value, "source");
if (!sourceValue) {
return nullopt;
@@ -125,7 +125,7 @@ optional<std::string> LayerFactory::getSource(const conversion::Convertible& val
return source;
}
-bool LayerFactory::initSourceLayerAndFilter(Layer* layer, const conversion::Convertible& value) const noexcept {
+bool LayerFactory::initSourceLayerAndFilter(style::Layer* layer, const style::conversion::Convertible& value) const noexcept {
auto sourceLayerValue = objectMember(value, "source-layer");
if (sourceLayerValue) {
optional<std::string> sourceLayer = toString(*sourceLayerValue);
@@ -137,8 +137,8 @@ bool LayerFactory::initSourceLayerAndFilter(Layer* layer, const conversion::Conv
auto filterValue = objectMember(value, "filter");
if (filterValue) {
- conversion::Error error;
- optional<Filter> filter = conversion::convert<Filter>(*filterValue, error);
+ style::conversion::Error error;
+ optional<style::Filter> filter = style::conversion::convert<style::Filter>(*filterValue, error);
if (!filter) {
return false;
}
@@ -148,5 +148,25 @@ bool LayerFactory::initSourceLayerAndFilter(Layer* layer, const conversion::Conv
return true;
}
-} // namespace style
+std::unique_ptr<style::Layer> LayerManager::createLayer(
+ const std::string& type, const std::string& id,
+ const style::conversion::Convertible& value, style::conversion::Error& error) noexcept {
+ if (LayerFactory* factory = getFactory(type)) {
+ auto layer = factory->createLayer(id, value);
+ if (!layer) {
+ error.message = "Error parsing a layer of type: " + type;
+ }
+ return layer;
+ }
+ error.message = "Unsupported layer type: " + type;
+ return nullptr;
+}
+
+std::unique_ptr<RenderLayer> LayerManager::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ LayerFactory* factory = getFactory(impl->getTypeInfo());
+ assert(factory);
+ return factory->createRenderLayer(std::move(impl));
+}
+
+
} // namespace mbgl
diff --git a/src/mbgl/style/layer_impl.cpp b/src/mbgl/style/layer_impl.cpp
index c6a248de90..b6ab145012 100644
--- a/src/mbgl/style/layer_impl.cpp
+++ b/src/mbgl/style/layer_impl.cpp
@@ -3,9 +3,8 @@
namespace mbgl {
namespace style {
-Layer::Impl::Impl(LayerType type_, std::string layerID, std::string sourceID)
- : type(type_),
- id(std::move(layerID)),
+Layer::Impl::Impl(std::string layerID, std::string sourceID)
+ : id(std::move(layerID)),
source(std::move(sourceID)) {
}
diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp
index 948bbab619..c64173600e 100644
--- a/src/mbgl/style/layer_impl.hpp
+++ b/src/mbgl/style/layer_impl.hpp
@@ -29,7 +29,7 @@ namespace style {
*/
class Layer::Impl {
public:
- Impl(LayerType, std::string layerID, std::string sourceID);
+ Impl(std::string layerID, std::string sourceID);
virtual ~Impl() = default;
Impl& operator=(const Impl&) = delete;
@@ -47,8 +47,6 @@ public:
// Populates the given \a fontStack with fonts being used by the layer.
virtual void populateFontStack(std::set<FontStack>& fontStack) const;
- // Note: LayerType is deprecated, do not use it.
- const LayerType type;
std::string id;
std::string source;
std::string sourceLayer;
@@ -61,5 +59,10 @@ protected:
Impl(const Impl&) = default;
};
+// To be used in the inherited classes.
+#define DECLARE_LAYER_TYPE_INFO \
+const LayerTypeInfo* getTypeInfo() const noexcept final { return staticTypeInfo(); } \
+static const LayerTypeInfo* staticTypeInfo() noexcept
+
} // namespace style
-} // namespace mbgl
+} // namespace mbgl \ No newline at end of file
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index 1342afd7b1..8beafb0278 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_background_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoBackground
+
+// static
+const LayerTypeInfo* BackgroundLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"background",
LayerTypeInfo::Source::NotRequired,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::NotRequired,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
BackgroundLayer::BackgroundLayer(const std::string& layerID)
- : Layer(makeMutable<Impl>(LayerType::Background, layerID, std::string())) {
+ : Layer(makeMutable<Impl>(layerID, std::string())) {
}
BackgroundLayer::BackgroundLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> BackgroundLayer::cloneRef(const std::string& id_) const {
void BackgroundLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* BackgroundLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoBackground;
-}
-
// Layout properties
@@ -284,18 +286,20 @@ Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-BackgroundLayerFactory::BackgroundLayerFactory() = default;
-
-BackgroundLayerFactory::~BackgroundLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoBackground;
+const style::LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept {
+ return style::BackgroundLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
(void)value;
- return std::unique_ptr<style::Layer>(new BackgroundLayer(id));
+ return std::unique_ptr<style::Layer>(new style::BackgroundLayer(id));
+}
+
+std::unique_ptr<RenderLayer> BackgroundLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderBackgroundLayer>(staticImmutableCast<style::BackgroundLayer::Impl>(std::move(impl)));
}
-} // 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 5407c4c065..0c68610c62 100644
--- a/src/mbgl/style/layers/background_layer_impl.hpp
+++ b/src/mbgl/style/layers/background_layer_impl.hpp
@@ -13,9 +13,10 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
BackgroundPaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index c04d40083a..1e6200e4d2 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_circle_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoCircle
+
+// static
+const LayerTypeInfo* CircleLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"circle",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::NotRequired,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
CircleLayer::CircleLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Circle, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
CircleLayer::CircleLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> CircleLayer::cloneRef(const std::string& id_) const {
void CircleLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* CircleLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoCircle;
-}
-
// Layout properties
@@ -701,26 +703,28 @@ Mutable<Layer::Impl> CircleLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-CircleLayerFactory::CircleLayerFactory() = default;
-
-CircleLayerFactory::~CircleLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* CircleLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoCircle;
+const style::LayerTypeInfo* CircleLayerFactory::getTypeInfo() const noexcept {
+ return style::CircleLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new CircleLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::CircleLayer(id, *source));
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
}
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> CircleLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderCircleLayer>(staticImmutableCast<style::CircleLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp
index 358598e09c..bf0688ac8b 100644
--- a/src/mbgl/style/layers/circle_layer_impl.cpp
+++ b/src/mbgl/style/layers/circle_layer_impl.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace style {
bool CircleLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
- assert(other.type == LayerType::Circle);
+ assert(other.getTypeInfo() == getTypeInfo());
const auto& impl = static_cast<const style::CircleLayer::Impl&>(other);
return filter != impl.filter ||
visibility != impl.visibility ||
diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp
index 5cd56b630c..9b3ce48706 100644
--- a/src/mbgl/style/layers/circle_layer_impl.hpp
+++ b/src/mbgl/style/layers/circle_layer_impl.hpp
@@ -13,9 +13,10 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
CirclePaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp
index bff55a7a52..abea5d2d31 100644
--- a/src/mbgl/style/layers/custom_layer.cpp
+++ b/src/mbgl/style/layers/custom_layer.cpp
@@ -2,6 +2,8 @@
#include <mbgl/style/layers/custom_layer_impl.hpp>
#include <mbgl/style/layer_observer.hpp>
+#include <mbgl/renderer/layers/render_custom_layer.hpp>
+
namespace mbgl {
namespace style {
@@ -48,22 +50,24 @@ Mutable<Layer::Impl> CustomLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-const LayerTypeInfo* CustomLayer::Impl::getTypeInfo() const noexcept {
+// static
+const LayerTypeInfo* CustomLayer::Impl::staticTypeInfo() noexcept {
return &typeInfoCustom;
}
-CustomLayerFactory::CustomLayerFactory() = default;
-
-CustomLayerFactory::~CustomLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* CustomLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoCustom;
+const style::LayerTypeInfo* CustomLayerFactory::getTypeInfo() const noexcept {
+ return &style::typeInfoCustom;
}
-std::unique_ptr<style::Layer> CustomLayerFactory::createLayer(const std::string&, const conversion::Convertible&) {
+std::unique_ptr<style::Layer> CustomLayerFactory::createLayer(const std::string&, const style::conversion::Convertible&) noexcept {
assert(false);
return nullptr;
}
-} // namespace style
+std::unique_ptr<RenderLayer> CustomLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ return std::make_unique<RenderCustomLayer>(staticImmutableCast<style::CustomLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp
index 05c41623c4..f82cb1ea2c 100644
--- a/src/mbgl/style/layers/custom_layer_impl.cpp
+++ b/src/mbgl/style/layers/custom_layer_impl.cpp
@@ -5,7 +5,7 @@ namespace style {
CustomLayer::Impl::Impl(const std::string& id_,
std::unique_ptr<CustomLayerHost> host_)
- : Layer::Impl(LayerType::Custom, id_, std::string()) {
+ : Layer::Impl(id_, std::string()) {
host = std::move(host_);
}
diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp
index 6c7a9078a5..1ebf1b53f1 100644
--- a/src/mbgl/style/layers/custom_layer_impl.hpp
+++ b/src/mbgl/style/layers/custom_layer_impl.hpp
@@ -18,9 +18,10 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
std::shared_ptr<CustomLayerHost> host;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index 9a5cc02df4..7ca9d6ed6f 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoFillExtrusion
+
+// static
+const LayerTypeInfo* FillExtrusionLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"fill-extrusion",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::Required,
LayerTypeInfo::Layout::Required,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
FillExtrusionLayer::FillExtrusionLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::FillExtrusion, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
FillExtrusionLayer::FillExtrusionLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> FillExtrusionLayer::cloneRef(const std::string& id_) cons
void FillExtrusionLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* FillExtrusionLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoFillExtrusion;
-}
-
// Layout properties
@@ -503,26 +505,28 @@ Mutable<Layer::Impl> FillExtrusionLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-FillExtrusionLayerFactory::FillExtrusionLayerFactory() = default;
-
-FillExtrusionLayerFactory::~FillExtrusionLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* FillExtrusionLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoFillExtrusion;
+const style::LayerTypeInfo* FillExtrusionLayerFactory::getTypeInfo() const noexcept {
+ return style::FillExtrusionLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new FillExtrusionLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::FillExtrusionLayer(id, *source));
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
}
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> FillExtrusionLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderFillExtrusionLayer>(staticImmutableCast<style::FillExtrusionLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp
index 357ea3e973..18eea1f7fc 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace style {
bool FillExtrusionLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
- assert(other.type == LayerType::FillExtrusion);
+ assert(other.getTypeInfo() == getTypeInfo());
const auto& impl = static_cast<const style::FillExtrusionLayer::Impl&>(other);
return filter != impl.filter ||
visibility != impl.visibility ||
diff --git a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
index 6758320c2b..dcb6de1d8c 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer_impl.hpp
@@ -13,10 +13,11 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
Properties<>::Unevaluated layout;
FillExtrusionPaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 17a5eaf3b1..480fc597dd 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_fill_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoFill
+
+// static
+const LayerTypeInfo* FillLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"fill",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::Required,
LayerTypeInfo::Clipping::Required
};
-} // namespace
+ return &typeInfo;
+}
+
FillLayer::FillLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Fill, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
FillLayer::FillLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> FillLayer::cloneRef(const std::string& id_) const {
void FillLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* FillLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoFill;
-}
-
// Layout properties
@@ -503,26 +505,28 @@ Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-FillLayerFactory::FillLayerFactory() = default;
-
-FillLayerFactory::~FillLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* FillLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoFill;
+const style::LayerTypeInfo* FillLayerFactory::getTypeInfo() const noexcept {
+ return style::FillLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new FillLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::FillLayer(id, *source));
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
}
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> FillLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderFillLayer>(staticImmutableCast<style::FillLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp
index a8ba1b693b..4df32e02fa 100644
--- a/src/mbgl/style/layers/fill_layer_impl.cpp
+++ b/src/mbgl/style/layers/fill_layer_impl.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace style {
bool FillLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
- assert(other.type == LayerType::Fill);
+ assert(other.getTypeInfo() == getTypeInfo());
const auto& impl = static_cast<const style::FillLayer::Impl&>(other);
return filter != impl.filter ||
visibility != impl.visibility ||
diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp
index 5b0592d062..92f3c97284 100644
--- a/src/mbgl/style/layers/fill_layer_impl.hpp
+++ b/src/mbgl/style/layers/fill_layer_impl.hpp
@@ -13,10 +13,11 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
Properties<>::Unevaluated layout;
FillPaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp
index 113f158f51..92477615b2 100644
--- a/src/mbgl/style/layers/heatmap_layer.cpp
+++ b/src/mbgl/style/layers/heatmap_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_heatmap_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoHeatmap
+
+// static
+const LayerTypeInfo* HeatmapLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"heatmap",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::Required,
LayerTypeInfo::Layout::NotRequired,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
HeatmapLayer::HeatmapLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Heatmap, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
HeatmapLayer::HeatmapLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> HeatmapLayer::cloneRef(const std::string& id_) const {
void HeatmapLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* HeatmapLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoHeatmap;
-}
-
// Layout properties
@@ -388,26 +390,28 @@ Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-HeatmapLayerFactory::HeatmapLayerFactory() = default;
-
-HeatmapLayerFactory::~HeatmapLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* HeatmapLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoHeatmap;
+const style::LayerTypeInfo* HeatmapLayerFactory::getTypeInfo() const noexcept {
+ return style::HeatmapLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> HeatmapLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> HeatmapLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new HeatmapLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::HeatmapLayer(id, *source));
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
}
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> HeatmapLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderHeatmapLayer>(staticImmutableCast<style::HeatmapLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/heatmap_layer_impl.cpp b/src/mbgl/style/layers/heatmap_layer_impl.cpp
index 8fd0cf72b2..dd5baaeb44 100644
--- a/src/mbgl/style/layers/heatmap_layer_impl.cpp
+++ b/src/mbgl/style/layers/heatmap_layer_impl.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace style {
bool HeatmapLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
- assert(other.type == LayerType::Heatmap);
+ assert(other.getTypeInfo() == getTypeInfo());
const auto& impl = static_cast<const style::HeatmapLayer::Impl&>(other);
return filter != impl.filter ||
visibility != impl.visibility ||
diff --git a/src/mbgl/style/layers/heatmap_layer_impl.hpp b/src/mbgl/style/layers/heatmap_layer_impl.hpp
index 7645fa0cc1..3022293860 100644
--- a/src/mbgl/style/layers/heatmap_layer_impl.hpp
+++ b/src/mbgl/style/layers/heatmap_layer_impl.hpp
@@ -13,9 +13,10 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
HeatmapPaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp
index 81d2c32f6f..d914d0cdea 100644
--- a/src/mbgl/style/layers/hillshade_layer.cpp
+++ b/src/mbgl/style/layers/hillshade_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoHillshade
+
+// static
+const LayerTypeInfo* HillshadeLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"hillshade",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::Required,
LayerTypeInfo::Layout::NotRequired,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
HillshadeLayer::HillshadeLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Hillshade, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
HillshadeLayer::HillshadeLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> HillshadeLayer::cloneRef(const std::string& id_) const {
void HillshadeLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* HillshadeLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoHillshade;
-}
-
// Layout properties
@@ -435,23 +437,25 @@ Mutable<Layer::Impl> HillshadeLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-HillshadeLayerFactory::HillshadeLayerFactory() = default;
-
-HillshadeLayerFactory::~HillshadeLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoHillshade;
+const style::LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept {
+ return style::HillshadeLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> HillshadeLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> HillshadeLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new HillshadeLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::HillshadeLayer(id, *source));
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> HillshadeLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderHillshadeLayer>(staticImmutableCast<style::HillshadeLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/hillshade_layer_impl.hpp b/src/mbgl/style/layers/hillshade_layer_impl.hpp
index 520b18cc84..86409fa542 100644
--- a/src/mbgl/style/layers/hillshade_layer_impl.hpp
+++ b/src/mbgl/style/layers/hillshade_layer_impl.hpp
@@ -13,9 +13,10 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
HillshadePaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 0971e1af5b..d03e41da76 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -16,10 +16,12 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_<%- type.replace('-', '_') %>_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {<%
+<%
let layerCapabilities = {};
let defaults = { caps: { 'Source': 'NotRequired',
'Pass3D': 'NotRequired',
@@ -60,19 +62,23 @@ layerCapabilities['line'] = layerCapabilities['fill'];
layerCapabilities['heatmap'] = layerCapabilities['hillshade'];
layerCapabilities['raster'] = layerCapabilities['circle'];
%>
- const LayerTypeInfo typeInfo<%- `${camelize(type)}`%>
+// static
+const LayerTypeInfo* <%- camelize(type) %>Layer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"<%- type %>",
<%-`${layerCapabilities[type].map(cap => `LayerTypeInfo::${cap}`).join(',\n ')}` %>
};
-} // namespace
+ return &typeInfo;
+}
+
<% if (type === 'background') { -%>
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID)
- : Layer(makeMutable<Impl>(LayerType::<%- camelize(type) %>, layerID, std::string())) {
+ : Layer(makeMutable<Impl>(layerID, std::string())) {
}
<% } else { -%>
<%- camelize(type) %>Layer::<%- camelize(type) %>Layer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::<%- camelize(type) %>, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
<% } -%>
@@ -106,10 +112,6 @@ void <%- camelize(type) %>Layer::Impl::stringifyLayout(rapidjson::Writer<rapidjs
}
<% } -%>
-const LayerTypeInfo* <%- camelize(type) %>Layer::Impl::getTypeInfo() const noexcept {
- return &typeInfo<%- camelize(type) %>;
-}
-
// Layout properties
<% for (const property of layoutProperties) { -%>
@@ -311,25 +313,23 @@ Mutable<Layer::Impl> <%- camelize(type) %>Layer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-<%- camelize(type) %>LayerFactory::<%- camelize(type) %>LayerFactory() = default;
-
-<%- camelize(type) %>LayerFactory::~<%- camelize(type) %>LayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* <%- camelize(type) %>LayerFactory::getTypeInfo() const noexcept {
- return &typeInfo<%- camelize(type) %>;
+const style::LayerTypeInfo* <%- camelize(type) %>LayerFactory::getTypeInfo() const noexcept {
+ return style::<%- camelize(type) %>Layer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> <%- camelize(type) %>LayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> <%- camelize(type) %>LayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
<% if (type === 'background') { -%>
(void)value;
- return std::unique_ptr<style::Layer>(new <%- camelize(type) %>Layer(id));
+ return std::unique_ptr<style::Layer>(new style::<%- camelize(type) %>Layer(id));
<% } else { -%>
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new <%- camelize(type) %>Layer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::<%- camelize(type) %>Layer(id, *source));
<% if (type !== 'raster' && type !== 'hillshade') { -%>
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
@@ -339,5 +339,9 @@ std::unique_ptr<style::Layer> <%- camelize(type) %>LayerFactory::createLayer(con
<% } -%>
}
-} // namespace style
+std::unique_ptr<RenderLayer> <%- camelize(type) %>LayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<Render<%- camelize(type) %>Layer>(staticImmutableCast<style::<%- camelize(type) %>Layer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index aeb0635254..f021a5fd73 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_line_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoLine
+
+// static
+const LayerTypeInfo* LineLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"line",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::Required,
LayerTypeInfo::Clipping::Required
};
-} // namespace
+ return &typeInfo;
+}
+
LineLayer::LineLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Line, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
LineLayer::LineLayer(Immutable<Impl> impl_)
@@ -53,10 +59,6 @@ void LineLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>
layout.stringify(writer);
}
-const LayerTypeInfo* LineLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoLine;
-}
-
// Layout properties
PropertyValue<LineCapType> LineLayer::getDefaultLineCap() {
@@ -842,26 +844,28 @@ Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-LineLayerFactory::LineLayerFactory() = default;
-
-LineLayerFactory::~LineLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoLine;
+const style::LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept {
+ return style::LineLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new LineLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::LineLayer(id, *source));
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
}
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> LineLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderLineLayer>(staticImmutableCast<style::LineLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/line_layer_impl.cpp b/src/mbgl/style/layers/line_layer_impl.cpp
index 68cd3a8f49..b5183ba9ae 100644
--- a/src/mbgl/style/layers/line_layer_impl.cpp
+++ b/src/mbgl/style/layers/line_layer_impl.cpp
@@ -4,7 +4,7 @@ namespace mbgl {
namespace style {
bool LineLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
- assert(other.type == LayerType::Line);
+ assert(other.getTypeInfo() == getTypeInfo());
const auto& impl = static_cast<const style::LineLayer::Impl&>(other);
return filter != impl.filter ||
visibility != impl.visibility ||
diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp
index cd56a18fa8..af6c13dfd3 100644
--- a/src/mbgl/style/layers/line_layer_impl.hpp
+++ b/src/mbgl/style/layers/line_layer_impl.hpp
@@ -13,10 +13,11 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
LineLayoutProperties::Unevaluated layout;
LinePaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 0356c2f75c..40224a0b6d 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_raster_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoRaster
+
+// static
+const LayerTypeInfo* RasterLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"raster",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::NotRequired,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
RasterLayer::RasterLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Raster, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
RasterLayer::RasterLayer(Immutable<Impl> impl_)
@@ -52,10 +58,6 @@ std::unique_ptr<Layer> RasterLayer::cloneRef(const std::string& id_) const {
void RasterLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const {
}
-const LayerTypeInfo* RasterLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoRaster;
-}
-
// Layout properties
@@ -524,23 +526,25 @@ Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-RasterLayerFactory::RasterLayerFactory() = default;
-
-RasterLayerFactory::~RasterLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* RasterLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoRaster;
+const style::LayerTypeInfo* RasterLayerFactory::getTypeInfo() const noexcept {
+ return style::RasterLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> RasterLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> RasterLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new RasterLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::RasterLayer(id, *source));
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> RasterLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderRasterLayer>(staticImmutableCast<style::RasterLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp
index 2e93ecec80..740efff322 100644
--- a/src/mbgl/style/layers/raster_layer_impl.hpp
+++ b/src/mbgl/style/layers/raster_layer_impl.hpp
@@ -13,9 +13,10 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
RasterPaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 65a81c1071..f4fbf550f2 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -11,21 +11,27 @@
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/fnv_hash.hpp>
+#include <mbgl/renderer/layers/render_symbol_layer.hpp>
+
namespace mbgl {
namespace style {
-namespace {
- const LayerTypeInfo typeInfoSymbol
+
+// static
+const LayerTypeInfo* SymbolLayer::Impl::staticTypeInfo() noexcept {
+ const static LayerTypeInfo typeInfo
{"symbol",
LayerTypeInfo::Source::Required,
LayerTypeInfo::Pass3D::NotRequired,
LayerTypeInfo::Layout::Required,
LayerTypeInfo::Clipping::NotRequired
};
-} // namespace
+ return &typeInfo;
+}
+
SymbolLayer::SymbolLayer(const std::string& layerID, const std::string& sourceID)
- : Layer(makeMutable<Impl>(LayerType::Symbol, layerID, sourceID)) {
+ : Layer(makeMutable<Impl>(layerID, sourceID)) {
}
SymbolLayer::SymbolLayer(Immutable<Impl> impl_)
@@ -53,10 +59,6 @@ void SymbolLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffe
layout.stringify(writer);
}
-const LayerTypeInfo* SymbolLayer::Impl::getTypeInfo() const noexcept {
- return &typeInfoSymbol;
-}
-
// Layout properties
PropertyValue<SymbolPlacementType> SymbolLayer::getDefaultSymbolPlacement() {
@@ -1992,26 +1994,28 @@ Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
-SymbolLayerFactory::SymbolLayerFactory() = default;
-
-SymbolLayerFactory::~SymbolLayerFactory() = default;
+} // namespace style
-const LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept {
- return &typeInfoSymbol;
+const style::LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept {
+ return style::SymbolLayer::Impl::staticTypeInfo();
}
-std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
optional<std::string> source = getSource(value);
if (!source) {
return nullptr;
}
- std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new SymbolLayer(id, *source));
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::SymbolLayer(id, *source));
if (!initSourceLayerAndFilter(layer.get(), value)) {
return nullptr;
}
return layer;
}
-} // namespace style
+std::unique_ptr<RenderLayer> SymbolLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
+ assert(impl->getTypeInfo() == getTypeInfo());
+ return std::make_unique<RenderSymbolLayer>(staticImmutableCast<style::SymbolLayer::Impl>(std::move(impl)));
+}
+
} // namespace mbgl
diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp
index e177391686..3dd1da1136 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.cpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.cpp
@@ -6,7 +6,7 @@ namespace mbgl {
namespace style {
bool SymbolLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
- assert(other.type == LayerType::Symbol);
+ assert(other.getTypeInfo() == getTypeInfo());
const auto& impl = static_cast<const style::SymbolLayer::Impl&>(other);
return filter != impl.filter ||
visibility != impl.visibility ||
diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp
index 01ff9772b8..a5b0332f6c 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.hpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.hpp
@@ -13,11 +13,12 @@ public:
bool hasLayoutDifference(const Layer::Impl&) const override;
void stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const override;
- const LayerTypeInfo* getTypeInfo() const noexcept final;
void populateFontStack(std::set<FontStack>& fontStack) const final;
SymbolLayoutProperties::Unevaluated layout;
SymbolPaintProperties::Transitionable paint;
+
+ DECLARE_LAYER_TYPE_INFO;
};
} // namespace style
diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp
index 80b3e970bd..c85f9ef713 100644
--- a/src/mbgl/tile/geometry_tile.cpp
+++ b/src/mbgl/tile/geometry_tile.cpp
@@ -97,8 +97,7 @@ void GeometryTile::setLayers(const std::vector<Immutable<Layer::Impl>>& layers)
for (const auto& layer : layers) {
// Skip irrelevant layers.
- if (layer->type == LayerType::Background ||
- layer->type == LayerType::Custom ||
+ if (layer->getTypeInfo()->source == LayerTypeInfo::Source::NotRequired ||
layer->source != sourceID ||
id.overscaledZ < std::floor(layer->minZoom) ||
id.overscaledZ >= std::ceil(layer->maxZoom) ||
diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp
index 89592e12be..9e4c045ce5 100644
--- a/src/mbgl/tile/geometry_tile_worker.cpp
+++ b/src/mbgl/tile/geometry_tile_worker.cpp
@@ -312,7 +312,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(RenderLayer::create(layer));
+ renderLayers.push_back(LayerManager::get()->createRenderLayer(layer));
renderLayers.back()->transition(TransitionParameters {
Clock::time_point::max(),
diff --git a/test/gl/context.test.cpp b/test/gl/context.test.cpp
index 2561c84591..3818544021 100644
--- a/test/gl/context.test.cpp
+++ b/test/gl/context.test.cpp
@@ -95,7 +95,7 @@ TEST(GLContextMode, Shared) {
// Set transparent background layer.
auto layer = map.getStyle().getLayer("background");
- ASSERT_EQ(LayerType::Background, layer->getType());
+ ASSERT_STREQ("background", layer->getTypeInfo()->type);
static_cast<BackgroundLayer*>(layer)->setBackgroundColor( { { 1.0f, 0.0f, 0.0f, 0.5f } } );
{
diff --git a/test/renderer/group_by_layout.test.cpp b/test/renderer/group_by_layout.test.cpp
index a72ec43cb9..deaa30b9f4 100644
--- a/test/renderer/group_by_layout.test.cpp
+++ b/test/renderer/group_by_layout.test.cpp
@@ -15,7 +15,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(RenderLayer::create(layer->baseImpl));
+ result.push_back(LayerManager::get()->createRenderLayer(layer->baseImpl));
}
return result;
}
diff --git a/test/style/conversion/layer.test.cpp b/test/style/conversion/layer.test.cpp
index 18754a09fb..d65644b91b 100644
--- a/test/style/conversion/layer.test.cpp
+++ b/test/style/conversion/layer.test.cpp
@@ -25,7 +25,7 @@ TEST(StyleConversion, LayerTransition) {
}
}
})JSON");
- ASSERT_EQ(LayerType::Background, layer->getType());
+ ASSERT_STREQ("background", layer->getTypeInfo()->type);
ASSERT_EQ(400ms, *static_cast<BackgroundLayer*>(layer.get())->impl().paint
.get<BackgroundColor>().options.duration);
ASSERT_EQ(500ms, *static_cast<BackgroundLayer*>(layer.get())->impl().paint
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index 5ea16b7422..50aa643b50 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -54,7 +54,7 @@ const auto duration = 1.0f;
TEST(Layer, BackgroundProperties) {
auto layer = std::make_unique<BackgroundLayer>("background");
- ASSERT_EQ(LayerType::Background, layer->getType());
+ ASSERT_STREQ("background", layer->getTypeInfo()->type);
// Paint properties
@@ -70,7 +70,7 @@ TEST(Layer, BackgroundProperties) {
TEST(Layer, CircleProperties) {
auto layer = std::make_unique<CircleLayer>("circle", "source");
- ASSERT_EQ(LayerType::Circle, layer->getType());
+ ASSERT_STREQ("circle", layer->getTypeInfo()->type);
// Paint properties
@@ -95,7 +95,7 @@ TEST(Layer, CircleProperties) {
TEST(Layer, FillProperties) {
auto layer = std::make_unique<FillLayer>("fill", "source");
- ASSERT_EQ(LayerType::Fill, layer->getType());
+ ASSERT_STREQ("fill", layer->getTypeInfo()->type);
// Paint properties
@@ -123,7 +123,7 @@ TEST(Layer, FillProperties) {
TEST(Layer, LineProperties) {
auto layer = std::make_unique<LineLayer>("line", "source");
- ASSERT_EQ(LayerType::Line, layer->getType());
+ ASSERT_STREQ("line", layer->getTypeInfo()->type);
// Layout properties
@@ -174,7 +174,7 @@ TEST(Layer, LineProperties) {
TEST(Layer, RasterProperties) {
auto layer = std::make_unique<RasterLayer>("raster", "source");
- ASSERT_EQ(LayerType::Raster, layer->getType());
+ ASSERT_STREQ("raster", layer->getTypeInfo()->type);
// Paint properties