Merge pull request #410 from mapbox/no-uv-headers
remove header dependency on uv.h
This commit is contained in:
2
Makefile
2
Makefile
@@ -27,7 +27,7 @@ build/test/Makefile: src common config.gypi test/test.gyp
|
||||
test: build/test/Makefile
|
||||
$(MAKE) -C build/test BUILDTYPE=Testing V=$(V) test
|
||||
|
||||
test/%: build/test/Makefile
|
||||
test_%: build/test/Makefile
|
||||
$(MAKE) -C build/test BUILDTYPE=Testing V=$(V) $*
|
||||
(cd build/Testing && exec ./test_$*)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/platform/request.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <queue>
|
||||
|
||||
@@ -12,28 +12,15 @@
|
||||
#include <mbgl/platform/request.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <uv.h>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
uv_once_t request_initialize = UV_ONCE_INIT;
|
||||
dispatch_once_t request_initialize = 0;
|
||||
NSURLSession *session = nullptr;
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
std::atomic<int> active_tasks;
|
||||
#endif
|
||||
|
||||
void request_initialize_cb() {
|
||||
NSURLSessionConfiguration *sessionConfig =
|
||||
[NSURLSessionConfiguration defaultSessionConfiguration];
|
||||
sessionConfig.timeoutIntervalForResource = 30;
|
||||
sessionConfig.HTTPMaximumConnectionsPerHost = 8;
|
||||
sessionConfig.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
|
||||
|
||||
session = [NSURLSession sessionWithConfiguration:sessionConfig];
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
active_tasks = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// We're using a child class to make sure ARC is working correctly, as well as to add activity
|
||||
// indicators on iOS.
|
||||
@@ -69,7 +56,19 @@ std::shared_ptr<mbgl::platform::Request>
|
||||
mbgl::platform::request_http(const std::string &url,
|
||||
std::function<void(Response *)> callback,
|
||||
std::shared_ptr<uv::loop> loop) {
|
||||
uv_once(&request_initialize, request_initialize_cb);
|
||||
dispatch_once(&request_initialize, ^{
|
||||
NSURLSessionConfiguration *sessionConfig =
|
||||
[NSURLSessionConfiguration defaultSessionConfiguration];
|
||||
sessionConfig.timeoutIntervalForResource = 30;
|
||||
sessionConfig.HTTPMaximumConnectionsPerHost = 8;
|
||||
sessionConfig.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
|
||||
|
||||
session = [NSURLSession sessionWithConfiguration:sessionConfig];
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
active_tasks = 0;
|
||||
#endif
|
||||
});
|
||||
|
||||
std::shared_ptr<FoundationRequest> req =
|
||||
std::make_shared<FoundationRequest>(url, callback, loop);
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#endif
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
class GLFWView : public mbgl::View {
|
||||
public:
|
||||
GLFWView(bool fullscreen = false);
|
||||
@@ -43,8 +41,6 @@ public:
|
||||
double last_click = -1;
|
||||
|
||||
GLFWwindow *window = nullptr;
|
||||
|
||||
uv_loop_t *loop = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
private:
|
||||
bool async = false;
|
||||
std::shared_ptr<uv::loop> loop;
|
||||
uv_thread_t thread;
|
||||
std::unique_ptr<uv::thread> thread;
|
||||
uv_async_t *async_terminate = nullptr;
|
||||
uv_async_t *async_render = nullptr;
|
||||
uv_async_t *async_cleanup = nullptr;
|
||||
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
private:
|
||||
View &view;
|
||||
|
||||
mutable uv::rwlock mtx;
|
||||
std::unique_ptr<uv::rwlock> mtx;
|
||||
|
||||
// This reflects the current state of the transform, representing the actual position of the
|
||||
// map. After calling a transform function with a timer, this will likely remain the same until
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
#ifndef MBGL_PLATFORM_PLATFORM
|
||||
#define MBGL_PLATFORM_PLATFORM
|
||||
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
|
||||
namespace uv {
|
||||
class loop;
|
||||
}
|
||||
|
||||
namespace mbgl {
|
||||
namespace platform {
|
||||
|
||||
|
||||
@@ -7,14 +7,7 @@
|
||||
#include <atomic>
|
||||
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
|
||||
// Forward definition.
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
typedef struct uv_async_s uv_async_t;
|
||||
|
||||
namespace uv {
|
||||
class loop;
|
||||
}
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace platform {
|
||||
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
PropertyTransition defaultTransition;
|
||||
bool initial_render_complete = false;
|
||||
|
||||
mutable uv::rwlock mtx;
|
||||
std::unique_ptr<uv::rwlock> mtx;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#ifndef MBGL_UTIL_FILESOURCE
|
||||
#define MBGL_UTIL_FILESOURCE
|
||||
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
namespace uv {
|
||||
class loop;
|
||||
}
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
namespace platform {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef MBGL_UTIL_TIME
|
||||
#define MBGL_UTIL_TIME
|
||||
|
||||
#include <uv.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -13,9 +13,8 @@ namespace util {
|
||||
// Returns time in nanoseconds since an arbitrary point in the past. This has
|
||||
// no relation to the current time, but is continuously increasing, so
|
||||
// comparisons between different timestamps produce meaningful values.
|
||||
inline timestamp now() {
|
||||
return uv_hrtime();
|
||||
}
|
||||
timestamp now();
|
||||
|
||||
}
|
||||
|
||||
// used for time conversions
|
||||
|
||||
@@ -1,159 +1,19 @@
|
||||
#ifndef MBGL_UTIL_UV
|
||||
#define MBGL_UTIL_UV
|
||||
|
||||
#include <uv.h>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
|
||||
#include <boost/lockfree/queue.hpp>
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
typedef struct uv_async_s uv_async_t;
|
||||
typedef struct uv_handle_s uv_handle_t;
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
|
||||
namespace uv {
|
||||
|
||||
inline std::string cwd() {
|
||||
size_t max = 0;
|
||||
std::string dir;
|
||||
do {
|
||||
max += 256;
|
||||
dir.resize(max);
|
||||
uv_cwd(const_cast<char *>(dir.data()), &max);
|
||||
} while (max == dir.size());
|
||||
dir.resize(max - 1);
|
||||
return dir;
|
||||
}
|
||||
std::string cwd();
|
||||
|
||||
class loop {
|
||||
public:
|
||||
inline loop() {
|
||||
if (uv_loop_init(&l) != 0) {
|
||||
throw std::runtime_error("failed to initialize loop");
|
||||
}
|
||||
}
|
||||
|
||||
inline ~loop() { uv_loop_close(&l); }
|
||||
|
||||
inline uv_loop_t *operator*() { return &l; }
|
||||
|
||||
private:
|
||||
uv_loop_t l;
|
||||
};
|
||||
|
||||
class mutex {
|
||||
public:
|
||||
inline mutex() {
|
||||
if (uv_mutex_init(&mtx) != 0) {
|
||||
throw std::runtime_error("failed to initialize mutex");
|
||||
}
|
||||
}
|
||||
inline ~mutex() { uv_mutex_destroy(&mtx); }
|
||||
inline void lock() { uv_mutex_lock(&mtx); }
|
||||
inline void unlock() { uv_mutex_unlock(&mtx); }
|
||||
|
||||
private:
|
||||
uv_mutex_t mtx;
|
||||
};
|
||||
|
||||
class lock {
|
||||
public:
|
||||
lock(mutex &mtx) : mtx(mtx) { mtx.lock(); }
|
||||
~lock() { mtx.unlock(); }
|
||||
|
||||
private:
|
||||
mutex &mtx;
|
||||
};
|
||||
|
||||
class rwlock {
|
||||
public:
|
||||
inline rwlock() {
|
||||
if (uv_rwlock_init(&mtx) != 0) {
|
||||
throw std::runtime_error("failed to initialize read-write lock");
|
||||
}
|
||||
}
|
||||
inline ~rwlock() { uv_rwlock_destroy(&mtx); }
|
||||
inline void rdlock() { uv_rwlock_rdlock(&mtx); }
|
||||
inline void wrlock() { uv_rwlock_wrlock(&mtx); }
|
||||
inline void rdunlock() { uv_rwlock_rdunlock(&mtx); }
|
||||
inline void wrunlock() { uv_rwlock_wrunlock(&mtx); }
|
||||
|
||||
private:
|
||||
uv_rwlock_t mtx;
|
||||
};
|
||||
|
||||
class readlock {
|
||||
public:
|
||||
inline readlock(rwlock &mtx) : mtx(mtx) { mtx.rdlock(); }
|
||||
inline ~readlock() { mtx.rdunlock(); }
|
||||
|
||||
private:
|
||||
rwlock &mtx;
|
||||
};
|
||||
|
||||
class writelock {
|
||||
public:
|
||||
inline writelock(rwlock &mtx) : mtx(mtx) { mtx.wrlock(); }
|
||||
inline ~writelock() { mtx.wrunlock(); }
|
||||
|
||||
private:
|
||||
rwlock &mtx;
|
||||
};
|
||||
|
||||
class once {
|
||||
public:
|
||||
typedef void (*callback)();
|
||||
void operator()(void (*callback)(void)) {
|
||||
uv_once(&o, callback);
|
||||
}
|
||||
|
||||
private:
|
||||
uv_once_t o = UV_ONCE_INIT;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class work {
|
||||
public:
|
||||
typedef void (*work_callback)(T &object);
|
||||
typedef void (*after_work_callback)(T &object);
|
||||
|
||||
template<typename... Args>
|
||||
work(const std::shared_ptr<loop> &loop, work_callback work_cb, after_work_callback after_work_cb, Args&&... args)
|
||||
: loop(loop),
|
||||
data(std::forward<Args>(args)...),
|
||||
work_cb(work_cb),
|
||||
after_work_cb(after_work_cb) {
|
||||
req.data = this;
|
||||
uv_queue_work(**loop, &req, do_work, after_work);
|
||||
}
|
||||
|
||||
private:
|
||||
static void do_work(uv_work_t *req) {
|
||||
work<T> *w = static_cast<work<T> *>(req->data);
|
||||
w->work_cb(w->data);
|
||||
}
|
||||
|
||||
static void after_work(uv_work_t *req, int) {
|
||||
work<T> *w = static_cast<work<T> *>(req->data);
|
||||
w->after_work_cb(w->data);
|
||||
delete w;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<uv::loop> loop;
|
||||
uv_work_t req;
|
||||
T data;
|
||||
work_callback work_cb;
|
||||
after_work_callback after_work_cb;
|
||||
};
|
||||
class thread;
|
||||
class rwlock;
|
||||
class loop;
|
||||
|
||||
}
|
||||
|
||||
|
||||
158
include/mbgl/util/uv_detail.hpp
Normal file
158
include/mbgl/util/uv_detail.hpp
Normal file
@@ -0,0 +1,158 @@
|
||||
#ifndef MBGL_UTIL_UV_DETAIL
|
||||
#define MBGL_UTIL_UV_DETAIL
|
||||
|
||||
#include <uv.h>
|
||||
#include <functional>
|
||||
#include <cassert>
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
|
||||
#include <boost/lockfree/queue.hpp>
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace uv {
|
||||
|
||||
class thread {
|
||||
public:
|
||||
inline operator uv_thread_t *() { return &t; }
|
||||
|
||||
private:
|
||||
uv_thread_t t;
|
||||
};
|
||||
|
||||
class loop {
|
||||
public:
|
||||
inline loop() {
|
||||
if (uv_loop_init(&l) != 0) {
|
||||
throw std::runtime_error("failed to initialize loop");
|
||||
}
|
||||
}
|
||||
|
||||
inline ~loop() { uv_loop_close(&l); }
|
||||
|
||||
inline uv_loop_t *operator*() { return &l; }
|
||||
|
||||
private:
|
||||
uv_loop_t l;
|
||||
};
|
||||
|
||||
class mutex {
|
||||
public:
|
||||
inline mutex() {
|
||||
if (uv_mutex_init(&mtx) != 0) {
|
||||
throw std::runtime_error("failed to initialize mutex");
|
||||
}
|
||||
}
|
||||
inline ~mutex() { uv_mutex_destroy(&mtx); }
|
||||
inline void lock() { uv_mutex_lock(&mtx); }
|
||||
inline void unlock() { uv_mutex_unlock(&mtx); }
|
||||
|
||||
private:
|
||||
uv_mutex_t mtx;
|
||||
};
|
||||
|
||||
class lock {
|
||||
public:
|
||||
lock(mutex &mtx) : mtx(mtx) { mtx.lock(); }
|
||||
~lock() { mtx.unlock(); }
|
||||
|
||||
private:
|
||||
mutex &mtx;
|
||||
};
|
||||
|
||||
class rwlock {
|
||||
public:
|
||||
inline rwlock() {
|
||||
if (uv_rwlock_init(&mtx) != 0) {
|
||||
throw std::runtime_error("failed to initialize read-write lock");
|
||||
}
|
||||
}
|
||||
inline ~rwlock() { uv_rwlock_destroy(&mtx); }
|
||||
inline void rdlock() { uv_rwlock_rdlock(&mtx); }
|
||||
inline void wrlock() { uv_rwlock_wrlock(&mtx); }
|
||||
inline void rdunlock() { uv_rwlock_rdunlock(&mtx); }
|
||||
inline void wrunlock() { uv_rwlock_wrunlock(&mtx); }
|
||||
|
||||
private:
|
||||
uv_rwlock_t mtx;
|
||||
};
|
||||
|
||||
class readlock {
|
||||
public:
|
||||
inline readlock(rwlock &mtx) : mtx(mtx) { mtx.rdlock(); }
|
||||
inline readlock(const std::unique_ptr<rwlock> &mtx) : mtx(*mtx) { mtx->rdlock(); }
|
||||
inline ~readlock() { mtx.rdunlock(); }
|
||||
|
||||
private:
|
||||
rwlock &mtx;
|
||||
};
|
||||
|
||||
class writelock {
|
||||
public:
|
||||
inline writelock(rwlock &mtx) : mtx(mtx) { mtx.wrlock(); }
|
||||
inline writelock(const std::unique_ptr<rwlock> &mtx) : mtx(*mtx) { mtx->wrlock(); }
|
||||
inline ~writelock() { mtx.wrunlock(); }
|
||||
|
||||
private:
|
||||
rwlock &mtx;
|
||||
};
|
||||
|
||||
class once {
|
||||
public:
|
||||
typedef void (*callback)();
|
||||
void operator()(void (*callback)(void)) {
|
||||
uv_once(&o, callback);
|
||||
}
|
||||
|
||||
private:
|
||||
uv_once_t o = UV_ONCE_INIT;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class work {
|
||||
public:
|
||||
typedef void (*work_callback)(T &object);
|
||||
typedef void (*after_work_callback)(T &object);
|
||||
|
||||
template<typename... Args>
|
||||
work(const std::shared_ptr<loop> &loop, work_callback work_cb, after_work_callback after_work_cb, Args&&... args)
|
||||
: loop(loop),
|
||||
data(std::forward<Args>(args)...),
|
||||
work_cb(work_cb),
|
||||
after_work_cb(after_work_cb) {
|
||||
req.data = this;
|
||||
uv_queue_work(**loop, &req, do_work, after_work);
|
||||
}
|
||||
|
||||
private:
|
||||
static void do_work(uv_work_t *req) {
|
||||
work<T> *w = static_cast<work<T> *>(req->data);
|
||||
w->work_cb(w->data);
|
||||
}
|
||||
|
||||
static void after_work(uv_work_t *req, int) {
|
||||
work<T> *w = static_cast<work<T> *>(req->data);
|
||||
w->after_work_cb(w->data);
|
||||
delete w;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<uv::loop> loop;
|
||||
uv_work_t req;
|
||||
T data;
|
||||
work_callback work_cb;
|
||||
after_work_callback after_work_cb;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Submodule ios/mapbox-gl-cocoa updated: ced284d8a7...644f1f9f5d
@@ -1,5 +1,6 @@
|
||||
#include <mbgl/mbgl.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
|
||||
45
mapboxgl.gyp
45
mapboxgl.gyp
@@ -34,52 +34,45 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'bundle_styles',
|
||||
'target_name': 'touch_styles',
|
||||
'type': 'none',
|
||||
'hard_dependency': 1,
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'Touch Stylesheet Directory',
|
||||
'inputs': ['styles'],
|
||||
'outputs': ['styles'],
|
||||
'action': ['touch', 'styles'], # required for xcode http://openradar.appspot.com/7232149
|
||||
'outputs': ['<(PRODUCT_DIR)/'], # need to specify a distinct directory
|
||||
'action': ['touch', 'styles'],
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'bundle_styles',
|
||||
'type': 'none',
|
||||
'hard_dependency': 1,
|
||||
'dependencies': [ 'touch_styles' ], # required for xcode http://openradar.appspot.com/7232149
|
||||
'direct_dependent_settings': {
|
||||
'mac_bundle_resources': [
|
||||
'styles',
|
||||
],
|
||||
'mac_bundle_resources': [ 'styles' ],
|
||||
}
|
||||
},
|
||||
{
|
||||
'target_name': 'copy_styles',
|
||||
'type': 'none',
|
||||
'hard_dependency': 1,
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'Touch Stylesheet Directory',
|
||||
'inputs': ['styles'],
|
||||
'outputs': ['styles'],
|
||||
'action': ['touch', 'styles'], # required for xcode http://openradar.appspot.com/7232149
|
||||
}
|
||||
],
|
||||
'copies': [
|
||||
{
|
||||
'files': [ 'styles' ],
|
||||
'destination': '<(PRODUCT_DIR)'
|
||||
}
|
||||
]
|
||||
'dependencies': [ 'touch_styles' ], # required for xcode http://openradar.appspot.com/7232149
|
||||
'copies': [{
|
||||
'files': [ 'styles' ],
|
||||
'destination': '<(PRODUCT_DIR)'
|
||||
}],
|
||||
},
|
||||
{
|
||||
'target_name': 'copy_certificate_bundle',
|
||||
'type': 'none',
|
||||
'hard_dependency': 1,
|
||||
'copies': [
|
||||
{
|
||||
'files': [ 'common/ca-bundle.crt' ],
|
||||
'destination': '<(PRODUCT_DIR)'
|
||||
}
|
||||
]
|
||||
'copies': [{
|
||||
'files': [ 'common/ca-bundle.crt' ],
|
||||
'destination': '<(PRODUCT_DIR)'
|
||||
}],
|
||||
},
|
||||
{
|
||||
'target_name': 'mapboxgl',
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <mbgl/util/clip_ids.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/text/glyph_store.hpp>
|
||||
@@ -32,6 +32,7 @@ using namespace mbgl;
|
||||
|
||||
Map::Map(View& view)
|
||||
: loop(std::make_shared<uv::loop>()),
|
||||
thread(std::make_unique<uv::thread>()),
|
||||
view(view),
|
||||
transform(view),
|
||||
fileSource(std::make_shared<FileSource>()),
|
||||
@@ -78,7 +79,7 @@ void Map::start() {
|
||||
uv_async_init(**loop, async_cleanup, cleanup);
|
||||
async_cleanup->data = this;
|
||||
|
||||
uv_thread_create(&thread, [](void *arg) {
|
||||
uv_thread_create(*thread, [](void *arg) {
|
||||
Map *map = static_cast<Map *>(arg);
|
||||
map->run();
|
||||
}, this);
|
||||
@@ -89,7 +90,7 @@ void Map::stop() {
|
||||
uv_async_send(async_terminate);
|
||||
}
|
||||
|
||||
uv_thread_join(&thread);
|
||||
uv_thread_join(*thread);
|
||||
|
||||
// Run the event loop once to make sure our async delete handlers are called.
|
||||
uv_run(**loop, UV_RUN_ONCE);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/util/filesource.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/util/token.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/filesource.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
using namespace mbgl;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/transition.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <cstdio>
|
||||
@@ -16,9 +17,7 @@ const double R2D = 180.0 / M_PI;
|
||||
const double M2PI = 2 * M_PI;
|
||||
const double MIN_ROTATE_SCALE = 8;
|
||||
|
||||
Transform::Transform(View &view)
|
||||
: view(view) {
|
||||
|
||||
Transform::Transform(View &view) : view(view), mtx(std::make_unique<uv::rwlock>()) {
|
||||
setScale(current.scale);
|
||||
setAngle(current.angle);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <mbgl/platform/request.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
using namespace mbgl::platform;
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/util/error.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <csscolorparser/csscolorparser.hpp>
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
@@ -13,7 +15,8 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
Style::Style() {
|
||||
Style::Style()
|
||||
: mtx(std::make_unique<uv::rwlock>()) {
|
||||
}
|
||||
|
||||
void Style::updateProperties(float z, timestamp now) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <mbgl/util/math.hpp>
|
||||
#include <mbgl/util/filesource.hpp>
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <uv.h>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/platform/gl.hpp>
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/util/std.hpp>
|
||||
|
||||
#include <png.h>
|
||||
|
||||
12
src/util/time.cpp
Normal file
12
src/util/time.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
timestamp now() {
|
||||
return uv_hrtime();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
19
src/util/uv.cpp
Normal file
19
src/util/uv.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <mbgl/util/uv.hpp>
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
namespace uv {
|
||||
|
||||
std::string cwd() {
|
||||
size_t max = 0;
|
||||
std::string dir;
|
||||
do {
|
||||
max += 256;
|
||||
dir.resize(max);
|
||||
uv_cwd(const_cast<char *>(dir.data()), &max);
|
||||
} while (max == dir.size());
|
||||
dir.resize(max - 1);
|
||||
return dir;
|
||||
}
|
||||
|
||||
}
|
||||
2
test/fixtures/fixture_request.cpp
vendored
2
test/fixtures/fixture_request.cpp
vendored
@@ -1,6 +1,6 @@
|
||||
#include <mbgl/platform/platform.hpp>
|
||||
#include <mbgl/platform/request.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/uv_detail.hpp>
|
||||
#include <mbgl/platform/log.hpp>
|
||||
|
||||
const std::string base_directory = []{
|
||||
|
||||
@@ -189,7 +189,6 @@
|
||||
"dependencies": [
|
||||
"../deps/gtest/gtest.gyp:gtest",
|
||||
"../mapboxgl.gyp:mapboxgl",
|
||||
'../mapboxgl.gyp:bundle_styles',
|
||||
"link_gl",
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user