summaryrefslogtreecommitdiff
path: root/platform/darwin/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src')
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLBackgroundStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLCircleStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLFillExtrusionStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLFillStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLFillStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLHeatmapStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLHeatmapStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLHillshadeStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLHillshadeStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLLineStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLLineStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer.mm10
-rw-r--r--platform/darwin/src/MGLOpenGLStyleLayer_Private.h15
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLRasterStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLStyle.mm38
-rw-r--r--platform/darwin/src/MGLStyleLayer.mm.ejs11
-rw-r--r--platform/darwin/src/MGLStyleLayerManager.h30
-rw-r--r--platform/darwin/src/MGLStyleLayerManager.mm84
-rw-r--r--platform/darwin/src/MGLStyleLayer_Private.h17
-rw-r--r--platform/darwin/src/MGLStyleLayer_Private.h.ejs24
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer.mm11
-rw-r--r--platform/darwin/src/MGLSymbolStyleLayer_Private.h17
26 files changed, 436 insertions, 45 deletions
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer.mm b/platform/darwin/src/MGLBackgroundStyleLayer.mm
index ceaf2ce475..5ddfff5534 100644
--- a/platform/darwin/src/MGLBackgroundStyleLayer.mm
+++ b/platform/darwin/src/MGLBackgroundStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLBackgroundStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLBackgroundStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/background_layer.hpp>
+
@interface MGLBackgroundStyleLayer ()
@@ -146,3 +147,11 @@
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* BackgroundStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLBackgroundStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLBackgroundStyleLayer_Private.h b/platform/darwin/src/MGLBackgroundStyleLayer_Private.h
new file mode 100644
index 0000000000..07021669dc
--- /dev/null
+++ b/platform/darwin/src/MGLBackgroundStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/background_layer.hpp>
+
+namespace mbgl {
+
+class BackgroundStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::BackgroundLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLCircleStyleLayer.mm b/platform/darwin/src/MGLCircleStyleLayer.mm
index dd3729829c..0562414b05 100644
--- a/platform/darwin/src/MGLCircleStyleLayer.mm
+++ b/platform/darwin/src/MGLCircleStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLCircleStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLCircleStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/circle_layer.hpp>
+
namespace mbgl {
@@ -497,3 +498,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* CircleStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLCircleStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLCircleStyleLayer_Private.h b/platform/darwin/src/MGLCircleStyleLayer_Private.h
new file mode 100644
index 0000000000..3813a9a068
--- /dev/null
+++ b/platform/darwin/src/MGLCircleStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/circle_layer.hpp>
+
+namespace mbgl {
+
+class CircleStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::CircleLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm
index 09a58e37bb..03676a4ed5 100644
--- a/platform/darwin/src/MGLFillExtrusionStyleLayer.mm
+++ b/platform/darwin/src/MGLFillExtrusionStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLFillExtrusionStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLFillExtrusionStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/fill_extrusion_layer.hpp>
+
namespace mbgl {
@@ -350,3 +351,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* FillExtrusionStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLFillExtrusionStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h b/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h
new file mode 100644
index 0000000000..2b9a53f59f
--- /dev/null
+++ b/platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/fill_extrusion_layer.hpp>
+
+namespace mbgl {
+
+class FillExtrusionStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::FillExtrusionLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLFillStyleLayer.mm b/platform/darwin/src/MGLFillStyleLayer.mm
index 1d4882edd3..f5dc62cd5b 100644
--- a/platform/darwin/src/MGLFillStyleLayer.mm
+++ b/platform/darwin/src/MGLFillStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLFillStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLFillStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/fill_layer.hpp>
+
namespace mbgl {
@@ -338,3 +339,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* FillStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLFillStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLFillStyleLayer_Private.h b/platform/darwin/src/MGLFillStyleLayer_Private.h
new file mode 100644
index 0000000000..f31d397434
--- /dev/null
+++ b/platform/darwin/src/MGLFillStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/fill_layer.hpp>
+
+namespace mbgl {
+
+class FillStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::FillLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLHeatmapStyleLayer.mm b/platform/darwin/src/MGLHeatmapStyleLayer.mm
index 76675585f3..a3816c0fdd 100644
--- a/platform/darwin/src/MGLHeatmapStyleLayer.mm
+++ b/platform/darwin/src/MGLHeatmapStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLHeatmapStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLHeatmapStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/heatmap_layer.hpp>
+
@interface MGLHeatmapStyleLayer ()
@@ -220,3 +221,11 @@
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* HeatmapStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLHeatmapStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLHeatmapStyleLayer_Private.h b/platform/darwin/src/MGLHeatmapStyleLayer_Private.h
new file mode 100644
index 0000000000..16ad816be4
--- /dev/null
+++ b/platform/darwin/src/MGLHeatmapStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/heatmap_layer.hpp>
+
+namespace mbgl {
+
+class HeatmapStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::HeatmapLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLHillshadeStyleLayer.mm b/platform/darwin/src/MGLHillshadeStyleLayer.mm
index dcc18ba54d..c1f47b0b68 100644
--- a/platform/darwin/src/MGLHillshadeStyleLayer.mm
+++ b/platform/darwin/src/MGLHillshadeStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLHillshadeStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLHillshadeStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/hillshade_layer.hpp>
+
namespace mbgl {
@@ -249,3 +250,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* HillshadeStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLHillshadeStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLHillshadeStyleLayer_Private.h b/platform/darwin/src/MGLHillshadeStyleLayer_Private.h
new file mode 100644
index 0000000000..28958512d7
--- /dev/null
+++ b/platform/darwin/src/MGLHillshadeStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/hillshade_layer.hpp>
+
+namespace mbgl {
+
+class HillshadeStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::HillshadeLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLLineStyleLayer.mm b/platform/darwin/src/MGLLineStyleLayer.mm
index 1409a4608d..8fdd9a0bcc 100644
--- a/platform/darwin/src/MGLLineStyleLayer.mm
+++ b/platform/darwin/src/MGLLineStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLLineStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLLineStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/line_layer.hpp>
+
namespace mbgl {
@@ -592,3 +593,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* LineStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLLineStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLLineStyleLayer_Private.h b/platform/darwin/src/MGLLineStyleLayer_Private.h
new file mode 100644
index 0000000000..ba50ebbc0d
--- /dev/null
+++ b/platform/darwin/src/MGLLineStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/line_layer.hpp>
+
+namespace mbgl {
+
+class LineStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::LineLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLOpenGLStyleLayer.mm b/platform/darwin/src/MGLOpenGLStyleLayer.mm
index d89fbc80c3..678bf15bfc 100644
--- a/platform/darwin/src/MGLOpenGLStyleLayer.mm
+++ b/platform/darwin/src/MGLOpenGLStyleLayer.mm
@@ -1,4 +1,5 @@
#import "MGLOpenGLStyleLayer.h"
+#import "MGLOpenGLStyleLayer_Private.h"
#import "MGLMapView_Private.h"
#import "MGLStyle_Private.h"
@@ -184,3 +185,12 @@ private:
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* OpenGLStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLOpenGLStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
+
diff --git a/platform/darwin/src/MGLOpenGLStyleLayer_Private.h b/platform/darwin/src/MGLOpenGLStyleLayer_Private.h
new file mode 100644
index 0000000000..1188c50cd5
--- /dev/null
+++ b/platform/darwin/src/MGLOpenGLStyleLayer_Private.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/custom_layer.hpp>
+
+namespace mbgl {
+
+class OpenGLStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::CustomLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLRasterStyleLayer.mm b/platform/darwin/src/MGLRasterStyleLayer.mm
index 7416400b2e..bcaffe1c4a 100644
--- a/platform/darwin/src/MGLRasterStyleLayer.mm
+++ b/platform/darwin/src/MGLRasterStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLRasterStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLRasterStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/raster_layer.hpp>
+
namespace mbgl {
@@ -351,3 +352,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* RasterStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLRasterStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLRasterStyleLayer_Private.h b/platform/darwin/src/MGLRasterStyleLayer_Private.h
new file mode 100644
index 0000000000..1070751a61
--- /dev/null
+++ b/platform/darwin/src/MGLRasterStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/raster_layer.hpp>
+
+namespace mbgl {
+
+class RasterStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::RasterLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index c023ed80f4..4c98fd332b 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -13,6 +13,7 @@
#import "MGLRasterStyleLayer.h"
#import "MGLBackgroundStyleLayer.h"
#import "MGLOpenGLStyleLayer.h"
+#import "MGLStyleLayerManager.h"
#import "MGLSource.h"
#import "MGLSource_Private.h"
@@ -32,16 +33,6 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/image.hpp>
#include <mbgl/style/light.hpp>
-#include <mbgl/style/layers/fill_layer.hpp>
-#include <mbgl/style/layers/fill_extrusion_layer.hpp>
-#include <mbgl/style/layers/line_layer.hpp>
-#include <mbgl/style/layers/symbol_layer.hpp>
-#include <mbgl/style/layers/raster_layer.hpp>
-#include <mbgl/style/layers/heatmap_layer.hpp>
-#include <mbgl/style/layers/hillshade_layer.hpp>
-#include <mbgl/style/layers/circle_layer.hpp>
-#include <mbgl/style/layers/background_layer.hpp>
-#include <mbgl/style/layers/custom_layer.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/sources/raster_source.hpp>
@@ -358,31 +349,8 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
if (MGLStyleLayer *layer = rawLayer->peer.has_value() ? rawLayer->peer.get<LayerWrapper>().layer : nil) {
return layer;
}
- switch (rawLayer->getType()) {
- case mbgl::style::LayerType::Fill:
- return [[MGLFillStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::FillLayer*>(rawLayer)];
- case mbgl::style::LayerType::FillExtrusion:
- return [[MGLFillExtrusionStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::FillExtrusionLayer*>(rawLayer)];
- case mbgl::style::LayerType::Line:
- return [[MGLLineStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::LineLayer*>(rawLayer)];
- case mbgl::style::LayerType::Symbol:
- return [[MGLSymbolStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::SymbolLayer*>(rawLayer)];
- case mbgl::style::LayerType::Raster:
- return [[MGLRasterStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::RasterLayer*>(rawLayer)];
- case mbgl::style::LayerType::Heatmap:
- return [[MGLHeatmapStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::HeatmapLayer*>(rawLayer)];
- case mbgl::style::LayerType::Hillshade:
- return [[MGLHillshadeStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::HillshadeLayer*>(rawLayer)];
- case mbgl::style::LayerType::Circle:
- return [[MGLCircleStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::CircleLayer*>(rawLayer)];
- case mbgl::style::LayerType::Background:
- return [[MGLBackgroundStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::BackgroundLayer*>(rawLayer)];
- case mbgl::style::LayerType::Custom:
- return [[MGLOpenGLStyleLayer alloc] initWithRawLayer:static_cast<mbgl::style::CustomLayer*>(rawLayer)];
- default:
- MGLAssert(NO, @"Unrecognized layer type");
- return nil;;
- }
+
+ return mbgl::LayerManagerDarwin::get()->createPeer(rawLayer);
}
- (MGLStyleLayer *)layerWithIdentifier:(NSString *)identifier
diff --git a/platform/darwin/src/MGLStyleLayer.mm.ejs b/platform/darwin/src/MGLStyleLayer.mm.ejs
index b7be5fb9be..0cccd16a40 100644
--- a/platform/darwin/src/MGLStyleLayer.mm.ejs
+++ b/platform/darwin/src/MGLStyleLayer.mm.ejs
@@ -14,9 +14,10 @@
#import "MGLStyleValue_Private.h"
#import "MGL<%- camelize(type) %>StyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGL<%- camelize(type) %>StyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
+
<% if (enumProperties) { -%>
namespace mbgl {
@@ -254,3 +255,11 @@ namespace mbgl {
<% } -%>
@end
<% } -%>
+
+namespace mbgl {
+
+MGLStyleLayer* <%- camelize(type) %>StyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGL<%- camelize(type) %>StyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLStyleLayerManager.h b/platform/darwin/src/MGLStyleLayerManager.h
new file mode 100644
index 0000000000..0f7fab00ed
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayerManager.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#import "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layer.hpp>
+
+#include <map>
+#include <string>
+#include <vector>
+
+namespace mbgl {
+
+class LayerManagerDarwin : public style::LayerManager {
+public:
+ static LayerManagerDarwin* get() noexcept;
+ ~LayerManagerDarwin();
+
+ MGLStyleLayer* createPeer(style::Layer*);
+
+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;
+
+ std::vector<std::unique_ptr<LayerPeerFactory>> factories;
+ std::map<std::string, style::LayerFactory*> typeToFactory;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLStyleLayerManager.mm b/platform/darwin/src/MGLStyleLayerManager.mm
new file mode 100644
index 0000000000..2cb919dd9d
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayerManager.mm
@@ -0,0 +1,84 @@
+#import "MGLStyleLayerManager.h"
+
+#import "MGLBackgroundStyleLayer_Private.h"
+#import "MGLCircleStyleLayer_Private.h"
+#import "MGLFillExtrusionStyleLayer_Private.h"
+#import "MGLFillStyleLayer_Private.h"
+#import "MGLHeatmapStyleLayer_Private.h"
+#import "MGLHillshadeStyleLayer_Private.h"
+#import "MGLLineStyleLayer_Private.h"
+#import "MGLRasterStyleLayer_Private.h"
+#import "MGLSymbolStyleLayer_Private.h"
+#import "MGLOpenGLStyleLayer_Private.h"
+
+#include <vector>
+
+namespace mbgl {
+
+LayerManagerDarwin::LayerManagerDarwin() {
+ addLayerType(std::make_unique<FillStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<LineStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<CircleStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<SymbolStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<RasterStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<BackgroundStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<HillshadeStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<FillExtrusionStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<HeatmapStyleLayerPeerFactory>());
+ addLayerType(std::make_unique<OpenGLStyleLayerPeerFactory>());
+}
+
+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);
+ }
+ }
+ assert(false);
+ return nullptr;
+}
+
+void LayerManagerDarwin::addLayerType(std::unique_ptr<LayerPeerFactory> factory) {
+ auto* coreFactory = factory->getCoreLayerFactory();
+ std::string type{coreFactory->getTypeInfo()->type};
+ if (!type.empty()) {
+ typeToFactory.emplace(std::make_pair(std::move(type), coreFactory));
+ }
+ 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;
+ }
+ return layer;
+ }
+ error.message = "Unsupported layer type: " + type;
+ return 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 ea43c680e0..0d6e4094bd 100644
--- a/platform/darwin/src/MGLStyleLayer_Private.h
+++ b/platform/darwin/src/MGLStyleLayer_Private.h
@@ -82,4 +82,21 @@ struct LayerWrapper {
@end
+namespace mbgl {
+
+class LayerPeerFactory {
+public:
+ virtual ~LayerPeerFactory() = default;
+ /**
+ Get the corresponding core layer factory.
+ */
+ virtual style::LayerFactory* getCoreLayerFactory() = 0;
+ /**
+ Creates an MGLStyleLayer instance with a raw pointer to the backing store.
+ */
+ virtual MGLStyleLayer* createPeer(style::Layer*) = 0;
+};
+
+} // namespace mbgl
+
NS_ASSUME_NONNULL_END
diff --git a/platform/darwin/src/MGLStyleLayer_Private.h.ejs b/platform/darwin/src/MGLStyleLayer_Private.h.ejs
new file mode 100644
index 0000000000..245eeec29e
--- /dev/null
+++ b/platform/darwin/src/MGLStyleLayer_Private.h.ejs
@@ -0,0 +1,24 @@
+<%
+ const doc = locals.doc;
+ const type = locals.type;
+ const layoutProperties = locals.layoutProperties;
+ const paintProperties = locals.paintProperties;
+ const enumProperties = locals.enumProperties;
+-%>
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/<%- type.replace('-', '_') %>_layer.hpp>
+
+namespace mbgl {
+
+class <%- camelize(type) %>StyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::<%- camelize(type) %>LayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLSymbolStyleLayer.mm b/platform/darwin/src/MGLSymbolStyleLayer.mm
index cd293481fe..481570fdeb 100644
--- a/platform/darwin/src/MGLSymbolStyleLayer.mm
+++ b/platform/darwin/src/MGLSymbolStyleLayer.mm
@@ -8,9 +8,10 @@
#import "MGLStyleValue_Private.h"
#import "MGLSymbolStyleLayer.h"
#import "MGLLoggingConfiguration_Private.h"
+#import "MGLSymbolStyleLayer_Private.h"
#include <mbgl/style/transition_options.hpp>
-#include <mbgl/style/layers/symbol_layer.hpp>
+
namespace mbgl {
@@ -1610,3 +1611,11 @@ namespace mbgl {
}
@end
+
+namespace mbgl {
+
+MGLStyleLayer* SymbolStyleLayerPeerFactory::createPeer(style::Layer* rawLayer) {
+ return [[MGLSymbolStyleLayer alloc] initWithRawLayer:rawLayer];
+}
+
+} // namespace mbgl
diff --git a/platform/darwin/src/MGLSymbolStyleLayer_Private.h b/platform/darwin/src/MGLSymbolStyleLayer_Private.h
new file mode 100644
index 0000000000..6ba7c7bfd0
--- /dev/null
+++ b/platform/darwin/src/MGLSymbolStyleLayer_Private.h
@@ -0,0 +1,17 @@
+// This file is generated.
+// Edit platform/darwin/scripts/generate-style-code.js, then run `make darwin-style-code`.
+#pragma once
+
+#include "MGLStyleLayer_Private.h"
+
+#include <mbgl/style/layers/symbol_layer.hpp>
+
+namespace mbgl {
+
+class SymbolStyleLayerPeerFactory : public LayerPeerFactory, public mbgl::style::SymbolLayerFactory {
+ // LayerPeerFactory overrides.
+ style::LayerFactory* getCoreLayerFactory() final { return this; }
+ virtual MGLStyleLayer* createPeer(style::Layer*) final;
+};
+
+} // namespace mbgl