From 863b4577e42737762141301864ad1d304d400eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 15:02:08 +0200 Subject: compute unique clip ids per tile, taking covering children into account fixes #206 fixes #220 refs #229 --- include/mbgl/map/source.hpp | 1 + include/mbgl/map/tile.hpp | 12 ++++++++---- include/mbgl/map/tile_data.hpp | 4 ++++ include/mbgl/util/clip_ids.hpp | 25 ++++++++++++++++++++++--- include/mbgl/util/math.hpp | 4 ++++ 5 files changed, 39 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/mbgl/map/source.hpp b/include/mbgl/map/source.hpp index 4ffd097193..a9ff29e80a 100644 --- a/include/mbgl/map/source.hpp +++ b/include/mbgl/map/source.hpp @@ -36,6 +36,7 @@ public: void finishRender(Painter &painter); std::forward_list getIDs() const; + std::forward_list getLoadedTiles() const; void updateClipIDs(const std::map &mapping); static std::string normalizeSourceURL(const std::string &url, const std::string &access_token); diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index 9cf5ff5341..09462604a7 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 { diff --git a/include/mbgl/map/tile_data.hpp b/include/mbgl/map/tile_data.hpp index 5991613a2d..9bc76727a1 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..52c571d598 100644 --- a/include/mbgl/util/clip_ids.hpp +++ b/include/mbgl/util/clip_ids.hpp @@ -4,15 +4,34 @@ #include #include #include +#include +#include #include 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 &array); + Tile &tile; + std::forward_list children; + }; + + typedef std::vector Pool; + std::forward_list pools; + uint8_t bit_offset = 0; + +private: + bool reuseExisting(Leaf &leaf); + +public: + void update(std::forward_list tiles); +}; -std::map computeClipIDs(std::forward_list 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); + } } -- cgit v1.2.1 From bbd42fe91f238b10416f2323cfb42c422bd2597d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 15:34:14 +0200 Subject: don't trip up certain stdlib implementations --- include/mbgl/util/clip_ids.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/mbgl/util/clip_ids.hpp b/include/mbgl/util/clip_ids.hpp index 52c571d598..5855b16af7 100644 --- a/include/mbgl/util/clip_ids.hpp +++ b/include/mbgl/util/clip_ids.hpp @@ -22,7 +22,7 @@ private: }; typedef std::vector Pool; - std::forward_list pools; + std::forward_list pools; uint8_t bit_offset = 0; private: -- cgit v1.2.1 From 2c6e34a4fe4aa2d0d1a20028e972bfd0dc051cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 15:39:58 +0200 Subject: add != operator for certain stdlib implementations --- include/mbgl/map/tile.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index 09462604a7..24845c81a0 100644 --- a/include/mbgl/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -51,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; -- cgit v1.2.1 From 1fa3a3e85ae9ca247b61cd6bede0948dec0a641a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 15:46:20 +0200 Subject: add a few fixes for gcc fixes #437 --- include/mbgl/text/collision.hpp | 3 ++- include/mbgl/text/types.hpp | 2 +- include/mbgl/util/threadpool.hpp | 1 + include/mbgl/util/utf.hpp | 6 ++---- include/mbgl/util/vec.hpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include') 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::infinity() && + return !std::isnan(zoom) && zoom != std::numeric_limits::infinity() && rotationRange[0] != rotationRange[1]; } diff --git a/include/mbgl/util/threadpool.hpp b/include/mbgl/util/threadpool.hpp index 497d4e3083..ff913ec508 100644 --- a/include/mbgl/util/threadpool.hpp +++ b/include/mbgl/util/threadpool.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace mbgl { namespace util { diff --git a/include/mbgl/util/utf.hpp b/include/mbgl/util/utf.hpp index 5dfc4ad2d1..fa21df74c0 100644 --- a/include/mbgl/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -4,11 +4,9 @@ #include // g++/libstdc++ is missing c++11 codecvt support -#ifdef __linux__ -#pragma GCC diagnostic push #ifndef __clang__ +#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#endif #include #pragma GCC diagnostic pop #else @@ -20,7 +18,7 @@ namespace mbgl { namespace util { -#ifdef __linux__ +#ifndef __clang__ 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::has_quiet_NaN, int>::type = 0> inline operator bool() const { - return !isnan(x) && !isnan(y); + return !std::isnan(x) && !std::isnan(y); } template::has_quiet_NaN, int>::type = 0> -- cgit v1.2.1 From 6730beec0e7d515339a82e80263b9323c665f77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 15:51:10 +0200 Subject: remove unused threadpool class --- include/mbgl/util/threadpool.hpp | 46 ---------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 include/mbgl/util/threadpool.hpp (limited to 'include') diff --git a/include/mbgl/util/threadpool.hpp b/include/mbgl/util/threadpool.hpp deleted file mode 100644 index ff913ec508..0000000000 --- a/include/mbgl/util/threadpool.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef MBGL_UTIL_THREADPOOL -#define MBGL_UTIL_THREADPOOL - -#include -#include -#include -#include - -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 Task; - const int max_workers; - pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; - pthread_cond_t condition = PTHREAD_COND_INITIALIZER; - std::forward_list workers; - int worker_count = 0; - std::queue tasks; -}; - -extern std::unique_ptr threadpool; - -} -} - -#endif - -- cgit v1.2.1 From 178d8ca62d2b6a89b1ee9bcb6f8806d4494395b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 16:03:02 +0200 Subject: also use boost codecvt on linux --- include/mbgl/util/utf.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mbgl/util/utf.hpp b/include/mbgl/util/utf.hpp index fa21df74c0..503fff8b1e 100644 --- a/include/mbgl/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -4,12 +4,13 @@ #include // g++/libstdc++ is missing c++11 codecvt support -#ifndef __clang__ +#if ! defined(__clang__) || defined(__linux__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include #pragma GCC diagnostic pop #else +// Assume that codecvt is present on clang on non-linux systems #include #include #endif -- cgit v1.2.1 From f4929b0e6ffe671fc8e73683bf565922b18800c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 21 Aug 2014 16:22:41 +0200 Subject: use correct implementation --- include/mbgl/util/utf.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/mbgl/util/utf.hpp b/include/mbgl/util/utf.hpp index 503fff8b1e..bb63179123 100644 --- a/include/mbgl/util/utf.hpp +++ b/include/mbgl/util/utf.hpp @@ -19,7 +19,7 @@ namespace mbgl { namespace util { -#ifndef __clang__ +#if ! defined(__clang__) || defined(__linux__) class utf8_to_utf32 { public: -- cgit v1.2.1 From 6610a6370b9702d6dbd107716d5df3227be42e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 22 Aug 2014 12:37:23 +0200 Subject: use platform-specific NSString for case changes on OS X/iOS refs #309 --- include/mbgl/platform/platform.hpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') 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_http(const std::string &url, std::function callback, std::shared_ptr 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 &req); -- cgit v1.2.1