summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2018-11-16 13:59:41 +0200
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2018-11-19 14:06:21 +0200
commit527851e2aa71c828f013303c827b90aa496cec15 (patch)
treed74f3d1aad5993fa3f51a11c4007fa9955c47393 /src
parent9be6c8b1b77f8fc026caee8a09e0cf28e0781253 (diff)
downloadqtlocation-mapboxgl-527851e2aa71c828f013303c827b90aa496cec15.tar.gz
[core] Add static layer properties to mbgl::style::LayerTypeInfo
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/layers/background_layer.cpp8
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp8
-rw-r--r--src/mbgl/style/layers/custom_layer.cpp7
-rw-r--r--src/mbgl/style/layers/fill_extrusion_layer.cpp8
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp8
-rw-r--r--src/mbgl/style/layers/heatmap_layer.cpp8
-rw-r--r--src/mbgl/style/layers/hillshade_layer.cpp8
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs51
-rw-r--r--src/mbgl/style/layers/line_layer.cpp8
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp8
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp8
11 files changed, 114 insertions, 16 deletions
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index 43ada28ab7..1342afd7b1 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoBackground{ "background", LayerTypeInfo::SourceNotRequired };
+ const LayerTypeInfo typeInfoBackground
+ {"background",
+ LayerTypeInfo::Source::NotRequired,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
BackgroundLayer::BackgroundLayer(const std::string& layerID)
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index 76942d808a..c04d40083a 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoCircle{ "circle", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoCircle
+ {"circle",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
CircleLayer::CircleLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp
index 42d8349c41..bff55a7a52 100644
--- a/src/mbgl/style/layers/custom_layer.cpp
+++ b/src/mbgl/style/layers/custom_layer.cpp
@@ -6,7 +6,12 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoCustom{ "", LayerTypeInfo::SourceNotRequired };
+ const LayerTypeInfo typeInfoCustom
+ { "",
+ LayerTypeInfo::Source::NotRequired,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::Clipping::NotRequired };
} // namespace
CustomLayer::CustomLayer(const std::string& layerID,
diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp
index 5357197641..9a5cc02df4 100644
--- a/src/mbgl/style/layers/fill_extrusion_layer.cpp
+++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoFillExtrusion{ "fill-extrusion", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoFillExtrusion
+ {"fill-extrusion",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::Required,
+ LayerTypeInfo::Layout::Required,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
FillExtrusionLayer::FillExtrusionLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 621428fc7c..17a5eaf3b1 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoFill{ "fill", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoFill
+ {"fill",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::Required,
+ LayerTypeInfo::Clipping::Required
+ };
} // namespace
FillLayer::FillLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp
index 3d848ec128..113f158f51 100644
--- a/src/mbgl/style/layers/heatmap_layer.cpp
+++ b/src/mbgl/style/layers/heatmap_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoHeatmap{ "heatmap", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoHeatmap
+ {"heatmap",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::Required,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
HeatmapLayer::HeatmapLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp
index 6a7e3dc1a7..81d2c32f6f 100644
--- a/src/mbgl/style/layers/hillshade_layer.cpp
+++ b/src/mbgl/style/layers/hillshade_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoHillshade{ "hillshade", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoHillshade
+ {"hillshade",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::Required,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
HillshadeLayer::HillshadeLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 4a708041e9..0971e1af5b 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -19,12 +19,51 @@
namespace mbgl {
namespace style {
-namespace {
-<% if (type === 'background') { -%>
- const LayerTypeInfo typeInfo<%- camelize(type) %>{ "<%- type %>", LayerTypeInfo::SourceNotRequired };
-<% } else { -%>
- const LayerTypeInfo typeInfo<%- camelize(type) %>{ "<%- type %>", LayerTypeInfo::SourceRequired };
-<% } -%>
+namespace {<%
+let layerCapabilities = {};
+let defaults = { caps: { 'Source': 'NotRequired',
+ 'Pass3D': 'NotRequired',
+ 'Layout': 'NotRequired',
+ 'Clipping': 'NotRequired'
+ },
+ require: function(cap) {
+ let copy = Object.assign({}, this);
+ copy.caps = Object.assign({}, this.caps);
+ copy.caps[cap] = 'Required';
+ return copy;
+ },
+ finalize: function() {
+ return Object.keys(this.caps).reduce((acc, key) => {
+ acc.push(`${key}::${this.caps[key]}`);
+ return acc;
+ }, []);
+ }
+ };
+
+layerCapabilities['background'] = defaults.finalize();
+layerCapabilities['fill'] = defaults.require('Source')
+ .require('Layout')
+ .require('Clipping')
+ .finalize();
+layerCapabilities['fill-extrusion'] = defaults.require('Source')
+ .require('Pass3D')
+ .require('Layout')
+ .finalize();
+layerCapabilities['hillshade'] = defaults.require('Source')
+ .require('Pass3D')
+ .finalize();
+layerCapabilities['symbol'] = defaults.require('Source')
+ .require('Layout')
+ .finalize();
+layerCapabilities['circle'] = defaults.require('Source').finalize();
+layerCapabilities['line'] = layerCapabilities['fill'];
+layerCapabilities['heatmap'] = layerCapabilities['hillshade'];
+layerCapabilities['raster'] = layerCapabilities['circle'];
+%>
+ const LayerTypeInfo typeInfo<%- `${camelize(type)}`%>
+ {"<%- type %>",
+ <%-`${layerCapabilities[type].map(cap => `LayerTypeInfo::${cap}`).join(',\n ')}` %>
+ };
} // namespace
<% if (type === 'background') { -%>
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index e2875fc455..aeb0635254 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoLine{ "line", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoLine
+ {"line",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::Required,
+ LayerTypeInfo::Clipping::Required
+ };
} // namespace
LineLayer::LineLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index 8e7c768680..0356c2f75c 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoRaster{ "raster", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoRaster
+ {"raster",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::NotRequired,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
RasterLayer::RasterLayer(const std::string& layerID, const std::string& sourceID)
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 0c37396637..65a81c1071 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -15,7 +15,13 @@ namespace mbgl {
namespace style {
namespace {
- const LayerTypeInfo typeInfoSymbol{ "symbol", LayerTypeInfo::SourceRequired };
+ const LayerTypeInfo typeInfoSymbol
+ {"symbol",
+ LayerTypeInfo::Source::Required,
+ LayerTypeInfo::Pass3D::NotRequired,
+ LayerTypeInfo::Layout::Required,
+ LayerTypeInfo::Clipping::NotRequired
+ };
} // namespace
SymbolLayer::SymbolLayer(const std::string& layerID, const std::string& sourceID)