From f2ad89c463c6110d89caacd2ae62e85efb78af17 Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 16 May 2019 14:37:40 +0300 Subject: [core] Remove RenderLayerSymbolInterface --- src/mbgl/geometry/feature_index.cpp | 3 +- .../layers/render_layer_symbol_interface.hpp | 22 -------------- src/mbgl/renderer/layers/render_symbol_layer.cpp | 35 +++++++--------------- src/mbgl/renderer/layers/render_symbol_layer.hpp | 9 +----- src/mbgl/renderer/render_layer.cpp | 9 +++--- src/mbgl/renderer/render_layer.hpp | 5 ++-- src/mbgl/renderer/renderer_impl.cpp | 21 +++++++------ src/mbgl/style/layers/background_layer.cpp | 3 +- src/mbgl/style/layers/circle_layer.cpp | 3 +- src/mbgl/style/layers/custom_layer.cpp | 3 +- src/mbgl/style/layers/fill_extrusion_layer.cpp | 3 +- src/mbgl/style/layers/fill_layer.cpp | 3 +- src/mbgl/style/layers/heatmap_layer.cpp | 3 +- src/mbgl/style/layers/hillshade_layer.cpp | 3 +- src/mbgl/style/layers/layer.cpp.ejs | 4 ++- src/mbgl/style/layers/line_layer.cpp | 3 +- src/mbgl/style/layers/raster_layer.cpp | 3 +- src/mbgl/style/layers/symbol_layer.cpp | 3 +- src/mbgl/text/cross_tile_symbol_index.cpp | 1 - src/mbgl/text/placement.cpp | 1 - src/mbgl/text/placement.hpp | 1 - 21 files changed, 53 insertions(+), 88 deletions(-) delete mode 100644 src/mbgl/renderer/layers/render_layer_symbol_interface.hpp (limited to 'src/mbgl') diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index ffb1d6e72d..d42efa16f0 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -156,7 +156,8 @@ void FeatureIndex::addFeature( assert(geometryTileFeature); } - if (!renderLayer->getSymbolInterface() && + bool needsCrossTileIndex = renderLayer->baseImpl->getTypeInfo()->crossTileIndex == style::LayerTypeInfo::CrossTileIndex::Required; + if (!needsCrossTileIndex && !renderLayer->queryIntersectsFeature(queryGeometry, *geometryTileFeature, tileID.z, transformState, pixelsToTileUnits, posMatrix)) { continue; } diff --git a/src/mbgl/renderer/layers/render_layer_symbol_interface.hpp b/src/mbgl/renderer/layers/render_layer_symbol_interface.hpp deleted file mode 100644 index e5c16c6e7c..0000000000 --- a/src/mbgl/renderer/layers/render_layer_symbol_interface.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace mbgl { - -class RenderTile; -class SymbolBucket; - -class RenderLayerSymbolInterface { -public: - virtual const std::string& layerID() const = 0; - virtual const std::vector>& getRenderTiles() const = 0; - virtual SymbolBucket* getSymbolBucket(const RenderTile&) const = 0; - -protected: - virtual ~RenderLayerSymbolInterface() = default; -}; - -} // namespace mbgl diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 219ea43430..644056f24d 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -412,22 +412,6 @@ bool RenderSymbolLayer::hasCrossfade() const { return false; } -const std::string& RenderSymbolLayer::layerID() const { - return RenderLayer::getID(); -} - -const RenderLayerSymbolInterface* RenderSymbolLayer::getSymbolInterface() const { - return this; -} - -const std::vector>& RenderSymbolLayer::getRenderTiles() const { - return renderTiles; -} - -SymbolBucket* RenderSymbolLayer::getSymbolBucket(const RenderTile& renderTile) const { - return renderTile.tile.getBucket(*baseImpl); -} - void RenderSymbolLayer::upload(gfx::UploadPass& uploadPass, UploadParameters& uploadParameters) { for (const RenderTile& tile : renderTiles) { const LayerRenderData* renderData = tile.tile.getLayerRenderData(*baseImpl); @@ -670,17 +654,18 @@ style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProper void RenderSymbolLayer::setRenderTiles(RenderTiles tiles, const TransformState& state) { renderTiles = std::move(tiles); - // Sort symbol tiles in opposite y position, so tiles with overlapping symbols are drawn - // on top of each other, with lower symbols being drawn on top of higher symbols. - std::sort(renderTiles.begin(), renderTiles.end(), [&state](const auto& a, const auto& b) { - Point pa(a.get().id.canonical.x, a.get().id.canonical.y); - Point pb(b.get().id.canonical.x, b.get().id.canonical.y); + const auto comp = [bearing = state.getBearing()](const RenderTile& a, const RenderTile& b) { + Point pa(a.id.canonical.x, a.id.canonical.y); + Point pb(b.id.canonical.x, b.id.canonical.y); - auto par = util::rotate(pa, state.getBearing()); - auto pbr = util::rotate(pb, state.getBearing()); + auto par = util::rotate(pa, bearing); + auto pbr = util::rotate(pb, bearing); - return std::tie(b.get().id.canonical.z, par.y, par.x) < std::tie(a.get().id.canonical.z, pbr.y, pbr.x); - }); + return std::tie(b.id.canonical.z, par.y, par.x) < std::tie(a.id.canonical.z, pbr.y, pbr.x); + }; + // Sort symbol tiles in opposite y position, so tiles with overlapping symbols are drawn + // on top of each other, with lower symbols being drawn on top of higher symbols. + std::sort(renderTiles.begin(), renderTiles.end(), comp); placementData.clear(); for (RenderTile& renderTile : renderTiles) { diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp index ca9b42728c..351ed4833e 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.hpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -53,7 +52,7 @@ public: } // namespace style -class RenderSymbolLayer final: public RenderLayer, public RenderLayerSymbolInterface { +class RenderSymbolLayer final: public RenderLayer { public: explicit RenderSymbolLayer(Immutable); ~RenderSymbolLayer() override; @@ -69,12 +68,6 @@ private: void upload(gfx::UploadPass&, UploadParameters&) override; void render(PaintParameters&, RenderSource*) override; void setRenderTiles(RenderTiles, const TransformState&) override; - - // RenderLayerSymbolInterface overrides - const RenderLayerSymbolInterface* getSymbolInterface() const override; - const std::string& layerID() const override; - const std::vector>& getRenderTiles() const override; - SymbolBucket* getSymbolBucket(const RenderTile&) const override; // Paint properties style::SymbolPaintProperties::Unevaluated unevaluated; diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index 373a693ffd..da5269a20f 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -21,6 +21,11 @@ void RenderLayer::transition(const TransitionParameters& parameters, ImmutablegetTypeInfo()->crossTileIndex == style::LayerTypeInfo::CrossTileIndex::Required + && !placementData.empty(); +} + const std::string& RenderLayer::getID() const { return baseImpl->id; } @@ -43,10 +48,6 @@ void RenderLayer::setRenderTiles(RenderTiles tiles, const TransformState&) { renderTiles = filterRenderTiles(std::move(tiles)); } -const RenderLayerSymbolInterface* RenderLayer::getSymbolInterface() const { - return nullptr; -} - optional RenderLayer::getSolidBackground() const { return nullopt; } diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index dc2f4cb5d7..ae5e1a48b0 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -16,7 +16,6 @@ class PropertyEvaluationParameters; class UploadParameters; class PaintParameters; class RenderSource; -class RenderLayerSymbolInterface; class RenderTile; class TransformState; class GeometryTile; @@ -58,8 +57,8 @@ public: // Returns true if the layer has a pattern property and is actively crossfading. virtual bool hasCrossfade() const = 0; - // Returns instance of RenderLayerSymbolInterface if RenderLayer supports it. - virtual const RenderLayerSymbolInterface* getSymbolInterface() const; + // Returns true is the layer is subject to placement. + bool needsPlacement() const; const std::string& getID() const; diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index 4ca7f3847b..76c45aef76 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -224,7 +224,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { }; std::set renderItems; - std::vector> symbolLayers; + std::vector> layersNeedPlacement; auto renderItemsEmplaceHint = renderItems.begin(); // Update all sources and initialize renderItems. @@ -298,8 +298,8 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { } RenderLayer& renderLayer = renderItem.layer; renderLayer.setRenderTiles(renderItem.source->getRenderTiles(), updateParameters.transformState); - if (const RenderLayerSymbolInterface* symbolLayer = renderLayer.getSymbolInterface()) { - symbolLayers.push_back(renderLayer); + if (renderLayer.needsPlacement()) { + layersNeedPlacement.emplace_back(renderLayer); } } @@ -321,13 +321,13 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { updateParameters.transformState.getProjMatrix(projMatrix); } - for (auto it = symbolLayers.rbegin(); it != symbolLayers.rend(); ++it) { - const RenderLayer& symbolLayer = *it; - if (crossTileSymbolIndex.addLayer(symbolLayer, updateParameters.transformState.getLatLng().longitude())) symbolBucketsChanged = true; + for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) { + const RenderLayer& layer = *it; + if (crossTileSymbolIndex.addLayer(layer, updateParameters.transformState.getLatLng().longitude())) symbolBucketsChanged = true; if (placementChanged) { - usedSymbolLayers.insert(symbolLayer.getID()); - placement->placeLayer(symbolLayer, projMatrix, updateParameters.debugOptions & MapDebugOptions::Collision); + usedSymbolLayers.insert(layer.getID()); + placement->placeLayer(layer, projMatrix, updateParameters.debugOptions & MapDebugOptions::Collision); } } @@ -340,9 +340,8 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { } if (placementChanged || symbolBucketsChanged) { - for (auto it = symbolLayers.rbegin(); it != symbolLayers.rend(); ++it) { - const RenderLayer& symbolLayer = *it; - placement->updateLayerOpacities(symbolLayer); + for (auto it = layersNeedPlacement.rbegin(); it != layersNeedPlacement.rend(); ++it) { + placement->updateLayerOpacities(*it); } } } diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index c0350e2545..3c7a2a7569 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* BackgroundLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::NotRequired, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index 5d2cbb69d7..8c3debd1ac 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* CircleLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/custom_layer.cpp b/src/mbgl/style/layers/custom_layer.cpp index bf6db929c5..e77d6590f7 100644 --- a/src/mbgl/style/layers/custom_layer.cpp +++ b/src/mbgl/style/layers/custom_layer.cpp @@ -13,7 +13,8 @@ namespace { LayerTypeInfo::Source::NotRequired, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired }; + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; } // namespace CustomLayer::CustomLayer(const std::string& layerID, diff --git a/src/mbgl/style/layers/fill_extrusion_layer.cpp b/src/mbgl/style/layers/fill_extrusion_layer.cpp index 5112538c3f..2c07cc56c5 100644 --- a/src/mbgl/style/layers/fill_extrusion_layer.cpp +++ b/src/mbgl/style/layers/fill_extrusion_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* FillExtrusionLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::Required, LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp index a3adb1cf01..0aa19b834a 100644 --- a/src/mbgl/style/layers/fill_layer.cpp +++ b/src/mbgl/style/layers/fill_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* FillLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index a0582a7ea9..d35cb10b78 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* HeatmapLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::Required, LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp index f448233e28..ba22ab25ab 100644 --- a/src/mbgl/style/layers/hillshade_layer.cpp +++ b/src/mbgl/style/layers/hillshade_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* HillshadeLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::Required, LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs index 94650eba20..189857434f 100644 --- a/src/mbgl/style/layers/layer.cpp.ejs +++ b/src/mbgl/style/layers/layer.cpp.ejs @@ -25,7 +25,8 @@ let layerCapabilities = {}; let defaults = { caps: { 'Source': 'NotRequired', 'Pass3D': 'NotRequired', 'Layout': 'NotRequired', - 'FadingTiles': 'NotRequired' + 'FadingTiles': 'NotRequired', + 'CrossTileIndex': 'NotRequired' }, require: function(cap) { let copy = Object.assign({}, this); @@ -55,6 +56,7 @@ layerCapabilities['hillshade'] = defaults.require('Source') layerCapabilities['symbol'] = defaults.require('Source') .require('Layout') .require('FadingTiles') + .require('CrossTileIndex') .finalize(); layerCapabilities['circle'] = defaults.require('Source').finalize(); layerCapabilities['line'] = layerCapabilities['fill']; diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index 2efd424b2c..878816f6e4 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* LineLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp index af2c56cbae..1e2cd748c1 100644 --- a/src/mbgl/style/layers/raster_layer.cpp +++ b/src/mbgl/style/layers/raster_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* RasterLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::NotRequired, - LayerTypeInfo::FadingTiles::NotRequired + LayerTypeInfo::FadingTiles::NotRequired, + LayerTypeInfo::CrossTileIndex::NotRequired }; return &typeInfo; } diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index 3f3dc86b71..6748fbd4aa 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -23,7 +23,8 @@ const LayerTypeInfo* SymbolLayer::Impl::staticTypeInfo() noexcept { LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::Required, - LayerTypeInfo::FadingTiles::Required + LayerTypeInfo::FadingTiles::Required, + LayerTypeInfo::CrossTileIndex::Required }; return &typeInfo; } diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp index 780a0f551d..34b67c2a52 100644 --- a/src/mbgl/text/cross_tile_symbol_index.cpp +++ b/src/mbgl/text/cross_tile_symbol_index.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 8a6b21717c..bcb193d02a 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp index 96af27a89e..8dcb7e3ff9 100644 --- a/src/mbgl/text/placement.hpp +++ b/src/mbgl/text/placement.hpp @@ -10,7 +10,6 @@ namespace mbgl { -class RenderLayerSymbolInterface; class SymbolBucket; class SymbolInstance; -- cgit v1.2.1