- Symbol querying is now global instead of per-tile - Symbols that bleed over tile boundaries no longer missed in queries - Symbol results now sorted based on rendering order (ie overlapping symbols change their sort order when a bearing change causes their render order to change) - Placement::retainedQueryData now responsible for maintaining symbol querying data for buckets that may no longer be in the TilePyramid.
99 lines
3.3 KiB
C++
99 lines
3.3 KiB
C++
#include <mbgl/renderer/sources/render_vector_source.hpp>
|
|
#include <mbgl/renderer/render_tile.hpp>
|
|
#include <mbgl/renderer/paint_parameters.hpp>
|
|
#include <mbgl/tile/vector_tile.hpp>
|
|
|
|
#include <mbgl/algorithm/generate_clip_ids.hpp>
|
|
#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
|
|
|
|
namespace mbgl {
|
|
|
|
using namespace style;
|
|
|
|
RenderVectorSource::RenderVectorSource(Immutable<style::VectorSource::Impl> impl_)
|
|
: RenderSource(impl_) {
|
|
tilePyramid.setObserver(this);
|
|
}
|
|
|
|
const style::VectorSource::Impl& RenderVectorSource::impl() const {
|
|
return static_cast<const style::VectorSource::Impl&>(*baseImpl);
|
|
}
|
|
|
|
bool RenderVectorSource::isLoaded() const {
|
|
return tilePyramid.isLoaded();
|
|
}
|
|
|
|
void RenderVectorSource::update(Immutable<style::Source::Impl> baseImpl_,
|
|
const std::vector<Immutable<Layer::Impl>>& layers,
|
|
const bool needsRendering,
|
|
const bool needsRelayout,
|
|
const TileParameters& parameters) {
|
|
std::swap(baseImpl, baseImpl_);
|
|
|
|
enabled = needsRendering;
|
|
|
|
optional<Tileset> _tileset = impl().getTileset();
|
|
|
|
if (tileset != _tileset) {
|
|
tileset = _tileset;
|
|
|
|
// TODO: this removes existing buckets, and will cause flickering.
|
|
// Should instead refresh tile data in place.
|
|
tilePyramid.tiles.clear();
|
|
tilePyramid.renderTiles.clear();
|
|
tilePyramid.cache.clear();
|
|
}
|
|
// Allow clearing the tile pyramid first, before the early return in case
|
|
// the new tileset is not yet available or has an error in loading
|
|
if (!_tileset) {
|
|
return;
|
|
}
|
|
|
|
tilePyramid.update(layers,
|
|
needsRendering,
|
|
needsRelayout,
|
|
parameters,
|
|
SourceType::Vector,
|
|
util::tileSize,
|
|
tileset->zoomRange,
|
|
tileset->bounds,
|
|
[&] (const OverscaledTileID& tileID) {
|
|
return std::make_unique<VectorTile>(tileID, impl().id, parameters, *tileset);
|
|
});
|
|
}
|
|
|
|
void RenderVectorSource::startRender(PaintParameters& parameters) {
|
|
parameters.clipIDGenerator.update(tilePyramid.getRenderTiles());
|
|
tilePyramid.startRender(parameters);
|
|
}
|
|
|
|
void RenderVectorSource::finishRender(PaintParameters& parameters) {
|
|
tilePyramid.finishRender(parameters);
|
|
}
|
|
|
|
std::vector<std::reference_wrapper<RenderTile>> RenderVectorSource::getRenderTiles() {
|
|
return tilePyramid.getRenderTiles();
|
|
}
|
|
|
|
std::unordered_map<std::string, std::vector<Feature>>
|
|
RenderVectorSource::queryRenderedFeatures(const ScreenLineString& geometry,
|
|
const TransformState& transformState,
|
|
const std::vector<const RenderLayer*>& layers,
|
|
const RenderedQueryOptions& options) const {
|
|
return tilePyramid.queryRenderedFeatures(geometry, transformState, layers, options);
|
|
}
|
|
|
|
std::vector<Feature> RenderVectorSource::querySourceFeatures(const SourceQueryOptions& options) const {
|
|
return tilePyramid.querySourceFeatures(options);
|
|
}
|
|
|
|
void RenderVectorSource::reduceMemoryUse() {
|
|
tilePyramid.reduceMemoryUse();
|
|
}
|
|
|
|
void RenderVectorSource::dumpDebugLogs() const {
|
|
tilePyramid.dumpDebugLogs();
|
|
}
|
|
|
|
} // namespace mbgl
|