Merge branch 'master' into libuv010
Conflicts: setup-libraries.sh
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user