diff options
author | Mike Morris <michael.patrick.morris@gmail.com> | 2014-08-26 16:55:08 -0400 |
---|---|---|
committer | Mike Morris <michael.patrick.morris@gmail.com> | 2014-08-26 16:55:08 -0400 |
commit | 050b00cb5898af5d1ea82d8dd94878eb76da7faf (patch) | |
tree | f453add00f563c91ee1b188bf61939b940b5b707 /include | |
parent | 7ae3b8e8ee5f59481fb8373df1d17d25cccce2f0 (diff) | |
parent | 60f7813544e4e49ef2cabcab493ea2903d888f19 (diff) | |
download | qtlocation-mapboxgl-050b00cb5898af5d1ea82d8dd94878eb76da7faf.tar.gz |
Merge branch 'master' into libuv010
Conflicts:
setup-libraries.sh
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/platform/platform.hpp | 6 | ||||
-rw-r--r-- | include/mbgl/text/collision.hpp | 3 | ||||
-rw-r--r-- | include/mbgl/text/types.hpp | 2 | ||||
-rw-r--r-- | include/mbgl/util/clip_ids.hpp | 25 | ||||
-rw-r--r-- | include/mbgl/util/math.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/util/threadpool.hpp | 45 | ||||
-rw-r--r-- | include/mbgl/util/utf.hpp | 7 | ||||
-rw-r--r-- | include/mbgl/util/vec.hpp | 2 |
11 files changed, 56 insertions, 59 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/platform/platform.hpp b/include/mbgl/platform/platform.hpp index 43c6ce4f5e..22405a4cfd 100644 --- a/include/mbgl/platform/platform.hpp +++ b/include/mbgl/platform/platform.hpp @@ -28,6 +28,12 @@ std::shared_ptr<Request> request_http(const std::string &url, std::function<void(Response *)> callback, std::shared_ptr<uv::loop> loop = nullptr); +// Uppercase a string, potentially using platform-specific routines. +std::string uppercase(const std::string &string); + +// Lowercase a string, potentially using platform-specific routines. +std::string lowercase(const std::string &string); + // Cancels an HTTP request. void cancel_request_http(const std::shared_ptr<Request> &req); diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp index 7e65e979da..8eec30f216 100644 --- a/include/mbgl/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -5,8 +5,9 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#ifdef __clang__ #pragma GCC diagnostic ignored "-Wdeprecated-register" -#ifndef __clang__ +#else #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif diff --git a/include/mbgl/text/types.hpp b/include/mbgl/text/types.hpp index e2539bff62..dbb483ea8f 100644 --- a/include/mbgl/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -101,7 +101,7 @@ struct PlacementProperty { : zoom(zoom), rotationRange(rotationRange) {} inline operator bool() const { - return !isnan(zoom) && zoom != std::numeric_limits<float>::infinity() && + return !std::isnan(zoom) && zoom != std::numeric_limits<float>::infinity() && rotationRange[0] != rotationRange[1]; } 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); + } } diff --git a/include/mbgl/util/threadpool.hpp b/include/mbgl/util/threadpool.hpp deleted file mode 100644 index 497d4e3083..0000000000 --- a/include/mbgl/util/threadpool.hpp +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MBGL_UTIL_THREADPOOL -#define MBGL_UTIL_THREADPOOL - -#include <pthread.h> -#include <forward_list> -#include <queue> - -namespace mbgl { -namespace util { - -class Threadpool { -private: - class Worker { - public: - Worker(Threadpool& pool); - ~Worker(); - static void *loop(void *ptr); - - private: - Threadpool& pool; - pthread_t thread; - }; - -public: - Threadpool(int max_workers = 4); - typedef void (*Callback)(void *); - void add(Callback callback, void *data); - -private: - typedef std::pair<Callback, void *> Task; - const int max_workers; - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - pthread_cond_t condition = PTHREAD_COND_INITIALIZER; - std::forward_list<Worker> workers; - int worker_count = 0; - std::queue<Task> tasks; -}; - -extern std::unique_ptr<Threadpool> threadpool; - -} -} - -#endif - diff --git a/include/mbgl/util/utf.hpp b/include/mbgl/util/utf.hpp index 5dfc4ad2d1..bb63179123 100644 --- a/include/mbgl/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -4,14 +4,13 @@ #include <memory> // g++/libstdc++ is missing c++11 codecvt support -#ifdef __linux__ +#if ! defined(__clang__) || defined(__linux__) #pragma GCC diagnostic push -#ifndef __clang__ #pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#endif #include <boost/locale.hpp> #pragma GCC diagnostic pop #else +// Assume that codecvt is present on clang on non-linux systems #include <codecvt> #include <locale> #endif @@ -20,7 +19,7 @@ namespace mbgl { namespace util { -#ifdef __linux__ +#if ! defined(__clang__) || defined(__linux__) class utf8_to_utf32 { public: diff --git a/include/mbgl/util/vec.hpp b/include/mbgl/util/vec.hpp index 0b9bf63d53..a5fbee477b 100644 --- a/include/mbgl/util/vec.hpp +++ b/include/mbgl/util/vec.hpp @@ -71,7 +71,7 @@ struct vec2 { template<typename U = T, typename std::enable_if<std::numeric_limits<U>::has_quiet_NaN, int>::type = 0> inline operator bool() const { - return !isnan(x) && !isnan(y); + return !std::isnan(x) && !std::isnan(y); } template<typename U = T, typename std::enable_if<!std::numeric_limits<U>::has_quiet_NaN, int>::type = 0> |