From e4c311a864d522e402b67f5393f57d0f663330e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 11 Aug 2014 17:39:57 +0200 Subject: remove uv.h dependency in util/time.hpp --- src/util/time.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/util/time.cpp (limited to 'src') diff --git a/src/util/time.cpp b/src/util/time.cpp new file mode 100644 index 0000000000..493a6ccfa8 --- /dev/null +++ b/src/util/time.cpp @@ -0,0 +1,13 @@ +#include + +#include + +namespace mbgl { +namespace util { + +timestamp now() { + return uv_hrtime(); +} + +} +} -- cgit v1.2.1 From 6f802642917136eb29d385d31d1817a98b562bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 12 Aug 2014 11:45:30 +0200 Subject: remove uv.h dependency from header files --- src/map/map.cpp | 7 ++++--- src/map/sprite.cpp | 2 +- src/map/tile_data.cpp | 1 + src/map/transform.cpp | 5 ++--- src/platform/request.cpp | 2 +- src/style/style.cpp | 5 ++++- src/text/glyph_store.cpp | 2 +- src/util/raster.cpp | 2 +- src/util/time.cpp | 3 +-- src/util/uv.cpp | 19 +++++++++++++++++++ 10 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 src/util/uv.cpp (limited to 'src') diff --git a/src/map/map.cpp b/src/map/map.cpp index ef7b9548bd..81cbd394ba 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -32,6 +32,7 @@ using namespace mbgl; Map::Map(View& view) : loop(std::make_shared()), + thread(std::make_unique()), view(view), transform(view), fileSource(std::make_shared()), @@ -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(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); diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index f396fec07d..88e940c00e 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index a94eb00fbf..4333e2d2fd 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace mbgl; diff --git a/src/map/transform.cpp b/src/map/transform.cpp index 6338df6a48..a68cffdc7e 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -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()) { setScale(current.scale); setAngle(current.angle); } diff --git a/src/platform/request.cpp b/src/platform/request.cpp index 9382892a91..efd17895db 100644 --- a/src/platform/request.cpp +++ b/src/platform/request.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include using namespace mbgl::platform; diff --git a/src/style/style.cpp b/src/style/style.cpp index 03881f96a0..22c7610105 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include @@ -13,7 +15,8 @@ namespace mbgl { -Style::Style() { +Style::Style() + : mtx(std::make_unique()) { } void Style::updateProperties(float z, timestamp now) { diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 4b90b51c24..c32e1642e5 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include namespace mbgl { diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 4a040f9cb6..fe5acbd526 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/util/time.cpp b/src/util/time.cpp index 493a6ccfa8..4cd8077f98 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -1,6 +1,5 @@ #include - -#include +#include namespace mbgl { namespace util { diff --git a/src/util/uv.cpp b/src/util/uv.cpp new file mode 100644 index 0000000000..65c790b9c0 --- /dev/null +++ b/src/util/uv.cpp @@ -0,0 +1,19 @@ +#include + +#include + +namespace uv { + +std::string cwd() { + size_t max = 0; + std::string dir; + do { + max += 256; + dir.resize(max); + uv_cwd(const_cast(dir.data()), &max); + } while (max == dir.size()); + dir.resize(max - 1); + return dir; +} + +} -- cgit v1.2.1