From a9023914918ddc85772265c910bc6d7f7fe17c74 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 12 Aug 2014 18:53:32 -0400 Subject: [PATCH 001/116] clone libuv010 branch of mapnik-packaging --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 3e5e897a7..211a65316 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -44,7 +44,7 @@ NODE=`which node` NPM=`which npm` if [ ! -d 'mapnik-packaging/.git' ]; then - git clone --depth=1 https://github.com/mapnik/mapnik-packaging.git + git clone --depth=1 -b libuv010 https://github.com/mapnik/mapnik-packaging.git fi cd mapnik-packaging/osx/ From 6408e40a60be97555fe98a430f1ae81bd128f4f3 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 13 Aug 2014 16:04:10 -0400 Subject: [PATCH 002/116] revert https://github.com/mapbox/mapbox-gl-native/commit/992815cc3da3a440dbc56c61925a4e5443b58073 --- include/mbgl/util/uv_detail.hpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index c65c247ba..b3fdbb371 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -31,18 +31,13 @@ private: class loop { public: - inline loop() { - if (uv_loop_init(&l) != 0) { - throw std::runtime_error("failed to initialize loop"); - } - } + inline loop() : l(uv_loop_new()) {} + inline ~loop() { uv_loop_delete(l); } - inline ~loop() { uv_loop_close(&l); } - - inline uv_loop_t *operator*() { return &l; } + inline uv_loop_t *operator*() { return l; } private: - uv_loop_t l; + uv_loop_t *l; }; class mutex { From a57aefbd5d2ca494d0a4e7df438cef5fbfdfb65b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 14 Aug 2014 17:19:40 -0400 Subject: [PATCH 003/116] override LIBUV_VERSION --- setup-libraries.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 211a65316..c8a9bc1c2 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -44,7 +44,7 @@ NODE=`which node` NPM=`which npm` if [ ! -d 'mapnik-packaging/.git' ]; then - git clone --depth=1 -b libuv010 https://github.com/mapnik/mapnik-packaging.git + git clone --depth=1 https://github.com/mapnik/mapnik-packaging.git fi cd mapnik-packaging/osx/ @@ -54,21 +54,25 @@ export CXX11=true if [ ${UNAME} = 'Darwin' ]; then source iPhoneOS.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' source iPhoneOSs.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneos/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneos/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' source iPhoneOS64.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' source iPhoneSimulator.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' @@ -81,6 +85,7 @@ source iPhoneSimulator.sh # echo ' ...done' source MacOSX.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi @@ -108,6 +113,7 @@ if [ ! -z "${TRAVIS:-}" ]; then fi source Linux.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi From 40ee0dfb5f9fd0b17cf0c302776fba0be8bc0790 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 20 Aug 2014 16:54:43 -0400 Subject: [PATCH 004/116] add AWS_S3_BUCKET env var to .travis.yml --- .travis.yml | 1 + setup-libraries.sh | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b641c1158..d2d77a43b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ env: - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" + - AWS_S3_BUCKET=mapbox-gl-testing before_install: - source ./scripts/flags.sh diff --git a/setup-libraries.sh b/setup-libraries.sh index 9c83595a3..92ff675e9 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -66,7 +66,7 @@ export CXX11=true if [ ${UNAME} = 'Darwin' ]; then if [ ! -z "${TRAVIS:-}" ]; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libcpp-universal_${MP_HASH}.tar.gz ./out/ ; then + if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libcpp-universal_${MP_HASH}.tar.gz ./out/ ; then rm -rf out/build-cpp11-libcpp-universal tar -xzf out/build-cpp11-libcpp-universal_${MP_HASH}.tar.gz fi @@ -114,7 +114,7 @@ source MacOSX.sh if [ ! -z "${TRAVIS:-}" ]; then tar -zcf out/build-cpp11-libcpp-universal_${MP_HASH}.tar.gz out/build-cpp11-libcpp-universal - aws s3 cp out/build-cpp11-libcpp-universal_${MP_HASH}.tar.gz s3://mapbox-gl-testing/dependencies/ + aws s3 cp out/build-cpp11-libcpp-universal_${MP_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ fi fi @@ -129,7 +129,7 @@ cd ../../ elif [ ${UNAME} = 'Linux' ]; then if [ ! -z "${TRAVIS:-}" ]; then - if aws s3 cp s3://mapbox-gl-testing/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ./out/ ; then + if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ./out/ ; then rm -rf out/build-cpp11-libstdcpp-gcc-x86_64-linux tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz fi @@ -146,7 +146,7 @@ source Linux.sh if [ ! -z "${TRAVIS:-}" ]; then if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux - aws s3 cp out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://mapbox-gl-testing/dependencies/ + aws s3 cp out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ fi fi From 33562623c8a6939df39316020439189ae9d54eed Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 20 Aug 2014 18:53:56 -0400 Subject: [PATCH 005/116] pin mapnik-packaging to new hash to generate pkg-config .pc file for libuv --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 1884ebe12..3708c606c 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="6d7e83e8042" +MP_HASH="762527d980" if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git fi From 1ff71a78e05e0c12fca26fea2c7bda14b237631a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 20 Aug 2014 19:10:36 -0400 Subject: [PATCH 006/116] update mapnik-packaging --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 3708c606c..5ad69fb14 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="762527d980" +MP_HASH="9d134bf" if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git fi From 3466f364121b3a0a157ce62c417c94802484351a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 20 Aug 2014 19:43:29 -0400 Subject: [PATCH 007/116] bump mapnik-packaging, conform to libuv 0.10 api --- include/mbgl/map/map.hpp | 8 ++++---- include/mbgl/platform/request.hpp | 2 +- setup-libraries.sh | 2 +- src/map/map.cpp | 8 ++++---- src/platform/request.cpp | 2 +- src/util/uv.cpp | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index fba38879e..4c5952a2c 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -129,10 +129,10 @@ public: private: // uv async callbacks - static void render(uv_async_t *async); - static void terminate(uv_async_t *async); - static void cleanup(uv_async_t *async); - static void delete_async(uv_handle_t *handle); + static void render(uv_async_t *async, int status); + static void terminate(uv_async_t *async, int status); + static void cleanup(uv_async_t *async, int status); + static void delete_async(uv_handle_t *handle, int status); // Setup void setup(); diff --git a/include/mbgl/platform/request.hpp b/include/mbgl/platform/request.hpp index 0cbacf645..2a231769c 100644 --- a/include/mbgl/platform/request.hpp +++ b/include/mbgl/platform/request.hpp @@ -24,7 +24,7 @@ public: void complete(); private: - static void complete(uv_async_t *async); + static void complete(uv_async_t *async, int status); public: const std::string url; diff --git a/setup-libraries.sh b/setup-libraries.sh index 5ad69fb14..bcf318ae8 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="9d134bf" +MP_HASH="c07b197" if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git fi diff --git a/src/map/map.cpp b/src/map/map.cpp index 6aa9071a4..8caea4c79 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -98,7 +98,7 @@ void Map::stop() { async = false; } -void Map::delete_async(uv_handle_t *handle) { +void Map::delete_async(uv_handle_t *handle, int status) { delete (uv_async_t *)handle; } @@ -143,14 +143,14 @@ void Map::cleanup() { } } -void Map::cleanup(uv_async_t *async) { +void Map::cleanup(uv_async_t *async, int status) { Map *map = static_cast(async->data); map->view.make_active(); map->painter.cleanup(); } -void Map::render(uv_async_t *async) { +void Map::render(uv_async_t *async, int status) { Map *map = static_cast(async->data); @@ -170,7 +170,7 @@ void Map::render(uv_async_t *async) { } } -void Map::terminate(uv_async_t *async) { +void Map::terminate(uv_async_t *async, int status) { // Closes all open handles on the loop. This means that the loop will automatically terminate. uv_loop_t *loop = static_cast(async->data); uv_walk(loop, [](uv_handle_t *handle, void */*arg*/) { diff --git a/src/platform/request.cpp b/src/platform/request.cpp index efd17895d..b028d8322 100644 --- a/src/platform/request.cpp +++ b/src/platform/request.cpp @@ -41,7 +41,7 @@ void Request::complete() { } } -void Request::complete(uv_async_t *async) { +void Request::complete(uv_async_t *async, int status) { Response *res = static_cast *>(async->data)->get(); res->callback(res); diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 65c790b9c..94f074bfa 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -10,7 +10,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), &max); + uv_cwd(const_cast(dir.data()), max); } while (max == dir.size()); dir.resize(max - 1); return dir; From 2233f981fb49f6cd000979bea01a483f1abd25bf Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 26 Aug 2014 17:09:32 -0400 Subject: [PATCH 008/116] port curl_request to libuv 0.10.x --- common/curl_request.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/curl_request.cpp b/common/curl_request.cpp index 416ed90cd..3370c0a85 100644 --- a/common/curl_request.cpp +++ b/common/curl_request.cpp @@ -216,7 +216,7 @@ int handle_socket(CURL * /*easy*/, curl_socket_t s, int action, void * /*userp*/ return 0; } -void on_timeout(uv_timer_t * /*req*/) { +void on_timeout(uv_timer_t *, int status /*req*/) { int running_handles; CURLMcode error = curl_multi_socket_action(curl_multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); @@ -227,9 +227,9 @@ void on_timeout(uv_timer_t * /*req*/) { void start_timeout(CURLM * /*multi*/, long timeout_ms, void * /*userp*/) { if (timeout_ms <= 0) { - on_timeout(&timeout); + on_timeout(&timeout, -1); } else { - uv_timer_start(&timeout, on_timeout, timeout_ms, 0); + uv_timer_start(&timeout, &on_timeout, timeout_ms, 0); } } @@ -289,7 +289,7 @@ size_t curl_write_cb(void *contents, size_t size, size_t nmemb, void *userp) { // This callback is called in the request event loop (on the request thread). // It initializes newly queued up download requests and adds them to the CURL // multi handle. -void async_add_cb(uv_async_t * /*async*/) { +void async_add_cb(uv_async_t *, int status /*async*/) { std::shared_ptr *req = nullptr; while (add_queue.pop(req)) { // Make sure that we're not starting requests that have been cancelled @@ -321,7 +321,7 @@ void async_add_cb(uv_async_t * /*async*/) { } } -void async_cancel_cb(uv_async_t * /*async*/) { +void async_cancel_cb(uv_async_t *, int status /*async*/) { std::shared_ptr *req = nullptr; while (cancel_queue.pop(req)) { // It is possible that the request has not yet been started, but that it already has been @@ -343,8 +343,8 @@ void thread_init_cb() { curl_global_init(CURL_GLOBAL_ALL); loop = uv_loop_new(); - uv_async_init(loop, &async_add, async_add_cb); - uv_async_init(loop, &async_cancel, async_cancel_cb); + uv_async_init(loop, &async_add, &async_add_cb); + uv_async_init(loop, &async_cancel, &async_cancel_cb); uv_thread_create(&thread, thread_init, nullptr); } } // end namespace request From 1882884c9e3352256722487df3f7e96260c2a858 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 26 Aug 2014 17:38:34 -0400 Subject: [PATCH 009/116] fix uv_cwd call --- src/util/uv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 94f074bfa..65c790b9c 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -10,7 +10,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), max); + uv_cwd(const_cast(dir.data()), &max); } while (max == dir.size()); dir.resize(max - 1); return dir; From 5833f8af25842daf8079014cbae01d9df1ad4eff Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 26 Aug 2014 18:45:42 -0400 Subject: [PATCH 010/116] Revert "fix uv_cwd call" This reverts commit 1882884c9e3352256722487df3f7e96260c2a858. --- src/util/uv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 65c790b9c..94f074bfa 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -10,7 +10,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), &max); + uv_cwd(const_cast(dir.data()), max); } while (max == dir.size()); dir.resize(max - 1); return dir; From d85f03e1103b667285b4444b5e0aaccbf0bea8ed Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 27 Aug 2014 11:57:52 -0400 Subject: [PATCH 011/116] switch mapnik-packaging back to libuv-pkgconfig branch --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index e442333f4..cbc89a102 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="e741a075d28812e5d16b581e1540248fe19c52ce" +MP_HASH="bc0e0b4e02979e56dc9bbc2a601e98583f6e6e6e" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From fa85352612be82c6add5dd53c66211fe500b29b2 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 27 Aug 2014 15:25:16 -0400 Subject: [PATCH 012/116] switch uv_cwd back to &max --- src/util/uv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 94f074bfa..65c790b9c 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -10,7 +10,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), max); + uv_cwd(const_cast(dir.data()), &max); } while (max == dir.size()); dir.resize(max - 1); return dir; From 0c5ba67ac6a5a6dd61065c902241c723a9bf7e56 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 27 Aug 2014 15:57:28 -0400 Subject: [PATCH 013/116] roll back to boost 1.55 --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 3db28a0d2..e27fb33b9 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="bc0e0b4e02979e56dc9bbc2a601e98583f6e6e6e" +MP_HASH="7280b1ab4301d9102b2764a8f16c225c33ccc603" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From 81c9615122ed2c7a8502e25008ccb9c5038427f7 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 27 Aug 2014 15:58:06 -0400 Subject: [PATCH 014/116] more fixes for libuv v0.10 --- src/util/uv.cpp | 2 +- test/fixtures/fixture_request.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 65c790b9c..94f074bfa 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -10,7 +10,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), &max); + uv_cwd(const_cast(dir.data()), max); } while (max == dir.size()); dir.resize(max - 1); return dir; diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 7e351ecfa..11b308fce 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -40,8 +40,8 @@ platform::request_http(const std::string &url, uv_fs_req_cleanup(&open_req); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } @@ -53,13 +53,13 @@ platform::request_http(const std::string &url, err = uv_fs_fstat(l, &stat_req, fd, nullptr); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } - const uint64_t size = static_cast(stat_req.ptr)->st_size; + const uint64_t size = static_cast(stat_req.ptr)->st_size; std::string body; @@ -71,8 +71,8 @@ platform::request_http(const std::string &url, uv_fs_req_cleanup(&read_req); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } @@ -83,8 +83,8 @@ platform::request_http(const std::string &url, uv_fs_req_cleanup(&close_req); if (err < 0) { req->res->code = err; - req->res->error_message = uv_strerror(err); - Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(err)); + req->res->error_message = uv_strerror(uv_last_error(l)); + Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); req->complete(); return req; } From 0c803a78fa293b8103bbcff9fe679de9ebccba02 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 27 Aug 2014 19:34:37 -0400 Subject: [PATCH 015/116] copy libuv.a to build directory --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index e27fb33b9..6452b1fba 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="7280b1ab4301d9102b2764a8f16c225c33ccc603" +MP_HASH="6c52203e39ae5a8e1b921a66bb170b6fffc12248" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From cffd68f9cabb69491ff8f2c43c680f6b345b25be Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 28 Aug 2014 12:32:57 -0400 Subject: [PATCH 016/116] pull in cleaned up mapnik-packaging with libuv v0.10 fixes --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 6452b1fba..e9041cc93 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="6c52203e39ae5a8e1b921a66bb170b6fffc12248" +MP_HASH="fab18042260ce8aff361bd62cf77edfa914413c0" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From b18cf767c04e57f707c9a5dcc27706e6ec72e9e3 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 2 Sep 2014 17:30:35 -0400 Subject: [PATCH 017/116] use std::fopen/std::fread instead of libuv, thanks @springmeyer --- test/fixtures/fixture_request.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 11b308fce..865859238 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -3,6 +3,7 @@ #include #include #include +#include const std::string base_directory = []{ std::string fn = __FILE__; @@ -35,6 +36,20 @@ platform::request_http(const std::string &url, int err; + std::string body; + FILE *file = std::fopen(clean_url.c_str(),"rb"); + + if (file != NULL) + { + std::fseek(file, 0, SEEK_END); + std::size_t file_size = std::ftell(file); + std::fseek(file, 0, SEEK_SET); + body.resize(file_size); + std::fread(&body[0], file_size, 1, file); + std::fclose(file); + } + + /* uv_fs_t open_req; err = uv_fs_open(l, &open_req, clean_url.c_str(), O_RDONLY, S_IRUSR, nullptr); uv_fs_req_cleanup(&open_req); @@ -67,9 +82,12 @@ platform::request_http(const std::string &url, uv_buf_t uvbuf = uv_buf_init(const_cast(body.data()), body.size()); uv_fs_t read_req; + std::cerr << "fd: " << fd << '\n'; + std::cerr << "uvbuf.len: " << uvbuf.len << '\n'; err = uv_fs_read(l, &read_req, fd, &uvbuf, 1, 0, nullptr); uv_fs_req_cleanup(&read_req); if (err < 0) { + std::cerr << "err: " << read_req.errorno << '\n'; req->res->code = err; req->res->error_message = uv_strerror(uv_last_error(l)); Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); @@ -88,6 +106,7 @@ platform::request_http(const std::string &url, req->complete(); return req; } + */ req->res->body.swap(body); req->res->code = 200; From 6b23d05a234710c2d34064289c06362788af0e1b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 2 Sep 2014 17:48:34 -0400 Subject: [PATCH 018/116] remove debugging --- test/fixtures/fixture_request.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/fixtures/fixture_request.cpp b/test/fixtures/fixture_request.cpp index 865859238..417958a33 100644 --- a/test/fixtures/fixture_request.cpp +++ b/test/fixtures/fixture_request.cpp @@ -82,12 +82,9 @@ platform::request_http(const std::string &url, uv_buf_t uvbuf = uv_buf_init(const_cast(body.data()), body.size()); uv_fs_t read_req; - std::cerr << "fd: " << fd << '\n'; - std::cerr << "uvbuf.len: " << uvbuf.len << '\n'; err = uv_fs_read(l, &read_req, fd, &uvbuf, 1, 0, nullptr); uv_fs_req_cleanup(&read_req); if (err < 0) { - std::cerr << "err: " << read_req.errorno << '\n'; req->res->code = err; req->res->error_message = uv_strerror(uv_last_error(l)); Log::Warning(Event::HttpRequest, err, url + ": " + uv_strerror(uv_last_error(l))); From 6e5308a61b455ea9e87ca20bc18d6964e6313b74 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 3 Sep 2014 15:13:59 -0400 Subject: [PATCH 019/116] uv_async_init &complete --- src/platform/request.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/request.cpp b/src/platform/request.cpp index b028d8322..82e80b9a7 100644 --- a/src/platform/request.cpp +++ b/src/platform/request.cpp @@ -20,7 +20,7 @@ Request::Request(const std::string &url, // create an actual work request that is attached to the default loop. async = new uv_async_t(); async->data = new std::unique_ptr(); - uv_async_init(**loop, async, complete); + uv_async_init(**loop, async, &complete); } } From 88ef2f23e5061e744fefbb04f9bd908457690018 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 3 Sep 2014 17:20:48 -0400 Subject: [PATCH 020/116] cache linux deps builds on MP_HASH, DIR_HASH --- setup-libraries.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index e9041cc93..00df8795d 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -135,9 +135,9 @@ cd ../../ elif [ ${UNAME} = 'Linux' ]; then if [ ! -z "${TRAVIS:-}" ]; then - if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ./out/ ; then + if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then rm -rf out/build-cpp11-libstdcpp-gcc-x86_64-linux - tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz + tar -xzf out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz fi fi @@ -152,8 +152,8 @@ export LIBUV_VERSION=0.10.28 if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then - tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux - aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ + tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux + aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ fi fi From 74c4f976d1437e81e9bd57ee98fde05fba8c6e80 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 3 Sep 2014 19:05:07 -0400 Subject: [PATCH 021/116] fix ios builds? --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 00df8795d..6e9c8393b 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="fab18042260ce8aff361bd62cf77edfa914413c0" +MP_HASH="fd05efbb95003e81257b8af071eceaa62a998c16" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From 2e2c7befac062505d3120c2f40f299dcd97771af Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 9 Sep 2014 17:09:03 -0400 Subject: [PATCH 022/116] bump MP_HASH --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 6e9c8393b..e95530498 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="fd05efbb95003e81257b8af071eceaa62a998c16" +MP_HASH="d58d6f18b99e5283b43940882da9ea18deea1227" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From 4316d2c40585e3d0dcdb25fa6f2341531025e20e Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 10 Sep 2014 14:24:29 -0400 Subject: [PATCH 023/116] make context active before clearing buffers --- common/headless_view.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index f790d90ce..0fce22398 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -113,6 +113,8 @@ void HeadlessView::resize(int width, int height) { } void HeadlessView::clear_buffers() { + make_active(); + #if MBGL_USE_CGL glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); From c004c036964e9012b08aa4a2f8b16094630d62be Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 24 Jun 2014 00:25:20 +1000 Subject: [PATCH 024/116] Add View::make_inactive() to remove context from rendering thread View::make_inactive() is called just before termination of the rendering thread. The implementation must clear the thread's GL context. This ensures there is no context still bound to a thread during GL shutdown. This is needed as GL will not actually delete a context until it is not active on any thread. Fixes mapbox/mapbox-gl-native#340 Conflicts: common/glfw_view.hpp include/llmr/map/view.hpp test/headless.cpp --- common/glfw_view.cpp | 4 ++++ common/glfw_view.hpp | 1 + common/headless_view.cpp | 13 +++++++++++++ common/headless_view.hpp | 1 + include/mbgl/map/view.hpp | 4 ++++ src/map/map.cpp | 2 ++ 6 files changed, 25 insertions(+) diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index f53090a00..724b8bf18 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -192,6 +192,10 @@ void GLFWView::make_active() { glfwMakeContextCurrent(window); } +void GLFWView::make_inactive() { + glfwMakeContextCurrent(nullptr); +} + void GLFWView::swap() { glfwPostEmptyEvent(); diff --git a/common/glfw_view.hpp b/common/glfw_view.hpp index d2f6872fc..04085f775 100644 --- a/common/glfw_view.hpp +++ b/common/glfw_view.hpp @@ -17,6 +17,7 @@ public: void initialize(mbgl::Map *map); void swap(); void make_active(); + void make_inactive(); void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay = 0); static void key(GLFWwindow *window, int key, int scancode, int action, int mods); diff --git a/common/headless_view.cpp b/common/headless_view.cpp index f790d90ce..34326ae29 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -179,6 +179,19 @@ void HeadlessView::make_active() { #endif } +void HeadlessView::make_inactive() { +#if MBGL_USE_CGL + CGLError error = CGLSetCurrentContext(nullptr); + if (error) { + fprintf(stderr, "Removing OpenGL context failed\n"); + } +#endif + +#if MBGL_USE_GLX + // no-op +#endif +} + void HeadlessView::swap() {} unsigned int HeadlessView::root_fbo() { diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 0b255b4a3..a4432bbae 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -23,6 +23,7 @@ public: void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); + void make_inactive(); void swap(); unsigned int root_fbo(); diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index 92d60d4d0..3e2f1a4b5 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -35,6 +35,10 @@ public: // renderer setup since the render thread doesn't switch the contexts. virtual void make_active() = 0; + // Called from the render thread. Makes the GL context inactive in the current + // thread. This is called once just before the rendering thread terminates. + virtual void make_inactive() = 0; + // Returns the base framebuffer object, if any, and 0 if using the system // provided framebuffer. virtual unsigned int root_fbo() { diff --git a/src/map/map.cpp b/src/map/map.cpp index 9984f1b18..de7a7032d 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -114,6 +114,8 @@ void Map::run() { prepare(); render(); } + + view.make_inactive(); } void Map::rerender() { From 71549e7b93b6b44ed38e8915d8735c136889c3f1 Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 24 Jun 2014 00:41:28 +1000 Subject: [PATCH 025/116] Adds the function Map::terminate() to allow all GL resources held by the map to be released immediately. Map::terminate() will call any GL functions on the current thread without blocking or defering to the rendering thread. This function allows a GL context to be destroyed and recreated safely without having to delete the Map object. Fixes mapbox/mapbox-gl-native#341 Conflicts: include/llmr/renderer/painter.hpp test/headless.cpp --- common/glfw_view.cpp | 5 ++++- include/mbgl/map/map.hpp | 3 +++ include/mbgl/renderer/painter.hpp | 2 ++ src/map/map.cpp | 6 ++++++ src/renderer/painter.cpp | 19 +++++++++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 724b8bf18..0908786bb 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -8,7 +8,10 @@ GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) { #endif } -GLFWView::~GLFWView() { glfwTerminate(); } +GLFWView::~GLFWView() { + map->terminate(); + glfwTerminate(); +} void GLFWView::initialize(mbgl::Map *map) { View::initialize(map); diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index fba38879e..0d2926d04 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -53,6 +53,9 @@ public: // Triggers a cleanup that releases resources. void cleanup(); + // Releases resources immediately + void terminate(); + // Controls buffer swapping. bool needsSwap(); void swapped(); diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 75529d113..15331b9b6 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -63,6 +63,7 @@ public: // lazy initialization) in case rendering continues. void cleanup(); + void terminate(); // Renders the backdrop of the OpenGL view. This also paints in areas where we don't have any // tiles whatsoever. @@ -123,6 +124,7 @@ public: private: void setupShaders(); + void deleteShaders(); mat4 translatedMatrix(const mat4& matrix, const std::array &translation, const Tile::ID &id, TranslateAnchorType anchor); void prepareTile(const Tile& tile); diff --git a/src/map/map.cpp b/src/map/map.cpp index de7a7032d..00f0ac91c 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -153,6 +153,12 @@ void Map::cleanup(uv_async_t *async) { map->painter.cleanup(); } +void Map::terminate() { + view.make_active(); + painter.terminate(); + view.make_inactive(); +} + void Map::render(uv_async_t *async) { Map *map = static_cast(async->data); diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index c1705cd7c..b1522a56b 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -82,9 +82,28 @@ void Painter::setupShaders() { if (!gaussianShader) gaussianShader = std::make_unique(); } +void Painter::deleteShaders() { + plainShader = nullptr; + outlineShader = nullptr; + lineShader = nullptr; + linejoinShader = nullptr; + patternShader = nullptr; + iconShader = nullptr; + rasterShader = nullptr; + textShader = nullptr; + dotShader = nullptr; + compositeShader = nullptr; + gaussianShader = nullptr; +} + void Painter::cleanup() { } +void Painter::terminate() { + cleanup(); + deleteShaders(); +} + void Painter::resize() { const TransformState &state = map.getState(); if (gl_viewport != state.getFramebufferDimensions()) { From 7a4c914d05cab81ca55ac3cde478997c6d32477e Mon Sep 17 00:00:00 2001 From: Leith Bade Date: Tue, 24 Jun 2014 16:19:47 +1000 Subject: [PATCH 026/116] Move notify_map_change() from a global callback, to a callback in View. This allows for their to me more than one Map object alive at a time. Fixes mapbox/mapbox-gl-native#346 Conflicts: common/glfw_view.hpp include/llmr/map/view.hpp include/mbgl/map/transform.hpp src/map/map.cpp src/map/transform.cpp test/headless.cpp --- src/map/map.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index 00f0ac91c..e6c4e9d03 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -156,7 +156,6 @@ void Map::cleanup(uv_async_t *async) { void Map::terminate() { view.make_active(); painter.terminate(); - view.make_inactive(); } void Map::render(uv_async_t *async) { From 89f54e8789d799d3e7db24ef6ae281ca22fb715b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 10 Sep 2014 19:00:28 -0400 Subject: [PATCH 027/116] update Painter::deleteShaders --- src/renderer/painter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index b1522a56b..0d01fd166 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -87,12 +87,13 @@ void Painter::deleteShaders() { outlineShader = nullptr; lineShader = nullptr; linejoinShader = nullptr; + linepatternShader = nullptr; patternShader = nullptr; iconShader = nullptr; rasterShader = nullptr; - textShader = nullptr; + sdfGlyphShader = nullptr; + sdfIconShader = nullptr; dotShader = nullptr; - compositeShader = nullptr; gaussianShader = nullptr; } From c03beb070b205ef0d5dbceaa5fa3d8dd340ad1fd Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 10 Sep 2014 19:15:03 -0400 Subject: [PATCH 028/116] fix Map::terminate? --- src/map/map.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index 6da514d16..baa82e6c5 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -115,7 +115,7 @@ void Map::run() { render(); } - view.make_inactive(); + terminate(); } void Map::rerender() { @@ -156,6 +156,7 @@ void Map::cleanup(uv_async_t *async, int status) { void Map::terminate() { view.make_active(); painter.terminate(); + view.make_inactive(); } void Map::render(uv_async_t *async, int status) { From 57fb4b984d681fd56c58edc1840cc95c0582f503 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 10 Sep 2014 19:23:40 -0400 Subject: [PATCH 029/116] don't terminate after Map::run --- src/map/map.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/map/map.cpp b/src/map/map.cpp index baa82e6c5..10310ee16 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -114,8 +114,6 @@ void Map::run() { prepare(); render(); } - - terminate(); } void Map::rerender() { From d9ccc501c3d61f928479faf78ee21eb81b8cbdf3 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 10 Sep 2014 19:42:06 -0400 Subject: [PATCH 030/116] add GLX support to HeadlessView::make_inactive --- common/headless_view.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 0b4d7ce64..9fa75700a 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -190,7 +190,9 @@ void HeadlessView::make_inactive() { #endif #if MBGL_USE_GLX - // no-op + if (!glXMakeCurrent(x_display, None, nullptr)) { + fprintf(stderr, "Removing OpenGL context failed\n"); + } #endif } From f93a230e977522eba42046a2f6511cb776861aa7 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 11 Sep 2014 09:48:12 -0400 Subject: [PATCH 031/116] drop clear_buffers and glx make_inactive from descrtuctor --- common/headless_view.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 9fa75700a..ff903939b 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -148,14 +148,11 @@ void HeadlessView::clear_buffers() { } HeadlessView::~HeadlessView() { - clear_buffers(); - #if MBGL_USE_CGL CGLDestroyContext(gl_context); #endif #if MBGL_USE_GLX - glXMakeCurrent(x_display, None, NULL); glXDestroyContext(x_display, gl_context); XFree(x_info); XCloseDisplay(x_display); From 1f7c591bc45d95f9bdecc109fd4a3ddf6592e42d Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 11 Sep 2014 09:59:08 -0400 Subject: [PATCH 032/116] clear_buffers in make_inactive, call make_inactive in destructor --- common/headless_view.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index ff903939b..563fd8f24 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -148,6 +148,8 @@ void HeadlessView::clear_buffers() { } HeadlessView::~HeadlessView() { + make_inactive(); + #if MBGL_USE_CGL CGLDestroyContext(gl_context); #endif @@ -179,6 +181,8 @@ void HeadlessView::make_active() { } void HeadlessView::make_inactive() { + clear_buffers(); + #if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(nullptr); if (error) { From 70aaf8d343ab0dc80993038bd13148b20de0b83e Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 11 Sep 2014 10:09:30 -0400 Subject: [PATCH 033/116] pass NULL instead of nullptr to glXMakdeCurrent --- common/headless_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 563fd8f24..355206a3e 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -191,7 +191,7 @@ void HeadlessView::make_inactive() { #endif #if MBGL_USE_GLX - if (!glXMakeCurrent(x_display, None, nullptr)) { + if (!glXMakeCurrent(x_display, None, NULL)) { fprintf(stderr, "Removing OpenGL context failed\n"); } #endif From 9d369ec742f00e35fea97fe24415ecaaaad1f01a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 16 Sep 2014 18:00:52 -0400 Subject: [PATCH 034/116] dont make_active when clearing buffers, call make_inactive at end of Map::prepare() --- common/headless_view.cpp | 4 ---- src/map/map.cpp | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 355206a3e..c2e402c0b 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -113,8 +113,6 @@ void HeadlessView::resize(int width, int height) { } void HeadlessView::clear_buffers() { - make_active(); - #if MBGL_USE_CGL glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); @@ -181,8 +179,6 @@ void HeadlessView::make_active() { } void HeadlessView::make_inactive() { - clear_buffers(); - #if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(nullptr); if (error) { diff --git a/src/map/map.cpp b/src/map/map.cpp index 10310ee16..64940af9e 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -154,7 +154,6 @@ void Map::cleanup(uv_async_t *async, int status) { void Map::terminate() { view.make_active(); painter.terminate(); - view.make_inactive(); } void Map::render(uv_async_t *async, int status) { @@ -545,6 +544,8 @@ void Map::prepare() { spriteAtlas->update(*getSprite()); updateTiles(); + + view.make_inactive(); } void Map::render() { From d48e5e72213851e4ffb443eae1b6243f491682c3 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 16 Sep 2014 18:06:24 -0400 Subject: [PATCH 035/116] make_active only for CGL in clear_buffers --- common/headless_view.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index c2e402c0b..8ea1b1370 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -114,6 +114,8 @@ void HeadlessView::resize(int width, int height) { void HeadlessView::clear_buffers() { #if MBGL_USE_CGL + make_active(); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); if (fbo) { From 65df83ce4c0ccb410f3d6a9841aeea621483f0be Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 19 Sep 2014 16:16:44 -0400 Subject: [PATCH 036/116] bump mapnik-packaging, remove unnecessary view.make_active calls --- common/headless_view.cpp | 5 ++--- setup-libraries.sh | 2 +- src/map/map.cpp | 13 ++++--------- test/headless.cpp | 2 ++ 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 8ea1b1370..4ad22da9a 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -106,10 +106,7 @@ void HeadlessView::resize(int width, int height) { #if MBGL_USE_GLX x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32); glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); - - make_active(); #endif - } void HeadlessView::clear_buffers() { @@ -132,6 +129,8 @@ void HeadlessView::clear_buffers() { glDeleteRenderbuffersEXT(1, &fbo_depth_stencil); fbo_depth_stencil = 0; } + + make_inactive(); #endif #if MBGL_USE_GLX diff --git a/setup-libraries.sh b/setup-libraries.sh index e95530498..7d205ac4e 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="d58d6f18b99e5283b43940882da9ea18deea1227" +MP_HASH="8239a894fecdfc001016a4669bc5ca289763048f" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git diff --git a/src/map/map.cpp b/src/map/map.cpp index 64940af9e..6db6fa280 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -111,7 +111,6 @@ void Map::run() { // If the map rendering wasn't started asynchronously, we perform one render // *after* all events have been processed. if (!async) { - prepare(); render(); } } @@ -147,12 +146,10 @@ void Map::cleanup() { void Map::cleanup(uv_async_t *async, int status) { Map *map = static_cast(async->data); - map->view.make_active(); map->painter.cleanup(); } void Map::terminate() { - view.make_active(); painter.terminate(); } @@ -189,8 +186,6 @@ void Map::terminate(uv_async_t *async, int status) { #pragma mark - Setup void Map::setup() { - view.make_active(); - painter.setup(); } @@ -525,8 +520,6 @@ void Map::updateRenderState() { } void Map::prepare() { - view.make_active(); - // Update transform transitions. animationTime = util::now(); if (transform.needsTransition()) { @@ -544,11 +537,11 @@ void Map::prepare() { spriteAtlas->update(*getSprite()); updateTiles(); - - view.make_inactive(); } void Map::render() { + view.make_active(); + #if defined(DEBUG) std::vector debug; #endif @@ -583,6 +576,8 @@ void Map::render() { } glFlush(); + + view.make_inactive(); } void Map::renderLayers(std::shared_ptr group) { diff --git a/test/headless.cpp b/test/headless.cpp index 4299fd79b..9a4857dd1 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -91,7 +91,9 @@ TEST_P(HeadlessTest, render) { map.run(); const std::unique_ptr pixels(new uint32_t[width * height]); + map.view.make_active(); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); + map.view.make_inactive(); const std::string image = util::compress_png(width, height, pixels.get(), true); util::write_file(actual_image, image); From 8e1bbae81f61d7a5a86c959b0880a2a18842264b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 22 Sep 2014 18:06:24 -0400 Subject: [PATCH 037/116] bump mapnik-packaging --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index a605241da..7947efe49 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="d58d6f18b99e5283b43940882da9ea18deea1227" +MP_HASH="c0fc970e52950a6f16e3172f1114e5a4ae1e0aa9" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From 0cdaf58027b758650f4bb7ca7a006cb8568c080c Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 14:40:49 -0400 Subject: [PATCH 038/116] add debugging --- common/headless_view.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 0fce22398..d38a45007 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace mbgl { @@ -155,6 +156,10 @@ HeadlessView::~HeadlessView() { #endif #if MBGL_USE_GLX + std::cerr << "~HeadlessView()" << '\n'; + std::cerr << "x_display: " << x_display << '\n'; + std::cerr << "glx_pixmap: " << glx_pixmap << '\n'; + std::cerr << "gl_context: " << gl_context << '\n'; glXMakeCurrent(x_display, None, NULL); glXDestroyContext(x_display, gl_context); XFree(x_info); @@ -175,6 +180,10 @@ void HeadlessView::make_active() { #endif #if MBGL_USE_GLX + std::cerr << "make_active()" << '\n'; + std::cerr << "x_display: " << x_display << '\n'; + std::cerr << "glx_pixmap: " << glx_pixmap << '\n'; + std::cerr << "gl_context: " << gl_context << '\n'; if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) { fprintf(stderr, "Switching OpenGL context failed\n"); } From c5a7738dd640604a523e6e069cba92940d502614 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 15:17:42 -0400 Subject: [PATCH 039/116] move make_active call into MBGL_USE_CGL block --- common/headless_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index d38a45007..6ab005b6c 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -114,9 +114,9 @@ void HeadlessView::resize(int width, int height) { } void HeadlessView::clear_buffers() { +#if MBGL_USE_CGL make_active(); -#if MBGL_USE_CGL glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); if (fbo) { From 47c6bb5bd49b1535208a7d20e2646c21ab9687ff Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 16:10:36 -0400 Subject: [PATCH 040/116] update MP_HASH --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 7947efe49..a4fc59b93 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="c0fc970e52950a6f16e3172f1114e5a4ae1e0aa9" +MP_HASH="573abb5e0bfb87798172f6f9b90094e9efc58ad9" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From 86b7367994c933c1b91d571d348ec57620c7d26c Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 16:30:01 -0400 Subject: [PATCH 041/116] Revert "add debugging" This reverts commit 0cdaf58027b758650f4bb7ca7a006cb8568c080c. --- common/headless_view.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 94a6cd03b..42d595310 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -2,7 +2,6 @@ #include #include -#include namespace mbgl { @@ -159,10 +158,6 @@ HeadlessView::~HeadlessView() { #endif #if MBGL_USE_GLX - std::cerr << "~HeadlessView()" << '\n'; - std::cerr << "x_display: " << x_display << '\n'; - std::cerr << "glx_pixmap: " << glx_pixmap << '\n'; - std::cerr << "gl_context: " << gl_context << '\n'; glXMakeCurrent(x_display, None, NULL); glXDestroyContext(x_display, gl_context); XFree(x_info); @@ -183,10 +178,6 @@ void HeadlessView::make_active() { #endif #if MBGL_USE_GLX - std::cerr << "make_active()" << '\n'; - std::cerr << "x_display: " << x_display << '\n'; - std::cerr << "glx_pixmap: " << glx_pixmap << '\n'; - std::cerr << "gl_context: " << gl_context << '\n'; if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) { fprintf(stderr, "Switching OpenGL context failed\n"); } From 735d2456974f7a7c870c2c15c1cfaf0d7ad07c3b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 16:40:10 -0400 Subject: [PATCH 042/116] fix ios builds? --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index a4fc59b93..b110390a2 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="573abb5e0bfb87798172f6f9b90094e9efc58ad9" +MP_HASH="e2beefa4b52ab81dd8578f0d1a822e4a6e434d99" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From 768e23069c191dd73dd99985d0a620c581b0036d Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 17:11:18 -0400 Subject: [PATCH 043/116] build iPhoneSimulator64 against libuv 0.10.28 --- setup-libraries.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/setup-libraries.sh b/setup-libraries.sh index b110390a2..20fa5568b 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -104,6 +104,7 @@ export LIBUV_VERSION=0.10.28 echo ' ...done' source iPhoneSimulator64.sh +export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi echo ' ...done' From 92d00347a87eee10b961d4a1836c1dd6e1df6ba7 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 18:51:52 -0400 Subject: [PATCH 044/116] remove travis conditional in darwin_configure.sh --- setup-libraries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 20fa5568b..791db81a8 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -51,7 +51,7 @@ set -u NODE=$(which node) NPM=$(which npm) -MP_HASH="e2beefa4b52ab81dd8578f0d1a822e4a6e434d99" +MP_HASH="e82e6c00ea5a0cda147e4c121a3c7751cae69ff8" DIR_HASH=$(echo `pwd` | git hash-object --stdin) if [ ! -d 'mapnik-packaging/' ]; then git clone https://github.com/mapnik/mapnik-packaging.git From dffeaa07877c59a6a586545e45c4f6339b789a6d Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 24 Sep 2014 23:03:50 -0400 Subject: [PATCH 045/116] make active after resize --- common/headless_view.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 37982e689..9dee14b39 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -109,6 +109,8 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { #if MBGL_USE_GLX x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32); glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); + + make_active(); #endif } From 40562594083e4e7bbe78a673d2f656dc9baee65a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 25 Sep 2014 12:17:26 -0400 Subject: [PATCH 046/116] implement make_inactive in mapbox-gl-cocoa --- ios/mapbox-gl-cocoa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 461024ae4..1aa3db196 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 461024ae406fd98b7a27d3297298cf68284e32ad +Subproject commit 1aa3db196b210c6880df6b2aff5e0d924aa78764 From 8e6967669a64d9bc38428fe59fae171a9ac02919 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 25 Sep 2014 18:06:55 -0400 Subject: [PATCH 047/116] make inactive at end of clear_buffers() --- common/headless_view.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 9dee14b39..3fc3816f0 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -148,11 +148,13 @@ void HeadlessView::clear_buffers() { XFreePixmap(x_display, x_pixmap); x_pixmap = 0; } + + make_inactive(); #endif } HeadlessView::~HeadlessView() { - make_inactive(); + clear_buffers(); #if MBGL_USE_CGL CGLDestroyContext(gl_context); From 8ebe1bc36033cfbfe9cad5a2a9ef6b5cc803c38e Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 29 Sep 2014 16:33:26 -0400 Subject: [PATCH 048/116] add more possible errors returned by glCheckFramebufferStatusEXT from https://www.opengl.org/registry/specs/EXT/framebuffer_object.txt --- common/headless_view.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 3fc3816f0..e52bbf8b9 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -98,7 +98,10 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { switch (status) { case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: fprintf(stderr, "incomplete attachment\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: fprintf(stderr, "incomplete missing attachment\n"); break; + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: fprintf(stderr, "incomplete dimensions\n"); break; + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: fprintf(stderr, "incomplete formats\n"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: fprintf(stderr, "incomplete draw buffer\n"); break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: fprintf(stderr, "incomplete read buffer\n"); break; case GL_FRAMEBUFFER_UNSUPPORTED: fprintf(stderr, "unsupported\n"); break; default: fprintf(stderr, "other\n"); break; } From 848dccbcae8eb3ddf61b0d9344e150b721a8cf75 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 30 Sep 2014 12:06:51 -0400 Subject: [PATCH 049/116] make view active/inactive around Map::setup, don't leave active after view.resize() --- common/headless_view.cpp | 4 ++-- src/map/map.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index e52bbf8b9..61531bfd6 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -107,13 +107,13 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { } return; } + + make_inactive(); #endif #if MBGL_USE_GLX x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32); glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); - - make_active(); #endif } diff --git a/src/map/map.cpp b/src/map/map.cpp index 6db6fa280..ad8749ff0 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -186,7 +186,9 @@ void Map::terminate(uv_async_t *async, int status) { #pragma mark - Setup void Map::setup() { + view.make_active(); painter.setup(); + view.make_inactive(); } void Map::setStyleURL(const std::string &url) { From c4c4b3318a89c0a7548040f7182fb043704e230f Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 30 Sep 2014 17:42:27 -0400 Subject: [PATCH 050/116] log CGLErrorString for CGLChoosePixelFormat, enable OpenGL multithreading https://developer.apple.com/library/mac/technotes/tn2085/_index.html --- common/headless_view.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 61531bfd6..10888f7a7 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -20,7 +20,7 @@ HeadlessView::HeadlessView() { GLint num; CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num); if (error) { - fprintf(stderr, "Error pixel format\n"); + fprintf(stderr, "Error pixel format: %s\n", CGLErrorString(error)); return; } @@ -30,6 +30,12 @@ HeadlessView::HeadlessView() { fprintf(stderr, "Error creating GL context object\n"); return; } + + error = CGLEnable(gl_context, kCGLCEMPEngine); + if (error != kCGLNoError ) { + fprintf(stderr, "Error enabling OpenGL multithreading\n"); + return; + } #endif #if MBGL_USE_GLX From 0f1d33f5ee29adf9b62c912339935fdde44b0b98 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 3 Oct 2014 18:31:38 -0400 Subject: [PATCH 051/116] break out HeadlessDisplay from HeadlessView, ref #478 --- common/headless_display.cpp | 65 +++++++++++++++++++++++++++++++++++++ common/headless_display.hpp | 32 ++++++++++++++++++ common/headless_view.cpp | 60 ++++++++-------------------------- common/headless_view.hpp | 22 ++++++------- test/test.gyp | 2 ++ 5 files changed, 122 insertions(+), 59 deletions(-) create mode 100644 common/headless_display.cpp create mode 100644 common/headless_display.hpp diff --git a/common/headless_display.cpp b/common/headless_display.cpp new file mode 100644 index 000000000..580d3ef58 --- /dev/null +++ b/common/headless_display.cpp @@ -0,0 +1,65 @@ +#include "headless_view.hpp" + +#include + +namespace mbgl { + +HeadlessDisplay::HeadlessDisplay() { +#if MBGL_USE_CGL + // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported + // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension. + CGLPixelFormatAttribute attributes[] = { + kCGLPFAOpenGLProfile, + (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy, + kCGLPFAAccelerated, + (CGLPixelFormatAttribute) 0 + }; + + GLint num; + CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num); + if (error) { + fprintf(stderr, "Error pixel format: %s\n", CGLErrorString(error)); + return; + } +#endif + +#if MBGL_USE_GLX + x_display = XOpenDisplay(0); + + if (x_display == nullptr) { + throw std::runtime_error("Failed to open X display"); + } + + static int pixelFormat[] = { + GLX_RGBA, + GLX_DOUBLEBUFFER, + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, + GLX_ALPHA_SIZE, 8, + GLX_DEPTH_SIZE, 24, + GLX_STENCIL_SIZE, 8, + None + }; + + x_info = glXChooseVisual(x_display, DefaultScreen(x_display), pixelFormat); + + if (x_info == nullptr) { + throw std::runtime_error("Error pixel format"); + } +#endif +} + +HeadlessDisplay::~HeadlessDisplay() { +#if MBGL_USE_CGL + CGLDestroyPixelFormat(pixelFormat); +#endif + +#if MBGL_USE_GLX + XFree(x_info); + XCloseDisplay(x_display); +#endif +} + +} + diff --git a/common/headless_display.hpp b/common/headless_display.hpp new file mode 100644 index 000000000..4fc03da08 --- /dev/null +++ b/common/headless_display.hpp @@ -0,0 +1,32 @@ +#ifndef MBGL_COMMON_HEADLESS_DISPLAY +#define MBGL_COMMON_HEADLESS_DISPLAY + +#ifdef __APPLE__ +#define MBGL_USE_CGL 1 +#else +#include +#define MBGL_USE_GLX 1 +#endif + +#include + +namespace mbgl { + +class HeadlessDisplay { +public: + HeadlessDisplay(); + ~HeadlessDisplay(); + +#if MBGL_USE_CGL + CGLPixelFormatObj pixelFormat; +#endif + +#if MBGL_USE_GLX + Display *x_display = nullptr; + XVisualInfo *x_info = nullptr; +#endif +}; + +} + +#endif diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 10888f7a7..47cf3bd66 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -1,31 +1,21 @@ #include "headless_view.hpp" -#include #include namespace mbgl { -HeadlessView::HeadlessView() { +HeadlessView::HeadlessView() : display_(new HeadlessDisplay()) { + createContext(); +} + +HeadlessView::HeadlessView(HeadlessDisplay *display) + : display_(display) { + createContext(); +} + +void HeadlessView::createContext() { #if MBGL_USE_CGL - // TODO: test if OpenGL 4.1 with GL_ARB_ES2_compatibility is supported - // If it is, use kCGLOGLPVersion_3_2_Core and enable that extension. - CGLPixelFormatAttribute attributes[] = { - kCGLPFAOpenGLProfile, - (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy, - kCGLPFAAccelerated, - (CGLPixelFormatAttribute) 0 - }; - - CGLPixelFormatObj pixelFormat; - GLint num; - CGLError error = CGLChoosePixelFormat(attributes, &pixelFormat, &num); - if (error) { - fprintf(stderr, "Error pixel format: %s\n", CGLErrorString(error)); - return; - } - - error = CGLCreateContext(pixelFormat, NULL, &gl_context); - CGLDestroyPixelFormat(pixelFormat); + CGLError error = CGLCreateContext(display_->pixelFormat, NULL, &gl_context); if (error) { fprintf(stderr, "Error creating GL context object\n"); return; @@ -39,29 +29,8 @@ HeadlessView::HeadlessView() { #endif #if MBGL_USE_GLX - x_display = XOpenDisplay(0); - - if (x_display == nullptr) { - throw std::runtime_error("Failed to open X display"); - } - - static int pixelFormat[] = { - GLX_RGBA, - GLX_DOUBLEBUFFER, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_ALPHA_SIZE, 8, - GLX_DEPTH_SIZE, 24, - GLX_STENCIL_SIZE, 8, - None - }; - - x_info = glXChooseVisual(x_display, DefaultScreen(x_display), pixelFormat); - - if (x_info == nullptr) { - throw std::runtime_error("Error pixel format"); - } + x_display = display_->x_display; + x_info = display_->x_info; gl_context = glXCreateContext(x_display, x_info, 0, GL_TRUE); if (gl_context == nullptr) { @@ -70,7 +39,6 @@ HeadlessView::HeadlessView() { #endif } - void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { clear_buffers(); @@ -171,8 +139,6 @@ HeadlessView::~HeadlessView() { #if MBGL_USE_GLX glXDestroyContext(x_display, gl_context); - XFree(x_info); - XCloseDisplay(x_display); #endif } diff --git a/common/headless_view.hpp b/common/headless_view.hpp index c8475a251..d1b09ce70 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -1,24 +1,20 @@ -#ifndef MBGL_COMMON_HEADLESS_CGL -#define MBGL_COMMON_HEADLESS_CGL +#ifndef MBGL_COMMON_HEADLESS_VIEW +#define MBGL_COMMON_HEADLESS_VIEW -#ifdef __APPLE__ -#define MBGL_USE_CGL 1 -#else -#include -#define MBGL_USE_GLX 1 -#endif +#include "headless_display.hpp" #include -#include -#include namespace mbgl { class HeadlessView : public View { public: HeadlessView(); + HeadlessView(HeadlessDisplay *display); ~HeadlessView(); + void createContext(); + void resize(uint16_t width, uint16_t height, float pixelRatio); void notify_map_change(MapChange change, timestamp delay = 0); @@ -32,6 +28,8 @@ private: private: + HeadlessDisplay *display_; + #if MBGL_USE_CGL CGLContextObj gl_context; GLuint fbo = 0; @@ -40,9 +38,9 @@ private: #endif #if MBGL_USE_GLX - GLXContext gl_context = nullptr; - XVisualInfo *x_info = nullptr; Display *x_display = nullptr; + XVisualInfo *x_info = nullptr; + GLXContext gl_context = nullptr; Pixmap x_pixmap = 0; GLXPixmap glx_pixmap = 0; #endif diff --git a/test/test.gyp b/test/test.gyp index fd7725bb0..1ebaf6cc1 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -201,6 +201,8 @@ "./headless.cpp", "../common/headless_view.hpp", "../common/headless_view.cpp", + "../common/headless_display.hpp", + "../common/headless_display.cpp", "../common/platform_default.cpp", "./fixtures/fixture_request.cpp", "./fixtures/fixture_log.hpp", From 170ce422ceb20126cd7dc7b184b5edbc0685c7e7 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 6 Oct 2014 15:45:14 -0400 Subject: [PATCH 052/116] forward declare HeadlessDisplay in headless_view.hpp --- common/headless_display.cpp | 2 +- common/headless_display.hpp | 9 +-------- common/headless_view.cpp | 1 + common/headless_view.hpp | 10 +++++++++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/common/headless_display.cpp b/common/headless_display.cpp index 580d3ef58..38d123034 100644 --- a/common/headless_display.cpp +++ b/common/headless_display.cpp @@ -1,4 +1,4 @@ -#include "headless_view.hpp" +#include "headless_display.hpp" #include diff --git a/common/headless_display.hpp b/common/headless_display.hpp index 4fc03da08..0eb41911e 100644 --- a/common/headless_display.hpp +++ b/common/headless_display.hpp @@ -1,14 +1,7 @@ #ifndef MBGL_COMMON_HEADLESS_DISPLAY #define MBGL_COMMON_HEADLESS_DISPLAY -#ifdef __APPLE__ -#define MBGL_USE_CGL 1 -#else -#include -#define MBGL_USE_GLX 1 -#endif - -#include +#include "headless_view.hpp" namespace mbgl { diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 47cf3bd66..86fa445fc 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -1,4 +1,5 @@ #include "headless_view.hpp" +#include "headless_display.hpp" #include diff --git a/common/headless_view.hpp b/common/headless_view.hpp index d1b09ce70..381988ae9 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -1,12 +1,20 @@ #ifndef MBGL_COMMON_HEADLESS_VIEW #define MBGL_COMMON_HEADLESS_VIEW -#include "headless_display.hpp" +#ifdef __APPLE__ +#define MBGL_USE_CGL 1 +#else +#include +#define MBGL_USE_GLX 1 +#endif #include +#include namespace mbgl { +class HeadlessDisplay; + class HeadlessView : public View { public: HeadlessView(); From 8b06b65f35445a1dc8490ede523a23fab46529fa Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 6 Oct 2014 16:53:57 -0400 Subject: [PATCH 053/116] wrap GL/glx.h with undef None, use 0 instead, h/t @jfirebaugh --- common/glx.h | 2 ++ common/headless_display.cpp | 2 +- common/headless_view.cpp | 2 +- common/headless_view.hpp | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 common/glx.h diff --git a/common/glx.h b/common/glx.h new file mode 100644 index 000000000..6b7d9a3df --- /dev/null +++ b/common/glx.h @@ -0,0 +1,2 @@ +#include +#undef None diff --git a/common/headless_display.cpp b/common/headless_display.cpp index 38d123034..b183b0a50 100644 --- a/common/headless_display.cpp +++ b/common/headless_display.cpp @@ -39,7 +39,7 @@ HeadlessDisplay::HeadlessDisplay() { GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, - None + 0 }; x_info = glXChooseVisual(x_display, DefaultScreen(x_display), pixelFormat); diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 86fa445fc..cd8ee685d 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -171,7 +171,7 @@ void HeadlessView::make_inactive() { #endif #if MBGL_USE_GLX - if (!glXMakeCurrent(x_display, None, NULL)) { + if (!glXMakeCurrent(x_display, 0, NULL)) { fprintf(stderr, "Removing OpenGL context failed\n"); } #endif diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 381988ae9..cef4213e9 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -4,7 +4,7 @@ #ifdef __APPLE__ #define MBGL_USE_CGL 1 #else -#include +#include "glx.h" #define MBGL_USE_GLX 1 #endif From 41dac96408a08e3ad2fca7bbe1e7572db85acd13 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 6 Oct 2014 18:05:10 -0400 Subject: [PATCH 054/116] use shared_ptr for HeadlessDisplay in HeadlessView --- common/headless_view.cpp | 12 ++++++------ common/headless_view.hpp | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index cd8ee685d..5e8770b7a 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -5,18 +5,18 @@ namespace mbgl { -HeadlessView::HeadlessView() : display_(new HeadlessDisplay()) { +HeadlessView::HeadlessView() : display_ptr(std::make_shared()) { createContext(); } -HeadlessView::HeadlessView(HeadlessDisplay *display) - : display_(display) { +HeadlessView::HeadlessView(HeadlessDisplay &display) + : display_ptr(std::make_shared(display)) { createContext(); } void HeadlessView::createContext() { #if MBGL_USE_CGL - CGLError error = CGLCreateContext(display_->pixelFormat, NULL, &gl_context); + CGLError error = CGLCreateContext(display_ptr->pixelFormat, NULL, &gl_context); if (error) { fprintf(stderr, "Error creating GL context object\n"); return; @@ -30,8 +30,8 @@ void HeadlessView::createContext() { #endif #if MBGL_USE_GLX - x_display = display_->x_display; - x_info = display_->x_info; + x_display = display_ptr->x_display; + x_info = display_ptr->x_info; gl_context = glXCreateContext(x_display, x_info, 0, GL_TRUE); if (gl_context == nullptr) { diff --git a/common/headless_view.hpp b/common/headless_view.hpp index cef4213e9..5303f2c10 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -11,6 +11,8 @@ #include #include +#include + namespace mbgl { class HeadlessDisplay; @@ -18,7 +20,7 @@ class HeadlessDisplay; class HeadlessView : public View { public: HeadlessView(); - HeadlessView(HeadlessDisplay *display); + HeadlessView(HeadlessDisplay &display); ~HeadlessView(); void createContext(); @@ -36,7 +38,7 @@ private: private: - HeadlessDisplay *display_; + std::shared_ptr display_ptr; #if MBGL_USE_CGL CGLContextObj gl_context; From 5cc6b26229597ef78bd87d21367b75f2051b7314 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 6 Oct 2014 18:24:01 -0400 Subject: [PATCH 055/116] clean up shared_ptr usage --- common/headless_view.cpp | 12 ++++++------ common/headless_view.hpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 5e8770b7a..b8a2fa360 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -5,18 +5,18 @@ namespace mbgl { -HeadlessView::HeadlessView() : display_ptr(std::make_shared()) { +HeadlessView::HeadlessView() : display_ptr_(std::make_shared()) { createContext(); } -HeadlessView::HeadlessView(HeadlessDisplay &display) - : display_ptr(std::make_shared(display)) { +HeadlessView::HeadlessView(std::shared_ptr display_ptr) + : display_ptr_(display_ptr) { createContext(); } void HeadlessView::createContext() { #if MBGL_USE_CGL - CGLError error = CGLCreateContext(display_ptr->pixelFormat, NULL, &gl_context); + CGLError error = CGLCreateContext(display_ptr_->pixelFormat, NULL, &gl_context); if (error) { fprintf(stderr, "Error creating GL context object\n"); return; @@ -30,8 +30,8 @@ void HeadlessView::createContext() { #endif #if MBGL_USE_GLX - x_display = display_ptr->x_display; - x_info = display_ptr->x_info; + x_display = display_ptr_->x_display; + x_info = display_ptr_->x_info; gl_context = glXCreateContext(x_display, x_info, 0, GL_TRUE); if (gl_context == nullptr) { diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 5303f2c10..3ad5a669a 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -20,7 +20,7 @@ class HeadlessDisplay; class HeadlessView : public View { public: HeadlessView(); - HeadlessView(HeadlessDisplay &display); + HeadlessView(std::shared_ptr display_ptr); ~HeadlessView(); void createContext(); @@ -38,7 +38,7 @@ private: private: - std::shared_ptr display_ptr; + std::shared_ptr display_ptr_; #if MBGL_USE_CGL CGLContextObj gl_context; From 36b7bb0c0991b3c5c3a7d001139b120bee854484 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Tue, 7 Oct 2014 16:26:21 -0400 Subject: [PATCH 056/116] clean up shared_ptr usage in HeadlessView --- common/headless_view.cpp | 12 ++++++------ common/headless_view.hpp | 4 ++-- test/headless.cpp | 5 ++++- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index b8a2fa360..d11f63dbd 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -5,18 +5,18 @@ namespace mbgl { -HeadlessView::HeadlessView() : display_ptr_(std::make_shared()) { +HeadlessView::HeadlessView() : display_(std::make_shared()) { createContext(); } -HeadlessView::HeadlessView(std::shared_ptr display_ptr) - : display_ptr_(display_ptr) { +HeadlessView::HeadlessView(std::shared_ptr display) + : display_(display) { createContext(); } void HeadlessView::createContext() { #if MBGL_USE_CGL - CGLError error = CGLCreateContext(display_ptr_->pixelFormat, NULL, &gl_context); + CGLError error = CGLCreateContext(display_->pixelFormat, NULL, &gl_context); if (error) { fprintf(stderr, "Error creating GL context object\n"); return; @@ -30,8 +30,8 @@ void HeadlessView::createContext() { #endif #if MBGL_USE_GLX - x_display = display_ptr_->x_display; - x_info = display_ptr_->x_info; + x_display = display_->x_display; + x_info = display_->x_info; gl_context = glXCreateContext(x_display, x_info, 0, GL_TRUE); if (gl_context == nullptr) { diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 3ad5a669a..13a5b0109 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -20,7 +20,7 @@ class HeadlessDisplay; class HeadlessView : public View { public: HeadlessView(); - HeadlessView(std::shared_ptr display_ptr); + HeadlessView(std::shared_ptr display); ~HeadlessView(); void createContext(); @@ -38,7 +38,7 @@ private: private: - std::shared_ptr display_ptr_; + std::shared_ptr display_; #if MBGL_USE_CGL CGLContextObj gl_context; diff --git a/test/headless.cpp b/test/headless.cpp index d4c4d6036..981a9dcd5 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -10,6 +10,7 @@ #include #include "../common/headless_view.hpp" +#include "../common/headless_display.hpp" #include "./fixtures/fixture_log.hpp" @@ -22,6 +23,8 @@ const std::string base_directory = []{ return fn + "/node_modules/mapbox-gl-test-suite/"; }(); +auto display_ = std::make_shared(); + class HeadlessTest : public ::testing::TestWithParam {}; TEST_P(HeadlessTest, render) { @@ -78,7 +81,7 @@ TEST_P(HeadlessTest, render) { } } - HeadlessView view; + HeadlessView view(display_); Map map(view); map.setStyleJSON(style, base_directory); From 91f40daa6911f57f3dca534080241b46844c71b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 8 Oct 2014 15:27:33 +0200 Subject: [PATCH 057/116] don't do concurrent access to a static member variable in situations where the renderer is used from multiple threads, this causes memory corruption. fixes mapbox/node-mapbox-gl-native#7 --- include/mbgl/style/class_dictionary.hpp | 13 +++++++--- src/style/class_dictionary.cpp | 34 ++++++++++++++++++++----- src/style/style_layer.cpp | 2 +- src/style/style_parser.cpp | 2 +- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/include/mbgl/style/class_dictionary.hpp b/include/mbgl/style/class_dictionary.hpp index c7f9c6a28..ecf80be3e 100644 --- a/include/mbgl/style/class_dictionary.hpp +++ b/include/mbgl/style/class_dictionary.hpp @@ -14,17 +14,22 @@ enum class ClassID : uint32_t { }; class ClassDictionary { +private: + ClassDictionary(); + public: + static ClassDictionary &Get(); + // Returns an ID for a class name. If the class name does not yet have an ID, one is // auto-generated and stored for future reference. - static ClassID Lookup(const std::string &class_name); + ClassID lookup(const std::string &class_name); // Returns either Fallback, Default or Named, depending on the type of the class id. - static ClassID Normalize(ClassID id); + ClassID normalize(ClassID id); private: - static std::unordered_map store; - static uint32_t offset; + std::unordered_map store = { { "", ClassID::Default } }; + uint32_t offset = 0; }; } diff --git a/src/style/class_dictionary.cpp b/src/style/class_dictionary.cpp index 6e1eb5a87..ba7c0d55b 100644 --- a/src/style/class_dictionary.cpp +++ b/src/style/class_dictionary.cpp @@ -1,8 +1,34 @@ #include +#include + namespace mbgl { -ClassID ClassDictionary::Lookup(const std::string &class_name) { +ClassDictionary::ClassDictionary() {} + +ClassDictionary &ClassDictionary::Get() { + // Note: We should eventually switch to uv_key_* functions, but libuv 0.10 doesn't have these + // yet. Instead, we're using the pthread functions directly for now. + static pthread_once_t store_once = PTHREAD_ONCE_INIT; + static pthread_key_t store_key; + + // Create the key. + pthread_once(&store_once, []() { + pthread_key_create(&store_key, [](void *ptr) { + delete reinterpret_cast(ptr); + }); + }); + + ClassDictionary *ptr = reinterpret_cast(pthread_getspecific(store_key)); + if (ptr == nullptr) { + ptr = new ClassDictionary(); + pthread_setspecific(store_key, ptr); + } + + return *ptr; +} + +ClassID ClassDictionary::lookup(const std::string &class_name) { auto it = store.find(class_name); if (it == store.end()) { // Insert the class name into the store. @@ -14,7 +40,7 @@ ClassID ClassDictionary::Lookup(const std::string &class_name) { } } -ClassID ClassDictionary::Normalize(ClassID id) { +ClassID ClassDictionary::normalize(ClassID id) { if (id >= ClassID::Named) { return ClassID::Named; } else { @@ -22,8 +48,4 @@ ClassID ClassDictionary::Normalize(ClassID id) { } } - -std::unordered_map ClassDictionary::store = { { "", ClassID::Default } }; -uint32_t ClassDictionary::offset = 0; - } diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index 4f758fe72..b1b878cc8 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -23,7 +23,7 @@ void StyleLayer::setClasses(const std::vector &class_names, const t for (auto it = class_names.rbegin(); it != class_names.rend(); it++) { const std::string &class_name = *it; // From here on, we're only dealing with IDs to avoid comparing strings all the time. - const ClassID class_id = ClassDictionary::Lookup(class_name); + const ClassID class_id = ClassDictionary::Get().lookup(class_name); applyClassProperties(class_id, already_applied, now, defaultTransition); } diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 7e695e71c..ad7694d9a 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -554,7 +554,7 @@ void StyleParser::parseStyles(JSVal value, std::map &s if (name == "style") { parseStyle(replaceConstant(itr->value), styles[ClassID::Default]); } else if (name.compare(0, 6, "style.") == 0 && name.length() > 6) { - const ClassID class_id = ClassDictionary::Lookup(name.substr(6)); + const ClassID class_id = ClassDictionary::Get().lookup(name.substr(6)); parseStyle(replaceConstant(itr->value), styles[class_id]); } } From 7aea160760a0ad8338d0b3e15419332c1794848c Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 8 Oct 2014 14:47:41 -0400 Subject: [PATCH 058/116] throw std::runtime_error instead of fprintf in HeadlessView, closes #481 --- common/headless_view.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index d11f63dbd..d19db5748 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -2,6 +2,8 @@ #include "headless_display.hpp" #include +#include +#include namespace mbgl { @@ -18,14 +20,12 @@ void HeadlessView::createContext() { #if MBGL_USE_CGL CGLError error = CGLCreateContext(display_->pixelFormat, NULL, &gl_context); if (error) { - fprintf(stderr, "Error creating GL context object\n"); - return; + throw std::runtime_error("Error creating GL context object\n"); } error = CGLEnable(gl_context, kCGLCEMPEngine); if (error != kCGLNoError ) { - fprintf(stderr, "Error enabling OpenGL multithreading\n"); - return; + throw std::runtime_error("Error enabling OpenGL multithreading\n"); } #endif @@ -69,18 +69,18 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { - fprintf(stderr, "Couldn't create framebuffer: "); + std::stringstream error("Couldn't create framebuffer: "); switch (status) { - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: fprintf(stderr, "incomplete attachment\n"); break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: fprintf(stderr, "incomplete missing attachment\n"); break; - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: fprintf(stderr, "incomplete dimensions\n"); break; - case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: fprintf(stderr, "incomplete formats\n"); break; - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: fprintf(stderr, "incomplete draw buffer\n"); break; - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: fprintf(stderr, "incomplete read buffer\n"); break; - case GL_FRAMEBUFFER_UNSUPPORTED: fprintf(stderr, "unsupported\n"); break; - default: fprintf(stderr, "other\n"); break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: (error << "incomplete attachment\n"); break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: error << "incomplete missing attachment\n"; break; + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: error << "incomplete dimensions\n"; break; + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: error << "incomplete formats\n"; break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: error << "incomplete draw buffer\n"; break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: error << "incomplete read buffer\n"; break; + case GL_FRAMEBUFFER_UNSUPPORTED: error << "unsupported\n"; break; + default: error << "other\n"; break; } - return; + throw std::runtime_error(error.str()); } make_inactive(); @@ -151,13 +151,13 @@ void HeadlessView::make_active() { #if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(gl_context); if (error) { - fprintf(stderr, "Switching OpenGL context failed\n"); + throw std::runtime_error("Switching OpenGL context failed\n"); } #endif #if MBGL_USE_GLX if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) { - fprintf(stderr, "Switching OpenGL context failed\n"); + throw std::runtime_error("Switching OpenGL context failed\n"); } #endif } @@ -166,13 +166,13 @@ void HeadlessView::make_inactive() { #if MBGL_USE_CGL CGLError error = CGLSetCurrentContext(nullptr); if (error) { - fprintf(stderr, "Removing OpenGL context failed\n"); + throw std::runtime_error("Removing OpenGL context failed\n"); } #endif #if MBGL_USE_GLX if (!glXMakeCurrent(x_display, 0, NULL)) { - fprintf(stderr, "Removing OpenGL context failed\n"); + throw std::runtime_error("Removing OpenGL context failed\n"); } #endif } From a1bc8c766d6e204a44e2c7171a80330e123b582b Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 8 Oct 2014 15:31:41 -0400 Subject: [PATCH 059/116] add HeadlessView::readPixels, fixes #480 --- common/headless_view.cpp | 30 ++++++++++++++++++++++++------ common/headless_view.hpp | 5 ++++- test/headless.cpp | 8 +------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index d19db5748..9775da1d5 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -7,7 +7,8 @@ namespace mbgl { -HeadlessView::HeadlessView() : display_(std::make_shared()) { +HeadlessView::HeadlessView() + : display_(std::make_shared()) { createContext(); } @@ -43,8 +44,12 @@ void HeadlessView::createContext() { void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { clear_buffers(); - width *= pixelRatio; - height *= pixelRatio; + width_ = width; + height_ = height; + pixelRatio_ = pixelRatio; + + const unsigned int w = width_ * pixelRatio_; + const unsigned int h = height_ * pixelRatio_; #if MBGL_USE_CGL make_active(); @@ -52,12 +57,12 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { // Create depth/stencil buffer glGenRenderbuffersEXT(1, &fbo_depth_stencil); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo_depth_stencil); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, width, height); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, w, h); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); glGenRenderbuffersEXT(1, &fbo_color); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo_color); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, width, height); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, w, h); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); glGenFramebuffersEXT(1, &fbo); @@ -87,11 +92,24 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { #endif #if MBGL_USE_GLX - x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), width, height, 32); + x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), w, h, 32); glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); #endif } +const std::unique_ptr* HeadlessView::readPixels() { + const unsigned int w = width_ * pixelRatio_; + const unsigned int h = height_ * pixelRatio_; + + const std::unique_ptr pixels(new uint32_t[w * h]); + + make_active(); + glReadPixels(0, 0, width_, height_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); + make_inactive(); + + return &pixels; +} + void HeadlessView::clear_buffers() { #if MBGL_USE_CGL make_active(); diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 13a5b0109..b59366349 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -26,6 +26,7 @@ public: void createContext(); void resize(uint16_t width, uint16_t height, float pixelRatio); + const std::unique_ptr* readPixels(); void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); @@ -36,9 +37,11 @@ public: private: void clear_buffers(); - private: std::shared_ptr display_; + uint16_t width_; + uint16_t height_; + float pixelRatio_; #if MBGL_USE_CGL CGLContextObj gl_context; diff --git a/test/headless.cpp b/test/headless.cpp index 981a9dcd5..439a6dcab 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -98,13 +98,7 @@ TEST_P(HeadlessTest, render) { const unsigned int w = width * pixelRatio; const unsigned int h = height * pixelRatio; - const std::unique_ptr pixels(new uint32_t[w * h]); - - map.view.make_active(); - glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); - map.view.make_inactive(); - - const std::string image = util::compress_png(w, h, pixels.get(), true); + const std::string image = util::compress_png(w, h, view.readPixels()->get(), true); util::write_file(actual_image, image); } } From dfb81fe9ce796c06263c4b531cdba4d0e8571808 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Wed, 8 Oct 2014 16:04:13 -0400 Subject: [PATCH 060/116] fix HeadlessView::readPixels return value, ref #480 --- common/headless_view.cpp | 6 +++--- common/headless_view.hpp | 2 +- test/headless.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 9775da1d5..3f945ee6a 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -97,17 +97,17 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { #endif } -const std::unique_ptr* HeadlessView::readPixels() { +const std::unique_ptr HeadlessView::readPixels() { const unsigned int w = width_ * pixelRatio_; const unsigned int h = height_ * pixelRatio_; - const std::unique_ptr pixels(new uint32_t[w * h]); + std::unique_ptr pixels(new uint32_t[w * h]); make_active(); glReadPixels(0, 0, width_, height_, GL_RGBA, GL_UNSIGNED_BYTE, pixels.get()); make_inactive(); - return &pixels; + return pixels; } void HeadlessView::clear_buffers() { diff --git a/common/headless_view.hpp b/common/headless_view.hpp index b59366349..600e9d51f 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -26,7 +26,7 @@ public: void createContext(); void resize(uint16_t width, uint16_t height, float pixelRatio); - const std::unique_ptr* readPixels(); + const std::unique_ptr readPixels(); void notify_map_change(MapChange change, timestamp delay = 0); void make_active(); diff --git a/test/headless.cpp b/test/headless.cpp index 439a6dcab..91533bb36 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -98,7 +98,7 @@ TEST_P(HeadlessTest, render) { const unsigned int w = width * pixelRatio; const unsigned int h = height * pixelRatio; - const std::string image = util::compress_png(w, h, view.readPixels()->get(), true); + const std::string image = util::compress_png(w, h, view.readPixels().get(), true); util::write_file(actual_image, image); } } From 356cf956f413bbf4c4e69a849350f8fc0194356a Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 9 Oct 2014 15:16:01 -0400 Subject: [PATCH 061/116] XInitThreads --- common/headless_display.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/headless_display.cpp b/common/headless_display.cpp index b183b0a50..bbb1c10f5 100644 --- a/common/headless_display.cpp +++ b/common/headless_display.cpp @@ -24,6 +24,10 @@ HeadlessDisplay::HeadlessDisplay() { #endif #if MBGL_USE_GLX + if (!XInitThreads()) { + throw std::runtime_error("Failed to XInitThreads"); + } + x_display = XOpenDisplay(0); if (x_display == nullptr) { From 8f6e8eead12c6b2c2de0ce76fa7df39ca2445006 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 11:40:03 -0400 Subject: [PATCH 062/116] only upload binaries on travis --- setup-libraries.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup-libraries.sh b/setup-libraries.sh index 791db81a8..ce0a230bc 100755 --- a/setup-libraries.sh +++ b/setup-libraries.sh @@ -122,7 +122,7 @@ export LIBUV_VERSION=0.10.28 # setup iOS universal libs ./scripts/make_universal.sh -if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then +if [ ! -z "${TRAVIS:-}" ] && [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then tar -zcf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-universal aws s3 cp --acl public-read out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ tar -zcf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libcpp-x86_64-macosx @@ -154,7 +154,7 @@ export LIBUV_VERSION=0.10.28 if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi -if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then +if [ ! -z "${TRAVIS:-}" ] && [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then if ! tar --compare -zf out/build-cpp11-libstdcpp-gcc-x86_64-linux.tar.gz ; then tar -zcf out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz out/build-cpp11-libstdcpp-gcc-x86_64-linux aws s3 cp --acl public-read out/build-cpp11-libstdcpp-gcc-x86_64-linux_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/ From c458f246fa965407dd4cde44444f6017eac20171 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 12:52:24 -0400 Subject: [PATCH 063/116] bump mapbox-gl-cocoa to match master --- ios/mapbox-gl-cocoa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 1aa3db196..bc2c5fe69 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 1aa3db196b210c6880df6b2aff5e0d924aa78764 +Subproject commit bc2c5fe6974fa99ea4816e9e793757cc17066594 From ee68c091a858d70b8c66277cb4d3d9cbec1a9b14 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 13:25:26 -0400 Subject: [PATCH 064/116] adjust file_request_baton and http_request for libuv 0.10 api --- src/storage/file_request_baton.cpp | 11 ++++++----- src/storage/http_request.cpp | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index 127c78f3e..af4497689 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -29,7 +29,7 @@ void FileRequestBaton::notify_error(uv_fs_t *req) { if (ptr->request && req->result < 0 && !ptr->canceled && req->result != UV_ECANCELED) { ptr->request->response = std::unique_ptr(new Response); ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500; - ptr->request->response->message = uv_strerror(int(req->result)); + ptr->request->response->message = uv_strerror(uv_last_error(req->loop)); ptr->request->notify(); } } @@ -71,13 +71,14 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_req_cleanup(req); uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { - if (static_cast(req->ptr)->st_size > std::numeric_limits::max()) { + if (static_cast(req->ptr)->st_size > std::numeric_limits::max()) { // File is too large for us to open this way because uv_buf's only support unsigned // ints as maximum size. + const uv_err_t error = {UV_EFBIG, 0}; if (ptr->request) { ptr->request->response = std::unique_ptr(new Response); - ptr->request->response->code = UV_EFBIG; - ptr->request->response->message = uv_strerror(UV_EFBIG); + ptr->request->response->code = error.code; + ptr->request->response->message = uv_strerror(error); ptr->request->notify(); } @@ -85,7 +86,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { uv_fs_close(req->loop, req, ptr->fd, file_closed); } else { const unsigned int size = - (unsigned int)(static_cast(req->ptr)->st_size); + (unsigned int)(static_cast(req->ptr)->st_size); ptr->body.resize(size); ptr->buffer = uv_buf_init(const_cast(ptr->body.data()), size); uv_fs_req_cleanup(req); diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 1b799d489..4dcb12604 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -77,7 +77,7 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr &&res) { http_baton->response = std::move(res); http_baton->async->data = new util::ptr(http_baton); - uv_async_init(loop, http_baton->async, [](uv_async_t *async) { + uv_async_init(loop, http_baton->async, [](uv_async_t *async, int status) { util::ptr &http_baton = *(util::ptr *)async->data; if (http_baton->request) { @@ -193,7 +193,7 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr &&res, uint64_t tim backoff_timer = new uv_timer_t(); uv_timer_init(loop, backoff_timer); backoff_timer->data = new RetryBaton(this, std::move(res)); - uv_timer_start(backoff_timer, [](uv_timer_t *timer) { + uv_timer_start(backoff_timer, [](uv_timer_t *timer, int status) { std::unique_ptr pair { static_cast(timer->data) }; pair->first->startHTTPRequest(std::move(pair->second)); pair->first->backoff_timer = nullptr; From 35f2c7fe23fd9265e22897bbcb6bcef66e9e7032 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 14:37:10 -0400 Subject: [PATCH 065/116] switch http_request_baton_curl to libuv 0.10 api --- common/http_request_baton_curl.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/http_request_baton_curl.cpp b/common/http_request_baton_curl.cpp index 772aeb86e..726198d1d 100644 --- a/common/http_request_baton_curl.cpp +++ b/common/http_request_baton_curl.cpp @@ -253,7 +253,7 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void * return 0; } -void on_timeout(uv_timer_t *) { +void on_timeout(uv_timer_t *, int status) { int running_handles; CURLMcode error = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); if (error != CURLM_OK) { @@ -442,7 +442,6 @@ void stop_request(void *const ptr) { void create_thread() { uv_mutex_init(&share_mutex); - uv_loop_init(&loop); uv_messenger_init(&loop, &start_messenger, start_request); uv_messenger_init(&loop, &stop_messenger, stop_request); uv_thread_create(&thread, thread_init, nullptr); From 6e8e50e371b519e86955f004f53ce622923c5aa6 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 14:47:33 -0400 Subject: [PATCH 066/116] call on_timeout with status 0 (success) --- common/http_request_baton_curl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/http_request_baton_curl.cpp b/common/http_request_baton_curl.cpp index 726198d1d..3419dcc16 100644 --- a/common/http_request_baton_curl.cpp +++ b/common/http_request_baton_curl.cpp @@ -263,7 +263,7 @@ void on_timeout(uv_timer_t *, int status) { void start_timeout(CURLM *, long timeout_ms, void *) { if (timeout_ms <= 0) { - on_timeout(&timeout); + on_timeout(&timeout, 0); } else { uv_timer_start(&timeout, on_timeout, timeout_ms, 0); } From b3d064d1bbdfce42f394e96c63371b7f313b60d0 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Fri, 10 Oct 2014 18:34:15 -0400 Subject: [PATCH 067/116] use node-mapbox-gl-native AWS bucket for travis caching --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2bf164c6..b50a63eaa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ env: - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" - - AWS_S3_BUCKET=mapbox-gl-testing + - AWS_S3_BUCKET: 'node-mapbox-gl-native' before_install: - source ./scripts/flags.sh From 5d46caaf87e315a4c221e8c5f0ed10236b244b43 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Sat, 11 Oct 2014 12:48:34 -0400 Subject: [PATCH 068/116] use node-mapbox-gl-native AWS keys --- .travis.yml | 4 ++-- travis/travis-resources.template | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index b50a63eaa..79922f955 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,8 @@ matrix: env: global: - - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" - - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" + - secure: "2ie/lwLSSUpx9q98geDlT/BxKYExK18i3PIgaPpgojnWPOOYr1S9TQfwggxd4FdU3eUwgq8dxuW9NuH2qmEBYvnB9BTcGSoNhrnpDZ0lrA/dFOArDHEheyLz8XirTauzciq+r1pbF0dld5uVaxZfNzbI6labDZPjf/jjSDgVc4c=" + - secure: "RsEbBA2yhdg2MYvMucJ1mmfm99UjEaC47NcYimy0Fsvzjfoe1vYrSJlYzyb9SIOj2URo8v4sAFWUbD+RTX/5pBgXCzSzEKh6ZZ1Sd7O05sx5dz8M3kRzo4asm9di8kAI842eCW/n6EhlykQBvtgA00os3ivG0Gh6KS/WebMsXsM=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" - AWS_S3_BUCKET: 'node-mapbox-gl-native' diff --git a/travis/travis-resources.template b/travis/travis-resources.template index afe0478e3..0145e69ea 100644 --- a/travis/travis-resources.template +++ b/travis/travis-resources.template @@ -1,7 +1,7 @@ { "AWSTemplateFormatVersion": "2010-09-09", - "Description": "mapbox-gl-native travis resources", + "Description": "node-mapbox-gl-native travis resources", "Resources": { "BuildUser": { "Type": "AWS::IAM::User", @@ -17,7 +17,7 @@ ], "Effect": "Allow", "Resource": [ - "arn:aws:s3:::mapbox-gl-testing" + "arn:aws:s3:::node-mapbox-gl-native" ] } ] @@ -37,7 +37,7 @@ ], "Effect": "Allow", "Resource": [ - "arn:aws:s3:::mapbox-gl-testing/*" + "arn:aws:s3:::node-mapbox-gl-native/*" ] } ] From 38023928ad44ef86e84c045c77c571ce252306dc Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Sat, 11 Oct 2014 13:47:57 -0400 Subject: [PATCH 069/116] fix node-mapbox-gl-native AWS keys --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79922f955..5a3345971 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,8 @@ matrix: env: global: - - secure: "2ie/lwLSSUpx9q98geDlT/BxKYExK18i3PIgaPpgojnWPOOYr1S9TQfwggxd4FdU3eUwgq8dxuW9NuH2qmEBYvnB9BTcGSoNhrnpDZ0lrA/dFOArDHEheyLz8XirTauzciq+r1pbF0dld5uVaxZfNzbI6labDZPjf/jjSDgVc4c=" - - secure: "RsEbBA2yhdg2MYvMucJ1mmfm99UjEaC47NcYimy0Fsvzjfoe1vYrSJlYzyb9SIOj2URo8v4sAFWUbD+RTX/5pBgXCzSzEKh6ZZ1Sd7O05sx5dz8M3kRzo4asm9di8kAI842eCW/n6EhlykQBvtgA00os3ivG0Gh6KS/WebMsXsM=" + - secure: "HPlPuLk531F7bCyADMcxQ+I1CfGhJlhX9A3q3auNCdLsjqaZbktaCIGuq4R1IPZz0UTtO8RfrTfVaoktyZdq2QyU3iD8oj6BeZ/Jypr4TCBJxI5IeyU3gyPMFHqUYIJuHL9k40Xu7Dhf4HT123zr8KoeVqCHauZP1/TumA0nezg=" + - secure: "R/+uOeccl7GqjJbknailAV7VtjAtGwHHM9xToVnhfPVUXp9fzJs+oNk3IWcs3Eg4sw4WsYxXRfbCQG9bA3MnPlTOsxETGRioO9CAuXap6mwcwNAzeWuq7ePFki2u01pJGQD5b6WFqBCdnAQ4o2SgHgGzhs0TJzYd9tONQxSmkCI=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" - AWS_S3_BUCKET: 'node-mapbox-gl-native' From ed93d750ad69af642bbf87685f55c21c7dcd4271 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Oct 2014 16:00:31 -0400 Subject: [PATCH 070/116] add policies for mapbox-gl-testing bucket --- travis/travis-resources.template | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/travis/travis-resources.template b/travis/travis-resources.template index 0145e69ea..2891fcf59 100644 --- a/travis/travis-resources.template +++ b/travis/travis-resources.template @@ -42,6 +42,42 @@ } ] } + }, + { + "PolicyName": "list testing", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:ListBucket" + ], + "Effect": "Allow", + "Resource": [ + "arn:aws:s3:::mapbox-gl-testing" + ] + } + ] + } + }, + { + "PolicyName": "build testing", + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:DeleteObject", + "s3:GetObject", + "s3:GetObjectAcl", + "s3:PutObject", + "s3:PutObjectAcl" + ], + "Effect": "Allow", + "Resource": [ + "arn:aws:s3:::mapbox-gl-testing/*" + ] + } + ] + } } ] } From 21f642015197f2bb7f406f191a71cb0e875ede05 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Oct 2014 16:05:20 -0400 Subject: [PATCH 071/116] fix policy names --- travis/travis-resources.template | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/travis/travis-resources.template b/travis/travis-resources.template index 2891fcf59..e1b0cff8c 100644 --- a/travis/travis-resources.template +++ b/travis/travis-resources.template @@ -44,7 +44,7 @@ } }, { - "PolicyName": "list testing", + "PolicyName": "list-testing", "PolicyDocument": { "Statement": [ { @@ -60,7 +60,7 @@ } }, { - "PolicyName": "build testing", + "PolicyName": "build-testing", "PolicyDocument": { "Statement": [ { From aa4828762c2876c1842ee7a9d6be9dfa8173a31e Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Oct 2014 16:10:47 -0400 Subject: [PATCH 072/116] add int status arg to uv_messenger_callback --- src/util/uv-messenger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/uv-messenger.c b/src/util/uv-messenger.c index a25c84dc5..01c37dfd3 100644 --- a/src/util/uv-messenger.c +++ b/src/util/uv-messenger.c @@ -8,7 +8,7 @@ typedef struct { void *queue[2]; } uv__messenger_item_t; -void uv__messenger_callback(uv_async_t *async) { +void uv__messenger_callback(uv_async_t *async, int status) { uv_messenger_t *msgr = (uv_messenger_t *)async->data; uv__messenger_item_t *item; From c1e4d8554fac803304361550357e90d78d5acd46 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Mon, 13 Oct 2014 16:37:32 -0400 Subject: [PATCH 073/116] bump mapbox-gl-cocoa submodule with make_inactive fix --- ios/mapbox-gl-cocoa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index bc2c5fe69..dd4f4cac2 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit bc2c5fe6974fa99ea4816e9e793757cc17066594 +Subproject commit dd4f4cac252e0e9af5fbf73980370fc1528079ad From 9ff1d9e3bdc05817d9f9de820e1d07dd17a699cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 15 Oct 2014 16:08:36 +0200 Subject: [PATCH 074/116] experimental pbuffer support [skip ci] --- common/headless_display.cpp | 32 +++++++++++++++------- common/headless_display.hpp | 2 +- common/headless_view.cpp | 54 +++++++++++++++++++++++++------------ common/headless_view.hpp | 5 ++-- 4 files changed, 62 insertions(+), 31 deletions(-) diff --git a/common/headless_display.cpp b/common/headless_display.cpp index bbb1c10f5..a93834752 100644 --- a/common/headless_display.cpp +++ b/common/headless_display.cpp @@ -27,30 +27,42 @@ HeadlessDisplay::HeadlessDisplay() { if (!XInitThreads()) { throw std::runtime_error("Failed to XInitThreads"); } - - x_display = XOpenDisplay(0); + x_display = XOpenDisplay(nullptr); if (x_display == nullptr) { throw std::runtime_error("Failed to open X display"); } + const char *extensions = (char *)glXQueryServerString(x_display, DefaultScreen(x_display), GLX_EXTENSIONS); + if (!extensions) { + throw std::runtime_error("Cannot read GLX extensions"); + } + if (!strstr(extensions,"GLX_SGIX_fbconfig")) { + throw std::runtime_error("Extension GLX_SGIX_fbconfig was not found"); + } + if (!strstr(extensions, "GLX_SGIX_pbuffer")) { + throw std::runtime_error("Cannot find glXCreateContextAttribsARB"); + } + + static int pixelFormat[] = { - GLX_RGBA, - GLX_DOUBLEBUFFER, + GLX_DOUBLEBUFFER, False, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, 8, - 0 + None }; - x_info = glXChooseVisual(x_display, DefaultScreen(x_display), pixelFormat); - - if (x_info == nullptr) { - throw std::runtime_error("Error pixel format"); + int configs = 0; + fb_configs = glXChooseFBConfig(x_display, DefaultScreen(x_display), pixelFormat, &configs); + if (configs <= 0) { + throw std::runtime_error("No Framebuffer configurations"); } + + XSync(x_display, False); #endif } @@ -60,7 +72,7 @@ HeadlessDisplay::~HeadlessDisplay() { #endif #if MBGL_USE_GLX - XFree(x_info); + XFree(fb_configs); XCloseDisplay(x_display); #endif } diff --git a/common/headless_display.hpp b/common/headless_display.hpp index 0eb41911e..5b33fd699 100644 --- a/common/headless_display.hpp +++ b/common/headless_display.hpp @@ -16,7 +16,7 @@ public: #if MBGL_USE_GLX Display *x_display = nullptr; - XVisualInfo *x_info = nullptr; + GLXFBConfig *fb_configs = nullptr; #endif }; diff --git a/common/headless_view.cpp b/common/headless_view.cpp index c2084ac90..dd62d9d23 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -5,6 +5,11 @@ #include #include +#if MBGL_USE_GLX +typedef GLXContext (*glXCreateContextAttribsARBProc)(Display *, GLXFBConfig, GLXContext, Bool, const int *); +static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = nullptr; +#endif + namespace mbgl { HeadlessView::HeadlessView() @@ -31,13 +36,29 @@ void HeadlessView::createContext() { #endif #if MBGL_USE_GLX - x_display = display_->x_display; - x_info = display_->x_info; + if (glXCreateContextAttribsARB == nullptr) { + glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); + } + if (glXCreateContextAttribsARB == nullptr) { + throw std::runtime_error("Cannot find glXCreateContextAttribsARB"); + } - gl_context = glXCreateContext(x_display, x_info, 0, GL_TRUE); + x_display = display_->x_display; + fb_configs = display_->fb_configs; + + + int attributes[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, 2, + GLX_CONTEXT_MINOR_VERSION_ARB, 1, + GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, + GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + None + }; + gl_context = glXCreateContextAttribsARB(x_display, fb_configs[0], 0, True, attributes); if (gl_context == nullptr) { throw std::runtime_error("Error creating GL context object"); } + #endif } @@ -92,8 +113,12 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { #endif #if MBGL_USE_GLX - x_pixmap = XCreatePixmap(x_display, DefaultRootWindow(x_display), w, h, 32); - glx_pixmap = glXCreateGLXPixmap(x_display, x_info, x_pixmap); + int attributes[] = { + GLX_PBUFFER_WIDTH, w, + GLX_PBUFFER_HEIGHT, h, + None + }; + GLXPbuffer pbuffer = glXCreatePbuffer(x_display, fg_configs[0], attributes); #endif } @@ -135,17 +160,12 @@ void HeadlessView::clear_buffers() { #endif #if MBGL_USE_GLX - if (glx_pixmap) { - glXDestroyGLXPixmap(x_display, glx_pixmap); - glx_pixmap = 0; - } - - if (x_pixmap) { - XFreePixmap(x_display, x_pixmap); - x_pixmap = 0; - } - make_inactive(); + + if (glx_pbuffer) { + glXDestroyPbuffer(x_display, glx_pbuffer); + glx_pbuffer = 0; + } #endif } @@ -178,7 +198,7 @@ void HeadlessView::make_active() { #endif #if MBGL_USE_GLX - if (!glXMakeCurrent(x_display, glx_pixmap, gl_context)) { + if (!glXMakeContextCurrent(x_display, glx_pbuffer, glx_pbuffer, gl_context)) { throw std::runtime_error("Switching OpenGL context failed\n"); } #endif @@ -193,7 +213,7 @@ void HeadlessView::make_inactive() { #endif #if MBGL_USE_GLX - if (!glXMakeCurrent(x_display, 0, NULL)) { + if (!glXMakeContextCurrent(x_display, 0, 0, nullptr)) { throw std::runtime_error("Removing OpenGL context failed\n"); } #endif diff --git a/common/headless_view.hpp b/common/headless_view.hpp index d2fe75382..9ba25c73f 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -53,10 +53,9 @@ private: #if MBGL_USE_GLX Display *x_display = nullptr; - XVisualInfo *x_info = nullptr; + GLXFBConfig *fb_configs = nullptr; GLXContext gl_context = nullptr; - Pixmap x_pixmap = 0; - GLXPixmap glx_pixmap = 0; + GLXPBuffer glx_pbuffer = 0; #endif }; From 8eda68dd8a24ee5025db82d02f952fdd5921eea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 15 Oct 2014 14:20:28 +0000 Subject: [PATCH 075/116] fix errors that prevented compilation/running --- common/headless_display.cpp | 1 + common/headless_view.cpp | 2 +- common/headless_view.hpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/headless_display.cpp b/common/headless_display.cpp index a93834752..3e30d6274 100644 --- a/common/headless_display.cpp +++ b/common/headless_display.cpp @@ -1,5 +1,6 @@ #include "headless_display.hpp" +#include #include namespace mbgl { diff --git a/common/headless_view.cpp b/common/headless_view.cpp index dd62d9d23..51196faed 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -118,7 +118,7 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { GLX_PBUFFER_HEIGHT, h, None }; - GLXPbuffer pbuffer = glXCreatePbuffer(x_display, fg_configs[0], attributes); + glx_pbuffer = glXCreatePbuffer(x_display, fb_configs[0], attributes); #endif } diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 9ba25c73f..ec76f1a07 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -4,7 +4,7 @@ #ifdef __APPLE__ #define MBGL_USE_CGL 1 #else -#include "glx.h" +#include #define MBGL_USE_GLX 1 #endif @@ -55,7 +55,7 @@ private: Display *x_display = nullptr; GLXFBConfig *fb_configs = nullptr; GLXContext gl_context = nullptr; - GLXPBuffer glx_pbuffer = 0; + GLXPbuffer glx_pbuffer = 0; #endif }; From 5f40d27256b5da164bfdd19253ca4c2078b1800a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Wed, 15 Oct 2014 14:31:19 +0000 Subject: [PATCH 076/116] cast to correct int type --- common/headless_view.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 51196faed..c482bbd8b 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -114,8 +114,8 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { #if MBGL_USE_GLX int attributes[] = { - GLX_PBUFFER_WIDTH, w, - GLX_PBUFFER_HEIGHT, h, + GLX_PBUFFER_WIDTH, static_cast(w), + GLX_PBUFFER_HEIGHT, static_cast(h), None }; glx_pbuffer = glXCreatePbuffer(x_display, fb_configs[0], attributes); From ee54220c7df2863dbbda191ad666416a6c84531b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 15 Oct 2014 09:56:57 -0700 Subject: [PATCH 077/116] lower our expectations towards the pbuffer and use framebuffers instead --- common/headless_display.cpp | 12 ++---------- common/headless_view.cpp | 38 ++++++++++++++----------------------- common/headless_view.hpp | 8 +++++--- 3 files changed, 21 insertions(+), 37 deletions(-) diff --git a/common/headless_display.cpp b/common/headless_display.cpp index 3e30d6274..3aaf2020b 100644 --- a/common/headless_display.cpp +++ b/common/headless_display.cpp @@ -45,15 +45,9 @@ HeadlessDisplay::HeadlessDisplay() { throw std::runtime_error("Cannot find glXCreateContextAttribsARB"); } - + // We're creating a dummy pbuffer anyway that we're not using. static int pixelFormat[] = { - GLX_DOUBLEBUFFER, False, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_ALPHA_SIZE, 8, - GLX_DEPTH_SIZE, 24, - GLX_STENCIL_SIZE, 8, + GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, None }; @@ -62,8 +56,6 @@ HeadlessDisplay::HeadlessDisplay() { if (configs <= 0) { throw std::runtime_error("No Framebuffer configurations"); } - - XSync(x_display, False); #endif } diff --git a/common/headless_view.cpp b/common/headless_view.cpp index c482bbd8b..7b739e1d6 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -47,18 +47,25 @@ void HeadlessView::createContext() { fb_configs = display_->fb_configs; - int attributes[] = { + int context_attributes[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 2, GLX_CONTEXT_MINOR_VERSION_ARB, 1, GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, None }; - gl_context = glXCreateContextAttribsARB(x_display, fb_configs[0], 0, True, attributes); + gl_context = glXCreateContextAttribsARB(x_display, fb_configs[0], 0, True, context_attributes); if (gl_context == nullptr) { throw std::runtime_error("Error creating GL context object"); } + int pbuffer_attributes[] = { + GLX_PBUFFER_WIDTH, 32, + GLX_PBUFFER_HEIGHT, 32, + None + }; + glx_pbuffer = glXCreatePbuffer(x_display, fb_configs[0], pbuffer_attributes); + #endif } @@ -72,7 +79,6 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { const unsigned int w = width_ * pixelRatio_; const unsigned int h = height_ * pixelRatio_; -#if MBGL_USE_CGL make_active(); // Create depth/stencil buffer @@ -110,16 +116,6 @@ void HeadlessView::resize(uint16_t width, uint16_t height, float pixelRatio) { } make_inactive(); -#endif - -#if MBGL_USE_GLX - int attributes[] = { - GLX_PBUFFER_WIDTH, static_cast(w), - GLX_PBUFFER_HEIGHT, static_cast(h), - None - }; - glx_pbuffer = glXCreatePbuffer(x_display, fb_configs[0], attributes); -#endif } const std::unique_ptr HeadlessView::readPixels() { @@ -136,7 +132,6 @@ const std::unique_ptr HeadlessView::readPixels() { } void HeadlessView::clear_buffers() { -#if MBGL_USE_CGL make_active(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); @@ -157,16 +152,6 @@ void HeadlessView::clear_buffers() { } make_inactive(); -#endif - -#if MBGL_USE_GLX - make_inactive(); - - if (glx_pbuffer) { - glXDestroyPbuffer(x_display, glx_pbuffer); - glx_pbuffer = 0; - } -#endif } HeadlessView::~HeadlessView() { @@ -177,6 +162,11 @@ HeadlessView::~HeadlessView() { #endif #if MBGL_USE_GLX + if (glx_pbuffer) { + glXDestroyPbuffer(x_display, glx_pbuffer); + glx_pbuffer = 0; + } + glXDestroyContext(x_display, gl_context); #endif } diff --git a/common/headless_view.hpp b/common/headless_view.hpp index ec76f1a07..195364db6 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -4,6 +4,7 @@ #ifdef __APPLE__ #define MBGL_USE_CGL 1 #else +#define GL_GLEXT_PROTOTYPES #include #define MBGL_USE_GLX 1 #endif @@ -46,9 +47,6 @@ private: #if MBGL_USE_CGL CGLContextObj gl_context; - GLuint fbo = 0; - GLuint fbo_depth_stencil = 0; - GLuint fbo_color = 0; #endif #if MBGL_USE_GLX @@ -57,6 +55,10 @@ private: GLXContext gl_context = nullptr; GLXPbuffer glx_pbuffer = 0; #endif + + GLuint fbo = 0; + GLuint fbo_depth_stencil = 0; + GLuint fbo_color = 0; }; } From 8b08772d33ae37f05cf0ed4c5ce5c884cb8fab2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 03:49:29 -0700 Subject: [PATCH 078/116] first attempt to create an opengl core profile version before falling back to legacy opengl contexts --- common/headless_view.cpp | 99 ++++++++++++++++++++++++++++++++-------- common/headless_view.hpp | 2 +- 2 files changed, 82 insertions(+), 19 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 7b739e1d6..f746d97c3 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -6,8 +6,9 @@ #include #if MBGL_USE_GLX -typedef GLXContext (*glXCreateContextAttribsARBProc)(Display *, GLXFBConfig, GLXContext, Bool, const int *); -static glXCreateContextAttribsARBProc glXCreateContextAttribsARB = nullptr; +#ifdef GLX_ARB_create_context +static PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = nullptr; +#endif #endif namespace mbgl { @@ -22,6 +23,59 @@ HeadlessView::HeadlessView(std::shared_ptr display) createContext(); } + +#if MBGL_USE_GLX +#ifdef GLX_ARB_create_context + +// These are all of the OpenGL Core profile version that we know about. +struct core_profile_version { int major, minor; }; +static const core_profile_version core_profile_versions[] = { + {4, 5}, + {4, 4}, + {4, 3}, + {4, 2}, + {4, 1}, + {4, 0}, + {3, 3}, + {3, 2}, + {3, 1}, + {3, 0}, + {0, 0}, +}; + +GLXContext createCoreProfile(Display *dpy, GLXFBConfig fbconfig) { + static bool context_creation_failed = false; + GLXContext ctx = 0; + + // Set the Error Handler to avoid crashing the program when the context creation fails. + // It is expected that some context creation attempts fail, e.g. because the OpenGL + // implementation does not support the version we're requesting. + int (*previous_error_handler)(Display *, XErrorEvent *) = XSetErrorHandler([](Display *, XErrorEvent *) { + context_creation_failed = true; + return 0; + }); + + // Try to create core profiles from the highest known version on down. + for (int i = 0; !ctx && core_profile_versions[i].major; i++) { + context_creation_failed = false; + const int context_flags[] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, core_profile_versions[i].major, + GLX_CONTEXT_MINOR_VERSION_ARB, core_profile_versions[i].minor, + None + }; + ctx = glXCreateContextAttribsARB(dpy, fbconfig, 0, True, context_flags); + if (context_creation_failed) { + ctx = 0; + } + } + + // Restore the old error handler. + XSetErrorHandler(previous_error_handler); + return ctx; +} +#endif +#endif + void HeadlessView::createContext() { #if MBGL_USE_CGL CGLError error = CGLCreateContext(display_->pixelFormat, NULL, &gl_context); @@ -36,36 +90,45 @@ void HeadlessView::createContext() { #endif #if MBGL_USE_GLX +#ifdef GLX_ARB_create_context if (glXCreateContextAttribsARB == nullptr) { - glXCreateContextAttribsARB = (glXCreateContextAttribsARBProc)glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); - } - if (glXCreateContextAttribsARB == nullptr) { - throw std::runtime_error("Cannot find glXCreateContextAttribsARB"); + glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddressARB((const GLubyte *)"glXCreateContextAttribsARB"); } +#endif x_display = display_->x_display; fb_configs = display_->fb_configs; +#ifdef GLX_ARB_create_context + if (glXCreateContextAttribsARB) { + // Try to create a core profile context. + gl_context = createCoreProfile(x_display, fb_configs[0]); + } +#endif - int context_attributes[] = { - GLX_CONTEXT_MAJOR_VERSION_ARB, 2, - GLX_CONTEXT_MINOR_VERSION_ARB, 1, - GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB, - GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, - None - }; - gl_context = glXCreateContextAttribsARB(x_display, fb_configs[0], 0, True, context_attributes); - if (gl_context == nullptr) { + if (!gl_context) { + // Try to create a legacy context + gl_context = glXCreateNewContext(x_display, fb_configs[0], GLX_RGBA_TYPE, 0, True); + if (gl_context) { + if (!glXIsDirect(x_display, gl_context)) { + glXDestroyContext(x_display, gl_context); + gl_context = 0; + } + } + } + + if (gl_context == 0) { throw std::runtime_error("Error creating GL context object"); } + // Create a dummy pbuffer. We will render to framebuffers anyway, but we need a pbuffer to + // activate the context. int pbuffer_attributes[] = { - GLX_PBUFFER_WIDTH, 32, - GLX_PBUFFER_HEIGHT, 32, + GLX_PBUFFER_WIDTH, 8, + GLX_PBUFFER_HEIGHT, 8, None }; glx_pbuffer = glXCreatePbuffer(x_display, fb_configs[0], pbuffer_attributes); - #endif } diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 195364db6..6e4ddcd9e 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -52,7 +52,7 @@ private: #if MBGL_USE_GLX Display *x_display = nullptr; GLXFBConfig *fb_configs = nullptr; - GLXContext gl_context = nullptr; + GLXContext gl_context = 0; GLXPbuffer glx_pbuffer = 0; #endif From 4bc56eac24d399e5c58a7f9a936fe85a71180915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 04:26:50 -0700 Subject: [PATCH 079/116] we now always use the fbo [skip ci] --- common/headless_view.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index f746d97c3..6a5a2dc00 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -275,11 +275,7 @@ void HeadlessView::make_inactive() { void HeadlessView::swap() {} unsigned int HeadlessView::root_fbo() { -#if MBGL_USE_CGL return fbo; -#endif - - return 0; } } From 97986f603f5af6b12deb4cdb4e91cd5035457c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 04:27:30 -0700 Subject: [PATCH 080/116] we don't need a root_fbo function anymore [skip ci] --- common/headless_view.cpp | 4 ---- common/headless_view.hpp | 1 - include/mbgl/map/view.hpp | 6 ------ 3 files changed, 11 deletions(-) diff --git a/common/headless_view.cpp b/common/headless_view.cpp index 6a5a2dc00..d1d13db5f 100644 --- a/common/headless_view.cpp +++ b/common/headless_view.cpp @@ -274,9 +274,5 @@ void HeadlessView::make_inactive() { void HeadlessView::swap() {} -unsigned int HeadlessView::root_fbo() { - return fbo; -} - } diff --git a/common/headless_view.hpp b/common/headless_view.hpp index 6e4ddcd9e..c0baddb88 100644 --- a/common/headless_view.hpp +++ b/common/headless_view.hpp @@ -34,7 +34,6 @@ public: void make_active(); void make_inactive(); void swap(); - unsigned int root_fbo(); private: void clear_buffers(); diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index 395a05d43..b567cd424 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -39,12 +39,6 @@ public: // thread. This is called once just before the rendering thread terminates. virtual void make_inactive() = 0; - // Returns the base framebuffer object, if any, and 0 if using the system - // provided framebuffer. - virtual unsigned int root_fbo() { - return 0; - } - virtual void notify() = 0; // Notifies a watcher of map x/y/scale/rotation changes. From e211ee620d2cd64840019d682f61800e26dba7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 05:44:26 -0700 Subject: [PATCH 081/116] add more instrumentation and code folding to travis builds --- scripts/flags.sh | 11 +++++++++++ scripts/travis_before_install.sh | 13 +++++++++++++ scripts/travis_install.sh | 1 + scripts/travis_script.sh | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+) diff --git a/scripts/flags.sh b/scripts/flags.sh index 58aee18a0..21313b24c 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -1,7 +1,18 @@ #!/usr/bin/env bash +function mapbox_time { + local NAME=$1 ; shift + travis_fold start "${NAME}" + travis_time_start + "$@" + travis_time_finish + travis_fold end "${NAME}" +} + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then export DISPLAY=:99.0 + + mapbox_time "start xvfb" \ sh -e /etc/init.d/xvfb start # use g++ that supports c++11 diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index e9b3384de..ab955f6aa 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -10,18 +10,31 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then if [[ `lsb_release -r` =~ "12.04" ]]; then sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test fi + + mapbox_time "apt update" \ sudo apt-get update -y + + mapbox_time "install gcc" \ sudo apt-get -y install gcc-4.8 g++-4.8 + + mapbox_time "install build tools" \ sudo apt-get -y install git build-essential zlib1g-dev automake \ libtool xutils-dev make cmake pkg-config python-pip + + mapbox_time "install opengl" \ sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev \ x11proto-xext-dev libxrandr-dev \ x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev + + mapbox_time "install awscli" \ sudo pip install awscli elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # # install OS X dependencies # + mapbox_time "install build tools" \ brew install autoconf automake libtool makedepend cmake pkg-config node git + + mapbox_time "install awscli" \ sudo pip install awscli fi diff --git a/scripts/travis_install.sh b/scripts/travis_install.sh index eca24e719..d0539946b 100755 --- a/scripts/travis_install.sh +++ b/scripts/travis_install.sh @@ -4,5 +4,6 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # we'll need the test suite on Linux # + mapbox_time "install test suite" \ npm install git+https://github.com/mapbox/mapbox-gl-test-suite.git fi diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index f1cad6b9d..1c61dfa9d 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -7,12 +7,20 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # build & test Linux # + mapbox_time "compile program" \ make linux -j4 BUILDTYPE=${BUILDTYPE} + + mapbox_time "install tests" \ make test -j4 BUILDTYPE=${BUILDTYPE} + + mapbox_time "run tests" \ ./scripts/run_tests.sh + + mapbox_time "compare results" \ (cd ./node_modules/mapbox-gl-test-suite/ && (./bin/compare_images.js || true)) if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then + mapbox_time "deploy results" \ (cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh) fi @@ -20,13 +28,23 @@ elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # # build OS X # + mapbox_time "create osx project" \ make xproj-cli + + mapbox_time "build osx" \ xcodebuild -project ./build/macosx/mapboxgl-app.xcodeproj -jobs 4 + # # build iOS # git submodule init + + mapbox_time "load submodules" \ git submodule update + + mapbox_time "create ios project" \ make iproj-cli + + mapbox_time "build ios" \ xcodebuild -project ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -jobs 4 fi From 3d6304e8c3d9433199ae1b928fcf935ce1a43bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 05:50:10 -0700 Subject: [PATCH 082/116] remove spaces from fold command and put in separate file --- scripts/flags.sh | 9 +-------- scripts/travis_before_install.sh | 16 +++++++++------- scripts/travis_helper.sh | 10 ++++++++++ scripts/travis_install.sh | 4 +++- scripts/travis_script.sh | 22 ++++++++++++---------- 5 files changed, 35 insertions(+), 26 deletions(-) create mode 100755 scripts/travis_helper.sh diff --git a/scripts/flags.sh b/scripts/flags.sh index 21313b24c..83a413821 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -1,13 +1,6 @@ #!/usr/bin/env bash -function mapbox_time { - local NAME=$1 ; shift - travis_fold start "${NAME}" - travis_time_start - "$@" - travis_time_finish - travis_fold end "${NAME}" -} +. ./scripts/travis_helper.sh if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then export DISPLAY=:99.0 diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index ab955f6aa..654c9dcc6 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -3,6 +3,8 @@ set -e set -o pipefail +. ./scripts/travis_helper.sh + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # install Linux dependencies @@ -11,30 +13,30 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test fi - mapbox_time "apt update" \ + mapbox_time "apt_update" \ sudo apt-get update -y - mapbox_time "install gcc" \ + mapbox_time "install_gcc" \ sudo apt-get -y install gcc-4.8 g++-4.8 - mapbox_time "install build tools" \ + mapbox_time "install_build_tools" \ sudo apt-get -y install git build-essential zlib1g-dev automake \ libtool xutils-dev make cmake pkg-config python-pip - mapbox_time "install opengl" \ + mapbox_time "install_opengl" \ sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev \ x11proto-xext-dev libxrandr-dev \ x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev - mapbox_time "install awscli" \ + mapbox_time "install_awscli" \ sudo pip install awscli elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # # install OS X dependencies # - mapbox_time "install build tools" \ + mapbox_time "install_build_tools" \ brew install autoconf automake libtool makedepend cmake pkg-config node git - mapbox_time "install awscli" \ + mapbox_time "install_awscli" \ sudo pip install awscli fi diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh new file mode 100755 index 000000000..0a2aab663 --- /dev/null +++ b/scripts/travis_helper.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +function mapbox_time { + local NAME=$1 ; shift + travis_fold start "${NAME}" + travis_time_start + "$@" + travis_time_finish + travis_fold end "${NAME}" +} diff --git a/scripts/travis_install.sh b/scripts/travis_install.sh index d0539946b..9d17fee7f 100755 --- a/scripts/travis_install.sh +++ b/scripts/travis_install.sh @@ -1,9 +1,11 @@ #!/usr/bin/env bash +. ./scripts/travis_helper.sh + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # we'll need the test suite on Linux # - mapbox_time "install test suite" \ + mapbox_time "install_test_suite" \ npm install git+https://github.com/mapbox/mapbox-gl-test-suite.git fi diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index 1c61dfa9d..d4ebeb12d 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -3,24 +3,26 @@ set -e set -o pipefail +. ./scripts/travis_helper.sh + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # build & test Linux # - mapbox_time "compile program" \ + mapbox_time "compile_program" \ make linux -j4 BUILDTYPE=${BUILDTYPE} - mapbox_time "install tests" \ + mapbox_time "install_tests" \ make test -j4 BUILDTYPE=${BUILDTYPE} - mapbox_time "run tests" \ + mapbox_time "run_tests" \ ./scripts/run_tests.sh - mapbox_time "compare results" \ + mapbox_time "compare_results" \ (cd ./node_modules/mapbox-gl-test-suite/ && (./bin/compare_images.js || true)) if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - mapbox_time "deploy results" \ + mapbox_time "deploy_results" \ (cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh) fi @@ -28,10 +30,10 @@ elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # # build OS X # - mapbox_time "create osx project" \ + mapbox_time "create_osx_project" \ make xproj-cli - mapbox_time "build osx" \ + mapbox_time "build_osx" \ xcodebuild -project ./build/macosx/mapboxgl-app.xcodeproj -jobs 4 # @@ -39,12 +41,12 @@ elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then # git submodule init - mapbox_time "load submodules" \ + mapbox_time "load_submodules" \ git submodule update - mapbox_time "create ios project" \ + mapbox_time "create_ios_project" \ make iproj-cli - mapbox_time "build ios" \ + mapbox_time "build_ios" \ xcodebuild -project ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO -jobs 4 fi From 0d213283c0cc7bf7ebd06210b42577c9b8dece43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 05:56:18 -0700 Subject: [PATCH 083/116] export function to subshells --- .travis.yml | 1 + scripts/flags.sh | 2 -- scripts/travis_before_install.sh | 2 -- scripts/travis_helper.sh | 2 ++ scripts/travis_install.sh | 2 -- scripts/travis_script.sh | 2 -- 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a3345971..78b2754a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ env: - AWS_S3_BUCKET: 'node-mapbox-gl-native' before_install: +- source ./scripts/travis_helper.sh - source ./scripts/flags.sh - ./scripts/travis_before_install.sh diff --git a/scripts/flags.sh b/scripts/flags.sh index 83a413821..1cb8b766e 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -. ./scripts/travis_helper.sh - if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then export DISPLAY=:99.0 diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index 654c9dcc6..d3add138c 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -3,8 +3,6 @@ set -e set -o pipefail -. ./scripts/travis_helper.sh - if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # install Linux dependencies diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh index 0a2aab663..0c54e3dd0 100755 --- a/scripts/travis_helper.sh +++ b/scripts/travis_helper.sh @@ -8,3 +8,5 @@ function mapbox_time { travis_time_finish travis_fold end "${NAME}" } + +export -f mapbox_time diff --git a/scripts/travis_install.sh b/scripts/travis_install.sh index 9d17fee7f..cb2422d70 100755 --- a/scripts/travis_install.sh +++ b/scripts/travis_install.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -. ./scripts/travis_helper.sh - if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # we'll need the test suite on Linux diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index d4ebeb12d..a9c26f34f 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -3,8 +3,6 @@ set -e set -o pipefail -. ./scripts/travis_helper.sh - if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # # build & test Linux From 42b54b11d8f90aeeb7fd37309a06de91553caa6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 05:59:47 -0700 Subject: [PATCH 084/116] export all required functions --- scripts/travis_helper.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh index 0c54e3dd0..ebe1e965b 100755 --- a/scripts/travis_helper.sh +++ b/scripts/travis_helper.sh @@ -9,4 +9,9 @@ function mapbox_time { travis_fold end "${NAME}" } +export -f travis_fold +export -f travis_time_start +export -f travis_time_finish +export -f travis_nanoseconds +export ANSI_CLEAR export -f mapbox_time From 21b97d490625b016243aea4d2d627040de8879c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 06:54:36 -0700 Subject: [PATCH 085/116] better timing functions --- scripts/travis_helper.sh | 46 ++++++++++++++++++++++++++++++---------- scripts/travis_script.sh | 6 ++++-- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh index ebe1e965b..040ef2944 100755 --- a/scripts/travis_helper.sh +++ b/scripts/travis_helper.sh @@ -1,17 +1,41 @@ #!/usr/bin/env bash -function mapbox_time { - local NAME=$1 ; shift - travis_fold start "${NAME}" - travis_time_start - "$@" - travis_time_finish - travis_fold end "${NAME}" +function mapbox_time_start { + local name=$1 + mapbox_timer_name=$name + + travis_fold start $name + + mapbox_timer_id=$(printf %08x $(( RANDOM * RANDOM ))) + eval "mapbox_start_time_$mapbox_timer_id=$(travis_nanoseconds)" + echo -en "travis_time:start:$mapbox_timer_id\n" } -export -f travis_fold -export -f travis_time_start -export -f travis_time_finish -export -f travis_nanoseconds +function mapbox_time_finish { + local name=${1:-$mapbox_timer_name} + local timer_id=${2:-$mapbox_timer_id} + local timer_start="mapbox_start_time_$timer_id" + eval local start_time=\${$timer_start} + local end_time=$(travis_nanoseconds) + local duration=$(($end_time-$start_time)) + echo -en "travis_time:end:$timer_id:start=$start_time,finish=$end_time,duration=$duration\n" + + travis_fold end $name +} + +function mapbox_time { + local name=$1 ; shift + mapbox_time_start $name + local timer_id=$mapbox_timer_id + echo "\$ $@" + $@ + mapbox_time_finish $name $timer_id +} + + export ANSI_CLEAR +export -f travis_fold +export -f travis_nanoseconds export -f mapbox_time +export -f mapbox_time_start +export -f mapbox_time_finish diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index a9c26f34f..ae26467a0 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -16,12 +16,14 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then mapbox_time "run_tests" \ ./scripts/run_tests.sh - mapbox_time "compare_results" \ + mapbox_time_start "compare_results" (cd ./node_modules/mapbox-gl-test-suite/ && (./bin/compare_images.js || true)) + mapbox_time_end if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then - mapbox_time "deploy_results" \ + mapbox_time_start "deploy_results" (cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh) + mapbox_time_end fi elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then From 2c6d9374a4f30dde2585ef7f18344643df3c823c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 07:00:04 -0700 Subject: [PATCH 086/116] fix misnamed function --- scripts/travis_script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/travis_script.sh b/scripts/travis_script.sh index ae26467a0..f306dbcb7 100755 --- a/scripts/travis_script.sh +++ b/scripts/travis_script.sh @@ -10,7 +10,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then mapbox_time "compile_program" \ make linux -j4 BUILDTYPE=${BUILDTYPE} - mapbox_time "install_tests" \ + mapbox_time "compile_tests" \ make test -j4 BUILDTYPE=${BUILDTYPE} mapbox_time "run_tests" \ @@ -18,12 +18,12 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then mapbox_time_start "compare_results" (cd ./node_modules/mapbox-gl-test-suite/ && (./bin/compare_images.js || true)) - mapbox_time_end + mapbox_time_finish if [ ! -z "${AWS_ACCESS_KEY_ID}" ] && [ ! -z "${AWS_SECRET_ACCESS_KEY}" ] ; then mapbox_time_start "deploy_results" (cd ./node_modules/mapbox-gl-test-suite/ && ./bin/deploy_results.sh) - mapbox_time_end + mapbox_time_finish fi elif [[ ${TRAVIS_OS_NAME} == "osx" ]]; then From 8954b3971f5cb90dc4b18e61b58ea6e41c54fffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 16 Oct 2014 07:07:05 -0700 Subject: [PATCH 087/116] don't time xvfb startup --- scripts/flags.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/flags.sh b/scripts/flags.sh index 1cb8b766e..9c7e1cff9 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -3,7 +3,6 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then export DISPLAY=:99.0 - mapbox_time "start xvfb" \ sh -e /etc/init.d/xvfb start # use g++ that supports c++11 From 02e88e445d9960c3b248ea95d03d4a191ef91289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 15:29:28 +0200 Subject: [PATCH 088/116] fixes for libuv 0.11 --- common/curl_request.cpp | 383 ----------------------------- src/storage/file_request_baton.cpp | 1 - src/util/uv.cpp | 2 +- 3 files changed, 1 insertion(+), 385 deletions(-) delete mode 100644 common/curl_request.cpp diff --git a/common/curl_request.cpp b/common/curl_request.cpp deleted file mode 100644 index 3370c0a85..000000000 --- a/common/curl_request.cpp +++ /dev/null @@ -1,383 +0,0 @@ - -#include -#include -#include -#include - -#include -#include - -#include - -// This file contains code from http://curl.haxx.se/libcurl/c/multi-uv.html: - -/*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ - * \___|\___/|_| \_\_____| - * - * Copyright (C) 1998 - 2013, Daniel Stenberg, , et al. - * - * This software is licensed as described in the file COPYING, which - * you should have received as part of this distribution. The terms - * are also available at http://curl.haxx.se/docs/copyright.html. - * - * You may opt to use, copy, modify, merge, publish, distribute and/or sell - * copies of the Software, and permit persons to whom the Software is - * furnished to do so, under the terms of the COPYING file. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ***************************************************************************/ - -/* Example application code using the multi socket interface to download - multiple files at once, but instead of using curl_multi_perform and - curl_multi_wait, which uses select(), we use libuv. - It supports epoll, kqueue, etc. on unixes and fast IO completion ports on - Windows, which means, it should be very fast on all platforms.. - - Written by Clemens Gruber, based on an outdated example from uvbook and - some tests from libuv. - - Requires libuv and (of course) libcurl. - - See http://nikhilm.github.com/uvbook/ for more information on libuv. -*/ - -namespace mbgl { -namespace platform { -namespace request { - -struct curl_context { - uv_poll_t poll_handle; - curl_socket_t sockfd; -}; - -// Handles the request thread + messaging to the thread. -static uv_thread_t thread; -static uv::once init_thread_once; -static uv_loop_t *loop = nullptr; -static uv_async_t async_add; -static uv_async_t async_cancel; - -// Stores pointers (!) to shared_ptrs. We use shared_ptrs so that request objects don't get -// auto-destructed while they're in progress. The TileData object retains a weak_ptr to this -// request, so we have to use a shared_ptr here to ensure that this object stays alive. -static boost::lockfree::queue *> add_queue(8); -static boost::lockfree::queue *> cancel_queue(8); - -// Used as the CURL timer function to periodically check for socket updates. -static uv_timer_t timeout; - -// CURL multi handle that we use to request multiple URLs at the same time, without having to block -// and spawn threads. -static CURLM *curl_multi = nullptr; - -// CURL share handles are used for sharing session state (e.g.) -static uv::mutex curl_share_mutex; -static CURLSH *curl_share = nullptr; - -// A queue that we use for storing resuable CURL easy handles to avoid creating and destroying them -// all the time. -static std::queue curl_handle_cache; - - -class CURLRequest : public mbgl::platform::Request { -public: - CURLRequest(const std::string &url, - std::function callback, - std::shared_ptr loop) - : Request(url, callback, loop) {} - - CURL *curl = nullptr; -}; - - -// Implementation starts here. - -// Locks the CURL share handle -void curl_share_lock(CURL *, curl_lock_data, curl_lock_access, void *) { curl_share_mutex.lock(); } - -// Unlocks the CURL share handle -void curl_share_unlock(CURL *, curl_lock_data, void *) { curl_share_mutex.unlock(); } - -curl_context *create_curl_context(curl_socket_t sockfd) { - curl_context *context = new curl_context; - context->sockfd = sockfd; - - uv_poll_init_socket(loop, &context->poll_handle, sockfd); - context->poll_handle.data = context; - - return context; -} - -void curl_close_cb(uv_handle_t *handle) { - curl_context *context = (curl_context *)handle->data; - free(context); -} - -void destroy_curl_context(curl_context *context) { - uv_close((uv_handle_t *)&context->poll_handle, curl_close_cb); -} - -void remove_curl_handle(CURL *handle) { - CURLMcode error = curl_multi_remove_handle(curl_multi, handle); - if (error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(error)); - } - - curl_easy_reset(handle); - curl_handle_cache.push(handle); -} - -void curl_perform(uv_poll_t *req, int /*status*/, int events) { - int running_handles; - int flags = 0; - curl_context *context; - CURLMsg *message; - int pending; - - uv_timer_stop(&timeout); - - if (events & UV_READABLE) - flags |= CURL_CSELECT_IN; - if (events & UV_WRITABLE) - flags |= CURL_CSELECT_OUT; - - context = (curl_context *)req; - - curl_multi_socket_action(curl_multi, context->sockfd, flags, &running_handles); - - while ((message = curl_multi_info_read(curl_multi, &pending))) { - switch (message->msg) { - case CURLMSG_DONE: { - std::shared_ptr *req = nullptr; - curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, (char *)&req); - - // Add human-readable error code - if (message->data.result != CURLE_OK) { - (*req)->res->error_message = curl_easy_strerror(message->data.result); - (*req)->res->code = -1; - } else { - curl_easy_getinfo(message->easy_handle, CURLINFO_RESPONSE_CODE, &(*req)->res->code); - } - - // We're currently in the CURL request thread. We're going to schedule a uv_work request - // that executes the background function in a threadpool, and tell it to call the - // after callback back in the main uv loop. - (*req)->complete(); - - CURL *handle = message->easy_handle; - remove_curl_handle(handle); - - // We're setting this to NULL because there might still be shared_ptrs around that could - // be cancelled. - ((CURLRequest *)req->get())->curl = nullptr; - - // Delete the shared_ptr pointer we created earlier. - delete req; - break; - } - - default: - // This should never happen, because there are no other message types. - throw std::runtime_error("CURLMSG returned unknown message type"); - } - } -} - -int handle_socket(CURL * /*easy*/, curl_socket_t s, int action, void * /*userp*/, void *socketp) { - curl_context *context = nullptr; - - if (socketp) { - context = (curl_context *)socketp; - } else if (action != CURL_POLL_REMOVE) { - context = create_curl_context(s); - } - - if (context) { - curl_multi_assign(curl_multi, s, (void *)context); - if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) { - uv_poll_start(&context->poll_handle, UV_READABLE, curl_perform); - } - if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) { - uv_poll_start(&context->poll_handle, UV_WRITABLE, curl_perform); - } - if (action == CURL_POLL_REMOVE && socketp) { - uv_poll_stop(&context->poll_handle); - destroy_curl_context(context); - curl_multi_assign(curl_multi, s, NULL); - } - } - - return 0; -} - -void on_timeout(uv_timer_t *, int status /*req*/) { - int running_handles; - CURLMcode error = - curl_multi_socket_action(curl_multi, CURL_SOCKET_TIMEOUT, 0, &running_handles); - if (error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(error)); - } -} - -void start_timeout(CURLM * /*multi*/, long timeout_ms, void * /*userp*/) { - if (timeout_ms <= 0) { - on_timeout(&timeout, -1); - } else { - uv_timer_start(&timeout, &on_timeout, timeout_ms, 0); - } -} - -// This function is the first function called in the request thread. It sets up the CURL share/multi -// handles and runs the thread loop. -void thread_init(void * /*ptr*/) { - uv_timer_init(loop, &timeout); - - CURLSHcode share_error; - curl_share = curl_share_init(); - - share_error = curl_share_setopt(curl_share, CURLSHOPT_LOCKFUNC, curl_share_lock); - if (share_error != CURLSHE_OK) { - throw std::runtime_error(std::string("CURL share error: ") + curl_share_strerror(share_error)); - } - - share_error = curl_share_setopt(curl_share, CURLSHOPT_UNLOCKFUNC, curl_share_unlock); - if (share_error != CURLSHE_OK) { - throw std::runtime_error(std::string("CURL share error: ") + curl_share_strerror(share_error)); - } - - CURLMcode multi_error; - curl_multi = curl_multi_init(); - - multi_error = curl_multi_setopt(curl_multi, CURLMOPT_SOCKETFUNCTION, handle_socket); - if (multi_error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(multi_error)); - } - multi_error = curl_multi_setopt(curl_multi, CURLMOPT_TIMERFUNCTION, start_timeout); - if (multi_error != CURLM_OK) { - throw std::runtime_error(std::string("CURL multi error: ") + curl_multi_strerror(multi_error)); - - } - - // Main event loop. This will not return until the request loop is terminated. - uv_run(loop, UV_RUN_DEFAULT); - - curl_multi_cleanup(curl_multi); - curl_multi = nullptr; - curl_share_cleanup(curl_share); - curl_share = nullptr; - - // Clean up all the CURL easy handles that we kept around for potential future reuse. - while (!curl_handle_cache.empty()) { - curl_easy_cleanup(curl_handle_cache.front()); - curl_handle_cache.pop(); - } -} - -// This function is called when we have new data for a request. We just append it to the string -// containing the previous data. -size_t curl_write_cb(void *contents, size_t size, size_t nmemb, void *userp) { - ((std::string *)userp)->append((char *)contents, size * nmemb); - return size * nmemb; -} - -// This callback is called in the request event loop (on the request thread). -// It initializes newly queued up download requests and adds them to the CURL -// multi handle. -void async_add_cb(uv_async_t *, int status /*async*/) { - std::shared_ptr *req = nullptr; - while (add_queue.pop(req)) { - // Make sure that we're not starting requests that have been cancelled - // already by async_cancel_cb. - if ((*req)->cancelled) { - delete req; - continue; - } - - // Obtain a curl handle (and try to reuse existing handles before creating new ones). - CURL *handle = nullptr; - if (!curl_handle_cache.empty()) { - handle = curl_handle_cache.front(); - curl_handle_cache.pop(); - } else { - handle = curl_easy_init(); - } - - ((CURLRequest *)req->get())->curl = handle; - - curl_easy_setopt(handle, CURLOPT_PRIVATE, req); - curl_easy_setopt(handle, CURLOPT_CAINFO, "ca-bundle.crt"); - curl_easy_setopt(handle, CURLOPT_URL, (*req)->url.c_str()); - curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curl_write_cb); - curl_easy_setopt(handle, CURLOPT_WRITEDATA, &(*req)->res->body); - curl_easy_setopt(handle, CURLOPT_ACCEPT_ENCODING, "gzip, deflate"); - curl_easy_setopt(handle, CURLOPT_SHARE, curl_share); - curl_multi_add_handle(curl_multi, handle); - } -} - -void async_cancel_cb(uv_async_t *, int status /*async*/) { - std::shared_ptr *req = nullptr; - while (cancel_queue.pop(req)) { - // It is possible that the request has not yet been started, but that it already has been - // added to the queue for scheduling new requests. In this case, the CURL handle is invalid - // and we manually mark the Request as cancelled. - CURL *handle = ((CURLRequest *)req->get())->curl; - if (handle && !(*req)->cancelled) { - remove_curl_handle(handle); - ((CURLRequest *)req->get())->curl = nullptr; - } - (*req)->cancelled = true; - - delete req; - req = nullptr; - } -} - -void thread_init_cb() { - curl_global_init(CURL_GLOBAL_ALL); - - loop = uv_loop_new(); - uv_async_init(loop, &async_add, &async_add_cb); - uv_async_init(loop, &async_cancel, &async_cancel_cb); - uv_thread_create(&thread, thread_init, nullptr); -} -} // end namespace request -} // end namespace platform - - -std::shared_ptr -platform::request_http(const std::string &url, - std::function callback, - std::shared_ptr loop) { - using namespace request; - init_thread_once(thread_init_cb); - std::shared_ptr req = std::make_shared(url, callback, loop); - - // Note that we are creating a new shared_ptr pointer(!) because the lockless queue can't store - // objects with nontrivial destructors. We have to make absolutely sure that we manually delete - // the shared_ptr when we pop it from the queue. - add_queue.push(new std::shared_ptr(req)); - uv_async_send(&async_add); - - return req; -} - -// Cancels an HTTP request. -void platform::cancel_request_http(const std::shared_ptr &req) { - if (req) { - using namespace request; - - // Note that we are creating a new shared_ptr pointer(!) because the lockless queue can't - // store objects with nontrivial destructors. We have to make absolutely shure that we - // manually delete the shared_ptr when we pop it from the queue. - cancel_queue.push(new std::shared_ptr(req)); - uv_async_send(&async_cancel); - } -} -} // end namespace mbgl diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index e54b743c4..aafed82d5 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -83,7 +83,6 @@ void FileRequestBaton::file_stated(uv_fs_t *req) { if (stat->st_size > std::numeric_limits::max()) { // File is too large for us to open this way because uv_buf's only support unsigned // ints as maximum size. - const uv_err_t error = {UV_EFBIG, 0}; if (ptr->request) { ptr->request->response = std::unique_ptr(new Response); ptr->request->response->code = UV_EFBIG; diff --git a/src/util/uv.cpp b/src/util/uv.cpp index 1e51d3dbb..03a885d30 100644 --- a/src/util/uv.cpp +++ b/src/util/uv.cpp @@ -15,7 +15,7 @@ std::string cwd() { do { max += 256; dir.resize(max); - uv_cwd(const_cast(dir.data()), max); + uv_cwd(const_cast(dir.data()), &max); } while (max == dir.size()); dir.resize(max - 1); return dir; From 2422e938ac87f5790c4977d93e667c95e695f76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 15:50:54 +0200 Subject: [PATCH 089/116] fix typo --- scripts/travis_before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index d445ae817..1ecfc4f26 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -24,7 +24,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \ libpng-dev libsqlite3-dev - apbox_time "install_opengl" \ + mapbox_time "install_opengl" \ sudo apt-get -y install libxi-dev libglu1-mesa-dev x11proto-randr-dev \ x11proto-xext-dev libxrandr-dev \ x11proto-xf86vidmode-dev libxxf86vm-dev \ From 7d6feffd56cde7d6e5d9dd53b358f5afa8e4eb47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:29:10 +0200 Subject: [PATCH 090/116] replace boost optional with mapbox optional --- include/mbgl/text/types.hpp | 7 ++-- include/mbgl/util/optional.hpp | 69 ++++++++++++++++++++++++++++++++++ include/mbgl/util/variant.hpp | 20 +++------- test/fixtures/fixture_log.hpp | 17 ++++----- test/variant.cpp | 7 ---- 5 files changed, 85 insertions(+), 35 deletions(-) create mode 100644 include/mbgl/util/optional.hpp diff --git a/include/mbgl/text/types.hpp b/include/mbgl/text/types.hpp index dbb483ea8..1d21ded2a 100644 --- a/include/mbgl/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -3,11 +3,10 @@ #include #include +#include #include #include -#include - namespace mbgl { typedef vec2 CollisionPoint; @@ -53,7 +52,7 @@ struct GlyphBox { float minScale = 0.0f; float maxScale = std::numeric_limits::infinity(); float padding = 0.0f; - boost::optional hBox; + mapbox::util::optional hBox; }; typedef std::vector GlyphBoxes; @@ -88,7 +87,7 @@ typedef std::vector PlacedGlyphs; struct PlacementBox { CollisionAnchor anchor; CollisionRect box; - boost::optional hBox; + mapbox::util::optional hBox; PlacementRange placementRange = {{0.0f, 0.0f}}; float placementScale = 0.0f; float maxScale = std::numeric_limits::infinity(); diff --git a/include/mbgl/util/optional.hpp b/include/mbgl/util/optional.hpp new file mode 100644 index 000000000..133e2c8f9 --- /dev/null +++ b/include/mbgl/util/optional.hpp @@ -0,0 +1,69 @@ +#ifndef MAPBOX_UTIL_OPTIONAL_HPP +#define MAPBOX_UTIL_OPTIONAL_HPP + +#include + +#include "variant.hpp" + +namespace mapbox +{ +namespace util +{ + +template class optional +{ + static_assert(!std::is_reference::value, "optional doesn't support references"); + + struct none_type + { + }; + + variant variant_; + + public: + optional() = default; + + optional(optional const &rhs) + { + if (this != &rhs) + { // protect against invalid self-assignment + variant_ = rhs.variant_; + } + } + + optional(T const &v) { variant_ = v; } + + explicit operator bool() const noexcept { return variant_.template is(); } + + T const &get() const { return variant_.template get(); } + T &get() { return variant_.template get(); } + + T const &operator*() const { return this->get(); } + T operator*() { return this->get(); } + + optional &operator=(T const &v) + { + variant_ = v; + return *this; + } + + optional &operator=(optional const &rhs) + { + if (this != &rhs) + { + variant_ = rhs.variant_; + } + return *this; + } + + template void emplace(Args &&... args) + { + variant_ = T{std::forward(args)...}; + } + + void reset() { variant_ = none_type{}; } +}; +} +} + +#endif diff --git a/include/mbgl/util/variant.hpp b/include/mbgl/util/variant.hpp index 1eca5160c..3b5659425 100644 --- a/include/mbgl/util/variant.hpp +++ b/include/mbgl/util/variant.hpp @@ -4,7 +4,6 @@ #include #include #include -#include // std::move/swap #include // runtime_error #include // operator new #include // size_t @@ -515,22 +514,13 @@ public: VARIANT_INLINE variant(no_init) : type_index(detail::invalid_value) {} + // http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers template ::value>::type> - VARIANT_INLINE explicit variant(T const& val) noexcept - : type_index(detail::value_traits::index) - { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; - using target_type = typename detail::select_type::type; - new (&data) target_type(val); - } - - template ::value>::type> + detail::is_valid_type::type, Types...>::value>::type> VARIANT_INLINE variant(T && val) noexcept - : type_index(detail::value_traits::index) + : type_index(detail::value_traits::type, Types...>::index) { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; + constexpr std::size_t index = sizeof...(Types) - detail::value_traits::type, Types...>::index - 1; using target_type = typename detail::select_type::type; new (&data) target_type(std::forward(val)); // nothrow } @@ -565,7 +555,7 @@ public: template VARIANT_INLINE variant& operator=(T && rhs) noexcept { - variant temp(std::move(rhs)); + variant temp(std::forward(rhs)); swap(*this, temp); return *this; } diff --git a/test/fixtures/fixture_log.hpp b/test/fixtures/fixture_log.hpp index 263871575..dc92f9319 100644 --- a/test/fixtures/fixture_log.hpp +++ b/test/fixtures/fixture_log.hpp @@ -3,8 +3,7 @@ #include #include - -#include +#include #include #include @@ -17,11 +16,11 @@ public: inline LogMessage(EventSeverity severity, Event event, int64_t code, const std::string &msg) : severity(severity), event(event), code(code), msg(msg) {} inline LogMessage(EventSeverity severity, Event event, int64_t code) - : severity(severity), event(event), code(code) {} + : severity(severity), event(event), code(code), msg() {} inline LogMessage(EventSeverity severity, Event event, const std::string &msg) - : severity(severity), event(event), msg(msg) {} + : severity(severity), event(event), code(), msg(msg) {} inline LogMessage(EventSeverity severity, Event event) - : severity(severity), event(event) {} + : severity(severity), event(event), code(), msg() {} inline bool operator==(const LogMessage &rhs) const { return (!severity || !rhs.severity || severity.get() == rhs.severity.get()) && @@ -30,10 +29,10 @@ public: (!msg || !rhs.msg || msg.get() == rhs.msg.get()); } - const boost::optional severity; - const boost::optional event; - const boost::optional code; - const boost::optional msg; + const mapbox::util::optional severity; + const mapbox::util::optional event; + const mapbox::util::optional code; + const mapbox::util::optional msg; mutable bool checked = false; }; diff --git a/test/variant.cpp b/test/variant.cpp index dd4578b49..4557465cf 100644 --- a/test/variant.cpp +++ b/test/variant.cpp @@ -4,13 +4,6 @@ #include #include -#pragma GCC diagnostic push -#ifndef __clang__ -#pragma GCC diagnostic ignored "-Wunused-local-typedefs" -#endif -#include -#pragma GCC diagnostic pop - using namespace mbgl; TEST(Variant, toString) { From 20ea7ef104eab469cb88edab0d580b5b56e94560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:30:06 +0200 Subject: [PATCH 091/116] remove erroneous output during test run --- test/enums.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/enums.cpp b/test/enums.cpp index 67ff0aa7e..b45fc0ed0 100644 --- a/test/enums.cpp +++ b/test/enums.cpp @@ -8,8 +8,6 @@ using namespace mbgl; TEST(Enums, StyleLayerType) { - std::cerr << StyleLayerType::Raster; - ASSERT_EQ(StyleLayerType::Unknown, StyleLayerTypeClass("unknown")); ASSERT_EQ(StyleLayerType::Fill, StyleLayerTypeClass("fill")); ASSERT_EQ(StyleLayerType::Line, StyleLayerTypeClass("line")); From 74387c54e35e0f8f6bf1dcc7b7b171a3ec6db212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 16:37:59 +0200 Subject: [PATCH 092/116] add missing include header --- src/storage/file_request_baton.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/storage/file_request_baton.cpp b/src/storage/file_request_baton.cpp index aafed82d5..1b41a5370 100644 --- a/src/storage/file_request_baton.cpp +++ b/src/storage/file_request_baton.cpp @@ -2,6 +2,8 @@ #include #include +#include + namespace mbgl { FileRequestBaton::FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop) From 214f99673f6f7480f9cc3bf9d6fa32ef8dd2ede5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 18:06:11 +0200 Subject: [PATCH 093/116] fix variable shadowing --- Makefile | 2 +- common/glfw_view.cpp | 2 +- include/csscolorparser/csscolorparser.hpp | 4 +- include/mbgl/geometry/anchor.hpp | 8 ++-- include/mbgl/geometry/elements_buffer.hpp | 6 +-- include/mbgl/geometry/geometry.hpp | 4 +- include/mbgl/geometry/glyph_atlas.hpp | 4 +- include/mbgl/map/tile.hpp | 4 +- include/mbgl/map/view.hpp | 4 +- include/mbgl/renderer/frame_history.hpp | 2 +- include/mbgl/renderer/painter.hpp | 8 ++-- include/mbgl/style/class_properties.hpp | 4 +- include/mbgl/style/filter_comparison.hpp | 6 +-- include/mbgl/style/filter_expression.hpp | 2 +- include/mbgl/style/function_properties.hpp | 6 +-- include/mbgl/style/style_source.hpp | 4 +- include/mbgl/text/collision.hpp | 1 + include/mbgl/text/glyph.hpp | 10 ++-- include/mbgl/text/types.hpp | 56 +++++++++++----------- include/mbgl/util/enum.hpp | 8 ++-- include/mbgl/util/error.hpp | 2 +- include/mbgl/util/pbf.hpp | 6 +-- include/mbgl/util/rect.hpp | 2 +- include/mbgl/util/transition.hpp | 20 ++++---- include/mbgl/util/uv_detail.hpp | 16 +++---- include/mbgl/util/vec.hpp | 6 +-- src/clipper/clipper.cpp | 2 +- src/geometry/debug_font.cpp | 8 ++-- src/geometry/glyph_atlas.cpp | 10 ++-- src/geometry/sprite_atlas.cpp | 12 ++--- src/map/map.cpp | 9 ++-- src/map/source.cpp | 10 ++-- src/map/sprite.cpp | 28 +++++------ src/map/tile.cpp | 4 +- src/map/tile_data.cpp | 10 ++-- src/map/tile_parser.cpp | 4 +- src/map/transform.cpp | 2 +- src/map/transform_state.cpp | 4 +- src/map/vector_tile.cpp | 12 ++--- src/renderer/debug_bucket.cpp | 4 +- src/renderer/fill_bucket.cpp | 28 +++++------ src/renderer/line_bucket.cpp | 24 +++++----- src/renderer/painter.cpp | 4 +- src/renderer/prerendered_texture.cpp | 4 +- src/renderer/raster_bucket.cpp | 10 ++-- src/renderer/symbol_bucket.cpp | 14 +++--- src/shader/shader.cpp | 4 +- src/storage/http_request.cpp | 14 +++--- src/storage/sqlite_store.cpp | 4 +- src/style/applied_class_properties.cpp | 8 ++-- src/style/style_layer.cpp | 18 +++---- src/style/style_parser.cpp | 14 +++--- src/text/collision.cpp | 6 +-- src/text/glyph_store.cpp | 2 +- src/text/placement.cpp | 8 ++-- src/util/image.cpp | 8 ++-- src/util/raster.cpp | 30 ++++++------ src/util/timer.cpp | 20 ++++---- test/comparisons.cpp | 2 +- test/fixtures/fixture_log.hpp | 16 +++---- 60 files changed, 276 insertions(+), 278 deletions(-) diff --git a/Makefile b/Makefile index 06b38ec34..95a7d90f3 100644 --- a/Makefile +++ b/Makefile @@ -98,5 +98,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl test linux build/test/Makefile +.PHONY: mbgl test linux build/test/Makefile clean distclean # DO NOT DELETE diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 120faf4df..53cd068d0 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -2,7 +2,7 @@ #include -GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) { +GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) { #ifdef NVIDIA glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC)glfwGetProcAddress("glDiscardFramebufferEXT"); #endif diff --git a/include/csscolorparser/csscolorparser.hpp b/include/csscolorparser/csscolorparser.hpp index 1d074627f..6caf79694 100644 --- a/include/csscolorparser/csscolorparser.hpp +++ b/include/csscolorparser/csscolorparser.hpp @@ -31,8 +31,8 @@ namespace CSSColorParser { struct Color { inline Color() {} - inline Color(unsigned char r, unsigned char g, unsigned char b, float a) - : r(r), g(g), b(b), a(a) {} + inline Color(unsigned char r_, unsigned char g_, unsigned char b_, float a_) + : r(r_), g(g_), b(b_), a(a_) {} unsigned char r = 0, g = 0, b = 0; float a = 1.0f; }; diff --git a/include/mbgl/geometry/anchor.hpp b/include/mbgl/geometry/anchor.hpp index ab006530f..d30394f0b 100644 --- a/include/mbgl/geometry/anchor.hpp +++ b/include/mbgl/geometry/anchor.hpp @@ -12,10 +12,10 @@ struct Anchor { float scale = 0.0f; int segment = -1; - explicit Anchor(float x, float y, float angle, float scale) - : x(x), y(y), angle(angle), scale(scale) {} - explicit Anchor(float x, float y, float angle, float scale, int segment) - : x(x), y(y), angle(angle), scale(scale), segment(segment) {} + explicit Anchor(float x_, float y_, float angle_, float scale_) + : x(x_), y(y_), angle(angle_), scale(scale_) {} + explicit Anchor(float x_, float y_, float angle_, float scale_, int segment_) + : x(x_), y(y_), angle(angle_), scale(scale_), segment(segment_) {} }; typedef std::vector Anchors; diff --git a/include/mbgl/geometry/elements_buffer.hpp b/include/mbgl/geometry/elements_buffer.hpp index 56080e29f..045560f9a 100644 --- a/include/mbgl/geometry/elements_buffer.hpp +++ b/include/mbgl/geometry/elements_buffer.hpp @@ -16,9 +16,9 @@ struct ElementGroup : public util::noncopyable { uint32_t elements_length; ElementGroup() : vertex_length(0), elements_length(0) {} - ElementGroup(uint32_t vertex_length, uint32_t elements_length) - : vertex_length(vertex_length), - elements_length(elements_length) { + ElementGroup(uint32_t vertex_length_, uint32_t elements_length_) + : vertex_length(vertex_length_), + elements_length(elements_length_) { } ElementGroup(ElementGroup &&rhs) noexcept diff --git a/include/mbgl/geometry/geometry.hpp b/include/mbgl/geometry/geometry.hpp index 961569204..484d17b36 100644 --- a/include/mbgl/geometry/geometry.hpp +++ b/include/mbgl/geometry/geometry.hpp @@ -30,8 +30,8 @@ private: int32_t ox, oy; }; -Geometry::Geometry(pbf& data) - : data(data), +Geometry::Geometry(pbf& data_) + : data(data_), cmd(1), length(0), x(0), y(0), diff --git a/include/mbgl/geometry/glyph_atlas.hpp b/include/mbgl/geometry/glyph_atlas.hpp index 336c4af28..5b09cbcd6 100644 --- a/include/mbgl/geometry/glyph_atlas.hpp +++ b/include/mbgl/geometry/glyph_atlas.hpp @@ -18,8 +18,8 @@ public: private: struct GlyphValue { - GlyphValue(const Rect& rect, uint64_t id) - : rect(rect), ids({ id }) {} + GlyphValue(const Rect& rect_, uint64_t id) + : rect(rect_), ids({ id }) {} Rect rect; std::set ids; }; diff --git a/include/mbgl/map/tile.hpp b/include/mbgl/map/tile.hpp index b9f0556ad..1ae13dd79 100644 --- a/include/mbgl/map/tile.hpp +++ b/include/mbgl/map/tile.hpp @@ -37,8 +37,8 @@ public: const int8_t z = 0; const int32_t x = 0, y = 0; - inline explicit ID(int8_t z, int32_t x, int32_t y) - : w((x < 0 ? x - (1 << z) + 1 : x) / (1 << z)), z(z), x(x), y(y) {} + inline explicit ID(int8_t z_, int32_t x_, int32_t y_) + : w((x_ < 0 ? x_ - (1 << z_) + 1 : x_) / (1 << z_)), z(z_), x(x_), y(y_) {} inline uint64_t to_uint64() const { return ((std::pow(2, z) * y + x) * 32) + z; diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp index b567cd424..513c73b48 100644 --- a/include/mbgl/map/view.hpp +++ b/include/mbgl/map/view.hpp @@ -22,8 +22,8 @@ enum MapChange : uint8_t { class View { public: - virtual void initialize(Map *map) { - this->map = map; + virtual void initialize(Map *map_) { + map = map_; } // Called from the render (=GL) thread. Signals that the context should diff --git a/include/mbgl/renderer/frame_history.hpp b/include/mbgl/renderer/frame_history.hpp index b1f0bcb59..61bb59da3 100644 --- a/include/mbgl/renderer/frame_history.hpp +++ b/include/mbgl/renderer/frame_history.hpp @@ -11,7 +11,7 @@ namespace mbgl { struct FrameSnapshot { - explicit inline FrameSnapshot(timestamp t, float z) : t(t), z(z) {} + explicit inline FrameSnapshot(timestamp t_, float z_) : t(t_), z(z_) {} float t; float z; }; diff --git a/include/mbgl/renderer/painter.hpp b/include/mbgl/renderer/painter.hpp index 0f9bd7917..a8229a097 100644 --- a/include/mbgl/renderer/painter.hpp +++ b/include/mbgl/renderer/painter.hpp @@ -154,10 +154,10 @@ public: // used to composite images and flips the geometry upside down const mat4 flipMatrix = []{ - mat4 flipMatrix; - matrix::ortho(flipMatrix, 0, 4096, -4096, 0, 0, 1); - matrix::translate(flipMatrix, flipMatrix, 0, -4096, 0); - return flipMatrix; + mat4 flip; + matrix::ortho(flip, 0, 4096, -4096, 0, 0, 1); + matrix::translate(flip, flip, 0, -4096, 0); + return flip; }(); const mat4 identityMatrix = []{ diff --git a/include/mbgl/style/class_properties.hpp b/include/mbgl/style/class_properties.hpp index 84b6f483b..888a90c5d 100644 --- a/include/mbgl/style/class_properties.hpp +++ b/include/mbgl/style/class_properties.hpp @@ -12,8 +12,8 @@ namespace mbgl { class ClassProperties { public: inline ClassProperties() {} - inline ClassProperties(ClassProperties &&properties) - : properties(std::move(properties.properties)) {} + inline ClassProperties(ClassProperties &&properties_) + : properties(std::move(properties_.properties)) {} inline void set(PropertyKey key, const PropertyValue &value) { properties.emplace(key, value); diff --git a/include/mbgl/style/filter_comparison.hpp b/include/mbgl/style/filter_comparison.hpp index bf48744f1..1b0a9b548 100644 --- a/include/mbgl/style/filter_comparison.hpp +++ b/include/mbgl/style/filter_comparison.hpp @@ -24,8 +24,8 @@ public: class Instance { public: - Instance(Operator op, std::vector &&values) - : op(op), values(values) {} + Instance(Operator op_, std::vector &&values_) + : op(op_), values(values_) {} bool compare(const std::vector &property_values) const; @@ -37,7 +37,7 @@ public: }; public: - FilterComparison(const std::string &field) : field(field) {}; + FilterComparison(const std::string &field_) : field(field_) {}; const std::string &getField() const; template inline bool compare(const Extractor &extractor) const; diff --git a/include/mbgl/style/filter_expression.hpp b/include/mbgl/style/filter_expression.hpp index 2a9657879..915d3931d 100644 --- a/include/mbgl/style/filter_expression.hpp +++ b/include/mbgl/style/filter_expression.hpp @@ -28,7 +28,7 @@ public: public: FilterExpression() = default; - FilterExpression(Operator op) : op(op) {}; + FilterExpression(Operator op_) : op(op_) {}; bool empty() const; diff --git a/include/mbgl/style/function_properties.hpp b/include/mbgl/style/function_properties.hpp index 56092f9a6..924f19233 100644 --- a/include/mbgl/style/function_properties.hpp +++ b/include/mbgl/style/function_properties.hpp @@ -9,7 +9,7 @@ namespace mbgl { template struct ConstantFunction { - inline ConstantFunction(const T &value) : value(value) {} + inline ConstantFunction(const T &value_) : value(value_) {} inline T evaluate(float) const { return value; } private: @@ -18,7 +18,7 @@ private: template struct StopsFunction { - inline StopsFunction(const std::vector> &values, float base) : values(values), base(base) {} + inline StopsFunction(const std::vector> &values_, float base_) : values(values_), base(base_) {} T evaluate(float z) const; private: @@ -36,7 +36,7 @@ using Function = mapbox::util::variant< template struct FunctionEvaluator { typedef T result_type; - inline FunctionEvaluator(float z) : z(z) {} + inline FunctionEvaluator(float z_) : z(z_) {} inline result_type operator()(const std::false_type &) { return result_type(); diff --git a/include/mbgl/style/style_source.hpp b/include/mbgl/style/style_source.hpp index 00c48431a..86473079c 100644 --- a/include/mbgl/style/style_source.hpp +++ b/include/mbgl/style/style_source.hpp @@ -36,8 +36,8 @@ public: bool enabled = false; util::ptr source; - StyleSource(const util::ptr &info) - : info(info) + StyleSource(const util::ptr &info_) + : info(info_) {} }; diff --git a/include/mbgl/text/collision.hpp b/include/mbgl/text/collision.hpp index b7ee6b452..dfefab689 100644 --- a/include/mbgl/text/collision.hpp +++ b/include/mbgl/text/collision.hpp @@ -6,6 +6,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wshadow" #ifdef __clang__ #pragma GCC diagnostic ignored "-Wdeprecated-register" #else diff --git a/include/mbgl/text/glyph.hpp b/include/mbgl/text/glyph.hpp index de7f55bdc..4fbb75fc1 100644 --- a/include/mbgl/text/glyph.hpp +++ b/include/mbgl/text/glyph.hpp @@ -30,9 +30,9 @@ struct GlyphMetrics { struct Glyph { inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {} - inline explicit Glyph(const Rect &rect, - const GlyphMetrics &metrics) - : rect(rect), metrics(metrics) {} + inline explicit Glyph(const Rect &rect_, + const GlyphMetrics &metrics_) + : rect(rect_), metrics(metrics_) {} operator bool() const { return metrics || rect; @@ -46,8 +46,8 @@ typedef std::map GlyphPositions; class PositionedGlyph { public: - inline explicit PositionedGlyph(uint32_t glyph, float x, float y) - : glyph(glyph), x(x), y(y) {} + inline explicit PositionedGlyph(uint32_t glyph_, float x_, float y_) + : glyph(glyph_), x(x_), y(y_) {} uint32_t glyph = 0; float x = 0; diff --git a/include/mbgl/text/types.hpp b/include/mbgl/text/types.hpp index 1d21ded2a..23f49aa74 100644 --- a/include/mbgl/text/types.hpp +++ b/include/mbgl/text/types.hpp @@ -28,24 +28,24 @@ struct CollisionRect { CollisionPoint::Type bx, CollisionPoint::Type by) : tl(ax, ay), br(bx, by) {} - inline explicit CollisionRect(const CollisionPoint &tl, - const CollisionPoint &br) - : tl(tl), br(br) {} + inline explicit CollisionRect(const CollisionPoint &tl_, + const CollisionPoint &br_) + : tl(tl_), br(br_) {} }; // These are the glyph boxes that we want to have placed. struct GlyphBox { explicit GlyphBox() {} - explicit GlyphBox(const CollisionRect &box, - const CollisionAnchor &anchor, - float minScale, - float maxScale, - float padding) - : box(box), anchor(anchor), minScale(minScale), maxScale(maxScale), padding(padding) {} - explicit GlyphBox(const CollisionRect &box, - float minScale, - float padding) - : box(box), minScale(minScale), padding(padding) {} + explicit GlyphBox(const CollisionRect &box_, + const CollisionAnchor &anchor_, + float minScale_, + float maxScale_, + float padding_) + : box(box_), anchor(anchor_), minScale(minScale_), maxScale(maxScale_), padding(padding_) {} + explicit GlyphBox(const CollisionRect &box_, + float minScale_, + float padding_) + : box(box_), minScale(minScale_), padding(padding_) {} CollisionRect box; CollisionAnchor anchor; @@ -60,19 +60,19 @@ typedef std::vector GlyphBoxes; // TODO: Transform the vec2s to vec2 to save bytes struct PlacedGlyph { - explicit PlacedGlyph(const vec2 &tl, const vec2 &tr, - const vec2 &bl, const vec2 &br, - const Rect &tex, float angle, const vec2 &anchor, - float minScale, float maxScale) - : tl(tl), - tr(tr), - bl(bl), - br(br), - tex(tex), - angle(angle), - anchor(anchor), - minScale(minScale), - maxScale(maxScale) {} + explicit PlacedGlyph(const vec2 &tl_, const vec2 &tr_, + const vec2 &bl_, const vec2 &br_, + const Rect &tex_, float angle_, const vec2 &anchor_, + float minScale_, float maxScale_) + : tl(tl_), + tr(tr_), + bl(bl_), + br(br_), + tex(tex_), + angle(angle_), + anchor(anchor_), + minScale(minScale_), + maxScale(maxScale_) {} vec2 tl, tr, bl, br; Rect tex; @@ -96,8 +96,8 @@ struct PlacementBox { struct PlacementProperty { explicit PlacementProperty() {} - explicit PlacementProperty(float zoom, const PlacementRange &rotationRange) - : zoom(zoom), rotationRange(rotationRange) {} + explicit PlacementProperty(float zoom_, const PlacementRange &rotationRange_) + : zoom(zoom_), rotationRange(rotationRange_) {} inline operator bool() const { return !std::isnan(zoom) && zoom != std::numeric_limits::infinity() && diff --git a/include/mbgl/util/enum.hpp b/include/mbgl/util/enum.hpp index 195aaab5a..3c3e4a5c4 100644 --- a/include/mbgl/util/enum.hpp +++ b/include/mbgl/util/enum.hpp @@ -21,11 +21,11 @@ private: static constexpr inline bool compare(const char *a, const char *b) { return *a == *b && (*a == '\0' || compare(a + 1, b + 1)); } - static constexpr inline const char *lookup_type(Type e, EnumValue const * const l, size_t r) { - return r == 0 ? "" : l->value == e ? l->name : lookup_type(e, l + 1, r - 1); + static constexpr inline const char *lookup_type(Type e, EnumValue const * const list, size_t r) { + return r == 0 ? "" : list->value == e ? list->name : lookup_type(e, list + 1, r - 1); } - static constexpr inline Type lookup_name(const char *n, EnumValue const * const l, size_t r) { - return r == 0 ? Type(-1) : compare(l->name, n) ? l->value : lookup_name(n, l + 1, r - 1); + static constexpr inline Type lookup_name(const char *n, EnumValue const * const list, size_t r) { + return r == 0 ? Type(-1) : compare(list->name, n) ? list->value : lookup_name(n, list + 1, r - 1); } public: inline constexpr Enum(const char *n) : value(lookup_name(n, names, length)) {} diff --git a/include/mbgl/util/error.hpp b/include/mbgl/util/error.hpp index 99e27f770..09fa8d3e2 100644 --- a/include/mbgl/util/error.hpp +++ b/include/mbgl/util/error.hpp @@ -8,7 +8,7 @@ namespace mbgl { namespace error { struct style_parse : std::exception { - inline style_parse(size_t offset, const char *msg) : offset(offset), msg(msg) {} + inline style_parse(size_t offset_, const char *msg_) : offset(offset_), msg(msg_) {} inline const char* what() const noexcept { return msg.c_str(); } const size_t offset; const std::string msg; diff --git a/include/mbgl/util/pbf.hpp b/include/mbgl/util/pbf.hpp index 1f78a0072..ab4d60cd3 100644 --- a/include/mbgl/util/pbf.hpp +++ b/include/mbgl/util/pbf.hpp @@ -49,9 +49,9 @@ struct pbf { uint32_t tag = 0; }; -pbf::pbf(const unsigned char *data, size_t length) - : data(data), - end(data + length), +pbf::pbf(const unsigned char *data_, size_t length) + : data(data_), + end(data_ + length), value(0), tag(0) { } diff --git a/include/mbgl/util/rect.hpp b/include/mbgl/util/rect.hpp index dedd4afc9..f5c77f93d 100644 --- a/include/mbgl/util/rect.hpp +++ b/include/mbgl/util/rect.hpp @@ -6,7 +6,7 @@ namespace mbgl { template struct Rect { inline Rect() {} - inline Rect(T x, T y, T w, T h) : x(x), y(y), w(w), h(h) {} + inline Rect(T x_, T y_, T w_, T h_) : x(x_), y(y_), w(w_), h(h_) {} T x = 0, y = 0; T w = 0, h = 0; diff --git a/include/mbgl/util/transition.hpp b/include/mbgl/util/transition.hpp index 8a6836c88..16adc41ce 100644 --- a/include/mbgl/util/transition.hpp +++ b/include/mbgl/util/transition.hpp @@ -15,9 +15,9 @@ public: complete }; - inline transition(timestamp start, timestamp duration) - : start(start), - duration(duration) {} + inline transition(timestamp start_, timestamp duration_) + : start(start_), + duration(duration_) {} inline float progress(timestamp now) const { if (duration == 0) return 1; @@ -36,11 +36,11 @@ protected: template class ease_transition : public transition { public: - ease_transition(T from, T to, T& value, timestamp start, timestamp duration) + ease_transition(T from_, T to_, T& value_, timestamp start, timestamp duration) : transition(start, duration), - from(from), - to(to), - value(value) {} + from(from_), + to(to_), + value(value_) {} state update(timestamp now) const; @@ -53,10 +53,10 @@ private: template class timeout : public transition { public: - timeout(T final_value, T& value, timestamp start, timestamp duration) + timeout(T final_value_, T& value_, timestamp start, timestamp duration) : transition(start, duration), - final_value(final_value), - value(value) {} + final_value(final_value_), + value(value_) {} state update(timestamp now) const { if (progress(now) >= 1) { diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index f80ca1bff..b4b41f31a 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -68,7 +68,7 @@ private: class lock { public: - lock(mutex &mtx) : mtx(mtx) { mtx.lock(); } + lock(mutex &mtx_) : mtx(mtx_) { mtx.lock(); } ~lock() { mtx.unlock(); } private: @@ -94,8 +94,8 @@ private: class readlock { public: - inline readlock(rwlock &mtx) : mtx(mtx) { mtx.rdlock(); } - inline readlock(const std::unique_ptr &mtx) : mtx(*mtx) { mtx->rdlock(); } + inline readlock(rwlock &mtx_) : mtx(mtx_) { mtx.rdlock(); } + inline readlock(const std::unique_ptr &mtx_) : mtx(*mtx_) { mtx.rdlock(); } inline ~readlock() { mtx.rdunlock(); } private: @@ -104,8 +104,8 @@ private: class writelock { public: - inline writelock(rwlock &mtx) : mtx(mtx) { mtx.wrlock(); } - inline writelock(const std::unique_ptr &mtx) : mtx(*mtx) { mtx->wrlock(); } + inline writelock(rwlock &mtx_) : mtx(mtx_) { mtx.wrlock(); } + inline writelock(const std::unique_ptr &mtx_) : mtx(*mtx_) { mtx.wrlock(); } inline ~writelock() { mtx.wrunlock(); } private: @@ -148,10 +148,10 @@ public: typedef void (*after_work_callback)(T &object); template - work(worker &worker, work_callback work_cb, after_work_callback after_work_cb, Args&&... args) + work(worker &worker, work_callback work_cb_, after_work_callback after_work_cb_, Args&&... args) : data(std::forward(args)...), - work_cb(work_cb), - after_work_cb(after_work_cb) { + work_cb(work_cb_), + after_work_cb(after_work_cb_) { worker.add(this, do_work, after_work); } diff --git a/include/mbgl/util/vec.hpp b/include/mbgl/util/vec.hpp index a5fbee477..0179254fd 100644 --- a/include/mbgl/util/vec.hpp +++ b/include/mbgl/util/vec.hpp @@ -29,7 +29,7 @@ struct vec2 { template inline vec2(const U& u) : x(u.x), y(u.y) {} - inline vec2(T x, T y) : x(x), y(y) {} + inline vec2(T x_, T y_) : x(x_), y(y_) {} inline bool operator==(const vec2& rhs) const { return x == rhs.x && y == rhs.y; @@ -86,7 +86,7 @@ struct vec3 { inline vec3() {} inline vec3(const vec3& o) : x(o.x), y(o.y), z(o.z) {} - inline vec3(T x, T y, T z) : x(x), y(y), z(z) {} + inline vec3(T x_, T y_, T z_) : x(x_), y(y_), z(z_) {} inline bool operator==(const vec3& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } @@ -98,7 +98,7 @@ struct vec4 { inline vec4() {} inline vec4(const vec4& o) : x(o.x), y(o.y), z(o.z), w(o.w) {} - inline vec4(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {} + inline vec4(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) {} inline bool operator==(const vec4& rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z && w == rhs.w; } diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 56ad58416..7571ae143 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -3242,7 +3242,7 @@ void Clipper::BuildResult(Paths &polys) int cnt = PointCount(p); if (cnt < 2) continue; pg.reserve(cnt); - for (int i = 0; i < cnt; ++i) + for (int j = 0; j < cnt; ++j) { pg.push_back(p->Pt); p = p->Prev; diff --git a/src/geometry/debug_font.cpp b/src/geometry/debug_font.cpp index 2da0c6784..8ee9f6811 100644 --- a/src/geometry/debug_font.cpp +++ b/src/geometry/debug_font.cpp @@ -98,10 +98,10 @@ const int8_t simplex_94[] = { 3, 6, 3, 8, 4, 11, 6, 12, 8, 12, 10, 11, 14, 8, 16 struct glyph { glyph() : width(0), length(0), data(nullptr) { } - glyph(uint8_t width, uint8_t length, const int8_t *data) - : width(width), - length(length), - data(data) {} + glyph(uint8_t width_, uint8_t length_, const int8_t *data_) + : width(width_), + length(length_), + data(data_) {} uint8_t width; uint8_t length; const int8_t *data; diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index 76df941d9..6bee475da 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -9,11 +9,11 @@ using namespace mbgl; -GlyphAtlas::GlyphAtlas(uint16_t width, uint16_t height) - : width(width), - height(height), - bin(width, height), - data(new char[width *height]), +GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_) + : width(width_), + height(height_), + bin(width_, height_), + data(new char[width_ *height_]), dirty(true) { } diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 7ea9d4ce7..10922790c 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -14,10 +14,10 @@ using namespace mbgl; -SpriteAtlas::SpriteAtlas(dimension width, dimension height) - : width(width), - height(height), - bin(width, height), +SpriteAtlas::SpriteAtlas(dimension width_, dimension height_) + : width(width_), + height(height_), + bin(width_, height_), dirty(true) { } @@ -88,10 +88,10 @@ void copy_bitmap(const uint32_t *src, const int src_stride, const int src_x, con } } -Rect SpriteAtlas::allocateImage(size_t width, size_t height) { +Rect SpriteAtlas::allocateImage(size_t pixel_width, size_t pixel_height) { // We have to allocate a new area in the bin, and store an empty image in it. // Add a 1px border around every image. - Rect rect = bin.allocate(width + 2 * buffer, height + 2 * buffer); + Rect rect = bin.allocate(pixel_width + 2 * buffer, pixel_height + 2 * buffer); if (rect.w == 0) { return rect; } diff --git a/src/map/map.cpp b/src/map/map.cpp index 451385d3d..a7520b251 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -30,17 +30,17 @@ using namespace mbgl; -Map::Map(View& view) +Map::Map(View& view_) : loop(std::make_shared()), thread(std::make_unique()), async_terminate(new uv_async_t()), async_render(new uv_async_t()), async_cleanup(new uv_async_t()), - view(view), + view(view_), #ifndef NDEBUG main_thread(uv_thread_self()), #endif - transform(view), + transform(view_), glyphAtlas(std::make_shared(1024, 1024)), spriteAtlas(std::make_shared(512, 512)), texturepool(std::make_shared()), @@ -653,9 +653,6 @@ void Map::prepare() { void Map::render() { view.make_active(); -#if defined(DEBUG) - std::vector debug; -#endif painter.clear(); painter.resize(); diff --git a/src/map/source.cpp b/src/map/source.cpp index 36f1a71c8..ca1f3d532 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -20,8 +20,8 @@ namespace mbgl { -Source::Source(const util::ptr& info) - : info(info) +Source::Source(const util::ptr& info_) + : info(info_) { } @@ -219,15 +219,15 @@ std::forward_list Source::coveringTiles(const TransformState& state) c box points = state.cornersToBox(z); const vec2& center = points.center; - std::forward_list tiles = Tile::cover(z, points); + std::forward_list covering_tiles = Tile::cover(z, points); - tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { + covering_tiles.sort([¢er](const Tile::ID& a, const Tile::ID& b) { // Sorts by distance from the box center return std::fabs(a.x - center.x) + std::fabs(a.y - center.y) < std::fabs(b.x - center.x) + std::fabs(b.y - center.y); }); - return tiles; + return covering_tiles; } /** diff --git a/src/map/sprite.cpp b/src/map/sprite.cpp index c069ece45..876586e4b 100644 --- a/src/map/sprite.cpp +++ b/src/map/sprite.cpp @@ -13,13 +13,13 @@ using namespace mbgl; -SpritePosition::SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, float pixelRatio, bool sdf) - : x(x), - y(y), - width(width), - height(height), - pixelRatio(pixelRatio), - sdf(sdf) { +SpritePosition::SpritePosition(uint16_t x_, uint16_t y_, uint16_t width_, uint16_t height_, float pixelRatio_, bool sdf_) + : x(x_), + y(y_), + width(width_), + height(height_), + pixelRatio(pixelRatio_), + sdf(sdf_) { } util::ptr Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr &fileSource) { @@ -28,11 +28,11 @@ util::ptr Sprite::Create(const std::string& base_url, float pixelRatio, return sprite; } -Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio) +Sprite::Sprite(const Key &, const std::string& base_url, float pixelRatio_) : valid(base_url.length() > 0), - pixelRatio(pixelRatio), - spriteURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".png"), - jsonURL(base_url + (pixelRatio > 1 ? "@2x" : "") + ".json"), + pixelRatio(pixelRatio_), + spriteURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".png"), + jsonURL(base_url + (pixelRatio_ > 1 ? "@2x" : "") + ".json"), raster(), loadedImage(false), loadedJSON(false), @@ -123,16 +123,16 @@ void Sprite::parseJSON() { uint16_t y = 0; uint16_t width = 0; uint16_t height = 0; - float pixelRatio = 1.0f; + float spritePixelRatio = 1.0f; bool sdf = false; if (value.HasMember("x")) x = value["x"].GetInt(); if (value.HasMember("y")) y = value["y"].GetInt(); if (value.HasMember("width")) width = value["width"].GetInt(); if (value.HasMember("height")) height = value["height"].GetInt(); - if (value.HasMember("pixelRatio")) pixelRatio = value["pixelRatio"].GetInt(); + if (value.HasMember("pixelRatio")) spritePixelRatio = value["pixelRatio"].GetInt(); if (value.HasMember("sdf")) sdf = value["sdf"].GetBool(); - pos.emplace(name, SpritePosition { x, y, width, height, pixelRatio, sdf }); + pos.emplace(name, SpritePosition { x, y, width, height, spritePixelRatio, sdf }); } } } else { diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 863fbfbec..1fe0faefd 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -7,8 +7,8 @@ using namespace mbgl; #include -Tile::Tile(const ID& id) - : id(id) { +Tile::Tile(const ID& id_) + : id(id_) { } Tile::ID Tile::ID::parent(int8_t parent_z) const { diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp index 44e3826bf..7e4d1a1de 100644 --- a/src/map/tile_data.cpp +++ b/src/map/tile_data.cpp @@ -9,14 +9,14 @@ using namespace mbgl; -TileData::TileData(Tile::ID id, Map &map, const util::ptr &source) - : id(id), +TileData::TileData(Tile::ID id_, Map &map_, const util::ptr &source_) + : id(id_), state(State::initial), - map(map), - source(source), + map(map_), + source(source_), debugBucket(debugFontBuffer) { // Initialize tile debug coordinates - const std::string str = util::sprintf<32>("%d/%d/%d", id.z, id.x, id.y); + const std::string str = util::sprintf<32>("%d/%d/%d", id_.z, id_.x, id_.y); debugFontBuffer.addText(str.c_str(), 50, 200, 5); } diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 3dc5cb9ce..235151cd4 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -37,14 +37,14 @@ namespace mbgl { // its header file. TileParser::~TileParser() = default; -TileParser::TileParser(const std::string &data, VectorTileData &tile, +TileParser::TileParser(const std::string &data, VectorTileData &tile_, const util::ptr &style_, const util::ptr &glyphAtlas_, const util::ptr &glyphStore_, const util::ptr &spriteAtlas_, const util::ptr &sprite_) : vector_data(pbf((const uint8_t *)data.data(), data.size())), - tile(tile), + tile(tile_), style(style_), glyphAtlas(glyphAtlas_), glyphStore(glyphStore_), diff --git a/src/map/transform.cpp b/src/map/transform.cpp index baa615b94..b42f24a83 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -17,7 +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), mtx(std::make_unique()) { +Transform::Transform(View &view_) : view(view_), mtx(std::make_unique()) { setScale(current.scale); setAngle(current.angle); } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index 4b1bc4161..fa521400c 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -96,8 +96,8 @@ float TransformState::lngX(float lon) const { } float TransformState::latY(float lat) const { - float y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); - return (180 - y) * worldSize() / 360; + float latY = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - latY) * worldSize() / 360; } std::array TransformState::locationCoordinate(float lon, float lat) const { diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index 4ec25d6cf..8f097c829 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -103,9 +103,9 @@ VectorTileLayer::VectorTileLayer(pbf layer) : data(layer) { } } -FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer, const FilterExpression &filterExpression) - : layer(layer), - filterExpression(filterExpression) { +FilteredVectorTileLayer::FilteredVectorTileLayer(const VectorTileLayer& layer_, const FilterExpression &filterExpression_) + : layer(layer_), + filterExpression(filterExpression_) { } FilteredVectorTileLayer::iterator FilteredVectorTileLayer::begin() const { @@ -116,10 +116,10 @@ FilteredVectorTileLayer::iterator FilteredVectorTileLayer::end() const { return iterator(*this, pbf(layer.data.end, 0)); } -FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent, const pbf& data) - : parent(parent), +FilteredVectorTileLayer::iterator::iterator(const FilteredVectorTileLayer& parent_, const pbf& data_) + : parent(parent_), feature(pbf()), - data(data) { + data(data_) { operator++(); } diff --git a/src/renderer/debug_bucket.cpp b/src/renderer/debug_bucket.cpp index 699c1c1db..58fbf8a35 100644 --- a/src/renderer/debug_bucket.cpp +++ b/src/renderer/debug_bucket.cpp @@ -10,8 +10,8 @@ struct geometry_too_long_exception : std::exception {}; using namespace mbgl; -DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer) - : fontBuffer(fontBuffer) { +DebugBucket::DebugBucket(DebugFontBuffer& fontBuffer_) + : fontBuffer(fontBuffer_) { } void DebugBucket::render(Painter& painter, util::ptr /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) { diff --git a/src/renderer/fill_bucket.cpp b/src/renderer/fill_bucket.cpp index 5358cae0b..0a7d77935 100644 --- a/src/renderer/fill_bucket.cpp +++ b/src/renderer/fill_bucket.cpp @@ -30,11 +30,11 @@ void FillBucket::free(void *, void *ptr) { ::free(ptr); } -FillBucket::FillBucket(FillVertexBuffer &vertexBuffer, - TriangleElementsBuffer &triangleElementsBuffer, - LineElementsBuffer &lineElementsBuffer, - const StyleBucketFill &properties) - : properties(properties), +FillBucket::FillBucket(FillVertexBuffer &vertexBuffer_, + TriangleElementsBuffer &triangleElementsBuffer_, + LineElementsBuffer &lineElementsBuffer_, + const StyleBucketFill &properties_) + : properties(properties_), allocator(new TESSalloc{&alloc, &realloc, &free, nullptr, // userData 64, // meshEdgeBucketSize 64, // meshVertexBucketSize @@ -44,11 +44,11 @@ FillBucket::FillBucket(FillVertexBuffer &vertexBuffer, 128, // extraVertices allocated for the priority queue. }), tesselator(tessNewTess(allocator)), - vertexBuffer(vertexBuffer), - triangleElementsBuffer(triangleElementsBuffer), - lineElementsBuffer(lineElementsBuffer), - vertex_start(vertexBuffer.index()), - triangle_elements_start(triangleElementsBuffer.index()), + vertexBuffer(vertexBuffer_), + triangleElementsBuffer(triangleElementsBuffer_), + lineElementsBuffer(lineElementsBuffer_), + vertex_start(vertexBuffer_.index()), + triangle_elements_start(triangleElementsBuffer_.index()), line_elements_start(lineElementsBuffer.index()) { assert(tesselator); } @@ -123,10 +123,10 @@ void FillBucket::tessellate() { const size_t group_count = polygon.size(); assert(group_count >= 3); - std::vector line; + std::vector clipped_line; for (const ClipperLib::IntPoint& pt : polygon) { - line.push_back(pt.X); - line.push_back(pt.Y); + clipped_line.push_back(pt.X); + clipped_line.push_back(pt.Y); vertexBuffer.add(pt.X, pt.Y); } @@ -137,7 +137,7 @@ void FillBucket::tessellate() { lineIndex += group_count; - tessAddContour(tesselator, vertexSize, line.data(), stride, (int)line.size() / vertexSize); + tessAddContour(tesselator, vertexSize, clipped_line.data(), stride, (int)clipped_line.size() / vertexSize); } lineGroup.elements_length += total_vertex_count; diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index 3ef7411be..8267cbaba 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -17,17 +17,17 @@ struct geometry_too_long_exception : std::exception {}; using namespace mbgl; -LineBucket::LineBucket(LineVertexBuffer& vertexBuffer, - TriangleElementsBuffer& triangleElementsBuffer, - PointElementsBuffer& pointElementsBuffer, - const StyleBucketLine& properties) - : properties(properties), - vertexBuffer(vertexBuffer), - triangleElementsBuffer(triangleElementsBuffer), - pointElementsBuffer(pointElementsBuffer), - vertex_start(vertexBuffer.index()), - triangle_elements_start(triangleElementsBuffer.index()), - point_elements_start(pointElementsBuffer.index()) +LineBucket::LineBucket(LineVertexBuffer& vertexBuffer_, + TriangleElementsBuffer& triangleElementsBuffer_, + PointElementsBuffer& pointElementsBuffer_, + const StyleBucketLine& properties_) + : properties(properties_), + vertexBuffer(vertexBuffer_), + triangleElementsBuffer(triangleElementsBuffer_), + pointElementsBuffer(pointElementsBuffer_), + vertex_start(vertexBuffer_.index()), + triangle_elements_start(triangleElementsBuffer_.index()), + point_elements_start(pointElementsBuffer_.index()) { } @@ -53,7 +53,7 @@ void LineBucket::addGeometry(pbf& geom) { } struct TriangleElement { - TriangleElement(uint16_t a, uint16_t b, uint16_t c) : a(a), b(b), c(c) {} + TriangleElement(uint16_t a_, uint16_t b_, uint16_t c_) : a(a_), b(b_), c(c_) {} uint16_t a, b, c; }; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index e82b1b5f6..aa522734c 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -21,8 +21,8 @@ using namespace mbgl; #define BUFFER_OFFSET(i) ((char *)nullptr + (i)) -Painter::Painter(Map &map) - : map(map) { +Painter::Painter(Map &map_) + : map(map_) { } Painter::~Painter() { diff --git a/src/renderer/prerendered_texture.cpp b/src/renderer/prerendered_texture.cpp index 0a4781632..adb7a5910 100644 --- a/src/renderer/prerendered_texture.cpp +++ b/src/renderer/prerendered_texture.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties) - : properties(properties) { +PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties_) + : properties(properties_) { } PrerenderedTexture::~PrerenderedTexture() { diff --git a/src/renderer/raster_bucket.cpp b/src/renderer/raster_bucket.cpp index fc5e3dd3c..7adb3f845 100644 --- a/src/renderer/raster_bucket.cpp +++ b/src/renderer/raster_bucket.cpp @@ -3,9 +3,9 @@ using namespace mbgl; -RasterBucket::RasterBucket(const util::ptr &texturepool, const StyleBucketRaster& properties) -: properties(properties), - texture(properties), +RasterBucket::RasterBucket(const util::ptr &texturepool, const StyleBucketRaster& properties_) +: properties(properties_), + texture(properties_), raster(texturepool) { } @@ -24,8 +24,8 @@ void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index()); } -void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture) { - raster.bind(texture); +void RasterBucket::drawRaster(RasterShader& shader, StaticVertexBuffer &vertices, VertexArrayObject &array, GLuint texture_) { + raster.bind(texture_); shader.u_image = 0; array.bind(shader, vertices, BUFFER_OFFSET(0)); glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.index()); diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 3a4b017ef..47cc4db44 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -19,8 +19,8 @@ namespace mbgl { -SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties, Collision &collision) - : properties(properties), collision(collision) {} +SymbolBucket::SymbolBucket(const StyleBucketSymbol &properties_, Collision &collision_) + : properties(properties_), collision(collision_) {} void SymbolBucket::render(Painter &painter, util::ptr layer_desc, const Tile::ID &id, const mat4 &matrix) { @@ -52,12 +52,12 @@ std::vector SymbolBucket::processFeatures(const VectorTileLayer & const FilterExpression &filter, GlyphStore &glyphStore, const Sprite &sprite) { - const bool text = properties.text.field.size(); - const bool icon = properties.icon.image.size(); + const bool has_text = properties.text.field.size(); + const bool has_icon = properties.icon.image.size(); std::vector features; - if (!text && !icon) { + if (!has_text && !has_icon) { return features; } @@ -72,7 +72,7 @@ std::vector SymbolBucket::processFeatures(const VectorTileLayer & SymbolFeature ft; - if (text) { + if (has_text) { std::string u8string = util::replaceTokens(properties.text.field, feature.properties); if (properties.text.transform == TextTransformType::Uppercase) { @@ -91,7 +91,7 @@ std::vector SymbolBucket::processFeatures(const VectorTileLayer & } } - if (icon) { + if (has_icon) { ft.sprite = util::replaceTokens(properties.icon.image, feature.properties); } diff --git a/src/shader/shader.cpp b/src/shader/shader.cpp index 91c9b58c8..d9f63cae1 100644 --- a/src/shader/shader.cpp +++ b/src/shader/shader.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -Shader::Shader(const char *name, const GLchar *vertSource, const GLchar *fragSource) - : name(name), +Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSource) + : name(name_), valid(false), program(0) { util::timer timer("shader compilation", Event::Shader); diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index ca1412fd9..3da4fc7c3 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -82,19 +82,19 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr &&res) { #else uv_async_init(loop, http_baton->async, [](uv_async_t *async) { #endif - util::ptr &http_baton = *(util::ptr *)async->data; + util::ptr &baton = *(util::ptr *)async->data; - if (http_baton->request) { - HTTPRequest *request = http_baton->request; + if (baton->request) { + HTTPRequest *request = baton->request; request->http_baton.reset(); - http_baton->request = nullptr; - request->handleHTTPResponse(http_baton->type, std::move(http_baton->response)); + baton->request = nullptr; + request->handleHTTPResponse(baton->type, std::move(baton->response)); } delete (util::ptr *)async->data; uv_close((uv_handle_t *)async, [](uv_handle_t *handle) { - uv_async_t *async = (uv_async_t *)handle; - delete async; + uv_async_t *async_handle = (uv_async_t *)handle; + delete async_handle; }); }); attempts++; diff --git a/src/storage/sqlite_store.cpp b/src/storage/sqlite_store.cpp index 763100f41..e0757ecc3 100644 --- a/src/storage/sqlite_store.cpp +++ b/src/storage/sqlite_store.cpp @@ -68,8 +68,8 @@ SQLiteStore::~SQLiteStore() { // Nothing to do. This function needs to be here because we're forward-declaring // Database, so we need the actual definition here to be able to properly destruct it. if (worker) { - uv_worker_close(worker, [](uv_worker_t *worker) { - delete worker; + uv_worker_close(worker, [](uv_worker_t *worker_handle) { + delete worker_handle; }); } } diff --git a/src/style/applied_class_properties.cpp b/src/style/applied_class_properties.cpp index ca9c09436..9037c6ad5 100644 --- a/src/style/applied_class_properties.cpp +++ b/src/style/applied_class_properties.cpp @@ -2,11 +2,11 @@ namespace mbgl { -AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin, timestamp end, const PropertyValue &value) +AppliedClassProperty::AppliedClassProperty(ClassID class_id, timestamp begin_, timestamp end_, const PropertyValue &value_) : name(class_id), - begin(begin), - end(end), - value(value) {} + begin(begin_), + end(end_), + value(value_) {} // Returns thie ID of the most recent ClassID AppliedClassProperties::mostRecent() const { diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index 8f79bc904..4d64386be 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -7,8 +7,8 @@ namespace mbgl { -StyleLayer::StyleLayer(const std::string &id, std::map &&styles) - : id(id), styles(std::move(styles)) {} +StyleLayer::StyleLayer(const std::string &id_, std::map &&styles_) + : id(id_), styles(std::move(styles_)) {} bool StyleLayer::isBackground() const { return type == StyleLayerType::Background; @@ -70,8 +70,8 @@ void StyleLayer::applyClassProperties(const ClassID class_id, // Loop through all the properties in this style, and add transitions to them, if they're // not already the most recent transition. - const ClassProperties &properties = style_it->second; - for (const std::pair &property_pair : properties) { + const ClassProperties &class_properties = style_it->second; + for (const std::pair &property_pair : class_properties) { PropertyKey key = property_pair.first; if (already_applied.find(key) != already_applied.end()) { // This property has already been set by a previous class. @@ -87,7 +87,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id, AppliedClassProperties &appliedProperties = appliedStyle[key]; if (appliedProperties.mostRecent() != class_id) { const PropertyTransition &transition = - properties.getTransition(key, defaultTransition); + class_properties.getTransition(key, defaultTransition); const timestamp begin = now + transition.delay * 1_millisecond; const timestamp end = begin + transition.duration * 1_millisecond; const PropertyValue &value = property_pair.second; @@ -99,7 +99,7 @@ void StyleLayer::applyClassProperties(const ClassID class_id, template struct PropertyEvaluator { typedef T result_type; - PropertyEvaluator(float z) : z(z) {} + PropertyEvaluator(float z_) : z(z_) {} template ::value, int>::type = 0> T operator()(const P &value) const { @@ -269,11 +269,11 @@ void StyleLayer::cleanupAppliedStyleProperties(timestamp now) { auto it = appliedStyle.begin(); const auto end = appliedStyle.end(); while (it != end) { - AppliedClassProperties &properties = it->second; - properties.cleanup(now); + AppliedClassProperties &applied_properties = it->second; + applied_properties.cleanup(now); // If the current properties object is empty, remove it from the map entirely. - if (properties.empty()) { + if (applied_properties.empty()) { appliedStyle.erase(it++); } else { ++it; diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index a00fe6135..b2714f5da 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -108,13 +108,13 @@ template<> bool StyleParser::parseRenderProperty(JSVal value, uint16_t &target, if (value.HasMember(name)) { JSVal property = replaceConstant(value[name]); if (property.IsUint()) { - unsigned int value = property.GetUint(); - if (value > std::numeric_limits::max()) { + unsigned int int_value = property.GetUint(); + if (int_value > std::numeric_limits::max()) { Log::Warning(Event::ParseStyle, "values for %s that are larger than %d are not supported", name, std::numeric_limits::max()); return false; } - target = value; + target = int_value; return true; } else { Log::Warning(Event::ParseStyle, "%s must be an unsigned integer", name); @@ -763,11 +763,11 @@ FilterExpression StyleParser::parseFilter(JSVal value, FilterExpression::Operato FilterComparison comparison(name); JSVal filterValue = replaceConstant(itr->value); if (filterValue.IsObject()) { - rapidjson::Value::ConstMemberIterator itr = filterValue.MemberBegin(); - for (; itr != filterValue.MemberEnd(); ++itr) { + rapidjson::Value::ConstMemberIterator filter_itr = filterValue.MemberBegin(); + for (; filter_itr != filterValue.MemberEnd(); ++filter_itr) { comparison.add( - parseFilterComparisonOperator({ itr->name.GetString(), itr->name.GetStringLength() }), - parseValues(replaceConstant(itr->value)) + parseFilterComparisonOperator({ filter_itr->name.GetString(), filter_itr->name.GetStringLength() }), + parseValues(replaceConstant(filter_itr->value)) ); } } else if (filterValue.IsArray()) { diff --git a/src/text/collision.cpp b/src/text/collision.cpp index 6326bea82..2e0ec6dce 100644 --- a/src/text/collision.cpp +++ b/src/text/collision.cpp @@ -19,11 +19,11 @@ Box getBox(const CollisionAnchor &anchor, const CollisionRect &bbox, float minSc }; }; -Collision::Collision(float zoom, float tileExtent, float tileSize, float placementDepth) +Collision::Collision(float zoom_, float tileExtent, float tileSize, float placementDepth) // tile pixels per screen pixels at the tile's zoom level : tilePixelRatio(tileExtent / tileSize), - zoom(zoom), + zoom(zoom_), // Calculate the maximum scale we can go down in our fake-3d rtree so that // placement still makes sense. This is calculated so that the minimum @@ -33,7 +33,7 @@ Collision::Collision(float zoom, float tileExtent, float tileSize, float placeme // We don't want to place labels all the way to 25.5. This lets too many // glyphs be placed, slowing down collision checking. Only place labels if // they will show up within the intended zoom range of the tile. - maxPlacementScale(std::exp(std::log(2) * util::min(3.0f, placementDepth, 25.5f - zoom))) { + maxPlacementScale(std::exp(std::log(2) * util::min(3.0f, placementDepth, 25.5f - zoom_))) { const float m = 4096; const float edge = m * tilePixelRatio * 2; diff --git a/src/text/glyph_store.cpp b/src/text/glyph_store.cpp index 1723bd3d9..5619c4f93 100644 --- a/src/text/glyph_store.cpp +++ b/src/text/glyph_store.cpp @@ -228,7 +228,7 @@ void GlyphPBF::parse(FontStack &stack) { data.clear(); } -GlyphStore::GlyphStore(const util::ptr &fileSource) : fileSource(fileSource) {} +GlyphStore::GlyphStore(const util::ptr &fileSource_) : fileSource(fileSource_) {} void GlyphStore::setURL(const std::string &url) { glyphURL = url; diff --git a/src/text/placement.cpp b/src/text/placement.cpp index 0c95e3a80..84d4e20b2 100644 --- a/src/text/placement.cpp +++ b/src/text/placement.cpp @@ -12,10 +12,10 @@ namespace mbgl { const float Placement::globalMinScale = 0.5; // underscale by 1 zoom level struct GlyphInstance { - explicit GlyphInstance(const vec2 &anchor) : anchor(anchor) {} - explicit GlyphInstance(const vec2 &anchor, float offset, float minScale, float maxScale, - float angle) - : anchor(anchor), offset(offset), minScale(minScale), maxScale(maxScale), angle(angle) {} + explicit GlyphInstance(const vec2 &anchor_) : anchor(anchor_) {} + explicit GlyphInstance(const vec2 &anchor_, float offset_, float minScale_, float maxScale_, + float angle_) + : anchor(anchor_), offset(offset_), minScale(minScale_), maxScale(maxScale_), angle(angle_) {} const vec2 anchor; const float offset = 0.0f; diff --git a/src/util/image.cpp b/src/util/image.cpp index 28906c4e9..ec218e0be 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -30,8 +30,8 @@ std::string mbgl::util::compress_png(int width, int height, void *rgba, bool fli } std::string result; - png_set_write_fn(png_ptr, &result, [](png_structp png_ptr, png_bytep data, png_size_t length) { - std::string *out = static_cast(png_get_io_ptr(png_ptr)); + png_set_write_fn(png_ptr, &result, [](png_structp png_ptr_, png_bytep data, png_size_t length) { + std::string *out = static_cast(png_get_io_ptr(png_ptr_)); out->append(reinterpret_cast(data), length); }, NULL); @@ -57,8 +57,8 @@ using namespace mbgl::util; struct Buffer { - Buffer(const std::string& data) - : data(data.data()), length(data.size()) {} + Buffer(const std::string& data_) + : data(data_.data()), length(data_.size()) {} const char *const data = 0; const size_t length = 0; size_t pos = 0; diff --git a/src/util/raster.cpp b/src/util/raster.cpp index 7b52c5103..c4d7a1540 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -13,8 +13,8 @@ using namespace mbgl; -Raster::Raster(const util::ptr &texturepool) - : texturepool(texturepool) +Raster::Raster(const util::ptr &texturepool_) + : texturepool(texturepool_) {} Raster::~Raster() { @@ -59,32 +59,32 @@ void Raster::bind(bool linear) { glBindTexture(GL_TEXTURE_2D, texture); } - GLuint filter = linear ? GL_LINEAR : GL_NEAREST; - if (filter != this->filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - this->filter = filter; + GLuint new_filter = linear ? GL_LINEAR : GL_NEAREST; + if (new_filter != this->filter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter); + filter = new_filter; } } // overload ::bind for prerendered raster textures -void Raster::bind(const GLuint texture) { +void Raster::bind(const GLuint custom_texture) { if (img && !textured) { - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, custom_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->getData()); img.reset(); textured = true; } else if (textured) { - glBindTexture(GL_TEXTURE_2D, texture); + glBindTexture(GL_TEXTURE_2D, custom_texture); } - GLuint filter = GL_LINEAR; - if (filter != this->filter) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); - this->filter = filter; + GLuint new_filter = GL_LINEAR; + if (new_filter != this->filter) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, new_filter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, new_filter); + filter = new_filter; } } diff --git a/src/util/timer.cpp b/src/util/timer.cpp index d56860d19..5c4af51da 100644 --- a/src/util/timer.cpp +++ b/src/util/timer.cpp @@ -8,22 +8,22 @@ using namespace mbgl::util; -timer::timer(Event event) - : event(event), start(now()) {} +timer::timer(Event event_) + : event(event_), start(now()) {} -timer::timer(EventSeverity severity, Event event) - : severity(severity), event(event), start(now()) {} +timer::timer(EventSeverity severity_, Event event_) + : severity(severity_), event(event_), start(now()) {} -timer::timer(const std::string &name, Event event) - : name(name), event(event), start(now()) {} +timer::timer(const std::string &name_, Event event_) + : name(name_), event(event_), start(now()) {} -timer::timer(const std::string &name, EventSeverity severity, Event event) - : name(name), severity(severity), event(event), start(now()) {} +timer::timer(const std::string &name_, EventSeverity severity_, Event event_) + : name(name_), severity(severity_), event(event_), start(now()) {} -void timer::report(const std::string &name) { +void timer::report(const std::string &name_) { timestamp duration = now() - start; - Log::Record(severity, event, name + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); + Log::Record(severity, event, name_ + ": " + std::to_string((double)(duration) / 1_millisecond) + "ms"); start += duration; } diff --git a/test/comparisons.cpp b/test/comparisons.cpp index e1e991d41..4ffcf2e2e 100644 --- a/test/comparisons.cpp +++ b/test/comparisons.cpp @@ -10,7 +10,7 @@ class MockExtractor { public: - inline MockExtractor(const std::multimap &values) : values(values) {} + inline MockExtractor(const std::multimap &values_) : values(values_) {} inline MockExtractor() {} inline std::vector getValues(const std::string &key) const { diff --git a/test/fixtures/fixture_log.hpp b/test/fixtures/fixture_log.hpp index dc92f9319..99097a2c4 100644 --- a/test/fixtures/fixture_log.hpp +++ b/test/fixtures/fixture_log.hpp @@ -13,14 +13,14 @@ namespace mbgl { class FixtureLogBackend : public LogBackend, private util::noncopyable { public: struct LogMessage { - inline LogMessage(EventSeverity severity, Event event, int64_t code, const std::string &msg) - : severity(severity), event(event), code(code), msg(msg) {} - inline LogMessage(EventSeverity severity, Event event, int64_t code) - : severity(severity), event(event), code(code), msg() {} - inline LogMessage(EventSeverity severity, Event event, const std::string &msg) - : severity(severity), event(event), code(), msg(msg) {} - inline LogMessage(EventSeverity severity, Event event) - : severity(severity), event(event), code(), msg() {} + inline LogMessage(EventSeverity severity_, Event event_, int64_t code_, const std::string &msg_) + : severity(severity_), event(event_), code(code_), msg(msg_) {} + inline LogMessage(EventSeverity severity_, Event event_, int64_t code_) + : severity(severity_), event(event_), code(code_), msg() {} + inline LogMessage(EventSeverity severity_, Event event_, const std::string &msg_) + : severity(severity_), event(event_), code(), msg(msg_) {} + inline LogMessage(EventSeverity severity_, Event event_) + : severity(severity_), event(event_), code(), msg() {} inline bool operator==(const LogMessage &rhs) const { return (!severity || !rhs.severity || severity.get() == rhs.severity.get()) && From e2aaae665b96e3a39ee52702d43262595475ad07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 18:20:35 +0200 Subject: [PATCH 094/116] force exceptions and rtti in case they're disabled by another gyp file --- common.gypi | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/common.gypi b/common.gypi index 5d02a71c1..596db5449 100644 --- a/common.gypi +++ b/common.gypi @@ -1,17 +1,21 @@ { 'target_defaults': { 'default_configuration': 'Release', - 'xcode_settings': { - 'CLANG_CXX_LIBRARY': 'libc++', - 'CLANG_CXX_LANGUAGE_STANDARD':'c++11', - 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', - 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', - 'GCC_ENABLE_CPP_RTTI':'YES', - 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-Wno-variadic-macros' ], - 'GCC_WARN_PEDANTIC': 'YES', - 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE' - }, - 'cflags_cc': ['-std=c++11', '-Wall', '-Wextra'], + 'conditions': [ + ['OS=="mac"', { + 'xcode_settings': { + 'CLANG_CXX_LIBRARY': 'libc++', + 'CLANG_CXX_LANGUAGE_STANDARD':'c++11', + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', + 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', + 'GCC_ENABLE_CPP_RTTI':'YES', + 'OTHER_CPLUSPLUSFLAGS': [ '-Wall', '-Wextra', '-Wshadow', '-Wno-variadic-macros', '-frtti', '-fexceptions' ], + 'GCC_WARN_PEDANTIC': 'YES', + 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE', + }, + }], + ], + 'cflags_cc!': [ '-std=c++11', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], 'configurations': { 'Debug': { 'cflags_cc': [ '-g', '-O0', '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], @@ -31,7 +35,7 @@ 'GCC_OPTIMIZATION_LEVEL': '3', 'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO', 'DEAD_CODE_STRIPPING': 'YES', - 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' + 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'NO' } }, } From 40a933ddce390b7926c25bb00a95f34fd76453ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 22 Oct 2014 18:22:43 +0200 Subject: [PATCH 095/116] add missing header --- src/map/source.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/map/source.cpp b/src/map/source.cpp index ca1f3d532..9c0f7caf2 100644 --- a/src/map/source.cpp +++ b/src/map/source.cpp @@ -18,6 +18,8 @@ #include #include +#include + namespace mbgl { Source::Source(const util::ptr& info_) From 10cb83579feb53e7524ec899c0bff19161877669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 02:46:15 -0700 Subject: [PATCH 096/116] gcc fixes --- common.gypi | 8 +++++++- common/glfw_view.cpp | 4 ++-- common/http_request_baton_curl.cpp | 10 +++++----- include/mbgl/geometry/buffer.hpp | 6 +++--- include/mbgl/util/pbf.hpp | 4 ++-- include/mbgl/util/transition.hpp | 8 ++++---- src/clipper/clipper.cpp | 2 ++ src/geometry/debug_font_buffer.cpp | 6 +++--- src/map/raster_tile_data.cpp | 4 ++-- src/map/tile.cpp | 16 ++++++++-------- src/map/transform_state.cpp | 4 ++-- src/map/vector_tile_data.cpp | 4 ++-- src/renderer/painter.cpp | 8 ++++---- src/storage/file_source.cpp | 26 +++++++++++++------------- src/storage/http_request.cpp | 4 ++-- src/storage/response.cpp | 2 +- src/style/style.cpp | 1 + src/style/style_parser.cpp | 2 ++ src/util/image.cpp | 1 + src/util/raster.cpp | 2 -- test/fixtures/fixture_log.cpp | 12 ++++++------ 21 files changed, 72 insertions(+), 62 deletions(-) diff --git a/common.gypi b/common.gypi index 596db5449..627c18668 100644 --- a/common.gypi +++ b/common.gypi @@ -14,8 +14,14 @@ 'GCC_WARN_UNINITIALIZED_AUTOS': 'YES_AGGRESSIVE', }, }], + ['OS=="linux"', { + 'cflags_cc': [ + '-Wno-unknown-pragmas', # We are using '#pragma mark', but it is only available on Darwin. + '-Wno-literal-suffix', # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61653 + ], + }], ], - 'cflags_cc!': [ '-std=c++11', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], + 'cflags_cc': [ '-std=c++11', '-Werror', '-Wall', '-Wextra', '-Wshadow', '-frtti', '-fexceptions' ], 'configurations': { 'Debug': { 'cflags_cc': [ '-g', '-O0', '-fno-omit-frame-pointer','-fwrapv', '-fstack-protector-all', '-fno-common' ], diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index 53cd068d0..92d1e1908 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -13,8 +13,8 @@ GLFWView::~GLFWView() { glfwTerminate(); } -void GLFWView::initialize(mbgl::Map *map) { - View::initialize(map); +void GLFWView::initialize(mbgl::Map *map_) { + View::initialize(map_); if (!glfwInit()) { fprintf(stderr, "Failed to initialize glfw\n"); diff --git a/common/http_request_baton_curl.cpp b/common/http_request_baton_curl.cpp index b5226e20e..0c3d2b43f 100644 --- a/common/http_request_baton_curl.cpp +++ b/common/http_request_baton_curl.cpp @@ -154,11 +154,11 @@ void curl_perform(uv_poll_t *req, int, int events) { while ((message = curl_multi_info_read(multi, &pending))) { switch (message->msg) { case CURLMSG_DONE: { - CURLContext *context = nullptr; - curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, (char *)&context); + CURLContext *ctx = nullptr; + curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, (char *)&ctx); // Make a copy so that the Baton stays around even after we are calling finish_request - util::ptr baton = context->baton; + util::ptr baton = ctx->baton; // Add human-readable error code if (message->data.result != CURLE_OK) { @@ -242,8 +242,8 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void * } if (action == CURL_POLL_REMOVE && socketp) { uv_poll_stop(context->poll_handle); - uv_close((uv_handle_t *)context->poll_handle, [](uv_handle_t *handle) { - delete (uv_poll_t *)handle; + uv_close((uv_handle_t *)context->poll_handle, [](uv_handle_t *poll_handle) { + delete (uv_poll_t *)poll_handle; }); context->poll_handle = nullptr; curl_multi_assign(multi, sockfd, NULL); diff --git a/include/mbgl/geometry/buffer.hpp b/include/mbgl/geometry/buffer.hpp index 446177d44..80cc6b9d1 100644 --- a/include/mbgl/geometry/buffer.hpp +++ b/include/mbgl/geometry/buffer.hpp @@ -84,15 +84,15 @@ protected: } // Get a pointer to the item at a given index. - inline void *getElement(size_t index) { + inline void *getElement(size_t i) { if (array == nullptr) { throw std::runtime_error("Buffer was already deleted or doesn't contain elements"); } - if (index * itemSize >= pos) { + if (i * itemSize >= pos) { throw new std::runtime_error("Can't get element after array bounds"); } else { - return static_cast(array) + (index * itemSize); + return static_cast(array) + (i * itemSize); } } diff --git a/include/mbgl/util/pbf.hpp b/include/mbgl/util/pbf.hpp index ab4d60cd3..d017219a5 100644 --- a/include/mbgl/util/pbf.hpp +++ b/include/mbgl/util/pbf.hpp @@ -132,9 +132,9 @@ double pbf::float64() { std::string pbf::string() { uint32_t bytes = static_cast(varint()); - const char *string = reinterpret_cast(data); + const char *string_data = reinterpret_cast(data); skipBytes(bytes); - return std::string(string, bytes); + return std::string(string_data, bytes); } bool pbf::boolean() { diff --git a/include/mbgl/util/transition.hpp b/include/mbgl/util/transition.hpp index 16adc41ce..b78abfa8f 100644 --- a/include/mbgl/util/transition.hpp +++ b/include/mbgl/util/transition.hpp @@ -36,8 +36,8 @@ protected: template class ease_transition : public transition { public: - ease_transition(T from_, T to_, T& value_, timestamp start, timestamp duration) - : transition(start, duration), + ease_transition(T from_, T to_, T& value_, timestamp start_, timestamp duration_) + : transition(start_, duration_), from(from_), to(to_), value(value_) {} @@ -53,8 +53,8 @@ private: template class timeout : public transition { public: - timeout(T final_value_, T& value_, timestamp start, timestamp duration) - : transition(start, duration), + timeout(T final_value_, T& value_, timestamp start_, timestamp duration_) + : transition(start_, duration_), final_value(final_value_), value(value_) {} diff --git a/src/clipper/clipper.cpp b/src/clipper/clipper.cpp index 7571ae143..ea468d69e 100755 --- a/src/clipper/clipper.cpp +++ b/src/clipper/clipper.cpp @@ -48,6 +48,8 @@ #include #include +#pragma GCC diagnostic ignored "-Wshadow" + namespace ClipperLib { #ifdef use_int32 diff --git a/src/geometry/debug_font_buffer.cpp b/src/geometry/debug_font_buffer.cpp index 387a64629..2a0924a1c 100644 --- a/src/geometry/debug_font_buffer.cpp +++ b/src/geometry/debug_font_buffer.cpp @@ -10,9 +10,9 @@ using namespace mbgl; void DebugFontBuffer::addText(const char *text, double left, double baseline, double scale) { uint16_t *coords = nullptr; - size_t length = strlen(text); - for (size_t i = 0; i < length; ++i) { - if (text[i] < 32 || text[i] > 127) { + const size_t len = strlen(text); + for (size_t i = 0; i < len; ++i) { + if (text[i] < 32 || (unsigned char)(text[i]) > 127) { continue; } diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp index e7725b7ab..99ca327fe 100644 --- a/src/map/raster_tile_data.cpp +++ b/src/map/raster_tile_data.cpp @@ -5,8 +5,8 @@ using namespace mbgl; -RasterTileData::RasterTileData(Tile::ID id, Map &map, const util::ptr &source) - : TileData(id, map, source), +RasterTileData::RasterTileData(Tile::ID id_, Map &map_, const util::ptr &source_) + : TileData(id_, map_, source_), bucket(map.getTexturepool(), properties) { } diff --git a/src/map/tile.cpp b/src/map/tile.cpp index 1fe0faefd..3070d3fd9 100644 --- a/src/map/tile.cpp +++ b/src/map/tile.cpp @@ -25,13 +25,13 @@ std::forward_list Tile::ID::children(int32_t child_z) const { assert(child_z > z); int32_t factor = std::pow(2, child_z - z); - std::forward_list children; + std::forward_list child_ids; for (int32_t ty = y * factor, y_max = (y + 1) * factor; ty < y_max; ++ty) { for (int32_t tx = x * factor, x_max = (x + 1) * factor; tx < x_max; ++tx) { - children.emplace_front(child_z, tx, ty); + child_ids.emplace_front(child_z, tx, ty); } } - return children; + return child_ids; } Tile::ID Tile::ID::normalized() const { @@ -42,13 +42,13 @@ Tile::ID Tile::ID::normalized() const { return ID { z, nx, ny }; } -bool Tile::ID::isChildOf(const Tile::ID &parent) const { - if (parent.z >= z || parent.w != w) { +bool Tile::ID::isChildOf(const Tile::ID &parent_id) const { + if (parent_id.z >= z || parent_id.w != w) { return false; } - int32_t scale = std::pow(2, z - parent.z); - return parent.x == ((x < 0 ? x - scale + 1 : x) / scale) && - parent.y == y / scale; + int32_t scale = std::pow(2, z - parent_id.z); + return parent_id.x == ((x < 0 ? x - scale + 1 : x) / scale) && + parent_id.y == y / scale; } diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index fa521400c..0a858bce6 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -96,8 +96,8 @@ float TransformState::lngX(float lon) const { } float TransformState::latY(float lat) const { - float latY = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); - return (180 - latY) * worldSize() / 360; + float lat_y = 180 / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360)); + return (180 - lat_y) * worldSize() / 360; } std::array TransformState::locationCoordinate(float lon, float lat) const { diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp index 48b46059a..b94bc66de 100644 --- a/src/map/vector_tile_data.cpp +++ b/src/map/vector_tile_data.cpp @@ -8,8 +8,8 @@ using namespace mbgl; -VectorTileData::VectorTileData(Tile::ID id, Map &map, const util::ptr &source) - : TileData(id, map, source), +VectorTileData::VectorTileData(Tile::ID id_, Map &map_, const util::ptr &source_) + : TileData(id_, map_, source_), depth(id.z >= source->max_zoom ? map.getMaxZoom() - id.z : 1) { } diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index aa522734c..38c2176ae 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -128,10 +128,10 @@ void Painter::useProgram(uint32_t program) { } } -void Painter::lineWidth(float lineWidth) { - if (gl_lineWidth != lineWidth) { - glLineWidth(lineWidth); - gl_lineWidth = lineWidth; +void Painter::lineWidth(float line_width) { + if (gl_lineWidth != line_width) { + glLineWidth(line_width); + gl_lineWidth = line_width; } } diff --git a/src/storage/file_source.cpp b/src/storage/file_source.cpp index 12d924416..70b4abe4c 100644 --- a/src/storage/file_source.cpp +++ b/src/storage/file_source.cpp @@ -27,12 +27,12 @@ FileSource::~FileSource() { // NOTE: We don't need to delete the messenger since it will be deleted by the // uv_messenger_stop() function. - util::ptr request; + util::ptr req; // Send a cancel() message to all requests that we are still holding. for (const std::pair> &pair : pending) { - if ((request = pair.second.lock())) { - request->cancel(); + if ((req = pair.second.lock())) { + req->cancel(); } } } @@ -61,25 +61,25 @@ std::unique_ptr FileSource::request(ResourceType type, const std::strin } }(); - util::ptr request; + util::ptr req; // First, try to find an existing Request object. auto it = pending.find(absoluteURL); if (it != pending.end()) { - request = it->second.lock(); + req = it->second.lock(); } - if (!request) { + if (!req) { if (absoluteURL.substr(0, 7) == "file://") { - request = std::make_shared(absoluteURL.substr(7), loop); + req = std::make_shared(absoluteURL.substr(7), loop); } else { - request = std::make_shared(type, absoluteURL, loop, store); + req = std::make_shared(type, absoluteURL, loop, store); } - pending.emplace(absoluteURL, request); + pending.emplace(absoluteURL, req); } - return std::unique_ptr(new Request(request)); + return std::unique_ptr(new Request(req)); } void FileSource::prepare(std::function fn) { @@ -93,10 +93,10 @@ void FileSource::prepare(std::function fn) { void FileSource::retryAllPending() { assert(thread_id == uv_thread_self()); - util::ptr request; + util::ptr req; for (const std::pair> &pair : pending) { - if ((request = pair.second.lock())) { - request->retryImmediately(); + if ((req = pair.second.lock())) { + req->retryImmediately(); } } diff --git a/src/storage/http_request.cpp b/src/storage/http_request.cpp index 3da4fc7c3..46b1d5e19 100644 --- a/src/storage/http_request.cpp +++ b/src/storage/http_request.cpp @@ -20,8 +20,8 @@ struct CacheRequestBaton { util::ptr store; }; -HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path, uv_loop_t *loop_, util::ptr store_) - : BaseRequest(path), thread_id(uv_thread_self()), loop(loop_), store(store_), type(type_) { +HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path_, uv_loop_t *loop_, util::ptr store_) + : BaseRequest(path_), thread_id(uv_thread_self()), loop(loop_), store(store_), type(type_) { if (store) { startCacheRequest(); } else { diff --git a/src/storage/response.cpp b/src/storage/response.cpp index cdaf33e4e..f1e1c3587 100644 --- a/src/storage/response.cpp +++ b/src/storage/response.cpp @@ -9,7 +9,7 @@ int64_t Response::parseCacheControl(const char *value) { uint64_t seconds = 0; // TODO: cache-control may contain other information as well: // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9 - if (std::sscanf(value, "max-age=%llu", &seconds) == 1) { + if (std::sscanf(value, "max-age=%lu", &seconds) == 1) { return std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count() + seconds; diff --git a/src/style/style.cpp b/src/style/style.cpp index 6f0a0e3b2..aa5b15088 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -12,6 +12,7 @@ #include +#include namespace mbgl { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index b2714f5da..47ff0c30a 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -6,6 +6,8 @@ #include #include +#include + namespace mbgl { using JSVal = const rapidjson::Value&; diff --git a/src/util/image.cpp b/src/util/image.cpp index ec218e0be..fd0d34de2 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -1,4 +1,5 @@ #include + #include #include diff --git a/src/util/raster.cpp b/src/util/raster.cpp index c4d7a1540..76cd41122 100644 --- a/src/util/raster.cpp +++ b/src/util/raster.cpp @@ -6,8 +6,6 @@ #include #include -#include - #include #include diff --git a/test/fixtures/fixture_log.cpp b/test/fixtures/fixture_log.cpp index c2c10fc9e..1b1646e66 100644 --- a/test/fixtures/fixture_log.cpp +++ b/test/fixtures/fixture_log.cpp @@ -9,25 +9,25 @@ FixtureLogBackend::~FixtureLogBackend() { } size_t FixtureLogBackend::count(const LogMessage &message) const { - size_t count = 0; + size_t message_count = 0; for (const LogMessage &msg : messages) { if (msg == message) { - count++; + message_count++; msg.checked = true; } } - return count; + return message_count; } std::vector FixtureLogBackend::unchecked() const { - std::vector unchecked; + std::vector unchecked_messages; for (const LogMessage &msg : messages) { if (!msg.checked) { - unchecked.push_back(msg); + unchecked_messages.push_back(msg); msg.checked = true; } } - return unchecked; + return unchecked_messages; } ::std::ostream& operator<<(::std::ostream& os, const std::vector& messages) { From 3b397c56ed2b851b07bca3a7c7d38cb0e7cb53f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 03:30:05 -0700 Subject: [PATCH 097/116] print core dumps on application crashes --- .travis.yml | 5 +++++ scripts/run_tests.sh | 18 +++++++++++++++++- scripts/travis_before_install.sh | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bc714f77c..653b61037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,11 @@ before_install: install: - make config.gypi - ./scripts/travis_install_test_suite.sh +- ulimit -c + +before_script: + # Set the core file limit to unlimited so a core file is generated upon crash + - ulimit -c unlimited -S script: - ./scripts/travis_script.sh diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index dd9ee3f26..e9952e46b 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -3,8 +3,24 @@ set -e set -o pipefail +# allow writing core files +ulimit -c unlimited -S + cd build/${BUILDTYPE:-Release} for TEST in ./test_* ; do - ${TEST} + RESULT=0 + ${TEST} || RESULT=$? + + # output core dump if we got one + for DUMP in $(find ./ -maxdepth 1 -name 'core*' -print); do + gdb ${TEST} ${DUMP} -ex "thread apply all bt" -ex "set pagination 0" -batch + rm -rf ${DUMP} + done + + # now we should present travis with the original + # error code so the run cleanly stops + if [[ ${RESULT} != 0 ]]; then + exit $RESULT + fi done diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index 1ecfc4f26..fefd6937f 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -19,7 +19,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then sudo apt-get -y install gcc-4.8 g++-4.8 mapbox_time "install_build_tools" \ - sudo apt-get -y install git build-essential zlib1g-dev automake \ + sudo apt-get -y install git build-essential zlib1g-dev automake gdb \ libtool xutils-dev make cmake pkg-config python-pip \ libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \ libpng-dev libsqlite3-dev From 26e6ec20da4e85849d0688db5fd580056ebdfed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 05:34:16 -0700 Subject: [PATCH 098/116] show that the program crashed --- scripts/run_tests.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index e9952e46b..df0bf2521 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -3,15 +3,21 @@ set -e set -o pipefail -# allow writing core files -ulimit -c unlimited -S cd build/${BUILDTYPE:-Release} for TEST in ./test_* ; do + # allow writing core files + ulimit -c unlimited -S + RESULT=0 ${TEST} || RESULT=$? + if [[ ${RESULT} != 0 ]]; then + echo "The program crashed with exit code ${RESULT}. We're now trying to output the core dump." + ls -la + fi + # output core dump if we got one for DUMP in $(find ./ -maxdepth 1 -name 'core*' -print); do gdb ${TEST} ${DUMP} -ex "thread apply all bt" -ex "set pagination 0" -batch From 959d879f05da0e40270782e823435ca6946707ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 06:16:13 -0700 Subject: [PATCH 099/116] show more debug information --- scripts/run_tests.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index df0bf2521..fcd7fae09 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -2,20 +2,21 @@ set -e set -o pipefail - - +c cd build/${BUILDTYPE:-Release} for TEST in ./test_* ; do # allow writing core files ulimit -c unlimited -S + ulimit -c + cat /proc/sys/kernel/core_pattern + sysctl kernel.core_pattern RESULT=0 ${TEST} || RESULT=$? if [[ ${RESULT} != 0 ]]; then echo "The program crashed with exit code ${RESULT}. We're now trying to output the core dump." - ls -la fi # output core dump if we got one From ec73c369584315d91030faebc7e1a6e878c7e565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 06:22:08 -0700 Subject: [PATCH 100/116] fix typo --- scripts/run_tests.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index fcd7fae09..6b42b7991 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -2,14 +2,14 @@ set -e set -o pipefail -c + cd build/${BUILDTYPE:-Release} for TEST in ./test_* ; do # allow writing core files ulimit -c unlimited -S - ulimit -c - cat /proc/sys/kernel/core_pattern + echo 'ulimit -c: '`ulimit -c` + echo '/proc/sys/kernel/core_pattern: '`cat /proc/sys/kernel/core_pattern` sysctl kernel.core_pattern RESULT=0 From cd44abcc588c9fc988589c148e76e4590c2197b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 23 Oct 2014 07:34:01 -0700 Subject: [PATCH 101/116] disable the thread sanitizer on clang/Debug for now since this prevents core dumps from being generated on segfaults --- scripts/flags.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/flags.sh b/scripts/flags.sh index 2b4624aa1..0b1f69ae1 100755 --- a/scripts/flags.sh +++ b/scripts/flags.sh @@ -16,17 +16,17 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then # but it's not worth a standalone matrix so here # we just test address->gcc and thread->clang for # some limited coverage - if [[ ${BUILDTYPE} == "Debug" ]]; then - if [[ ${CXX} == "g++" ]]; then - export CXXFLAGS="-fsanitize=address -g ${CXXFLAGS}" - export CFLAGS="-fsanitize=address -g ${CFLAGS}" - export LDFLAGS="-fsanitize=address ${LDFLAGS}" - elif [[ ${CXX} == "clang++" ]]; then - export CXXFLAGS="-fsanitize=thread -g -fPIC ${CXXFLAGS}" - export CFLAGS="-fsanitize=thread -g ${CFLAGS}" - export LDFLAGS="-fsanitize=thread -pie ${LDFLAGS}" - fi - fi + # if [[ ${BUILDTYPE} == "Debug" ]]; then + # if [[ ${CXX} == "g++" ]]; then + # export CXXFLAGS="-fsanitize=address -g ${CXXFLAGS}" + # export CFLAGS="-fsanitize=address -g ${CFLAGS}" + # export LDFLAGS="-fsanitize=address ${LDFLAGS}" + # elif [[ ${CXX} == "clang++" ]]; then + # export CXXFLAGS="-fsanitize=thread -g -fPIC ${CXXFLAGS}" + # export CFLAGS="-fsanitize=thread -g ${CFLAGS}" + # export LDFLAGS="-fsanitize=thread -pie ${LDFLAGS}" + # fi + # fi fi # turn off a few warnings From cd9a89257a0004ca18460befc4b141bc07ed5c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 24 Oct 2014 15:43:05 +0200 Subject: [PATCH 102/116] restructure gyp files --- Makefile | 24 +- common.gypi | 2 +- gyp/certificates.gypi | 13 + gyp/fixtures.gypi | 18 ++ gyp/library.gypi | 75 ++++++ gyp/npm_install.gypi | 21 ++ gyp/platform-ios.gypi | 51 ++++ gyp/platform-linux.gypi | 53 ++++ gyp/platform-osx.gypi | 33 +++ gyp/shaders.gypi | 36 +++ gyp/styles.gypi | 36 +++ .../mbgl/platform/darwin/log_nslog.hpp | 0 .../mbgl/platform/darwin/reachability.h | 0 .../darwin}/settings_nsuserdefaults.hpp | 0 .../mbgl/platform/default}/glfw_view.hpp | 0 .../mbgl/platform/default}/headless_view.hpp | 0 .../mbgl/platform/default/log_stderr.hpp | 0 .../mbgl/platform/default}/settings_json.hpp | 0 ios/mapbox-gl-cocoa | 2 +- linux/main.cpp | 9 +- linux/mapboxgl-app.gyp | 21 +- macosx/main.mm | 11 +- macosx/mapboxgl-app.gyp | 18 +- mapboxgl.gyp | 254 +----------------- .../darwin}/http_request_baton_cocoa.mm | 0 .../darwin/log_nslog.mm | 2 +- .../darwin/reachability.m | 2 +- .../darwin}/settings_nsuserdefaults.mm | 2 +- .../darwin/string_nsstring.mm | 2 +- .../default/cache_database_tmp.cpp | 0 {common => platform/default}/glfw_view.cpp | 2 +- .../default}/headless_view.cpp | 0 .../default}/http_request_baton_curl.cpp | 0 .../default/log_stderr.cpp | 2 +- .../default}/settings_json.cpp | 2 +- .../default/string_stdlib.cpp | 0 .../ios/cache_database_library.mm | 0 .../osx/cache_database_application_support.mm | 0 test/test.gyp | 1 - 39 files changed, 392 insertions(+), 300 deletions(-) create mode 100644 gyp/certificates.gypi create mode 100644 gyp/fixtures.gypi create mode 100644 gyp/library.gypi create mode 100644 gyp/npm_install.gypi create mode 100644 gyp/platform-ios.gypi create mode 100644 gyp/platform-linux.gypi create mode 100644 gyp/platform-osx.gypi create mode 100644 gyp/shaders.gypi create mode 100644 gyp/styles.gypi rename common/nslog_log.hpp => include/mbgl/platform/darwin/log_nslog.hpp (100%) rename common/Reachability.h => include/mbgl/platform/darwin/reachability.h (100%) rename {common => include/mbgl/platform/darwin}/settings_nsuserdefaults.hpp (100%) rename {common => include/mbgl/platform/default}/glfw_view.hpp (100%) rename {common => include/mbgl/platform/default}/headless_view.hpp (100%) rename common/stderr_log.hpp => include/mbgl/platform/default/log_stderr.hpp (100%) rename {common => include/mbgl/platform/default}/settings_json.hpp (100%) rename {common => platform/darwin}/http_request_baton_cocoa.mm (100%) rename common/nslog_log.mm => platform/darwin/log_nslog.mm (98%) rename common/Reachability.m => platform/darwin/reachability.m (99%) rename {common => platform/darwin}/settings_nsuserdefaults.mm (96%) rename common/platform_nsstring.mm => platform/darwin/string_nsstring.mm (99%) rename common/linux.cpp => platform/default/cache_database_tmp.cpp (100%) rename {common => platform/default}/glfw_view.cpp (99%) rename {common => platform/default}/headless_view.cpp (100%) rename {common => platform/default}/http_request_baton_curl.cpp (100%) rename common/stderr_log.cpp => platform/default/log_stderr.cpp (94%) rename {common => platform/default}/settings_json.cpp (95%) rename common/platform_default.cpp => platform/default/string_stdlib.cpp (100%) rename common/ios.mm => platform/ios/cache_database_library.mm (100%) rename common/osx.mm => platform/osx/cache_database_application_support.mm (100%) diff --git a/Makefile b/Makefile index c0d76fd10..ae0ea1395 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,12 @@ BUILDTYPE ?= Release PYTHON ?= python V ?= 1 +ifeq ($(shell uname -s), Darwin) +PLATFORM ?= osx +endif +PLATFORM ?= linux + + all: mbgl config.gypi: configure @@ -12,13 +18,13 @@ config-ios.gypi: configure # Builds the regular library mbgl: config.gypi mapboxgl.gyp - deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl ##### Test cases ############################################################### build/test/Makefile: src common config.gypi test/test.gyp - deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/test -f make + deps/run_gyp test/test.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/test -f make test: build/test/Makefile $(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test @@ -29,7 +35,7 @@ test_%: build/test/Makefile # build Mac OS X project for Xcode xtest: config.gypi clear_xcode_cache - deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode + deps/run_gyp test/test.gyp -Iconfig.gypi -Dplatform=osx --depth=. -Goutput_dir=.. --generator-output=./build -f xcode open ./build/test/test.xcodeproj ##### Makefile builds ########################################################## @@ -37,7 +43,7 @@ xtest: config.gypi clear_xcode_cache # Builds the linux app with make. linux: config.gypi linux/mapboxgl-app.gyp - deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make $(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp # Executes the Linux binary @@ -48,7 +54,7 @@ run-linux: linux # Builds the OS X app with make. osx: config.gypi macosx/mapboxgl-app.gyp - deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=osx --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f make $(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp # Executes the OS X binary @@ -70,21 +76,21 @@ clear_xcode_cache: # build Mac OS X project for Xcode xproj-cli: config.gypi macosx/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp macosx/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=osx --depth=. --generator-output=./build -f xcode xproj: xproj-cli open ./build/macosx/mapboxgl-app.xcodeproj # build iOS project for Xcode iproj-cli: config-ios.gypi ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp -Iconfig-ios.gypi -Dplatform=ios --depth=. --generator-output=./build -f xcode iproj: iproj-cli open ./build/ios/mapbox-gl-cocoa/app/mapboxgl-app.xcodeproj # build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code) lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache - deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi --depth=. --generator-output=./build -f xcode + deps/run_gyp linux/mapboxgl-app.gyp -Iconfig.gypi -Dplatform=linux --depth=. --generator-output=./build -f xcode open ./build/linux/mapboxgl-app.xcodeproj @@ -98,5 +104,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl test linux build/test/Makefile +.PHONY: mbgl test linux clear_xcode_cache build/test/Makefile # DO NOT DELETE diff --git a/common.gypi b/common.gypi index 5d02a71c1..97481c1bb 100644 --- a/common.gypi +++ b/common.gypi @@ -34,6 +34,6 @@ 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' } }, - } + }, } } diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi new file mode 100644 index 000000000..6a358f0db --- /dev/null +++ b/gyp/certificates.gypi @@ -0,0 +1,13 @@ +{ + 'targets': [ + { + 'target_name': 'copy_certificate_bundle', + 'type': 'none', + 'hard_dependency': 1, + 'copies': [{ + 'files': [ '../common/ca-bundle.crt' ], + 'destination': '<(PRODUCT_DIR)' + }], + }, + ] +} diff --git a/gyp/fixtures.gypi b/gyp/fixtures.gypi new file mode 100644 index 000000000..f290da5d5 --- /dev/null +++ b/gyp/fixtures.gypi @@ -0,0 +1,18 @@ +{ + 'targets': [ + { + 'target_name': 'copy_fixtures', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'bundle_styles' + ], + 'copies': [ + { + 'files': [ '../styles' ], + 'destination': '../test/fixtures/style_parser' + } + ] + }, + ] +} diff --git a/gyp/library.gypi b/gyp/library.gypi new file mode 100644 index 000000000..bb86432da --- /dev/null +++ b/gyp/library.gypi @@ -0,0 +1,75 @@ +{ + 'targets': [ + { + 'target_name': 'mapboxgl', + 'product_name': 'mapboxgl', + 'type': 'static_library', + 'hard_dependency': 1, + 'dependencies': [ + 'shaders', + ], + 'sources': [ + ' -#include #include +#include +#include +#include +#include #include #include #include #include -#include "../common/settings_json.hpp" -#include "../common/glfw_view.hpp" -#include "../common/stderr_log.hpp" + GLFWView *view = nullptr; diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 05716dd11..09734fc1c 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -1,7 +1,6 @@ { 'includes': [ '../common.gypi', - '../config.gypi', ], 'targets': [ { @@ -10,15 +9,9 @@ 'type': 'executable', 'sources': [ './main.cpp', - '../common/settings_json.cpp', - '../common/settings_json.hpp', - '../common/platform_default.cpp', - '../common/glfw_view.hpp', - '../common/glfw_view.cpp', - '../common/http_request_baton_curl.cpp', - '../common/linux.cpp', - '../common/stderr_log.hpp', - '../common/stderr_log.cpp', + '../platform/default/settings_json.cpp', + '../platform/default/glfw_view.cpp', + '../platform/default/log_stderr.cpp', ], 'conditions': [ @@ -29,11 +22,9 @@ 'xcode_settings': { 'OTHER_CPLUSPLUSFLAGS':[ '<@(glfw3_cflags)', - '<@(curl_cflags)', ], 'OTHER_LDFLAGS': [ '<@(glfw3_libraries)', - '<@(curl_libraries)', ], } }, @@ -42,19 +33,19 @@ { 'cflags': [ '<@(glfw3_cflags)', - '<@(curl_cflags)', ], 'link_settings': { 'libraries': [ '<@(glfw3_libraries)', - '<@(curl_libraries)', - '-lboost_regex' + '-L<(boost_root)/lib', + '-lboost_regex', ], }, }], ], 'dependencies': [ '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mapboxgl-linux', '../mapboxgl.gyp:copy_styles', '../mapboxgl.gyp:copy_certificate_bundle', ], diff --git a/macosx/main.mm b/macosx/main.mm index 8cf3cc81c..81494821c 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -1,12 +1,10 @@ -#include "../common/settings_nsuserdefaults.hpp" -#include "../common/glfw_view.hpp" -#include "../common/nslog_log.hpp" -#include "../common/Reachability.h" +#include +#include +#include +#include #import -#include - @interface URLHandler : NSObject @property (nonatomic) mbgl::Map *map; @@ -71,7 +69,6 @@ @end int main() { - fprintf(stderr, "main thread: 0x%lx\n", uv_thread_self()); mbgl::Log::Set(); GLFWView view; diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 51f591fdd..4451a207b 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -1,7 +1,6 @@ { 'includes': [ '../common.gypi', - '../config.gypi' ], 'targets': [ { @@ -10,17 +9,11 @@ 'type': 'executable', 'sources': [ './main.mm', - '../common/settings_nsuserdefaults.hpp', - '../common/settings_nsuserdefaults.mm', - '../common/platform_nsstring.mm', - '../common/glfw_view.hpp', - '../common/glfw_view.cpp', - '../common/reachability.h', - '../common/reachability.m', - '../common/http_request_baton_cocoa.mm', - '../common/osx.mm', - '../common/nslog_log.hpp', - '../common/nslog_log.mm', + '../platform/darwin/settings_nsuserdefaults.hpp', + '../platform/darwin/settings_nsuserdefaults.mm', + '../platform/darwin/reachability.m', + '../platform/default/glfw_view.hpp', + '../platform/default/glfw_view.cpp', ], 'product_extension': 'app', 'mac_bundle': 1, @@ -45,6 +38,7 @@ 'dependencies': [ '../mapboxgl.gyp:bundle_styles', '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mapboxgl-osx', ] } ] diff --git a/mapboxgl.gyp b/mapboxgl.gyp index bdecb94d0..64c0ccc0c 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -1,248 +1,16 @@ { 'includes': [ './common.gypi', + './gyp/shaders.gypi', + './gyp/npm_install.gypi', + './gyp/styles.gypi', + './gyp/fixtures.gypi', + './gyp/certificates.gypi', + './gyp/library.gypi', + ], + 'conditions': [ + ['platform == "osx"', { 'includes': ['./gyp/platform-osx.gypi'] }], + ['platform == "ios"', { 'includes': ['./gyp/platform-ios.gypi'] }], + ['platform == "linux"', { 'includes': ['./gyp/platform-linux.gypi'] }], ], - 'targets': [ - { - 'target_name': 'shaders', - 'type': 'none', - 'hard_dependency': 1, - 'dependencies': [ - 'npm_install' - ], - 'actions': [ - { - 'action_name': 'Build Shaders', - 'inputs': [ - ' diff --git a/common/Reachability.m b/platform/darwin/reachability.m similarity index 99% rename from common/Reachability.m rename to platform/darwin/reachability.m index c6f6388f5..823465940 100644 --- a/common/Reachability.m +++ b/platform/darwin/reachability.m @@ -25,7 +25,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -#import "Reachability.h" +#import NSString *const kReachabilityChangedNotification = @"kReachabilityChangedNotification"; diff --git a/common/settings_nsuserdefaults.mm b/platform/darwin/settings_nsuserdefaults.mm similarity index 96% rename from common/settings_nsuserdefaults.mm rename to platform/darwin/settings_nsuserdefaults.mm index dfc601bdd..b9b0e134b 100644 --- a/common/settings_nsuserdefaults.mm +++ b/platform/darwin/settings_nsuserdefaults.mm @@ -1,6 +1,6 @@ #import -#include "settings_nsuserdefaults.hpp" +#include using namespace mbgl; diff --git a/common/platform_nsstring.mm b/platform/darwin/string_nsstring.mm similarity index 99% rename from common/platform_nsstring.mm rename to platform/darwin/string_nsstring.mm index 9119f2a8f..9b1dc745c 100644 --- a/common/platform_nsstring.mm +++ b/platform/darwin/string_nsstring.mm @@ -18,4 +18,4 @@ std::string lowercase(const std::string &string) { } } -} \ No newline at end of file +} diff --git a/common/linux.cpp b/platform/default/cache_database_tmp.cpp similarity index 100% rename from common/linux.cpp rename to platform/default/cache_database_tmp.cpp diff --git a/common/glfw_view.cpp b/platform/default/glfw_view.cpp similarity index 99% rename from common/glfw_view.cpp rename to platform/default/glfw_view.cpp index edfb3a6a6..fed21f7d9 100644 --- a/common/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -1,4 +1,4 @@ -#include "glfw_view.hpp" +#include #include diff --git a/common/headless_view.cpp b/platform/default/headless_view.cpp similarity index 100% rename from common/headless_view.cpp rename to platform/default/headless_view.cpp diff --git a/common/http_request_baton_curl.cpp b/platform/default/http_request_baton_curl.cpp similarity index 100% rename from common/http_request_baton_curl.cpp rename to platform/default/http_request_baton_curl.cpp diff --git a/common/stderr_log.cpp b/platform/default/log_stderr.cpp similarity index 94% rename from common/stderr_log.cpp rename to platform/default/log_stderr.cpp index bcb84447b..62938b6d6 100644 --- a/common/stderr_log.cpp +++ b/platform/default/log_stderr.cpp @@ -1,4 +1,4 @@ -#include "stderr_log.hpp" +#include #include #include diff --git a/common/settings_json.cpp b/platform/default/settings_json.cpp similarity index 95% rename from common/settings_json.cpp rename to platform/default/settings_json.cpp index f2f1248aa..f81c75115 100644 --- a/common/settings_json.cpp +++ b/platform/default/settings_json.cpp @@ -1,4 +1,4 @@ -#include "settings_json.hpp" +#include #include #include #include diff --git a/common/platform_default.cpp b/platform/default/string_stdlib.cpp similarity index 100% rename from common/platform_default.cpp rename to platform/default/string_stdlib.cpp diff --git a/common/ios.mm b/platform/ios/cache_database_library.mm similarity index 100% rename from common/ios.mm rename to platform/ios/cache_database_library.mm diff --git a/common/osx.mm b/platform/osx/cache_database_application_support.mm similarity index 100% rename from common/osx.mm rename to platform/osx/cache_database_application_support.mm diff --git a/test/test.gyp b/test/test.gyp index 1f63756e7..865bac867 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -1,7 +1,6 @@ { 'includes': [ '../common.gypi', - '../config.gypi' ], 'targets': [ { From 0e928b5204ad5e2a8cfc1dd1a993396be0bd9d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Fri, 24 Oct 2014 17:39:18 +0200 Subject: [PATCH 103/116] make tests work --- common.gypi => gyp/common.gypi | 0 gyp/platform-linux.gypi | 1 + gyp/platform.gypi | 16 + .../mbgl/platform/default}/glx.h | 0 .../platform/default}/headless_display.hpp | 0 ios/mapbox-gl-cocoa | 2 +- linux/mapboxgl-app.gyp | 2 +- macosx/mapboxgl-app.gyp | 2 +- mapboxgl.gyp | 8 +- platform/darwin/log_nslog.mm | 2 +- .../default}/headless_display.cpp | 2 +- platform/default/headless_view.cpp | 4 +- scripts/run_tests.sh | 5 +- test/headless.cpp | 4 +- test/test.gyp | 330 ++++++++---------- 15 files changed, 174 insertions(+), 204 deletions(-) rename common.gypi => gyp/common.gypi (100%) create mode 100644 gyp/platform.gypi rename {common => include/mbgl/platform/default}/glx.h (100%) rename {common => include/mbgl/platform/default}/headless_display.hpp (100%) rename {common => platform/default}/headless_display.cpp (97%) diff --git a/common.gypi b/gyp/common.gypi similarity index 100% rename from common.gypi rename to gyp/common.gypi diff --git a/gyp/platform-linux.gypi b/gyp/platform-linux.gypi index 4288def7f..9126652a7 100644 --- a/gyp/platform-linux.gypi +++ b/gyp/platform-linux.gypi @@ -44,6 +44,7 @@ 'libraries': [ '<@(uv_libraries)', '<@(curl_libraries)', + '-lboost_regex', ] }] ] diff --git a/gyp/platform.gypi b/gyp/platform.gypi new file mode 100644 index 000000000..605f3d712 --- /dev/null +++ b/gyp/platform.gypi @@ -0,0 +1,16 @@ +{ + 'conditions': [ + ['platform == "osx"', { + 'includes': ['platform-osx.gypi'], + 'variables': { 'platform_library': 'mapboxgl-osx' }, + }], + ['platform == "ios"', { + 'includes': ['platform-ios.gypi'], + 'variables': { 'platform_library': 'mapboxgl-ios' }, + }], + ['platform == "linux"', { + 'includes': ['platform-linux.gypi'], + 'variables': { 'platform_library': 'mapboxgl-linux' }, + }], + ], +} diff --git a/common/glx.h b/include/mbgl/platform/default/glx.h similarity index 100% rename from common/glx.h rename to include/mbgl/platform/default/glx.h diff --git a/common/headless_display.hpp b/include/mbgl/platform/default/headless_display.hpp similarity index 100% rename from common/headless_display.hpp rename to include/mbgl/platform/default/headless_display.hpp diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index cfbd1cfad..3f9579ad3 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit cfbd1cfad47802ee5489aef24a59e340b841e491 +Subproject commit 3f9579ad3a002433fee2df9b1a88869a57124175 diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 09734fc1c..e4dacd9af 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -1,6 +1,6 @@ { 'includes': [ - '../common.gypi', + '../gyp/common.gypi', ], 'targets': [ { diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index 4451a207b..dc65c3756 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -1,6 +1,6 @@ { 'includes': [ - '../common.gypi', + '../gyp/common.gypi', ], 'targets': [ { diff --git a/mapboxgl.gyp b/mapboxgl.gyp index 64c0ccc0c..8b805ae6d 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -1,16 +1,12 @@ { 'includes': [ - './common.gypi', + './gyp/common.gypi', './gyp/shaders.gypi', './gyp/npm_install.gypi', './gyp/styles.gypi', './gyp/fixtures.gypi', './gyp/certificates.gypi', './gyp/library.gypi', - ], - 'conditions': [ - ['platform == "osx"', { 'includes': ['./gyp/platform-osx.gypi'] }], - ['platform == "ios"', { 'includes': ['./gyp/platform-ios.gypi'] }], - ['platform == "linux"', { 'includes': ['./gyp/platform-linux.gypi'] }], + './gyp/platform.gypi', ], } diff --git a/platform/darwin/log_nslog.mm b/platform/darwin/log_nslog.mm index 231037b2d..b196930b2 100644 --- a/platform/darwin/log_nslog.mm +++ b/platform/darwin/log_nslog.mm @@ -1,4 +1,4 @@ -#include "log_nslog.hpp" +#include #import diff --git a/common/headless_display.cpp b/platform/default/headless_display.cpp similarity index 97% rename from common/headless_display.cpp rename to platform/default/headless_display.cpp index 3aaf2020b..409fcbf05 100644 --- a/common/headless_display.cpp +++ b/platform/default/headless_display.cpp @@ -1,4 +1,4 @@ -#include "headless_display.hpp" +#include #include #include diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index d1d13db5f..ec5c4aabe 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -1,5 +1,5 @@ -#include "headless_view.hpp" -#include "headless_display.hpp" +#include +#include #include #include diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 6b42b7991..e10700076 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -10,7 +10,10 @@ for TEST in ./test_* ; do ulimit -c unlimited -S echo 'ulimit -c: '`ulimit -c` echo '/proc/sys/kernel/core_pattern: '`cat /proc/sys/kernel/core_pattern` - sysctl kernel.core_pattern + + if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then + sysctl kernel.core_pattern + fi RESULT=0 ${TEST} || RESULT=$? diff --git a/test/headless.cpp b/test/headless.cpp index 02dd0165e..e1bdbdc06 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -9,8 +9,8 @@ #include #include -#include "../common/headless_view.hpp" -#include "../common/headless_display.hpp" +#include +#include #include "./fixtures/fixture_log.hpp" diff --git a/test/test.gyp b/test/test.gyp index 49cc33739..04287bd9a 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -1,200 +1,154 @@ { 'includes': [ - '../common.gypi', + '../gyp/common.gypi', + '../gyp/platform.gypi', ], 'targets': [ - { - 'target_name': 'link_gl', - 'type': 'none', - 'direct_dependent_settings': { - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW - ], - }, - }, { - 'link_settings': { - 'libraries': [ - '<@(glfw3_libraries)', # This is a hack since we're not actually using GLFW - '-lboost_regex', - ], - }, - }], - ], - }, + { 'target_name': 'rotation_range', + 'product_name': 'test_rotation_range', + 'type': 'executable', + 'sources': [ + './main.cpp', + './rotation_range.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + ] }, - { - 'target_name': 'link_curl', - 'type': 'none', - 'direct_dependent_settings': { - 'conditions': [ - ['OS == "mac"', { - 'xcode_settings': { - 'OTHER_CPLUSPLUSFLAGS':[ - '<@(curl_cflags)', - ], - 'OTHER_LDFLAGS': [ - '<@(curl_libraries)', - ], - }, - }, { - 'cflags': [ - '<@(curl_cflags)', - ], - 'link_settings': { - 'libraries': [ - '<@(curl_libraries)', - ], - }, - }], - ], - }, + { 'target_name': 'clip_ids', + 'product_name': 'test_clip_ids', + 'type': 'executable', + 'sources': [ + './main.cpp', + './clip_ids.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + ] }, - { - "target_name": "rotation_range", - "product_name": "test_rotation_range", - "type": "executable", - "sources": [ - "./main.cpp", - "./rotation_range.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", + { 'target_name': 'enums', + 'product_name': 'test_enums', + 'type': 'executable', + 'sources': [ + './main.cpp', + './enums.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + ] + }, + { 'target_name': 'style_parser', + 'product_name': 'test_style_parser', + 'type': 'executable', + 'sources': [ + './main.cpp', + './style_parser.cpp', + './fixtures/fixture_log.hpp', + './fixtures/fixture_log.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:copy_fixtures', + ] + }, + { 'target_name': 'variant', + 'product_name': 'test_variant', + 'type': 'executable', + 'sources': [ + './main.cpp', + './variant.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + ] + }, + { 'target_name': 'comparisons', + 'product_name': 'test_comparisons', + 'type': 'executable', + 'sources': [ + './main.cpp', + './comparisons.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + ] + }, + { 'target_name': 'tile', + 'product_name': 'test_tile', + 'type': 'executable', + 'sources': [ + './main.cpp', + './tile.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + ] + }, + { 'target_name': 'functions', + 'product_name': 'test_functions', + 'type': 'executable', + 'sources': [ + './main.cpp', + './functions.cpp', + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', ] }, - { - "target_name": "clip_ids", - "product_name": "test_clip_ids", - "type": "executable", - "sources": [ - "./main.cpp", - "./clip_ids.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] + { 'target_name': 'headless', + 'product_name': 'test_headless', + 'type': 'executable', + 'sources': [ + './main.cpp', + './headless.cpp', + './fixtures/fixture_request.cpp', + './fixtures/fixture_log.cpp', + '../platform/default/headless_view.cpp', + '../platform/default/headless_display.cpp', + ], + 'conditions': [ + # add libuv include path and OpenGL libs + ['OS == "mac"', + { + 'xcode_settings': { + 'OTHER_CPLUSPLUSFLAGS': ['<@(uv_cflags)'], + 'OTHER_LDFLAGS': ['<@(glfw3_libraries)'], + }, + }, + { + 'cflags': ['<@(uv_cflags)'], + 'libraries': ['<@(glfw3_libraries)'], + }], + ], + 'dependencies': [ + '../deps/gtest/gtest.gyp:gtest', + '../mapboxgl.gyp:mapboxgl', + '<(platform_library)', + ], }, - { - "target_name": "enums", - "product_name": "test_enums", - "type": "executable", - "sources": [ - "./main.cpp", - "./enums.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "style_parser", - "product_name": "test_style_parser", - "type": "executable", - "sources": [ - "./main.cpp", - "./style_parser.cpp", - "./fixtures/fixture_log.hpp", - "./fixtures/fixture_log.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - "../mapboxgl.gyp:copy_fixtures", - ] - }, - { - "target_name": "variant", - "product_name": "test_variant", - "type": "executable", - "sources": [ - "./main.cpp", - "./variant.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "comparisons", - "product_name": "test_comparisons", - "type": "executable", - "sources": [ - "./main.cpp", - "./comparisons.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "tile", - "product_name": "test_tile", - "type": "executable", - "sources": [ - "./main.cpp", - "./tile.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "functions", - "product_name": "test_functions", - "type": "executable", - "sources": [ - "./main.cpp", - "./functions.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - ] - }, - { - "target_name": "headless", - "product_name": "test_headless", - "type": "executable", - "sources": [ - "./main.cpp", - "./headless.cpp", - "../common/headless_view.hpp", - "../common/headless_view.cpp", - "../common/headless_display.hpp", - "../common/headless_display.cpp", - "../common/platform_default.cpp", - "./fixtures/fixture_request.cpp", - "./fixtures/fixture_log.hpp", - "./fixtures/fixture_log.cpp", - ], - "dependencies": [ - "../deps/gtest/gtest.gyp:gtest", - "../mapboxgl.gyp:mapboxgl", - "link_gl", - ] - }, - { - "target_name": "test", - "type": "none", - "dependencies": [ - "rotation_range", - "clip_ids", - "enums", - "variant", - "tile", - "functions", - "headless", - "style_parser", - "comparisons", - ], + + # Build all targets + { 'target_name': 'test', + 'type': 'none', + 'dependencies': [ + 'rotation_range', + 'clip_ids', + 'enums', + 'variant', + 'tile', + 'functions', + 'headless', + 'style_parser', + 'comparisons', + ], } ] } From 84700fce9095ef9a7d30a580a552f2393f8acc8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 27 Oct 2014 10:05:05 -0400 Subject: [PATCH 104/116] allow installing the library --- Makefile | 9 ++++++-- gyp/certificates.gypi | 3 +-- gyp/common.gypi | 3 +++ gyp/fixtures.gypi | 3 +-- gyp/install.gypi | 23 ++++++++++++++++++++ gyp/mbgl-headless.gypi | 15 +++++++++++++ gyp/{platform-ios.gypi => mbgl-ios.gypi} | 6 ++--- gyp/{platform-linux.gypi => mbgl-linux.gypi} | 6 ++--- gyp/{platform-osx.gypi => mbgl-osx.gypi} | 6 ++--- gyp/mbgl-platform.gypi | 16 ++++++++++++++ gyp/{library.gypi => mbgl.gypi} | 5 ++--- gyp/npm_install.gypi | 3 +-- gyp/platform.gypi | 16 -------------- ios/mapbox-gl-cocoa | 2 +- linux/mapboxgl-app.gyp | 4 ++-- macosx/mapboxgl-app.gyp | 4 ++-- mapboxgl.gyp | 6 +++-- test/test.gyp | 20 ++++++++--------- 18 files changed, 97 insertions(+), 53 deletions(-) create mode 100644 gyp/install.gypi create mode 100644 gyp/mbgl-headless.gypi rename gyp/{platform-ios.gypi => mbgl-ios.gypi} (93%) rename gyp/{platform-linux.gypi => mbgl-linux.gypi} (92%) rename gyp/{platform-osx.gypi => mbgl-osx.gypi} (87%) create mode 100644 gyp/mbgl-platform.gypi rename gyp/{library.gypi => mbgl.gypi} (96%) delete mode 100644 gyp/platform.gypi diff --git a/Makefile b/Makefile index 6ff610305..2431f7be7 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ BUILDTYPE ?= Release PYTHON ?= python V ?= 1 +PREFIX ?= /usr/local ifeq ($(shell uname -s), Darwin) PLATFORM ?= osx @@ -19,7 +20,11 @@ config-ios.gypi: configure # Builds the regular library mbgl: config.gypi mapboxgl.gyp deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make - $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mbgl + +install: config.gypi mapboxgl.gyp + deps/run_gyp mapboxgl.gyp -Iconfig.gypi -Dplatform=$(PLATFORM) -Dinstall_prefix=$(PREFIX) --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make + $(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) install ##### Test cases ############################################################### @@ -104,5 +109,5 @@ clean: clear_xcode_cache distclean: clean -rm -rf ./mason_packages -.PHONY: mbgl test linux clear_xcode_cache build/test/Makefile clean distclean +.PHONY: mbgl install test linux clear_xcode_cache build/test/Makefile clean distclean # DO NOT DELETE diff --git a/gyp/certificates.gypi b/gyp/certificates.gypi index 6a358f0db..1d0c2acf8 100644 --- a/gyp/certificates.gypi +++ b/gyp/certificates.gypi @@ -1,7 +1,6 @@ { 'targets': [ - { - 'target_name': 'copy_certificate_bundle', + { 'target_name': 'copy_certificate_bundle', 'type': 'none', 'hard_dependency': 1, 'copies': [{ diff --git a/gyp/common.gypi b/gyp/common.gypi index 89a82fbdb..6d6b0e667 100644 --- a/gyp/common.gypi +++ b/gyp/common.gypi @@ -1,4 +1,7 @@ { + 'variables': { + 'install_prefix%': '', + }, 'target_defaults': { 'default_configuration': 'Release', 'conditions': [ diff --git a/gyp/fixtures.gypi b/gyp/fixtures.gypi index f290da5d5..199865a6f 100644 --- a/gyp/fixtures.gypi +++ b/gyp/fixtures.gypi @@ -1,7 +1,6 @@ { 'targets': [ - { - 'target_name': 'copy_fixtures', + { 'target_name': 'copy_fixtures', 'type': 'none', 'hard_dependency': 1, 'dependencies': [ diff --git a/gyp/install.gypi b/gyp/install.gypi new file mode 100644 index 000000000..8b79a4518 --- /dev/null +++ b/gyp/install.gypi @@ -0,0 +1,23 @@ +{ + 'conditions': [ + ['install_prefix != ""', { + 'targets': [ + { 'target_name': 'install', + 'type': 'none', + 'hard_dependency': 1, + 'dependencies': [ + 'mbgl', + 'mbgl-headless', + 'mbgl-<(platform)', + ], + 'copies': [ + { 'files': [ '<(PRODUCT_DIR)/libmbgl.a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '<(PRODUCT_DIR)/libmbgl-headless.a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '<(PRODUCT_DIR)/libmbgl-<(platform).a' ], 'destination': '<(install_prefix)/lib' }, + { 'files': [ '../include/mbgl' ], 'destination': '<(install_prefix)/include' } + ], + }, + ] + }], + ], +} diff --git a/gyp/mbgl-headless.gypi b/gyp/mbgl-headless.gypi new file mode 100644 index 000000000..5ffc251d2 --- /dev/null +++ b/gyp/mbgl-headless.gypi @@ -0,0 +1,15 @@ +{ + 'targets': [ + { 'target_name': 'mbgl-headless', + 'product_name': 'mbgl-headless', + 'type': 'static_library', + 'include_dirs': [ + '../include', + ], + 'sources': [ + '../platform/default/headless_view.cpp', + '../platform/default/headless_display.cpp', + ], + }, + ] +} \ No newline at end of file diff --git a/gyp/platform-ios.gypi b/gyp/mbgl-ios.gypi similarity index 93% rename from gyp/platform-ios.gypi rename to gyp/mbgl-ios.gypi index d07074492..e6fa50bd5 100644 --- a/gyp/platform-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -18,10 +18,10 @@ ], }, 'targets': [ - { - 'target_name': 'mapboxgl-ios', - 'product_name': 'mapboxgl-ios', + { 'target_name': 'mbgl-ios', + 'product_name': 'mbgl-ios', 'type': 'static_library', + 'hard_dependency': 1, 'include_dirs': [ '../include', ], diff --git a/gyp/platform-linux.gypi b/gyp/mbgl-linux.gypi similarity index 92% rename from gyp/platform-linux.gypi rename to gyp/mbgl-linux.gypi index 9126652a7..39a175556 100644 --- a/gyp/platform-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -1,9 +1,9 @@ { 'targets': [ - { - 'target_name': 'mapboxgl-linux', - 'product_name': 'mapboxgl-linux', + { 'target_name': 'mbgl-linux', + 'product_name': 'mbgl-linux', 'type': 'static_library', + 'hard_dependency': 1, 'include_dirs': [ '../include' ], diff --git a/gyp/platform-osx.gypi b/gyp/mbgl-osx.gypi similarity index 87% rename from gyp/platform-osx.gypi rename to gyp/mbgl-osx.gypi index adc0d3232..ba117e5a5 100644 --- a/gyp/platform-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -1,9 +1,9 @@ { 'targets': [ - { - 'target_name': 'mapboxgl-osx', - 'product_name': 'mapboxgl-osx', + { 'target_name': 'mbgl-osx', + 'product_name': 'mbgl-osx', 'type': 'static_library', + 'hard_dependency': 1, 'include_dirs': [ '../include', ], diff --git a/gyp/mbgl-platform.gypi b/gyp/mbgl-platform.gypi new file mode 100644 index 000000000..74ac9aecc --- /dev/null +++ b/gyp/mbgl-platform.gypi @@ -0,0 +1,16 @@ +{ + 'conditions': [ + ['platform == "osx"', { + 'includes': ['mbgl-osx.gypi'], + 'variables': { 'platform_library': 'mbgl-osx' }, + }], + ['platform == "ios"', { + 'includes': ['mbgl-ios.gypi'], + 'variables': { 'platform_library': 'mbgl-ios' }, + }], + ['platform == "linux"', { + 'includes': ['mbgl-linux.gypi'], + 'variables': { 'platform_library': 'mbgl-linux' }, + }], + ], +} diff --git a/gyp/library.gypi b/gyp/mbgl.gypi similarity index 96% rename from gyp/library.gypi rename to gyp/mbgl.gypi index bb86432da..f268fd625 100644 --- a/gyp/library.gypi +++ b/gyp/mbgl.gypi @@ -1,8 +1,7 @@ { 'targets': [ - { - 'target_name': 'mapboxgl', - 'product_name': 'mapboxgl', + { 'target_name': 'mbgl', + 'product_name': 'mbgl', 'type': 'static_library', 'hard_dependency': 1, 'dependencies': [ diff --git a/gyp/npm_install.gypi b/gyp/npm_install.gypi index 07d2e3e00..ddd3081ad 100644 --- a/gyp/npm_install.gypi +++ b/gyp/npm_install.gypi @@ -1,7 +1,6 @@ { 'targets': [ - { - 'target_name': 'npm_install', + { 'target_name': 'npm_install', 'type': 'none', 'hard_dependency': 1, 'actions': [ diff --git a/gyp/platform.gypi b/gyp/platform.gypi deleted file mode 100644 index 605f3d712..000000000 --- a/gyp/platform.gypi +++ /dev/null @@ -1,16 +0,0 @@ -{ - 'conditions': [ - ['platform == "osx"', { - 'includes': ['platform-osx.gypi'], - 'variables': { 'platform_library': 'mapboxgl-osx' }, - }], - ['platform == "ios"', { - 'includes': ['platform-ios.gypi'], - 'variables': { 'platform_library': 'mapboxgl-ios' }, - }], - ['platform == "linux"', { - 'includes': ['platform-linux.gypi'], - 'variables': { 'platform_library': 'mapboxgl-linux' }, - }], - ], -} diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 3f9579ad3..2d8fa07ab 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 3f9579ad3a002433fee2df9b1a88869a57124175 +Subproject commit 2d8fa07ab7dc1ff93728e656bac4a82da423e8b0 diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index e4dacd9af..ee38b4b26 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -44,8 +44,8 @@ }], ], 'dependencies': [ - '../mapboxgl.gyp:mapboxgl', - '../mapboxgl.gyp:mapboxgl-linux', + '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-linux', '../mapboxgl.gyp:copy_styles', '../mapboxgl.gyp:copy_certificate_bundle', ], diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp index dc65c3756..fe8d9f7ae 100644 --- a/macosx/mapboxgl-app.gyp +++ b/macosx/mapboxgl-app.gyp @@ -37,8 +37,8 @@ }, 'dependencies': [ '../mapboxgl.gyp:bundle_styles', - '../mapboxgl.gyp:mapboxgl', - '../mapboxgl.gyp:mapboxgl-osx', + '../mapboxgl.gyp:mbgl', + '../mapboxgl.gyp:mbgl-osx', ] } ] diff --git a/mapboxgl.gyp b/mapboxgl.gyp index 8b805ae6d..9126a1a62 100644 --- a/mapboxgl.gyp +++ b/mapboxgl.gyp @@ -6,7 +6,9 @@ './gyp/styles.gypi', './gyp/fixtures.gypi', './gyp/certificates.gypi', - './gyp/library.gypi', - './gyp/platform.gypi', + './gyp/mbgl.gypi', + './gyp/mbgl-platform.gypi', + './gyp/mbgl-headless.gypi', + './gyp/install.gypi', ], } diff --git a/test/test.gyp b/test/test.gyp index 04287bd9a..daf74b3e9 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -1,7 +1,7 @@ { 'includes': [ '../gyp/common.gypi', - '../gyp/platform.gypi', + '../gyp/mbgl-platform.gypi', ], 'targets': [ { 'target_name': 'rotation_range', @@ -13,7 +13,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'clip_ids', @@ -25,7 +25,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'enums', @@ -37,7 +37,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'style_parser', @@ -51,7 +51,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', '../mapboxgl.gyp:copy_fixtures', ] }, @@ -64,7 +64,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'comparisons', @@ -76,7 +76,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'tile', @@ -88,7 +88,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'functions', @@ -100,7 +100,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', ] }, { 'target_name': 'headless', @@ -130,7 +130,7 @@ ], 'dependencies': [ '../deps/gtest/gtest.gyp:gtest', - '../mapboxgl.gyp:mapboxgl', + '../mapboxgl.gyp:mbgl', '<(platform_library)', ], }, From 7211ed1bfe501ffd16cdcdc511896e93fd3cbda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 27 Oct 2014 10:21:19 -0400 Subject: [PATCH 105/116] Reverts AWS key change This reverts commit 38023928ad44ef86e84c045c77c571ce252306dc. This reverts commit 5d46caaf87e315a4c221e8c5f0ed10236b244b43. This reverts commit b3d064d1bbdfce42f394e96c63371b7f313b60d0. --- .travis.yml | 5 ++--- travis/travis-resources.template | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 653b61037..e836cc0bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,10 +19,9 @@ matrix: env: global: - - secure: "HPlPuLk531F7bCyADMcxQ+I1CfGhJlhX9A3q3auNCdLsjqaZbktaCIGuq4R1IPZz0UTtO8RfrTfVaoktyZdq2QyU3iD8oj6BeZ/Jypr4TCBJxI5IeyU3gyPMFHqUYIJuHL9k40Xu7Dhf4HT123zr8KoeVqCHauZP1/TumA0nezg=" - - secure: "R/+uOeccl7GqjJbknailAV7VtjAtGwHHM9xToVnhfPVUXp9fzJs+oNk3IWcs3Eg4sw4WsYxXRfbCQG9bA3MnPlTOsxETGRioO9CAuXap6mwcwNAzeWuq7ePFki2u01pJGQD5b6WFqBCdnAQ4o2SgHgGzhs0TJzYd9tONQxSmkCI=" + - secure: "bG4YYWMfl9API0MSRgmOaJrlGLv06tRg9KJNawBieZvBJbITPpxVGJZT3/l/SEJ+Rl15e2dRex4k+MGQlmT2SqPQxTEYWv1qxNigKPPcla7IWeNmWWqW8uVvFjdglojgBOK2k/xErVQtA4zDfi3mwSXH4DKwquXWsoEKmX2SV7M=" + - secure: "Cbvap9ubVKgjPe3hUhI6JGeDZzBXHpOG9RaYKh+SdoIPhKnlJiNOYm1egomi+e4uqJInlFKuVHTw7Ng9Cun6Zm0jIxpkSchv1GpsR7hmB3UGnGed19Dw8121FwuUaktN+4YnbVlsyd+u8EHD3+h58t4eELrLrZolM4rS7DL6caA=" - secure: "RiBIBfVhhaMjU5ksuwJO3shdvG9FpinBjdSv4co9jg9171SR8edNriedHjVKSIeBhSGNmZmX+twS3dJS/By6tl/LKh9sTynA+ZAYYljkE7jn881B/gMrlYvdAA6og5KvkhV1/0iJWlhuZrMTkhpDR200iLgg3EWBhWjltzmDW/I=" - - AWS_S3_BUCKET: 'node-mapbox-gl-native' before_install: - source ./scripts/travis_helper.sh diff --git a/travis/travis-resources.template b/travis/travis-resources.template index e1b0cff8c..2b7cea836 100644 --- a/travis/travis-resources.template +++ b/travis/travis-resources.template @@ -1,7 +1,7 @@ { "AWSTemplateFormatVersion": "2010-09-09", - "Description": "node-mapbox-gl-native travis resources", + "Description": "mapbox-gl-native travis resources", "Resources": { "BuildUser": { "Type": "AWS::IAM::User", @@ -17,7 +17,7 @@ ], "Effect": "Allow", "Resource": [ - "arn:aws:s3:::node-mapbox-gl-native" + "arn:aws:s3:::mapbox-gl-testing" ] } ] @@ -37,7 +37,7 @@ ], "Effect": "Allow", "Resource": [ - "arn:aws:s3:::node-mapbox-gl-native/*" + "arn:aws:s3:::mapbox-gl-testing/*" ] } ] From f50d8bbf3a2e089ee076c2d4527d3922fd5781a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 27 Oct 2014 12:05:29 -0400 Subject: [PATCH 106/116] fix build with libuv 0.11 --- include/mbgl/map/map.hpp | 6 ------ include/mbgl/util/uv_detail.hpp | 2 +- src/map/map.cpp | 31 ++++++++++++++++--------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index ab9775a8c..bc67e5b35 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -146,15 +146,9 @@ public: private: // uv async callbacks -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 - static void render(uv_async_t *async, int status); - static void terminate(uv_async_t *async, int status); - static void cleanup(uv_async_t *async, int status); -#else static void render(uv_async_t *async); static void terminate(uv_async_t *async); static void cleanup(uv_async_t *async); -#endif // Setup void setup(); diff --git a/include/mbgl/util/uv_detail.hpp b/include/mbgl/util/uv_detail.hpp index b4b41f31a..3bbfa4ac5 100644 --- a/include/mbgl/util/uv_detail.hpp +++ b/include/mbgl/util/uv_detail.hpp @@ -29,7 +29,7 @@ public: if (l == nullptr) { #else l = new uv_loop_t; - if (uv_loop_init(&l) != 0) { + if (uv_loop_init(l) != 0) { #endif throw std::runtime_error("failed to initialize loop"); } diff --git a/src/map/map.cpp b/src/map/map.cpp index a7520b251..2f0dceb42 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -91,15 +91,28 @@ void Map::start() { is_stopped = false; // Setup async notifications - uv_async_init(**loop, async_terminate.get(), terminate); + +// Iron out the differences between libuv 0.10 and 0.11 +#ifdef UV_ASYNC_CALLBACK +#error Cannot overwrite UV_ASYNC_CALLBACK +#endif +#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 +#define UV_ASYNC_CALLBACK(name) [](uv_async_t *a, int) { return Map::name(a); } +#else +#define UV_ASYNC_CALLBACK(name) name +#endif + + uv_async_init(**loop, async_terminate.get(), UV_ASYNC_CALLBACK(terminate)); async_terminate->data = this; - uv_async_init(**loop, async_render.get(), render); + uv_async_init(**loop, async_render.get(), UV_ASYNC_CALLBACK(render)); async_render->data = this; - uv_async_init(**loop, async_cleanup.get(), cleanup); + uv_async_init(**loop, async_cleanup.get(), UV_ASYNC_CALLBACK(cleanup)); async_cleanup->data = this; +#undef UV_ASYNC_CALLBACK + uv_thread_create(*thread, [](void *arg) { Map *map = static_cast(arg); #ifndef NDEBUG @@ -198,11 +211,7 @@ void Map::cleanup() { } } -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void Map::cleanup(uv_async_t *async, int) { -#else void Map::cleanup(uv_async_t *async) { -#endif Map *map = static_cast(async->data); map->painter.cleanup(); @@ -223,11 +232,7 @@ void Map::setReachability(bool reachable) { } } -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void Map::render(uv_async_t *async, int) { -#else void Map::render(uv_async_t *async) { -#endif Map *map = static_cast(async->data); assert(uv_thread_self() == map->map_thread); @@ -247,11 +252,7 @@ void Map::render(uv_async_t *async) { } } -#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10 -void Map::terminate(uv_async_t *async, int) { -#else void Map::terminate(uv_async_t *async) { -#endif // Closes all open handles on the loop. This means that the loop will automatically terminate. Map *map = static_cast(async->data); assert(uv_thread_self() == map->map_thread); From 6695d5249d495e30c7689a29d012d5a8098007ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 27 Oct 2014 12:05:39 -0400 Subject: [PATCH 107/116] bump cocoa --- ios/mapbox-gl-cocoa | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 2d8fa07ab..bba56f27f 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 2d8fa07ab7dc1ff93728e656bac4a82da423e8b0 +Subproject commit bba56f27fa747409ac9ea20cf77f470f59a415a7 From 5508285424b68c6f0a26e70ede8e389715d02deb Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 11:00:31 -0400 Subject: [PATCH 108/116] prefer c++ style memory alloc --- src/util/image.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util/image.cpp b/src/util/image.cpp index fd0d34de2..4cbecc8c2 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -139,7 +139,8 @@ Image::Image(const std::string &data, bool flip) { png_size_t rowbytes = png_get_rowbytes(png, info); assert(width * 4 == rowbytes); - img = (char *)std::malloc(width * height * 4); + img = static_cast(::operator new(width * height * 4)); + char *surface = img; assert(surface); @@ -162,7 +163,7 @@ Image::Image(const std::string &data, bool flip) { fprintf(stderr, "loading PNG failed: %s\n", e.what()); png_destroy_read_struct(&png, &info, nullptr); if (img) { - std::free(img); + ::operator delete(img); img = nullptr; } width = 0; @@ -172,7 +173,7 @@ Image::Image(const std::string &data, bool flip) { Image::~Image() { if (img) { - std::free(img); + ::operator delete(img); img = nullptr; } } From 9364fd7322166578f6f0b7b57273db5a20bea2f7 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 12:35:17 -0400 Subject: [PATCH 109/116] make addGlyphsToAtlas static method of SymbolBucket + add addGlyphs method to minimise number of mutex locking --- include/mbgl/geometry/glyph_atlas.hpp | 4 ++++ include/mbgl/renderer/symbol_bucket.hpp | 4 ++-- src/geometry/glyph_atlas.cpp | 25 ++++++++++++++++++++++++- src/renderer/symbol_bucket.cpp | 17 ++++------------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/include/mbgl/geometry/glyph_atlas.hpp b/include/mbgl/geometry/glyph_atlas.hpp index 5b09cbcd6..639c6cc51 100644 --- a/include/mbgl/geometry/glyph_atlas.hpp +++ b/include/mbgl/geometry/glyph_atlas.hpp @@ -24,6 +24,8 @@ private: std::set ids; }; + Rect addGlyph_impl(uint64_t tile_id, const std::string& face_name, + const SDFGlyph& glyph); public: GlyphAtlas(uint16_t width, uint16_t height); ~GlyphAtlas(); @@ -31,6 +33,8 @@ public: Rect addGlyph(uint64_t tile_id, const std::string& face_name, const SDFGlyph& glyph); + void addGlyphs(uint64_t tileid, std::u32string const& text, std::string const& stackname, + FontStack const& fontStack, GlyphPositions & face); void removeGlyphs(uint64_t tile_id); void bind(); diff --git a/include/mbgl/renderer/symbol_bucket.hpp b/include/mbgl/renderer/symbol_bucket.hpp index 42682401e..9a5da1d01 100644 --- a/include/mbgl/renderer/symbol_bucket.hpp +++ b/include/mbgl/renderer/symbol_bucket.hpp @@ -86,8 +86,8 @@ private: void addSymbols(Buffer &buffer, const PlacedGlyphs &symbols, float scale, PlacementRange placementRange); // Adds glyphs to the glyph atlas so that they have a left/top/width/height coordinates associated to them that we can use for writing to a buffer. - void addGlyphsToAtlas(uint64_t tileid, const std::string stackname, const std::u32string &string, - const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face); + static void addGlyphsToAtlas(uint64_t tileid, const std::string stackname, const std::u32string &string, + const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face); public: const StyleBucketSymbol &properties; diff --git a/src/geometry/glyph_atlas.cpp b/src/geometry/glyph_atlas.cpp index 6bee475da..72c961fda 100644 --- a/src/geometry/glyph_atlas.cpp +++ b/src/geometry/glyph_atlas.cpp @@ -22,9 +22,15 @@ GlyphAtlas::~GlyphAtlas() { } Rect GlyphAtlas::addGlyph(uint64_t tile_id, const std::string& face_name, - const SDFGlyph& glyph) { + const SDFGlyph& glyph) +{ std::lock_guard lock(mtx); + return addGlyph_impl(tile_id, face_name, glyph); +} +Rect GlyphAtlas::addGlyph_impl(uint64_t tile_id, const std::string& face_name, + const SDFGlyph& glyph) +{ // Use constant value for now. const uint8_t buffer = 3; @@ -83,6 +89,23 @@ Rect GlyphAtlas::addGlyph(uint64_t tile_id, const std::string& face_na return rect; } +void GlyphAtlas::addGlyphs(uint64_t tileid, std::u32string const& text, std::string const& stackname, FontStack const& fontStack, GlyphPositions & face) +{ + std::lock_guard lock(mtx); + + std::map const& sdfs = fontStack.getSDFs(); + for (uint32_t chr : text) + { + auto sdf_it = sdfs.find(chr); + if (sdf_it != sdfs.end()) + { + SDFGlyph const& sdf = sdf_it->second; + Rect rect = addGlyph_impl(tileid, stackname, sdf); + face.emplace(chr, Glyph{rect, sdf.metrics}); + } + } +} + void GlyphAtlas::removeGlyphs(uint64_t tile_id) { std::lock_guard lock(mtx); diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 47cc4db44..7d5036eea 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -34,18 +34,9 @@ bool SymbolBucket::hasTextData() const { return !text.groups.empty(); } bool SymbolBucket::hasIconData() const { return !icon.groups.empty(); } void SymbolBucket::addGlyphsToAtlas(uint64_t tileid, const std::string stackname, - const std::u32string &string, const FontStack &fontStack, + const std::u32string &text, const FontStack &fontStack, GlyphAtlas &glyphAtlas, GlyphPositions &face) { - const std::map &sdfs = fontStack.getSDFs(); - // Loop through all characters and add glyph to atlas, positions. - for (uint32_t chr : string) { - auto sdf_it = sdfs.find(chr); - if (sdf_it != sdfs.end()) { - const SDFGlyph &sdf = sdf_it->second; - const Rect rect = glyphAtlas.addGlyph(tileid, stackname, sdf); - face.emplace(chr, Glyph{rect, sdf.metrics}); - } - } + glyphAtlas.addGlyphs(tileid, text, stackname, fontStack,face); } std::vector SymbolBucket::processFeatures(const VectorTileLayer &layer, @@ -150,8 +141,8 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress // Add the glyphs we need for this label to the glyph atlas. if (shaping.size()) { - addGlyphsToAtlas(id.to_uint64(), properties.text.font, feature.label, fontStack, - glyphAtlas, face); + SymbolBucket::addGlyphsToAtlas(id.to_uint64(), properties.text.font, feature.label, fontStack, + glyphAtlas, face); } } From e4294ec29446a6b1944d4d977d162d0a6bb4573f Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 13:34:22 -0400 Subject: [PATCH 110/116] use prefix operator++ --- src/style/style_layer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index 4d64386be..ded73c044 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -20,7 +20,7 @@ void StyleLayer::setClasses(const std::vector &class_names, const t std::set already_applied; // Reverse iterate through all class names and apply them last to first. - for (auto it = class_names.rbegin(); it != class_names.rend(); it++) { + for (auto it = class_names.rbegin(); it != class_names.rend(); ++it) { const std::string &class_name = *it; // From here on, we're only dealing with IDs to avoid comparing strings all the time. const ClassID class_id = ClassDictionary::Get().lookup(class_name); From 95213cd3829fb2565c8b492c7eeb44a421df7bc7 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 13:55:14 -0400 Subject: [PATCH 111/116] c++ style memory allocations/deallocations --- src/geometry/sprite_atlas.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/geometry/sprite_atlas.cpp b/src/geometry/sprite_atlas.cpp index 10922790c..22e6a29a0 100644 --- a/src/geometry/sprite_atlas.cpp +++ b/src/geometry/sprite_atlas.cpp @@ -53,7 +53,7 @@ bool SpriteAtlas::resize(const float newRatio) { } } - free(old_data); + ::operator delete(old_data); dirty = true; // Mark all sprite images as in need of update @@ -154,7 +154,8 @@ void SpriteAtlas::allocate() { if (!data) { dimension w = static_cast(width * pixelRatio); dimension h = static_cast(height * pixelRatio); - data = (uint32_t *)calloc(w * h, sizeof(uint32_t)); + data = static_cast(::operator new(w * h * sizeof(uint32_t))); + std::fill(data, data + w * h, 0); } } @@ -268,9 +269,5 @@ SpriteAtlas::~SpriteAtlas() { glDeleteTextures(1, &texture); texture = 0; - - if (data) { - free(data); - data = nullptr; - } + ::operator delete(data), data = nullptr; } From efeaba832d955e2a31add33e87b7c8cb8aa053f3 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 13:56:32 -0400 Subject: [PATCH 112/116] c++ - don't test if pointer is nullptr before deleting --- src/util/image.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/util/image.cpp b/src/util/image.cpp index 4cbecc8c2..ffa65bf0b 100644 --- a/src/util/image.cpp +++ b/src/util/image.cpp @@ -172,8 +172,5 @@ Image::Image(const std::string &data, bool flip) { } Image::~Image() { - if (img) { - ::operator delete(img); - img = nullptr; - } + ::operator delete(img),img = nullptr; } From dcf643fb4b27f7dd1249514e4644d85d17cb1eb6 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 14:16:38 -0400 Subject: [PATCH 113/116] add new line at the end --- src/util/io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/io.cpp b/src/util/io.cpp index b88956743..76f7c35ad 100644 --- a/src/util/io.cpp +++ b/src/util/io.cpp @@ -31,4 +31,4 @@ std::string read_file(const std::string &filename) { } } -} \ No newline at end of file +} From c3f3b9ddd52a3f1540eb6eb6711caca7efc4a8fb Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 27 Oct 2014 14:17:27 -0400 Subject: [PATCH 114/116] canonical move ctor --- src/util/sqlite3.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/util/sqlite3.cpp b/src/util/sqlite3.cpp index 19e0ce9c7..787db8399 100644 --- a/src/util/sqlite3.cpp +++ b/src/util/sqlite3.cpp @@ -15,9 +15,8 @@ Database::Database(const std::string &filename, int flags) { } } -Database::Database(Database &&other) { - *this = std::move(other); -} +Database::Database(Database &&other) + : db(std::move(other.db)) {} Database &Database::operator=(Database &&other) { std::swap(db, other.db); From 071f92079082aa0676772946d8d40184dcc3d40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Mon, 27 Oct 2014 12:34:10 -0700 Subject: [PATCH 115/116] mark as standalone static libraries so they get placed into the correct directory on non-osx targets --- gyp/mbgl-ios.gypi | 1 + gyp/mbgl-linux.gypi | 1 + gyp/mbgl-osx.gypi | 1 + gyp/mbgl.gypi | 1 + 4 files changed, 4 insertions(+) diff --git a/gyp/mbgl-ios.gypi b/gyp/mbgl-ios.gypi index dbad60086..4398f04eb 100644 --- a/gyp/mbgl-ios.gypi +++ b/gyp/mbgl-ios.gypi @@ -28,6 +28,7 @@ { 'target_name': 'mbgl-ios', 'product_name': 'mbgl-ios', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'include_dirs': [ '../include', diff --git a/gyp/mbgl-linux.gypi b/gyp/mbgl-linux.gypi index 39a175556..6d8631e8d 100644 --- a/gyp/mbgl-linux.gypi +++ b/gyp/mbgl-linux.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl-linux', 'product_name': 'mbgl-linux', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'include_dirs': [ '../include' diff --git a/gyp/mbgl-osx.gypi b/gyp/mbgl-osx.gypi index ba117e5a5..80af5b97a 100644 --- a/gyp/mbgl-osx.gypi +++ b/gyp/mbgl-osx.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl-osx', 'product_name': 'mbgl-osx', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'include_dirs': [ '../include', diff --git a/gyp/mbgl.gypi b/gyp/mbgl.gypi index f268fd625..0d914f46f 100644 --- a/gyp/mbgl.gypi +++ b/gyp/mbgl.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl', 'product_name': 'mbgl', 'type': 'static_library', + 'standalone_static_library': 1, 'hard_dependency': 1, 'dependencies': [ 'shaders', From f716acb0621e1f4ae04dee4fd648666d469fb176 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Mon, 27 Oct 2014 15:43:54 -0400 Subject: [PATCH 116/116] standalone flag for mbgl-headless --- gyp/mbgl-headless.gypi | 1 + 1 file changed, 1 insertion(+) diff --git a/gyp/mbgl-headless.gypi b/gyp/mbgl-headless.gypi index 5ffc251d2..e71fb7efb 100644 --- a/gyp/mbgl-headless.gypi +++ b/gyp/mbgl-headless.gypi @@ -3,6 +3,7 @@ { 'target_name': 'mbgl-headless', 'product_name': 'mbgl-headless', 'type': 'static_library', + 'standalone_static_library': 1, 'include_dirs': [ '../include', ],