summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Muesch <muesch@fb.com>2019-01-10 15:25:19 -0500
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-01-17 18:56:58 +0200
commit24468956fc49ba1495e4dba7363a15b6f07f25e7 (patch)
tree7fe783926cc5c46e490727995c28b1ad5e64112c
parentdd3027c9b851e92b872caaccfaf3e4e602f14516 (diff)
downloadqtlocation-mapboxgl-24468956fc49ba1495e4dba7363a15b6f07f25e7.tar.gz
Ability to disable any layer using pre-processing flags.
-rw-r--r--platform/android/src/style/layers/layer_manager.cpp46
-rw-r--r--platform/darwin/src/MGLStyleLayerManager.mm44
-rw-r--r--platform/default/src/mbgl/layermanager/layer_manager.cpp28
3 files changed, 115 insertions, 3 deletions
diff --git a/platform/android/src/style/layers/layer_manager.cpp b/platform/android/src/style/layers/layer_manager.cpp
index 2f023bd3ae..7822502cfa 100644
--- a/platform/android/src/style/layers/layer_manager.cpp
+++ b/platform/android/src/style/layers/layer_manager.cpp
@@ -23,16 +23,56 @@ namespace mbgl {
namespace android {
LayerManagerAndroid::LayerManagerAndroid() {
+#if defined(MBGL_LAYER_FILL_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<FillJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_FILL_DISABLE_ALL)
addLayerType(std::make_unique<FillJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_LINE_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<LineJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_LINE_DISABLE_ALL)
addLayerType(std::make_unique<LineJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_CIRCLE_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<CircleJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_CIRCLE_DISABLE_ALL)
addLayerType(std::make_unique<CircleJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_SYMBOL_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<SymbolJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_SYMBOL_DISABLE_ALL)
addLayerType(std::make_unique<SymbolJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_RASTER_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<RasterJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_RASTER_DISABLE_ALL)
addLayerType(std::make_unique<RasterJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_BACKGROUND_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<BackgroundJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_BACKGROUND_DISABLE_ALL)
addLayerType(std::make_unique<BackgroundJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_HILLSHADE_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<HillshadeJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_HILLSHADE_DISABLE_ALL)
addLayerType(std::make_unique<HillshadeJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<FillExtrusionJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_ALL)
addLayerType(std::make_unique<FillExtrusionJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_HEATMAP_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<HeatmapJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_HEATMAP_DISABLE_ALL)
addLayerType(std::make_unique<HeatmapJavaLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_CUSTOM_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<CustomJavaLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
addLayerType(std::make_unique<CustomJavaLayerPeerFactory>());
+#endif
}
LayerManagerAndroid::~LayerManagerAndroid() = default;
@@ -111,7 +151,7 @@ LayerFactory* LayerManagerAndroid::getFactory(const mbgl::style::LayerTypeInfo*
return nullptr;
}
-// static
+// static
LayerManagerAndroid* LayerManagerAndroid::get() noexcept {
static LayerManagerAndroid impl;
return &impl;
@@ -123,6 +163,10 @@ LayerManager* LayerManager::get() noexcept {
return android::LayerManagerAndroid::get();
}
+#if defined(MBGL_LAYER_LINE_DISABLE_ALL) || defined(MBGL_LAYER_SYMBOL_DISABLE_ALL) || defined(MBGL_LAYER_FILL_DISABLE_ALL)
+const bool LayerManager::annotationsEnabled = false;
+#else
const bool LayerManager::annotationsEnabled = true;
+#endif
} // namespace mbgl
diff --git a/platform/darwin/src/MGLStyleLayerManager.mm b/platform/darwin/src/MGLStyleLayerManager.mm
index a05e24bd9d..c0b72e4451 100644
--- a/platform/darwin/src/MGLStyleLayerManager.mm
+++ b/platform/darwin/src/MGLStyleLayerManager.mm
@@ -16,16 +16,56 @@
namespace mbgl {
LayerManagerDarwin::LayerManagerDarwin() {
+#if defined(MBGL_LAYER_FILL_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<FillStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_FILL_DISABLE_ALL)
addLayerType(std::make_unique<FillStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_LINE_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<LineStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_LINE_DISABLE_ALL)
addLayerType(std::make_unique<LineStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_CIRCLE_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<CircleStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_CIRCLE_DISABLE_ALL)
addLayerType(std::make_unique<CircleStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_SYMBOL_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<SymbolStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_SYMBOL_DISABLE_ALL)
addLayerType(std::make_unique<SymbolStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_RASTER_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<RasterStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_RASTER_DISABLE_ALL)
addLayerType(std::make_unique<RasterStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_BACKGROUND_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<BackgroundStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_BACKGROUND_DISABLE_ALL)
addLayerType(std::make_unique<BackgroundStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_HILLSHADE_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<HillshadeStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_HILLSHADE_DISABLE_ALL)
addLayerType(std::make_unique<HillshadeStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<FillExtrusionStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_ALL)
addLayerType(std::make_unique<FillExtrusionStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_HEATMAP_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<HeatmapStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_HEATMAP_DISABLE_ALL)
addLayerType(std::make_unique<HeatmapStyleLayerPeerFactory>());
+#endif
+#if defined(MBGL_LAYER_CUSTOM_DISABLE_RUNTIME)
+ addLayerTypeCoreOnly(std::make_unique<OpenGLStyleLayerPeerFactory>());
+#elif !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
addLayerType(std::make_unique<OpenGLStyleLayerPeerFactory>());
+#endif
}
LayerManagerDarwin::~LayerManagerDarwin() = default;
@@ -98,6 +138,10 @@ LayerManager* LayerManager::get() noexcept {
return LayerManagerDarwin::get();
}
+#if defined(MBGL_LAYER_LINE_DISABLE_ALL) || defined(MBGL_LAYER_SYMBOL_DISABLE_ALL) || defined(MBGL_LAYER_FILL_DISABLE_ALL)
+const bool LayerManager::annotationsEnabled = false;
+#else
const bool LayerManager::annotationsEnabled = true;
+#endif
} // namespace mbgl
diff --git a/platform/default/src/mbgl/layermanager/layer_manager.cpp b/platform/default/src/mbgl/layermanager/layer_manager.cpp
index 05d0f4d1ae..b8abf794fc 100644
--- a/platform/default/src/mbgl/layermanager/layer_manager.cpp
+++ b/platform/default/src/mbgl/layermanager/layer_manager.cpp
@@ -16,7 +16,7 @@
#include <vector>
namespace mbgl {
-
+
class LayerManagerDefault final : public LayerManager {
public:
LayerManagerDefault();
@@ -32,16 +32,36 @@ private:
};
LayerManagerDefault::LayerManagerDefault() {
+#if !defined(MBGL_LAYER_FILL_DISABLE_ALL)
addLayerType(std::make_unique<FillLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_LINE_DISABLE_ALL)
addLayerType(std::make_unique<LineLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_CIRCLE_DISABLE_ALL)
addLayerType(std::make_unique<CircleLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_SYMBOL_DISABLE_ALL)
addLayerType(std::make_unique<SymbolLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_RASTER_DISABLE_ALL)
addLayerType(std::make_unique<RasterLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_BACKGROUND_DISABLE_ALL)
addLayerType(std::make_unique<BackgroundLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_HILLSHADE_DISABLE_ALL)
addLayerType(std::make_unique<HillshadeLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_FILL_EXTRUSION_DISABLE_ALL)
addLayerType(std::make_unique<FillExtrusionLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_HEATMAP_DISABLE_ALL)
addLayerType(std::make_unique<HeatmapLayerFactory>());
+#endif
+#if !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
addLayerType(std::make_unique<CustomLayerFactory>());
+#endif
}
void LayerManagerDefault::addLayerType(std::unique_ptr<LayerFactory> factory) {
@@ -68,12 +88,16 @@ LayerFactory* LayerManagerDefault::getFactory(const std::string& type) noexcept
return (search != typeToFactory.end()) ? search->second : nullptr;
}
-// static
+// static
LayerManager* LayerManager::get() noexcept {
static LayerManagerDefault instance;
return &instance;
}
+#if defined(MBGL_LAYER_LINE_DISABLE_ALL) || defined(MBGL_LAYER_SYMBOL_DISABLE_ALL) || defined(MBGL_LAYER_FILL_DISABLE_ALL)
+const bool LayerManager::annotationsEnabled = false;
+#else
const bool LayerManager::annotationsEnabled = true;
+#endif
} // namespace mbgl