diff --git a/include/llmr/style/properties.hpp b/include/llmr/style/properties.hpp index e68239025..9a6d6d86d 100644 --- a/include/llmr/style/properties.hpp +++ b/include/llmr/style/properties.hpp @@ -127,6 +127,7 @@ struct TextClass { FunctionProperty size = 12.0f; FunctionProperty rotate = 0.0f; FunctionProperty alwaysVisible = false; + FunctionProperty opacity = 1; }; struct TextProperties { @@ -138,6 +139,7 @@ struct TextProperties { float size = 12.0f; float rotate = 0.0f; bool alwaysVisible = false; + float opacity = 1.0; }; struct BackgroundClass { diff --git a/src/map/map.cpp b/src/map/map.cpp index 6775f4721..1d797baaf 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -484,6 +484,16 @@ void Map::renderLayers(const std::vector& layers, RenderPass p } } +template +bool is_invisible(const Styles &styles, const LayerDescription &layer_desc) { + auto it = styles.find(layer_desc.name); + if (it == styles.end()) return true; + const auto &properties = it->second; + if (!properties.enabled) return true; + if (properties.opacity <= 0) return true; + return false; +} + void Map::renderLayer(const LayerDescription& layer_desc, RenderPass pass) { if (layer_desc.child_layer.size()) { gl::group group(std::string("group: ") + layer_desc.name); @@ -501,13 +511,25 @@ void Map::renderLayer(const LayerDescription& layer_desc, RenderPass pass) { // Abort early if we can already deduce from the bucket type that // we're not going to render anything anyway during this pass. switch (bucket_desc.type) { + case BucketType::Fill: + if (is_invisible(style.computed.fills, layer_desc)) return; + break; case BucketType::Line: + if (pass == Opaque) return; + if (is_invisible(style.computed.lines, layer_desc)) return; + break; case BucketType::Point: + if (pass == Opaque) return; + if (is_invisible(style.computed.points, layer_desc)) return; + break; case BucketType::Text: if (pass == Opaque) return; + if (is_invisible(style.computed.texts, layer_desc)) return; break; case BucketType::Raster: if (pass == Translucent) return; + if (is_invisible(style.computed.lines, layer_desc)) return; + break; default: break; } diff --git a/src/style/style.cpp b/src/style/style.cpp index 18fe0f416..a49311030 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -103,6 +103,7 @@ void Style::cascade(float z) { text.haloRadius = layer.haloRadius.evaluate(z); text.rotate = layer.rotate.evaluate(z); text.alwaysVisible = layer.alwaysVisible.evaluate(z); + text.opacity = layer.opacity.evaluate(z); } // Cascade raster classes