summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-04-02 16:46:02 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-04-02 17:40:53 +0300
commit45e8154d334aa967ac22910cad1f3d96f4c8e72b (patch)
treed1d869991ada3473ff9dceb609bba304a935893f
parent2fed2155c58bf8dfaa00062928f766fd848163a0 (diff)
downloadqtlocation-mapboxgl-45e8154d334aa967ac22910cad1f3d96f4c8e72b.tar.gz
[core] Simplify render symbol layer initialization
Obviate few extra calls from the renderer impl parts initializing symbol layers.
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp7
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.hpp5
-rw-r--r--src/mbgl/renderer/render_layer.cpp13
-rw-r--r--src/mbgl/renderer/render_layer.hpp5
-rw-r--r--src/mbgl/renderer/renderer_impl.cpp23
5 files changed, 20 insertions, 33 deletions
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 743e94447e..d7951c647a 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -470,12 +470,9 @@ style::SymbolPropertyValues RenderSymbolLayer::textPropertyValues(const style::S
};
}
-RenderLayer::RenderTiles RenderSymbolLayer::filterRenderTiles(RenderTiles tiles) const {
+void RenderSymbolLayer::setRenderTiles(RenderTiles tiles, const TransformState& state) {
auto filterFn = [](auto& tile){ return !tile.tile.isRenderable(); };
- return RenderLayer::filterRenderTiles(std::move(tiles), filterFn);
-}
-
-void RenderSymbolLayer::sortRenderTiles(const TransformState& state) {
+ renderTiles = RenderLayer::filterRenderTiles(std::move(tiles), filterFn);
// 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) {
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.hpp b/src/mbgl/renderer/layers/render_symbol_layer.hpp
index e44ad398f4..4de5c8538a 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.hpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.hpp
@@ -57,7 +57,7 @@ class BucketParameters;
class SymbolLayout;
class GeometryTileLayer;
-class RenderSymbolLayer: public RenderLayer, public RenderLayerSymbolInterface {
+class RenderSymbolLayer final: public RenderLayer, public RenderLayerSymbolInterface {
public:
RenderSymbolLayer(Immutable<style::SymbolLayer::Impl>);
~RenderSymbolLayer() final = default;
@@ -67,6 +67,7 @@ public:
bool hasTransition() const override;
bool hasCrossfade() const override;
void render(PaintParameters&, RenderSource*) override;
+ void setRenderTiles(RenderTiles, const TransformState&) override;
static style::IconPaintProperties::PossiblyEvaluated iconPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
static style::TextPaintProperties::PossiblyEvaluated textPaintProperties(const style::SymbolPaintProperties::PossiblyEvaluated&);
@@ -91,8 +92,6 @@ protected:
const style::SymbolLayoutProperties::PossiblyEvaluated&);
static style::SymbolPropertyValues textPropertyValues(const style::SymbolPaintProperties::PossiblyEvaluated&,
const style::SymbolLayoutProperties::PossiblyEvaluated&);
- RenderTiles filterRenderTiles(RenderTiles) const final;
- void sortRenderTiles(const TransformState&) final;
void updateBucketPaintProperties(Bucket*) const final;
};
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp
index 803b5b2190..24a45b9146 100644
--- a/src/mbgl/renderer/render_layer.cpp
+++ b/src/mbgl/renderer/render_layer.cpp
@@ -33,18 +33,9 @@ bool RenderLayer::needsRendering(float zoom) const {
&& baseImpl->maxZoom >= zoom;
}
-void RenderLayer::setRenderTiles(RenderTiles tiles, const TransformState& state) {
- renderTiles = filterRenderTiles(std::move(tiles));
- sortRenderTiles(state);
-}
-
-RenderLayer::RenderTiles RenderLayer::filterRenderTiles(RenderTiles tiles) const {
+void RenderLayer::setRenderTiles(RenderTiles tiles, const TransformState&) {
auto filterFn = [](auto& tile){ return !tile.tile.isRenderable() || tile.tile.holdForFade(); };
- return filterRenderTiles(std::move(tiles), filterFn);
-}
-
-void RenderLayer::sortRenderTiles(const TransformState&) {
- // no-op
+ renderTiles = filterRenderTiles(std::move(tiles), filterFn);
}
const RenderLayerSymbolInterface* RenderLayer::getSymbolInterface() const {
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index ec4c71b08c..98e151435a 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -63,7 +63,7 @@ public:
const mat4&) const { return false; };
using RenderTiles = std::vector<std::reference_wrapper<RenderTile>>;
- void setRenderTiles(RenderTiles, const TransformState&);
+ virtual void setRenderTiles(RenderTiles, const TransformState&);
// Private implementation
Immutable<style::Layer::Impl> baseImpl;
@@ -84,9 +84,6 @@ protected:
// in the console to inform the developer.
void checkRenderability(const PaintParameters&, uint32_t activeBindingCount);
- // Code specific to RenderTiles sorting / filtering
- virtual RenderTiles filterRenderTiles(RenderTiles) const;
- virtual void sortRenderTiles(const TransformState&);
// For some layers, we want Buckets to cache their corresponding paint properties, so that outdated buckets (and
// the cached paint properties) can be still in use while the tile is loading new buckets (which will
// correpond to the current paint properties of the layer).
diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp
index 61fe7e91c6..059bf6bf8d 100644
--- a/src/mbgl/renderer/renderer_impl.cpp
+++ b/src/mbgl/renderer/renderer_impl.cpp
@@ -297,6 +297,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
};
std::vector<RenderItem> order;
+ std::vector<const RenderLayerSymbolInterface*> renderItemsWithSymbols;
for (auto& layerImpl : *layerImpls) {
RenderLayer* layer = getRenderLayer(layerImpl->id);
@@ -331,6 +332,10 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
layer->setRenderTiles(source->getRenderTiles(), parameters.state);
order.emplace_back(*layer, source);
+
+ if (const RenderLayerSymbolInterface* symbolLayer = layer->getSymbolInterface()) {
+ renderItemsWithSymbols.push_back(symbolLayer);
+ }
}
{
@@ -339,10 +344,6 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
crossTileSymbolIndex.reset();
}
- std::vector<RenderItem> renderItemsWithSymbols;
- std::copy_if(order.rbegin(), order.rend(), std::back_inserter(renderItemsWithSymbols),
- [](const auto& item) { return item.layer.getSymbolInterface() != nullptr; });
-
bool symbolBucketsChanged = false;
const bool placementChanged = !placement->stillRecent(parameters.timePoint);
std::set<std::string> usedSymbolLayers;
@@ -351,12 +352,13 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
placement = std::make_unique<Placement>(parameters.state, parameters.mapMode, updateParameters.transitionOptions, updateParameters.crossSourceCollisions, std::move(placement));
}
- for (const auto& item : renderItemsWithSymbols) {
- if (crossTileSymbolIndex.addLayer(*item.layer.getSymbolInterface(), parameters.state.getLatLng().longitude())) symbolBucketsChanged = true;
+ for (auto it = renderItemsWithSymbols.rbegin(); it != renderItemsWithSymbols.rend(); ++it) {
+ const RenderLayerSymbolInterface *symbolLayer = *it;
+ if (crossTileSymbolIndex.addLayer(*symbolLayer, parameters.state.getLatLng().longitude())) symbolBucketsChanged = true;
if (placementChanged) {
- usedSymbolLayers.insert(item.layer.getID());
- placement->placeLayer(*item.layer.getSymbolInterface(), parameters.projMatrix, parameters.debugOptions & MapDebugOptions::Collision);
+ usedSymbolLayers.insert(symbolLayer->layerID());
+ placement->placeLayer(*symbolLayer, parameters.projMatrix, parameters.debugOptions & MapDebugOptions::Collision);
}
}
@@ -372,8 +374,9 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) {
parameters.symbolFadeChange = placement->symbolFadeChange(parameters.timePoint);
if (placementChanged || symbolBucketsChanged) {
- for (const auto& item : renderItemsWithSymbols) {
- placement->updateLayerOpacities(*item.layer.getSymbolInterface());
+ for (auto it = renderItemsWithSymbols.rbegin(); it != renderItemsWithSymbols.rend(); ++it) {
+ const RenderLayerSymbolInterface *symbolLayer = *it;
+ placement->updateLayerOpacities(*symbolLayer);
}
}
}