From ab045087dade7ff9f365c5a525d520d0194ec2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 17 Jul 2014 16:04:17 -0700 Subject: [PATCH] skip rendering layer when min/max-zoom condition isn't met --- src/map/map.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index 88fe8cf85..d6c09606c 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -653,6 +653,19 @@ void Map::renderLayer(std::shared_ptr layer_desc, RenderPass pass) { StyleSource &style_source = *layer_desc->bucket->style_source; + // Skip this layer if there is no data. + if (!style_source.source) { + return; + } + + // Skip this layer if it's outside the range of min/maxzoom. + // This may occur when there /is/ a bucket created for this layer, but the min/max-zoom + // is set to a fractional value, or value that is larger than the source maxzoom. + if (style_source.info.min_zoom > state.getZoom() || + style_source.info.max_zoom <= state.getZoom()) { + return; + } + // Abort early if we can already deduce from the bucket type that // we're not going to render anything anyway during this pass. switch (layer_desc->type) { @@ -684,8 +697,6 @@ void Map::renderLayer(std::shared_ptr layer_desc, RenderPass pass) { << layer_desc->type << ")" << std::endl; } - if (style_source.source) { - style_source.source->render(painter, layer_desc); - } + style_source.source->render(painter, layer_desc); } }