summaryrefslogtreecommitdiff
path: root/src/mbgl/layer
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/layer')
-rw-r--r--src/mbgl/layer/background_layer.cpp12
-rw-r--r--src/mbgl/layer/background_layer.hpp18
-rw-r--r--src/mbgl/layer/circle_layer.cpp15
-rw-r--r--src/mbgl/layer/circle_layer.hpp18
-rw-r--r--src/mbgl/layer/fill_layer.cpp29
-rw-r--r--src/mbgl/layer/fill_layer.hpp18
-rw-r--r--src/mbgl/layer/line_layer.cpp22
-rw-r--r--src/mbgl/layer/line_layer.hpp18
-rw-r--r--src/mbgl/layer/raster_layer.cpp16
-rw-r--r--src/mbgl/layer/raster_layer.hpp18
-rw-r--r--src/mbgl/layer/symbol_layer.cpp39
-rw-r--r--src/mbgl/layer/symbol_layer.hpp18
12 files changed, 241 insertions, 0 deletions
diff --git a/src/mbgl/layer/background_layer.cpp b/src/mbgl/layer/background_layer.cpp
new file mode 100644
index 0000000000..c97124feb6
--- /dev/null
+++ b/src/mbgl/layer/background_layer.cpp
@@ -0,0 +1,12 @@
+#include <mbgl/layer/background_layer.hpp>
+
+namespace mbgl {
+
+RenderPass BackgroundLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory& zoomHistory) {
+ applyTransitionedStyleProperty(PropertyKey::BackgroundOpacity, properties.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::BackgroundColor, properties.color, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::BackgroundImage, properties.image, z, now, zoomHistory);
+ return properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
+}
+
+}
diff --git a/src/mbgl/layer/background_layer.hpp b/src/mbgl/layer/background_layer.hpp
new file mode 100644
index 0000000000..817c234239
--- /dev/null
+++ b/src/mbgl/layer/background_layer.hpp
@@ -0,0 +1,18 @@
+#ifndef MBGL_BACKGROUND_LAYER
+#define MBGL_BACKGROUND_LAYER
+
+#include <mbgl/style/style_layer.hpp>
+#include <mbgl/style/style_properties.hpp>
+
+namespace mbgl {
+
+class BackgroundLayer : public StyleLayer {
+public:
+ RenderPass applyStyleProperties(float z, const TimePoint& now, const ZoomHistory&) override;
+
+ BackgroundPaintProperties properties;
+};
+
+}
+
+#endif
diff --git a/src/mbgl/layer/circle_layer.cpp b/src/mbgl/layer/circle_layer.cpp
new file mode 100644
index 0000000000..384d56dfb8
--- /dev/null
+++ b/src/mbgl/layer/circle_layer.cpp
@@ -0,0 +1,15 @@
+#include <mbgl/layer/circle_layer.hpp>
+
+namespace mbgl {
+
+RenderPass CircleLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory& zoomHistory) {
+ applyTransitionedStyleProperty(PropertyKey::CircleRadius, properties.radius, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::CircleColor, properties.color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::CircleOpacity, properties.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::CircleTranslate, properties.translate, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::CircleTranslateAnchor, properties.translateAnchor, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::CircleBlur, properties.blur, z, now, zoomHistory);
+ return properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
+}
+
+}
diff --git a/src/mbgl/layer/circle_layer.hpp b/src/mbgl/layer/circle_layer.hpp
new file mode 100644
index 0000000000..f3a1cf9733
--- /dev/null
+++ b/src/mbgl/layer/circle_layer.hpp
@@ -0,0 +1,18 @@
+#ifndef MBGL_CIRCLE_LAYER
+#define MBGL_CIRCLE_LAYER
+
+#include <mbgl/style/style_layer.hpp>
+#include <mbgl/style/style_properties.hpp>
+
+namespace mbgl {
+
+class CircleLayer : public StyleLayer {
+public:
+ RenderPass applyStyleProperties(float z, const TimePoint& now, const ZoomHistory&) override;
+
+ CirclePaintProperties properties;
+};
+
+}
+
+#endif
diff --git a/src/mbgl/layer/fill_layer.cpp b/src/mbgl/layer/fill_layer.cpp
new file mode 100644
index 0000000000..7a45774c2d
--- /dev/null
+++ b/src/mbgl/layer/fill_layer.cpp
@@ -0,0 +1,29 @@
+#include <mbgl/layer/fill_layer.hpp>
+
+namespace mbgl {
+
+RenderPass FillLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory& zoomHistory) {
+ applyStyleProperty(PropertyKey::FillAntialias, properties.antialias, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::FillOpacity, properties.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::FillColor, properties.fill_color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::FillOutlineColor, properties.stroke_color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::FillTranslate, properties.translate, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::FillTranslateAnchor, properties.translateAnchor, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::FillImage, properties.image, z, now, zoomHistory);
+
+ RenderPass result = RenderPass::None;
+
+ if (properties.antialias) {
+ result |= RenderPass::Translucent;
+ }
+
+ if (!properties.image.from.empty() || (properties.fill_color[3] * properties.opacity) < 1.0f) {
+ result |= RenderPass::Translucent;
+ } else {
+ result |= RenderPass::Opaque;
+ }
+
+ return result;
+}
+
+}
diff --git a/src/mbgl/layer/fill_layer.hpp b/src/mbgl/layer/fill_layer.hpp
new file mode 100644
index 0000000000..d8e8e6d37a
--- /dev/null
+++ b/src/mbgl/layer/fill_layer.hpp
@@ -0,0 +1,18 @@
+#ifndef MBGL_FILL_LAYER
+#define MBGL_FILL_LAYER
+
+#include <mbgl/style/style_layer.hpp>
+#include <mbgl/style/style_properties.hpp>
+
+namespace mbgl {
+
+class FillLayer : public StyleLayer {
+public:
+ RenderPass applyStyleProperties(float z, const TimePoint& now, const ZoomHistory&) override;
+
+ FillPaintProperties properties;
+};
+
+}
+
+#endif
diff --git a/src/mbgl/layer/line_layer.cpp b/src/mbgl/layer/line_layer.cpp
new file mode 100644
index 0000000000..340f8fe7f4
--- /dev/null
+++ b/src/mbgl/layer/line_layer.cpp
@@ -0,0 +1,22 @@
+#include <mbgl/layer/line_layer.hpp>
+
+namespace mbgl {
+
+RenderPass LineLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory& zoomHistory) {
+ applyTransitionedStyleProperty(PropertyKey::LineOpacity, properties.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::LineColor, properties.color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::LineTranslate, properties.translate, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::LineTranslateAnchor, properties.translateAnchor, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::LineWidth, properties.width, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::LineGapWidth, properties.gap_width, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::LineBlur, properties.blur, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::LineDashArray, properties.dash_array, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::LineImage, properties.image, z, now, zoomHistory);
+
+ // for scaling dasharrays
+ applyStyleProperty(PropertyKey::LineWidth, properties.dash_line_width, std::floor(z), now, zoomHistory);
+
+ return properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
+}
+
+}
diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp
new file mode 100644
index 0000000000..9f59768c1f
--- /dev/null
+++ b/src/mbgl/layer/line_layer.hpp
@@ -0,0 +1,18 @@
+#ifndef MBGL_LINE_LAYER
+#define MBGL_LINE_LAYER
+
+#include <mbgl/style/style_layer.hpp>
+#include <mbgl/style/style_properties.hpp>
+
+namespace mbgl {
+
+class LineLayer : public StyleLayer {
+public:
+ RenderPass applyStyleProperties(float z, const TimePoint& now, const ZoomHistory&) override;
+
+ LinePaintProperties properties;
+};
+
+}
+
+#endif
diff --git a/src/mbgl/layer/raster_layer.cpp b/src/mbgl/layer/raster_layer.cpp
new file mode 100644
index 0000000000..2831483b82
--- /dev/null
+++ b/src/mbgl/layer/raster_layer.cpp
@@ -0,0 +1,16 @@
+#include <mbgl/layer/raster_layer.hpp>
+
+namespace mbgl {
+
+RenderPass RasterLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory& zoomHistory) {
+ applyTransitionedStyleProperty(PropertyKey::RasterOpacity, properties.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::RasterHueRotate, properties.hue_rotate, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::RasterBrightnessLow, properties.brightness[0], z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::RasterBrightnessHigh, properties.brightness[1], z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::RasterSaturation, properties.saturation, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::RasterContrast, properties.contrast, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::RasterFade, properties.fade, z, now, zoomHistory);
+ return properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
+}
+
+}
diff --git a/src/mbgl/layer/raster_layer.hpp b/src/mbgl/layer/raster_layer.hpp
new file mode 100644
index 0000000000..fc57a91717
--- /dev/null
+++ b/src/mbgl/layer/raster_layer.hpp
@@ -0,0 +1,18 @@
+#ifndef MBGL_RASTER_LAYER
+#define MBGL_RASTER_LAYER
+
+#include <mbgl/style/style_layer.hpp>
+#include <mbgl/style/style_properties.hpp>
+
+namespace mbgl {
+
+class RasterLayer : public StyleLayer {
+public:
+ RenderPass applyStyleProperties(float z, const TimePoint& now, const ZoomHistory&) override;
+
+ RasterPaintProperties properties;
+};
+
+}
+
+#endif
diff --git a/src/mbgl/layer/symbol_layer.cpp b/src/mbgl/layer/symbol_layer.cpp
new file mode 100644
index 0000000000..bdfa577ce7
--- /dev/null
+++ b/src/mbgl/layer/symbol_layer.cpp
@@ -0,0 +1,39 @@
+#include <mbgl/layer/symbol_layer.hpp>
+#include <mbgl/style/style_bucket.hpp>
+#include <mbgl/style/property_evaluator.hpp>
+
+namespace mbgl {
+
+RenderPass SymbolLayer::applyStyleProperties(const float z, const TimePoint& now, const ZoomHistory& zoomHistory) {
+ applyTransitionedStyleProperty(PropertyKey::IconOpacity, properties.icon.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::IconColor, properties.icon.color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::IconHaloColor, properties.icon.halo_color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::IconHaloWidth, properties.icon.halo_width, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::IconHaloBlur, properties.icon.halo_blur, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::IconTranslate, properties.icon.translate, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::IconTranslateAnchor, properties.icon.translate_anchor, z, now, zoomHistory);
+
+ applyTransitionedStyleProperty(PropertyKey::TextOpacity, properties.text.opacity, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::TextColor, properties.text.color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::TextHaloColor, properties.text.halo_color, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::TextHaloWidth, properties.text.halo_width, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::TextHaloBlur, properties.text.halo_blur, z, now, zoomHistory);
+ applyTransitionedStyleProperty(PropertyKey::TextTranslate, properties.text.translate, z, now, zoomHistory);
+ applyStyleProperty(PropertyKey::TextTranslateAnchor, properties.text.translate_anchor, z, now, zoomHistory);
+
+ // text-size and icon-size are layout properties but they also need to be evaluated as paint properties:
+ auto it = bucket->layout.properties.find(PropertyKey::IconSize);
+ if (it != bucket->layout.properties.end()) {
+ const PropertyEvaluator<float> evaluator(z, zoomHistory);
+ properties.icon.size = mapbox::util::apply_visitor(evaluator, it->second);
+ }
+ it = bucket->layout.properties.find(PropertyKey::TextSize);
+ if (it != bucket->layout.properties.end()) {
+ const PropertyEvaluator<float> evaluator(z, zoomHistory);
+ properties.text.size = mapbox::util::apply_visitor(evaluator, it->second);
+ }
+
+ return properties.isVisible() ? RenderPass::Translucent : RenderPass::None;
+}
+
+}
diff --git a/src/mbgl/layer/symbol_layer.hpp b/src/mbgl/layer/symbol_layer.hpp
new file mode 100644
index 0000000000..ee25b00be7
--- /dev/null
+++ b/src/mbgl/layer/symbol_layer.hpp
@@ -0,0 +1,18 @@
+#ifndef MBGL_SYMBOL_LAYER
+#define MBGL_SYMBOL_LAYER
+
+#include <mbgl/style/style_layer.hpp>
+#include <mbgl/style/style_properties.hpp>
+
+namespace mbgl {
+
+class SymbolLayer : public StyleLayer {
+public:
+ RenderPass applyStyleProperties(float z, const TimePoint& now, const ZoomHistory&) override;
+
+ SymbolPaintProperties properties;
+};
+
+}
+
+#endif