summaryrefslogtreecommitdiff
path: root/src/mbgl/layermanager
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-12-10 17:21:08 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-12-10 18:20:32 +0200
commitebd87a5442772e9e840cd5c00be56cccfddb5c68 (patch)
treeb65309b89e2d63f063369e97ccced610fd025a60 /src/mbgl/layermanager
parentcbcd0875e375b06cbd163af105e8f1e0226f2df0 (diff)
downloadqtlocation-mapboxgl-ebd87a5442772e9e840cd5c00be56cccfddb5c68.tar.gz
[core, android, darwin] Move layer factories to separate files
Diffstat (limited to 'src/mbgl/layermanager')
-rw-r--r--src/mbgl/layermanager/background_layer_factory.cpp23
-rw-r--r--src/mbgl/layermanager/circle_layer_factory.cpp31
-rw-r--r--src/mbgl/layermanager/custom_layer_factory.cpp22
-rw-r--r--src/mbgl/layermanager/fill_extrusion_layer_factory.cpp31
-rw-r--r--src/mbgl/layermanager/fill_layer_factory.cpp31
-rw-r--r--src/mbgl/layermanager/heatmap_layer_factory.cpp31
-rw-r--r--src/mbgl/layermanager/hillshade_layer_factory.cpp28
-rw-r--r--src/mbgl/layermanager/line_layer_factory.cpp31
-rw-r--r--src/mbgl/layermanager/raster_layer_factory.cpp28
-rw-r--r--src/mbgl/layermanager/symbol_layer_factory.cpp31
10 files changed, 287 insertions, 0 deletions
diff --git a/src/mbgl/layermanager/background_layer_factory.cpp b/src/mbgl/layermanager/background_layer_factory.cpp
new file mode 100644
index 0000000000..0e27e10343
--- /dev/null
+++ b/src/mbgl/layermanager/background_layer_factory.cpp
@@ -0,0 +1,23 @@
+#include <mbgl/layermanager/background_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_background_layer.hpp>
+#include <mbgl/style/layers/background_layer.hpp>
+#include <mbgl/style/layers/background_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept {
+ return style::BackgroundLayer::Impl::staticTypeInfo();
+}
+
+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 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 mbgl
diff --git a/src/mbgl/layermanager/circle_layer_factory.cpp b/src/mbgl/layermanager/circle_layer_factory.cpp
new file mode 100644
index 0000000000..215f228aa2
--- /dev/null
+++ b/src/mbgl/layermanager/circle_layer_factory.cpp
@@ -0,0 +1,31 @@
+#include <mbgl/layermanager/circle_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_circle_layer.hpp>
+#include <mbgl/style/layers/circle_layer.hpp>
+#include <mbgl/style/layers/circle_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* CircleLayerFactory::getTypeInfo() const noexcept {
+ return style::CircleLayer::Impl::staticTypeInfo();
+}
+
+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 style::CircleLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
+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/layermanager/custom_layer_factory.cpp b/src/mbgl/layermanager/custom_layer_factory.cpp
new file mode 100644
index 0000000000..31b1730fc9
--- /dev/null
+++ b/src/mbgl/layermanager/custom_layer_factory.cpp
@@ -0,0 +1,22 @@
+#include <mbgl/layermanager/custom_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_custom_layer.hpp>
+#include <mbgl/style/layers/custom_layer.hpp>
+#include <mbgl/style/layers/custom_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* CustomLayerFactory::getTypeInfo() const noexcept {
+ return style::CustomLayer::Impl::staticTypeInfo();
+}
+
+std::unique_ptr<style::Layer> CustomLayerFactory::createLayer(const std::string&, const style::conversion::Convertible&) noexcept {
+ assert(false);
+ return nullptr;
+}
+
+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/layermanager/fill_extrusion_layer_factory.cpp b/src/mbgl/layermanager/fill_extrusion_layer_factory.cpp
new file mode 100644
index 0000000000..8b90d950d0
--- /dev/null
+++ b/src/mbgl/layermanager/fill_extrusion_layer_factory.cpp
@@ -0,0 +1,31 @@
+#include <mbgl/layermanager/fill_extrusion_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp>
+#include <mbgl/style/layers/fill_extrusion_layer.hpp>
+#include <mbgl/style/layers/fill_extrusion_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* FillExtrusionLayerFactory::getTypeInfo() const noexcept {
+ return style::FillExtrusionLayer::Impl::staticTypeInfo();
+}
+
+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 style::FillExtrusionLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
+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/layermanager/fill_layer_factory.cpp b/src/mbgl/layermanager/fill_layer_factory.cpp
new file mode 100644
index 0000000000..664788de17
--- /dev/null
+++ b/src/mbgl/layermanager/fill_layer_factory.cpp
@@ -0,0 +1,31 @@
+#include <mbgl/layermanager/fill_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_fill_layer.hpp>
+#include <mbgl/style/layers/fill_layer.hpp>
+#include <mbgl/style/layers/fill_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* FillLayerFactory::getTypeInfo() const noexcept {
+ return style::FillLayer::Impl::staticTypeInfo();
+}
+
+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 style::FillLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
+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/layermanager/heatmap_layer_factory.cpp b/src/mbgl/layermanager/heatmap_layer_factory.cpp
new file mode 100644
index 0000000000..4785b7c010
--- /dev/null
+++ b/src/mbgl/layermanager/heatmap_layer_factory.cpp
@@ -0,0 +1,31 @@
+#include <mbgl/layermanager/heatmap_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_heatmap_layer.hpp>
+#include <mbgl/style/layers/heatmap_layer.hpp>
+#include <mbgl/style/layers/heatmap_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* HeatmapLayerFactory::getTypeInfo() const noexcept {
+ return style::HeatmapLayer::Impl::staticTypeInfo();
+}
+
+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 style::HeatmapLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
+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/layermanager/hillshade_layer_factory.cpp b/src/mbgl/layermanager/hillshade_layer_factory.cpp
new file mode 100644
index 0000000000..9291af0711
--- /dev/null
+++ b/src/mbgl/layermanager/hillshade_layer_factory.cpp
@@ -0,0 +1,28 @@
+#include <mbgl/layermanager/hillshade_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
+#include <mbgl/style/layers/hillshade_layer.hpp>
+#include <mbgl/style/layers/hillshade_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept {
+ return style::HillshadeLayer::Impl::staticTypeInfo();
+}
+
+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 style::HillshadeLayer(id, *source));
+ return layer;
+}
+
+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/layermanager/line_layer_factory.cpp b/src/mbgl/layermanager/line_layer_factory.cpp
new file mode 100644
index 0000000000..7a8ea01d79
--- /dev/null
+++ b/src/mbgl/layermanager/line_layer_factory.cpp
@@ -0,0 +1,31 @@
+#include <mbgl/layermanager/line_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_line_layer.hpp>
+#include <mbgl/style/layers/line_layer.hpp>
+#include <mbgl/style/layers/line_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept {
+ return style::LineLayer::Impl::staticTypeInfo();
+}
+
+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 style::LineLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
+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/layermanager/raster_layer_factory.cpp b/src/mbgl/layermanager/raster_layer_factory.cpp
new file mode 100644
index 0000000000..ac9205a140
--- /dev/null
+++ b/src/mbgl/layermanager/raster_layer_factory.cpp
@@ -0,0 +1,28 @@
+#include <mbgl/layermanager/raster_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_raster_layer.hpp>
+#include <mbgl/style/layers/raster_layer.hpp>
+#include <mbgl/style/layers/raster_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* RasterLayerFactory::getTypeInfo() const noexcept {
+ return style::RasterLayer::Impl::staticTypeInfo();
+}
+
+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 style::RasterLayer(id, *source));
+ return layer;
+}
+
+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/layermanager/symbol_layer_factory.cpp b/src/mbgl/layermanager/symbol_layer_factory.cpp
new file mode 100644
index 0000000000..8acefb9f41
--- /dev/null
+++ b/src/mbgl/layermanager/symbol_layer_factory.cpp
@@ -0,0 +1,31 @@
+#include <mbgl/layermanager/symbol_layer_factory.hpp>
+
+#include <mbgl/renderer/layers/render_symbol_layer.hpp>
+#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/layers/symbol_layer_impl.hpp>
+
+namespace mbgl {
+
+const style::LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept {
+ return style::SymbolLayer::Impl::staticTypeInfo();
+}
+
+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 style::SymbolLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
+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