summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-01 12:00:01 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-04 16:56:43 +0300
commitd57083497509a1918fcccfb3005be2ba532e0266 (patch)
tree51ee178b7c9743e9add97c2faee8b4faee7657c2
parentdd16eadc382fe853f4b877fbcfd909d103a339f5 (diff)
downloadqtlocation-mapboxgl-d57083497509a1918fcccfb3005be2ba532e0266.tar.gz
[core] Remove orchestration methods from RenderTile
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp7
-rw-r--r--src/mbgl/renderer/render_layer.cpp2
-rw-r--r--src/mbgl/renderer/render_layer.hpp1
-rw-r--r--src/mbgl/renderer/render_source.hpp5
-rw-r--r--src/mbgl/renderer/render_tile.cpp9
-rw-r--r--src/mbgl/renderer/render_tile.hpp2
-rw-r--r--src/mbgl/renderer/sources/render_image_source.hpp2
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.cpp6
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.hpp3
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp29
-rw-r--r--src/mbgl/renderer/tile_pyramid.hpp5
-rw-r--r--src/mbgl/text/placement.cpp3
-rw-r--r--src/mbgl/text/placement.hpp1
13 files changed, 42 insertions, 33 deletions
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 33b095b7e7..e254466e0b 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -493,7 +493,7 @@ style::TextPaintProperties::PossiblyEvaluated RenderSymbolLayer::textPaintProper
}
void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
- renderTiles = params.source->getRenderedTiles();
+ renderTiles = params.source->getRenderTiles();
const auto comp = [bearing = params.state.getBearing()](const RenderTile& a, const RenderTile& b) {
Point<float> pa(a.id.canonical.x, a.id.canonical.y);
Point<float> pb(b.id.canonical.x, b.id.canonical.y);
@@ -512,7 +512,10 @@ void RenderSymbolLayer::prepare(const LayerPrepareParameters& params) {
auto* bucket = static_cast<SymbolBucket*>(renderTile.getBucket(*baseImpl));
if (bucket && bucket->bucketLeaderID == getID()) {
// Only place this layer if it's the "group leader" for the bucket
- placementData.push_back({*bucket, renderTile});
+ const Tile* tile = params.source->getRenderedTile(renderTile.id);
+ assert(tile);
+ assert(tile->kind == Tile::Kind::Geometry);
+ placementData.push_back({*bucket, renderTile, static_cast<const GeometryTile*>(tile)->getFeatureIndex()});
}
}
}
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp
index 4ad93a0d16..2f57d9ed9c 100644
--- a/src/mbgl/renderer/render_layer.cpp
+++ b/src/mbgl/renderer/render_layer.cpp
@@ -47,7 +47,7 @@ bool RenderLayer::supportsZoom(float zoom) const {
void RenderLayer::prepare(const LayerPrepareParameters& params) {
assert(params.source);
- renderTiles = filterRenderTiles(params.source->getRenderedTiles());
+ renderTiles = filterRenderTiles(params.source->getRenderTiles());
}
optional<Color> RenderLayer::getSolidBackground() const {
diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp
index 1eaa79ab2b..7f73826c34 100644
--- a/src/mbgl/renderer/render_layer.hpp
+++ b/src/mbgl/renderer/render_layer.hpp
@@ -31,6 +31,7 @@ class LayerPlacementData {
public:
std::reference_wrapper<Bucket> bucket;
std::reference_wrapper<RenderTile> tile;
+ std::shared_ptr<FeatureIndex> featureIndex;
};
class LayerPrepareParameters {
diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp
index 71e38f2afd..f0da360dd0 100644
--- a/src/mbgl/renderer/render_source.hpp
+++ b/src/mbgl/renderer/render_source.hpp
@@ -74,7 +74,10 @@ public:
virtual void updateFadingTiles() = 0;
virtual bool hasFadingTiles() const = 0;
// Returns a list of RenderTiles, sorted by tile id.
- virtual std::vector<std::reference_wrapper<RenderTile>> getRenderedTiles() = 0;
+ virtual std::vector<std::reference_wrapper<RenderTile>> getRenderTiles() = 0;
+ virtual const Tile* getRenderedTile(const UnwrappedTileID&) const {
+ return nullptr;
+ }
virtual std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
diff --git a/src/mbgl/renderer/render_tile.cpp b/src/mbgl/renderer/render_tile.cpp
index f1f6a4ac45..74fc945ac1 100644
--- a/src/mbgl/renderer/render_tile.cpp
+++ b/src/mbgl/renderer/render_tile.cpp
@@ -89,15 +89,6 @@ const gfx::Texture& RenderTile::getIconAtlasTexture() const {
return *(static_cast<const GeometryTile&>(tile).iconAtlasTexture);
}
-std::shared_ptr<FeatureIndex> RenderTile::getFeatureIndex() const {
- assert(tile.kind == Tile::Kind::Geometry);
- return static_cast<const GeometryTile&>(tile).getFeatureIndex();
-}
-
-void RenderTile::setMask(TileMask&& mask) {
- tile.setMask(std::move(mask));
-}
-
void RenderTile::upload(gfx::UploadPass& uploadPass) {
tile.upload(uploadPass);
diff --git a/src/mbgl/renderer/render_tile.hpp b/src/mbgl/renderer/render_tile.hpp
index f0abb4150c..c863c5970e 100644
--- a/src/mbgl/renderer/render_tile.hpp
+++ b/src/mbgl/renderer/render_tile.hpp
@@ -58,9 +58,7 @@ public:
optional<ImagePosition> getPattern(const std::string& pattern) const;
const gfx::Texture& getGlyphAtlasTexture() const;
const gfx::Texture& getIconAtlasTexture() const;
- std::shared_ptr<FeatureIndex> getFeatureIndex() const;
- void setMask(TileMask&&);
void upload(gfx::UploadPass&);
void prepare(const SourcePrepareParameters&);
void finishRender(PaintParameters&);
diff --git a/src/mbgl/renderer/sources/render_image_source.hpp b/src/mbgl/renderer/sources/render_image_source.hpp
index a656ccd539..f1d3a86db1 100644
--- a/src/mbgl/renderer/sources/render_image_source.hpp
+++ b/src/mbgl/renderer/sources/render_image_source.hpp
@@ -33,7 +33,7 @@ public:
bool needsRelayout,
const TileParameters&) final;
- std::vector<std::reference_wrapper<RenderTile>> getRenderedTiles() final {
+ std::vector<std::reference_wrapper<RenderTile>> getRenderTiles() final {
return {};
}
diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp
index 1037a2f78e..2d82603dd5 100644
--- a/src/mbgl/renderer/sources/render_tile_source.cpp
+++ b/src/mbgl/renderer/sources/render_tile_source.cpp
@@ -49,10 +49,14 @@ bool RenderTileSource::hasFadingTiles() const {
return tilePyramid.hasFadingTiles();
}
-std::vector<std::reference_wrapper<RenderTile>> RenderTileSource::getRenderedTiles() {
+std::vector<std::reference_wrapper<RenderTile>> RenderTileSource::getRenderTiles() {
return { renderTiles.begin(), renderTiles.end() };
}
+const Tile* RenderTileSource::getRenderedTile(const UnwrappedTileID& tileID) const {
+ return tilePyramid.getRenderedTile(tileID);
+}
+
std::unordered_map<std::string, std::vector<Feature>>
RenderTileSource::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
diff --git a/src/mbgl/renderer/sources/render_tile_source.hpp b/src/mbgl/renderer/sources/render_tile_source.hpp
index 5501e260f5..91b453968d 100644
--- a/src/mbgl/renderer/sources/render_tile_source.hpp
+++ b/src/mbgl/renderer/sources/render_tile_source.hpp
@@ -22,7 +22,8 @@ public:
void updateFadingTiles() override;
bool hasFadingTiles() const override;
- std::vector<std::reference_wrapper<RenderTile>> getRenderedTiles() override;
+ std::vector<std::reference_wrapper<RenderTile>> getRenderTiles() override;
+ const Tile* getRenderedTile(const UnwrappedTileID&) const override;
std::unordered_map<std::string, std::vector<Feature>>
queryRenderedFeatures(const ScreenLineString& geometry,
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index b931b2d279..e08803134d 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -39,11 +39,16 @@ bool TilePyramid::isLoaded() const {
return true;
}
-Tile* TilePyramid::getTile(const OverscaledTileID& tileID){
+Tile* TilePyramid::getTile(const OverscaledTileID& tileID) {
auto it = tiles.find(tileID);
return it == tiles.end() ? cache.get(tileID) : it->second.get();
}
+const Tile* TilePyramid::getRenderedTile(const UnwrappedTileID& tileID) const {
+ auto it = renderedTiles.find(tileID);
+ return it != renderedTiles.end() ? &it->second.get() : nullptr;
+}
+
void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& layers,
const bool needsRendering,
const bool needsRelayout,
@@ -68,7 +73,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
}
tiles.clear();
- renderTiles.clear();
+ renderedTiles.clear();
return;
}
@@ -153,7 +158,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
return tiles.emplace(tileID, std::move(tile)).first->second.get();
};
- auto previouslyRenderedTiles = std::move(renderTiles);
+ auto previouslyRenderedTiles = std::move(renderedTiles);
auto renderTileFn = [&](const UnwrappedTileID& tileID, Tile& tile) {
addRenderTile(tileID, tile);
@@ -161,7 +166,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
tile.markRenderedIdeal();
};
- renderTiles.clear();
+ renderedTiles.clear();
if (!panTiles.empty()) {
algorithm::updateRenderables(getTileFn, createTileFn, retainTileFn,
@@ -219,7 +224,7 @@ void TilePyramid::update(const std::vector<Immutable<style::LayerProperties>>& l
fadingTiles = false;
// Initialize renderable tiles and update the contained layer render data.
- for (auto& entry : renderTiles) {
+ for (auto& entry : renderedTiles) {
Tile& tile = entry.second;
assert(tile.isRenderable());
tile.usedByRenderedLayers = false;
@@ -268,11 +273,11 @@ void TilePyramid::handleWrapJump(float lng) {
}
tiles = std::move(newTiles);
- for (auto& tile : renderTiles) {
+ for (auto& tile : renderedTiles) {
UnwrappedTileID newID = tile.first.unwrapTo(tile.first.wrap + wrapDelta);
newRenderTiles.emplace(newID, tile.second);
}
- renderTiles = std::move(newRenderTiles);
+ renderedTiles = std::move(newRenderTiles);
}
}
@@ -283,7 +288,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
const RenderedQueryOptions& options,
const mat4& projMatrix) const {
std::unordered_map<std::string, std::vector<Feature>> result;
- if (renderTiles.empty() || geometry.empty()) {
+ if (renderedTiles.empty() || geometry.empty()) {
return result;
}
@@ -301,7 +306,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
std::tie(b.canonical.z, b.canonical.y, b.wrap, b.canonical.x);
};
- std::map<UnwrappedTileID, std::reference_wrapper<Tile>, decltype(cmp)> sortedTiles{renderTiles.begin(), renderTiles.end(), cmp};
+ std::map<UnwrappedTileID, std::reference_wrapper<Tile>, decltype(cmp)> sortedTiles{renderedTiles.begin(), renderedTiles.end(), cmp};
auto maxPitchScaleFactor = transformState.maxPitchScaleFactor();
@@ -369,17 +374,17 @@ void TilePyramid::dumpDebugLogs() const {
void TilePyramid::clearAll() {
tiles.clear();
- renderTiles.clear();
+ renderedTiles.clear();
cache.clear();
}
void TilePyramid::addRenderTile(const UnwrappedTileID& tileID, Tile& tile) {
assert(tile.isRenderable());
- renderTiles.emplace(tileID, tile);
+ renderedTiles.emplace(tileID, tile);
}
void TilePyramid::updateFadingTiles() {
- for (auto& entry : renderTiles) {
+ for (auto& entry : renderedTiles) {
Tile& tile = entry.second;
if (tile.holdForFade()) {
tile.performedFadePlacement();
diff --git a/src/mbgl/renderer/tile_pyramid.hpp b/src/mbgl/renderer/tile_pyramid.hpp
index 610828bdb3..675831fbc9 100644
--- a/src/mbgl/renderer/tile_pyramid.hpp
+++ b/src/mbgl/renderer/tile_pyramid.hpp
@@ -43,8 +43,9 @@ public:
optional<LatLngBounds> bounds,
std::function<std::unique_ptr<Tile> (const OverscaledTileID&)> createTile);
- const std::map<UnwrappedTileID, std::reference_wrapper<Tile>>& getRenderedTiles() const { return renderTiles; }
+ const std::map<UnwrappedTileID, std::reference_wrapper<Tile>>& getRenderedTiles() const { return renderedTiles; }
Tile* getTile(const OverscaledTileID&);
+ const Tile* getRenderedTile(const UnwrappedTileID&) const;
void handleWrapJump(float lng);
@@ -75,7 +76,7 @@ private:
std::map<OverscaledTileID, std::unique_ptr<Tile>> tiles;
TileCache cache;
- std::map<UnwrappedTileID, std::reference_wrapper<Tile>> renderTiles; // Sorted by tile id.
+ std::map<UnwrappedTileID, std::reference_wrapper<Tile>> renderedTiles; // Sorted by tile id.
TileObserver* observer = nullptr;
float prevLng = 0;
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index edf73101ab..62110fefa7 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -78,6 +78,7 @@ void Placement::placeLayer(const RenderLayer& layer, const mat4& projMatrix, boo
item.tile,
projMatrix,
layer.baseImpl->source,
+ item.featureIndex,
showCollisionBoxes};
bucket.place(*this, params, seenCrossTileIDs);
}
@@ -332,7 +333,7 @@ void Placement::placeBucket(
// matching FeatureIndex/data for querying purposes
retainedQueryData.emplace(std::piecewise_construct,
std::forward_as_tuple(bucket.bucketInstanceId),
- std::forward_as_tuple(bucket.bucketInstanceId, renderTile.getFeatureIndex(), overscaledID));
+ std::forward_as_tuple(bucket.bucketInstanceId, params.featureIndex, overscaledID));
}
void Placement::commit(TimePoint now) {
diff --git a/src/mbgl/text/placement.hpp b/src/mbgl/text/placement.hpp
index 6ffe58afc5..0f56b0007e 100644
--- a/src/mbgl/text/placement.hpp
+++ b/src/mbgl/text/placement.hpp
@@ -93,6 +93,7 @@ public:
const RenderTile& tile;
const mat4& projMatrix;
std::string sourceId;
+ std::shared_ptr<FeatureIndex> featureIndex;
bool showCollisionBoxes;
};