[core] Add changes to respect minzoom and maxzoom

This adds only the changes made in
https://github.com/mapbox/mapbox-gl-native/pull/5828 to address the
issue where the style zoom levels were not respected when deciding
when to render a layer.
This commit is contained in:
Jesse Bounds
2016-07-29 09:48:26 -07:00
parent 85183dd46e
commit e643ffe7f4
3 changed files with 8 additions and 5 deletions

View File

@@ -11,9 +11,12 @@ bool Layer::Impl::hasRenderPass(RenderPass pass) const {
return bool(passes & pass);
}
bool Layer::Impl::needsRendering() const {
return passes != RenderPass::None && visibility != VisibilityType::None;
}
bool Layer::Impl::needsRendering(float zoom) const {
return passes != RenderPass::None
&& visibility != VisibilityType::None
&& minZoom <= zoom
&& maxZoom >= zoom;
}
} // namespace style
} // namespace mbgl

View File

@@ -59,7 +59,7 @@ public:
bool hasRenderPass(RenderPass) const;
// Checks whether this layer can be rendered.
bool needsRendering() const;
bool needsRendering(float zoom) const;
virtual float getQueryRadius() const { return 0; }
virtual bool queryIntersectsGeometry(

View File

@@ -212,7 +212,7 @@ void Style::recalculate(float z, const TimePoint& timePoint, MapMode mode) {
hasPendingTransitions |= layer->baseImpl->recalculate(parameters);
Source* source = getSource(layer->baseImpl->source);
if (source && layer->baseImpl->needsRendering()) {
if (source && layer->baseImpl->needsRendering(z)) {
source->enabled = true;
if (!source->loaded && !source->isLoading()) {
source->load(fileSource);