diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-08-26 17:42:53 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-08-26 17:42:53 +0200 |
commit | 0f73a0192e60823e49261dae2202d572be90c28b (patch) | |
tree | 1a70a1ec1daa5da7dd8d3a517c93145838a33af8 /include | |
parent | a889cde6de5137aa13d9b0b1b3bfe4ebcd138a1a (diff) | |
parent | 2c6e34a4fe4aa2d0d1a20028e972bfd0dc051cd8 (diff) | |
download | qtlocation-mapboxgl-0f73a0192e60823e49261dae2202d572be90c28b.tar.gz |
Merge pull request #439 from mapbox/clipping
Compute unique clip IDSs per tile
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/map/source.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/map/tile.hpp | 16 | ||||
-rw-r--r-- | include/mbgl/map/tile_data.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/util/clip_ids.hpp | 25 | ||||
-rw-r--r-- | include/mbgl/util/math.hpp | 4 |
5 files changed, 43 insertions, 7 deletions
diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp index 5b51268bfe..4bc4c86dd0 100644 --- a/include/mbgl/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -38,6 +38,7 @@ public: void finishRender(Painter &painter); std::forward_list<Tile::ID> getIDs() const; + std::forward_list<Tile *> getLoadedTiles() const; void updateClipIDs(const std::map<Tile::ID, ClipID> &mapping); private: diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index 9cf5ff5341..24845c81a0 100644 --- a/include/mbgl/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -18,11 +18,15 @@ namespace mbgl { class TileData; struct ClipID { - explicit ClipID() {} - explicit ClipID(const std::bitset<8> &mask, uint8_t length) : mask(mask), length(length) {} - explicit ClipID(const std::string &mask, uint8_t length) : mask(mask), length(length) {} + inline ClipID() {} + inline ClipID(const std::string &mask_, const std::string &reference_) : mask(mask_), reference(reference_) {} + std::bitset<8> mask; - uint8_t length = 0; + std::bitset<8> reference; + + inline bool operator==(const ClipID &other) const { + return mask == other.mask && reference == other.reference; + } }; class Tile : private util::noncopyable { @@ -47,6 +51,10 @@ public: return w == rhs.w && z == rhs.z && x == rhs.x && y == rhs.y; } + inline bool operator!=(const ID& rhs) const { + return !operator==(rhs); + } + inline bool operator<(const ID &rhs) const { if (w != rhs.w) return w < rhs.w; if (z != rhs.z) return z < rhs.z; diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index 3e639fcea1..9aaef84e04 100644 --- a/include/mbgl/map/tile_data.hpp +++ b/include/mbgl/map/tile_data.hpp @@ -49,6 +49,10 @@ public: void reparse(); const std::string toString() const; + inline bool ready() const { + return state == State::parsed; + } + // Override this in the child class. virtual void beforeParse(); virtual void parse() = 0; diff --git a/include/mbgl/util/clip_ids.hpp b/include/mbgl/util/clip_ids.hpp index 748d3d8f5f..5855b16af7 100644 --- a/include/mbgl/util/clip_ids.hpp +++ b/include/mbgl/util/clip_ids.hpp @@ -4,15 +4,34 @@ #include <mbgl/map/tile.hpp> #include <list> #include <set> +#include <vector> +#include <forward_list> #include <map> namespace mbgl { -static constexpr uint8_t clipMask[9] { 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF }; +class ClipIDGenerator { +private: + struct Leaf { + Leaf(Tile &tile); + void add(const Tile::ID &p); + bool operator==(const Leaf &other) const; -void updateClipIDs(const std::list<Tile *> &array); + Tile &tile; + std::forward_list<Tile::ID> children; + }; + + typedef std::vector<Leaf> Pool; + std::forward_list<Pool> pools; + uint8_t bit_offset = 0; + +private: + bool reuseExisting(Leaf &leaf); + +public: + void update(std::forward_list<Tile *> tiles); +}; -std::map<Tile::ID, ClipID> computeClipIDs(std::forward_list<Tile::ID> array); } diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp index fde2a4720b..2bef5b18e2 100644 --- a/include/mbgl/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -104,6 +104,10 @@ T smoothstep(T edge0, T edge1, T x) { return t * t * (T(3) - T(2) * t); } +// Computes the log2(x) rounded up to the next integer. +// (== number of bits required to store x) +uint32_t ceil_log2(uint64_t x); + } } |