summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mbgl/renderer/render_layer.cpp11
-rw-r--r--src/mbgl/renderer/render_layer.hpp5
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp14
3 files changed, 20 insertions, 10 deletions
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp
index b7639f83fe..757ee4f241 100644
--- a/src/mbgl/renderer/render_layer.cpp
+++ b/src/mbgl/renderer/render_layer.cpp
@@ -29,11 +29,14 @@ bool RenderLayer::hasRenderPass(RenderPass pass) const {
return bool(passes & pass);
}
-bool RenderLayer::needsRendering(float zoom) const {
+bool RenderLayer::needsRendering() const {
return passes != RenderPass::None
- && baseImpl->visibility != style::VisibilityType::None
- && baseImpl->minZoom <= zoom
- && baseImpl->maxZoom >= zoom;
+ && baseImpl->visibility != style::VisibilityType::None;
+}
+
+bool RenderLayer::supportsZoom(float zoom) const {
+ // TODO: shall we use rounding or epsilon comparisons?
+ return baseImpl->minZoom <= zoom && baseImpl->maxZoom >= zoom;
}
void RenderLayer::setRenderTiles(RenderTiles tiles, const TransformState&) {
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index cda67cfe15..2ecd7c0ae5 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -57,7 +57,10 @@ public:
bool hasRenderPass(RenderPass) const;
// Checks whether this layer can be rendered.
- bool needsRendering(float zoom) const;
+ bool needsRendering() const;
+
+ // Checks whether the given zoom is inside this layer zoom range.
+ bool supportsZoom(float zoom) const;
virtual void render(PaintParameters&, RenderSource*) = 0;
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index ecb26fa330..c756234e8d 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -247,23 +247,26 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
const Immutable<Layer::Impl>& layerImpl = *it;
RenderLayer* layer = getRenderLayer(layerImpl->id);
const auto* layerInfo = layerImpl->getTypeInfo();
- const bool layerNeedsRendering = layer->needsRendering(zoomHistory.lastZoom);
+ const bool layerNeedsRendering = layer->needsRendering();
+ const bool zoomFitsLayer = layer->supportsZoom(zoomHistory.lastZoom);
staticData->has3D = (staticData->has3D || layerInfo->pass3d == LayerTypeInfo::Pass3D::Required);
if (layerInfo->source != LayerTypeInfo::Source::NotRequired) {
if (layerImpl->source == sourceImpl->id) {
sourceNeedsRelayout = (sourceNeedsRelayout || hasImageDiff || hasLayoutDifference(layerDiff, layerImpl->id));
if (layerNeedsRendering) {
- sourceNeedsRendering = true;
filteredLayersForSource.push_back(layer->evaluatedProperties);
- renderItemsEmplaceHint = renderItems.emplace_hint(renderItemsEmplaceHint, *layer, source, index);
+ if (zoomFitsLayer) {
+ sourceNeedsRendering = true;
+ renderItemsEmplaceHint = renderItems.emplace_hint(renderItemsEmplaceHint, *layer, source, index);
+ }
}
}
continue;
}
// Handle layers without source.
- if (layerNeedsRendering && sourceImpl.get() == sourceImpls->at(0).get()) {
+ if (layerNeedsRendering && zoomFitsLayer && sourceImpl.get() == sourceImpls->at(0).get()) {
if (!backend.contextIsShared() && layerImpl.get() == layerImpls->at(0).get()) {
const auto& solidBackground = layer->getSolidBackground();
if (solidBackground) {
@@ -577,9 +580,10 @@ std::vector<Feature> Renderer::Impl::queryRenderedFeatures(const ScreenLineStrin
// Combine all results based on the style layer renderItems.
for (const auto& layerImpl : *layerImpls) {
const RenderLayer* layer = getRenderLayer(layerImpl->id);
- if (!layer->needsRendering(zoomHistory.lastZoom)) {
+ if (!layer->needsRendering() || !layer->supportsZoom(zoomHistory.lastZoom)) {
continue;
}
+
auto it = resultsByLayer.find(layer->baseImpl->id);
if (it != resultsByLayer.end()) {
std::move(it->second.begin(), it->second.end(), std::back_inserter(result));