diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-11-09 13:24:25 -0800 |
---|---|---|
committer | Chris Loer <chris.loer@mapbox.com> | 2017-11-17 10:05:15 -0800 |
commit | 31f0f47195ae7d4a6f96b1c64cd39e1268fdfc8d (patch) | |
tree | 734ff45581fcfdb3a887e5f17e7d36584f224101 /src/mbgl/text/cross_tile_symbol_index.hpp | |
parent | dcd7da14f6627a09a5840a3046b5708449962f69 (diff) | |
download | qtlocation-mapboxgl-31f0f47195ae7d4a6f96b1c64cd39e1268fdfc8d.tar.gz |
[core] Add CrossTileSymbolIndex.
This class is responsible for tracking which symbols are "the same" between tiles at different zoom levels, so that symbol opacities (fade animations) can be copied smoothly between tiles.
Diffstat (limited to 'src/mbgl/text/cross_tile_symbol_index.hpp')
-rw-r--r-- | src/mbgl/text/cross_tile_symbol_index.hpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/mbgl/text/cross_tile_symbol_index.hpp b/src/mbgl/text/cross_tile_symbol_index.hpp new file mode 100644 index 0000000000..0b8c5c4780 --- /dev/null +++ b/src/mbgl/text/cross_tile_symbol_index.hpp @@ -0,0 +1,67 @@ +#pragma once + +#include <mbgl/tile/tile_id.hpp> +#include <mbgl/util/geometry.hpp> +#include <mbgl/util/constants.hpp> +#include <mbgl/util/optional.hpp> + +#include <map> +#include <vector> +#include <string> +#include <memory> +#include <unordered_set> + +namespace mbgl { + +class SymbolInstance; +class RenderSymbolLayer; +class SymbolBucket; + +class IndexEntry { + Point<float> anchorPoint; + +}; + +class IndexedSymbolInstance { + public: + IndexedSymbolInstance(uint32_t crossTileID_, Point<int64_t> coord_) + : crossTileID(crossTileID_), coord(coord_) {}; + uint32_t crossTileID; + Point<int64_t> coord; +}; + +class TileLayerIndex { + public: + TileLayerIndex(OverscaledTileID coord, std::vector<SymbolInstance>&, uint32_t bucketInstanceId); + + Point<int64_t> getScaledCoordinates(SymbolInstance&, const OverscaledTileID&); + void findMatches(std::vector<SymbolInstance>&, const OverscaledTileID&); + + OverscaledTileID coord; + uint32_t bucketInstanceId; + std::map<std::u16string,std::vector<IndexedSymbolInstance>> indexedSymbolInstances; +}; + +class CrossTileSymbolLayerIndex { + public: + CrossTileSymbolLayerIndex(); + void addBucket(const OverscaledTileID&, SymbolBucket&); + bool removeStaleBuckets(const std::unordered_set<uint32_t>& currentIDs); + private: + std::map<uint8_t,std::map<OverscaledTileID,TileLayerIndex>> indexes; + uint32_t maxBucketInstanceId = 0; + static uint32_t maxCrossTileID; +}; + +class CrossTileSymbolIndex { + public: + CrossTileSymbolIndex(); + + bool addLayer(RenderSymbolLayer&); + + void reset(); + private: + std::map<std::string,CrossTileSymbolLayerIndex> layerIndexes; +}; + +} // namespace mbgl |