Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] [CP] Less strict rules for adding render layers to sources #14540

Merged
merged 1 commit into from
Apr 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/mbgl/renderer/render_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,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&) {
Expand Down
5 changes: 4 additions & 1 deletion src/mbgl/renderer/render_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ class RenderLayer {
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;

Expand Down
14 changes: 9 additions & 5 deletions src/mbgl/renderer/renderer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,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) {
Expand Down Expand Up @@ -632,9 +635,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));
Expand Down