Merge branch 'headless-display' into mesa

This commit is contained in:
Mike Morris
2014-10-22 16:48:30 -04:00
104 changed files with 851 additions and 1265 deletions

3
.gitignore vendored
View File

@@ -4,10 +4,11 @@
*.actual.png
*.diff.png
/node_modules
/mapnik-packaging
/mason_packages
/macosx/build
/ios/build
/config.gypi
/config-ios.gypi
/config/constants_local.cpp
/build
/bin/node_modules

View File

@@ -28,15 +28,13 @@ env:
before_install:
- source ./scripts/travis_helper.sh
- source ./scripts/flags.sh
- (git clone https://github.com/mapbox/mason.git ~/.mason ; sudo ln -s ~/.mason/mason /usr/local/bin/mason)
- ./scripts/travis_before_install.sh
- if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then glxinfo; fi
install:
- make setup
- ./scripts/travis_install.sh
before_script:
- rm -rf mapnik-packaging/out/packages
- make config.gypi
- ./scripts/travis_install_test_suite.sh
script:
- ./scripts/travis_script.sh

View File

@@ -2,31 +2,23 @@ BUILDTYPE ?= Release
PYTHON ?= python
V ?= 1
all: setup
setup: config.gypi
all: mbgl
config.gypi:
./setup-libraries.sh
./configure
xlibs:
@./mapnik-packaging/osx/darwin_configure.sh osx
ilibs:
@./mapnik-packaging/osx/darwin_configure.sh ios
config-ios.gypi:
MASON_PLATFORM=ios ./configure config-ios.gypi
# Builds the regular library
mbgl: config.gypi mapboxgl.gyp node
deps/run_gyp mapboxgl.gyp --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
mbgl: config.gypi mapboxgl.gyp
deps/run_gyp mapboxgl.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/mbgl -f make
$(MAKE) -C build/mbgl BUILDTYPE=$(BUILDTYPE) V=$(V) mapboxgl
node:
@if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi;
##### Test cases ###############################################################
build/test/Makefile: src common config.gypi test/test.gyp
deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build/test -f make
deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build/test -f make
test: build/test/Makefile
$(MAKE) -C build/test BUILDTYPE=$(BUILDTYPE) V=$(V) test
@@ -36,16 +28,16 @@ test_%: build/test/Makefile
(cd build/$(BUILDTYPE) && exec ./test_$*)
# build Mac OS X project for Xcode
xtest: config.gypi clear_xcode_cache node
deps/run_gyp test/test.gyp --depth=. -Goutput_dir=.. --generator-output=./build -f xcode
xtest: config.gypi clear_xcode_cache
deps/run_gyp test/test.gyp -Iconfig.gypi --depth=. -Goutput_dir=.. --generator-output=./build -f xcode
open ./build/test/test.xcodeproj
##### Makefile builds ##########################################################
# Builds the linux app with make.
linux: config.gypi linux/mapboxgl-app.gyp node
deps/run_gyp linux/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f 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
$(MAKE) -C build/linux BUILDTYPE=$(BUILDTYPE) V=$(V) linuxapp
# Executes the Linux binary
@@ -55,8 +47,8 @@ run-linux: linux
# Builds the OS X app with make.
osx: config.gypi macosx/mapboxgl-app.gyp node
deps/run_gyp macosx/mapboxgl-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/macosx -f 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
$(MAKE) -C build/macosx BUILDTYPE=$(BUILDTYPE) V=$(V) osxapp
# Executes the OS X binary
@@ -77,22 +69,22 @@ clear_xcode_cache:
fi
# build Mac OS X project for Xcode
xproj-cli: config.gypi xlibs macosx/mapboxgl-app.gyp clear_xcode_cache node
deps/run_gyp macosx/mapboxgl-app.gyp --depth=. --generator-output=./build -f 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
xproj: xproj-cli
open ./build/macosx/mapboxgl-app.xcodeproj
# build iOS project for Xcode
iproj-cli: config.gypi ilibs ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp clear_xcode_cache node
deps/run_gyp ios/mapbox-gl-cocoa/app/mapboxgl-app.gyp --depth=. --generator-output=./build -f 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
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 node
deps/run_gyp linux/mapboxgl-app.gyp --depth=. --generator-output=./build -f xcode
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
open ./build/linux/mapboxgl-app.xcodeproj
@@ -101,11 +93,10 @@ lproj: config.gypi linux/mapboxgl-app.gyp clear_xcode_cache node
clean: clear_xcode_cache
-find ./deps/gyp -name "*.pyc" -exec rm {} \;
-rm -rf ./build/
-rm -rf ./config.gypi
-rm -rf ./config.gypi ./config-ios.gypi
distclean: clean
-rm -rf ./mapnik-packaging/osx/out/build-*
-rm -rf ./mapnik-packaging/osx/out/universal
-find ./mapnik-packaging/osx/out/packages -type d ! -name 'packages' -maxdepth 1 -exec rm -rf {} \;
-rm -rf ./mason_packages
.PHONY: mbgl test linux build/test/Makefile
.PHONY: mbgl test linux build/test/Makefile clean distclean
# DO NOT DELETE

View File

@@ -1,4 +1,4 @@
[![Travis](https://api.travis-ci.org/mapbox/mapbox-gl-native.svg)](https://travis-ci.org/mapbox/mapbox-gl-native/builds)
[![Travis](https://api.travis-ci.org/mapbox/mapbox-gl-native.svg?branch=master)](https://travis-ci.org/mapbox/mapbox-gl-native/builds)
An OpenGL renderer for [Mapbox Vector Tiles](https://www.mapbox.com/blog/vector-tiles),
implemented in C++11, currently targeting iOS, OS X, and Ubuntu Linux.

View File

@@ -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'
}
},
}

View File

@@ -1,383 +0,0 @@
#include <mbgl/platform/platform.hpp>
#include <mbgl/platform/request.hpp>
#include <mbgl/util/uv_detail.hpp>
#include <mbgl/util/std.hpp>
#include <queue>
#include <boost/lockfree/queue.hpp>
#include <curl/curl.h>
// This file contains code from http://curl.haxx.se/libcurl/c/multi-uv.html:
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, 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<std::shared_ptr<mbgl::platform::Request> *> add_queue(8);
static boost::lockfree::queue<std::shared_ptr<mbgl::platform::Request> *> 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 *> curl_handle_cache;
class CURLRequest : public mbgl::platform::Request {
public:
CURLRequest(const std::string &url,
std::function<void(mbgl::platform::Response *)> callback,
std::shared_ptr<uv::loop> 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<Request> *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<Request> *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<Request> *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>
platform::request_http(const std::string &url,
std::function<void(Response *)> callback,
std::shared_ptr<uv::loop> loop) {
using namespace request;
init_thread_once(thread_init_cb);
std::shared_ptr<CURLRequest> req = std::make_shared<CURLRequest>(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<Request>(req));
uv_async_send(&async_add);
return req;
}
// Cancels an HTTP request.
void platform::cancel_request_http(const std::shared_ptr<Request> &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<Request>(req));
uv_async_send(&async_cancel);
}
}
} // end namespace mbgl

View File

@@ -2,7 +2,7 @@
#include <mbgl/util/string.hpp>
GLFWView::GLFWView(bool fullscreen) : fullscreen(fullscreen) {
GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) {
#ifdef NVIDIA
glDiscardFramebufferEXT = (PFNGLDISCARDFRAMEBUFFEREXTPROC)glfwGetProcAddress("glDiscardFramebufferEXT");
#endif

View File

@@ -52,7 +52,7 @@
// Handles the request thread + messaging to the thread.
static uv_once_t once;
static uv_loop_t loop;
static uv_loop_t *loop = nullptr;
static uv_messenger_t start_messenger;
static uv_messenger_t stop_messenger;
static uv_thread_t thread;
@@ -228,7 +228,7 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void *
context->sockfd = sockfd;
assert(!context->poll_handle);
context->poll_handle = new uv_poll_t;
uv_poll_init_socket(&loop, context->poll_handle, sockfd);
uv_poll_init_socket(loop, context->poll_handle, sockfd);
context->poll_handle->data = context;
curl_multi_assign(multi, sockfd, context);
}
@@ -253,7 +253,11 @@ int handle_socket(CURL *handle, curl_socket_t sockfd, int action, void *, void *
return 0;
}
void on_timeout(uv_timer_t *, int status) {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
void on_timeout(uv_timer_t *, int = 0) {
#else
void on_timeout(uv_timer_t *) {
#endif
int running_handles;
CURLMcode error = curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, 0, &running_handles);
if (error != CURLM_OK) {
@@ -275,7 +279,7 @@ void thread_init(void *) {
#endif
thread_id = uv_thread_self();
uv_timer_init(&loop, &timeout);
uv_timer_init(loop, &timeout);
CURLSHcode share_error;
share = curl_share_init();
@@ -305,7 +309,7 @@ void thread_init(void *) {
}
// Main event loop. This will not return until the request loop is terminated.
uv_run(&loop, UV_RUN_DEFAULT);
uv_run(loop, UV_RUN_DEFAULT);
curl_multi_cleanup(multi);
multi = nullptr;
@@ -442,8 +446,14 @@ void stop_request(void *const ptr) {
void create_thread() {
uv_mutex_init(&share_mutex);
uv_messenger_init(&loop, &start_messenger, start_request);
uv_messenger_init(&loop, &stop_messenger, stop_request);
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
loop = uv_loop_new();
#else
loop = new uv_loop_t;
uv_loop_init(loop);
#endif
uv_messenger_init(loop, &start_messenger, start_request);
uv_messenger_init(loop, &stop_messenger, stop_request);
uv_thread_create(&thread, thread_init, nullptr);
}

247
configure vendored
View File

@@ -1,144 +1,131 @@
#!/usr/bin/env python
import optparse
import os
import pprint
import re
import shlex
import subprocess
import sys
#!/usr/bin/env bash
root_dir = os.path.dirname(__file__)
set -e
set -o pipefail
# parse our options
parser = optparse.OptionParser()
CONFIG_FILE=${1:-config.gypi}
parser.add_option("--debug",
action="store_true",
dest="debug",
help="Also build debug build")
function finish {
>&2 echo -en "\033[0m";
}
trap finish EXIT
parser.add_option("--node",
action="store",
dest="node",
help="Name of the node executable (defaults to node)")
parser.add_option("--npm",
action="store",
dest="npm",
help="Name of the npm executable (defaults to npm)")
parser.add_option("--pkg-config-root",
action="store",
dest="pkgconfig_root",
help="Path to pkg-config directory")
parser.add_option("--boost",
action="store",
dest="boost_root",
help="Path to boost (defaults to /usr/local)")
(options, args) = parser.parse_args()
def pkg_config(pkg, pkgconfig_root):
env = os.environ.copy()
if pkgconfig_root:
env["PKG_CONFIG_PATH"] = pkgconfig_root
env["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "1"
env["PKG_CONFIG_ALLOW_SYSTEM_LIBS"] = "1"
cmd = subprocess.Popen(['pkg-config', '--static', '--libs', pkg], stdout=subprocess.PIPE, env=env)
libs, ret = cmd.communicate()
if (ret): return None
cmd = subprocess.Popen(['pkg-config', '--static', '--cflags', pkg], stdout=subprocess.PIPE, env=env)
cflags, ret = cmd.communicate()
if (ret): return None
return (libs, cflags)
def configure_mbgl(o):
if options.boost_root:
o['variables']['boost_root'] = options.boost_root
else:
o['variables']['boost_root'] = '/usr/local'
if options.node:
o['variables']['node'] = options.node
else:
o['variables']['node'] = 'node'
if options.npm:
o['variables']['npm'] = options.npm
else:
o['variables']['npm'] = 'npm'
o['target_defaults']['default_configuration'] = 'Debug' if options.debug else 'Release'
# Install node
if [[ ! -d ~/.nvm ]]; then
git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
fi
set +u
. ~/.nvm/nvm.sh
if [ ! `nvm use 0.10 > /dev/null; echo $?` = 0 ]; then
>&2 echo -en "\033[1m\033[32m* "
nvm install 0.10
>&2 echo -en "\033[0m";
else
>&2 echo -en "\033[1m\033[32m* "
nvm use 0.10
>&2 echo -en "\033[0m";
fi
def fix_frameworks(libs):
# don't split "-framework Foo"
return re.split('(?<!-framework)\s+', libs.strip())
case $MASON_PLATFORM in
'ios')
SQLITE_VERSION=system
LIBPNG_VERSION=1.6.13
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
BOOST_VERSION=system
;;
*)
GLFW_VERSION=a21f2377
SQLITE_VERSION=system
LIBPNG_VERSION=system
LIBCURL_VERSION=system
LIBUV_VERSION=0.10.28
ZLIB_VERSION=system
BOOST_VERSION=system
;;
esac
def configure_glfw3(o):
ret = pkg_config('glfw3', options.pkgconfig_root)
if not ret:
sys.stderr.write('could not find glfw3 with pkg-config')
sys.exit(-1)
o['variables']['glfw3_libraries'] = fix_frameworks(ret[0])
o['variables']['glfw3_cflags'] = ret[1].split()
function abort { >&2 echo -e "\033[1m\033[31m$1\033[0m"; exit 1; }
def configure_uv(o):
ret = pkg_config('libuv', options.pkgconfig_root)
if not ret:
sys.stderr.write('could not find uv with pkg-config')
sys.exit(-1)
o['variables']['uv_libraries'] = ret[0].split()
o['variables']['uv_cflags'] = ret[1].split()
NODE=`which node || abort 'Cannot find node'`
NPM=`which npm || abort 'Cannot find npm'`
PYTHON=`which python || abort 'Cannot find python'`
def configure_png(o):
ret = pkg_config('libpng', options.pkgconfig_root)
if not ret:
sys.stderr.write('could not find png with pkg-config')
sys.exit(-1)
o['variables']['png_libraries'] = ret[0].split()
o['variables']['png_cflags'] = ret[1].split()
>&2 echo -en "\033[1m\033[32m* Using npm "
>&2 ${NPM} --version
>&2 echo -en "\033[0m";
def configure_curl(o):
ret = pkg_config('libcurl', options.pkgconfig_root)
if not ret:
sys.stderr.write('could not find curl with pkg-config')
sys.exit(-1)
o['variables']['curl_libraries'] = ret[0].split()
o['variables']['curl_cflags'] = ret[1].split()
>&2 echo -en "\033[1m\033[32m* Using "
>&2 ${PYTHON} --version
>&2 echo -en "\033[0m";
def configure_sqlite3(o):
ret = pkg_config('sqlite3', options.pkgconfig_root)
if not ret:
sys.stderr.write('could not find sqlite3 with pkg-config')
sys.exit(-1)
o['variables']['sqlite3_libraries'] = ret[0].split()
o['variables']['sqlite3_cflags'] = ret[1].split()
def write(filename, data):
filename = os.path.join(root_dir, filename)
print "creating ", filename
f = open(filename, 'w+')
f.write(data)
output = {
'variables': { 'python': sys.executable },
'target_defaults' : {
'include_dirs': [],
'libraries': [],
'defines': [],
'cflags': []
}
function quote_flags {
${PYTHON} -c "import sys, re; print re.split('(?<!-framework)\s+', ' '.join(sys.argv[1:]))" "$@"
}
if __name__ == '__main__':
configure_mbgl(output)
configure_glfw3(output)
configure_uv(output)
configure_png(output)
configure_curl(output)
configure_sqlite3(output)
pprint.pprint(output, indent=2)
LN=$'\n'
write('config.gypi', "# Do not edit. Generated by the configure script.\n" +
pprint.pformat(output, indent=2) + "\n")
CONFIG="# Do not edit. Generated by the configure script.
{
'target_defaults': {
'cflags': [],
'default_configuration': 'Release',
'defines': [],
'include_dirs': [],
'libraries': []
},
'variables': {
'node': '${NODE}',
'npm': '${NPM}',
'python': '${PYTHON}',
"
if [ ! -z ${BOOST_VERSION} ]; then
mason install boost ${BOOST_VERSION}
CONFIG+=" 'boost_root': '$(mason prefix boost ${BOOST_VERSION})',"$LN
fi
if [ ! -z ${LIBCURL_VERSION} ]; then
mason install libcurl ${LIBCURL_VERSION}
CONFIG+=" 'curl_cflags': $(quote_flags $(mason cflags libcurl ${LIBCURL_VERSION})),"$LN
CONFIG+=" 'curl_libraries': $(quote_flags $(mason ldflags libcurl ${LIBCURL_VERSION})),"$LN
fi
if [ ! -z ${GLFW_VERSION} ]; then
mason install glfw ${GLFW_VERSION}
CONFIG+=" 'glfw3_cflags': $(quote_flags $(mason cflags glfw ${GLFW_VERSION})),"$LN
CONFIG+=" 'glfw3_libraries': $(quote_flags $(mason ldflags glfw ${GLFW_VERSION})),"$LN
fi
if [ ! -z ${LIBPNG_VERSION} ]; then
mason install libpng ${LIBPNG_VERSION}
CONFIG+=" 'png_cflags': $(quote_flags $(mason cflags libpng ${LIBPNG_VERSION})),"$LN
CONFIG+=" 'png_libraries': $(quote_flags $(mason ldflags libpng ${LIBPNG_VERSION})),"$LN
fi
if [ ! -z ${SQLITE_VERSION} ]; then
mason install sqlite ${SQLITE_VERSION}
CONFIG+=" 'sqlite3_cflags': $(quote_flags $(mason cflags sqlite ${SQLITE_VERSION})),"$LN
CONFIG+=" 'sqlite3_libraries': $(quote_flags $(mason ldflags sqlite ${SQLITE_VERSION})),"$LN
fi
if [ ! -z ${LIBUV_VERSION} ]; then
mason install libuv ${LIBUV_VERSION}
CONFIG+=" 'uv_cflags': $(quote_flags $(mason cflags libuv ${LIBUV_VERSION})),"$LN
CONFIG+=" 'uv_libraries': $(quote_flags $(mason ldflags libuv ${LIBUV_VERSION})),"$LN
fi
if [ ! -z ${ZLIB_VERSION} ]; then
mason install zlib ${ZLIB_VERSION}
CONFIG+=" 'zlib_cflags': $(quote_flags $(mason cflags zlib ${ZLIB_VERSION})),"$LN
CONFIG+=" 'zlib_libraries': $(quote_flags $(mason ldflags zlib ${ZLIB_VERSION})),"$LN
fi
CONFIG+=" }
}
"
echo "${CONFIG}" > ${CONFIG_FILE}
cat ${CONFIG_FILE}

View File

@@ -31,6 +31,10 @@ _intermediate_var = 'INTERMEDIATE_DIR'
# targets that share the same BUILT_PRODUCTS_DIR.
_shared_intermediate_var = 'SHARED_INTERMEDIATE_DIR'
# ONLY_ACTIVE_ARCH means that only the active architecture should be build for
# Debugging purposes to shorten the build time
_only_active_arch = 'ONLY_ACTIVE_ARCH'
_library_search_paths_var = 'LIBRARY_SEARCH_PATHS'
generator_default_variables = {
@@ -168,6 +172,8 @@ class XcodeProject(object):
xccl.SetBuildSetting(_shared_intermediate_var,
'$(SYMROOT)/DerivedSources/$(CONFIGURATION)')
xccl.ConfigurationNamed('Debug').SetBuildSetting(_only_active_arch, 'YES')
# Set user-specified project-wide build settings and config files. This
# is intended to be used very sparingly. Really, almost everything should
# go into target-specific build settings sections. The project-wide
@@ -604,7 +610,11 @@ def GenerateOutput(target_list, target_dicts, data, params):
if parallel_builds:
pbxp.SetProperty('attributes',
{'BuildIndependentTargetsInParallel': 'YES'})
{
'BuildIndependentTargetsInParallel': 'YES',
'LastUpgradeCheck': '0500'
}
)
if project_version:
xcp.project_file.SetXcodeVersion(project_version)

View File

@@ -2158,6 +2158,7 @@ class XCTarget(XCRemoteObject):
if configs.HasBuildSetting('PRODUCT_NAME') == 0:
configs.SetBuildSetting('PRODUCT_NAME',
self._properties['productName'])
configs.SetBuildSetting('COMBINE_HIDPI_IMAGES', 'YES')
def AddDependency(self, other):
pbxproject = self.PBXProjectAncestor()
@@ -2811,7 +2812,7 @@ class XCProjectFile(XCObject):
_schema.update({
'archiveVersion': [0, int, 0, 1, 1],
'classes': [0, dict, 0, 1, {}],
'objectVersion': [0, int, 0, 1, 45],
'objectVersion': [0, int, 0, 1, 46],
'rootObject': [0, PBXProject, 1, 1],
})

View File

@@ -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;
};

View File

@@ -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<Anchor> Anchors;

View File

@@ -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

View File

@@ -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),

View File

@@ -18,8 +18,8 @@ public:
private:
struct GlyphValue {
GlyphValue(const Rect<uint16_t>& rect, uint64_t id)
: rect(rect), ids({ id }) {}
GlyphValue(const Rect<uint16_t>& rect_, uint64_t id)
: rect(rect_), ids({ id }) {}
Rect<uint16_t> rect;
std::set<uint64_t> ids;
};

View File

@@ -146,10 +146,15 @@ 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);
static void delete_async(uv_handle_t *handle, 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();

View File

@@ -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;

View File

@@ -29,10 +29,16 @@ public:
const std::array<uint16_t, 2> getFramebufferDimensions() const;
float getPixelRatio() const;
float worldSize() const;
float lngX(float lon) const;
float latY(float lat) const;
std::array<float, 2> locationCoordinate(float lon, float lat) const;
// Zoom
float getNormalizedZoom() const;
int32_t getIntegerZoom() const;
double getZoom() const;
int32_t getIntegerZoom() const;
double getZoomFraction() const;
double getScale() const;
// Rotation

View File

@@ -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

View File

@@ -58,12 +58,13 @@ struct EventPermutation {
};
constexpr EventSeverity disabledEventSeverities[] = {
#if !DEBUG
EventSeverity::Debug,
#if DEBUG
EventSeverity(-1) // Avoid zero size array
#else
EventSeverity::Debug
#endif
};
constexpr Event disabledEvents[] = {
Event(-1) // Avoid zero size array
};

View File

@@ -19,9 +19,9 @@ public:
class Log {
private:
template <typename T>
constexpr static bool includes(const T e, T const *l, const size_t i = 0) {
return i >= sizeof l ? false : *(l + i) == e ? true : includes(e, l, i + 1);
template <typename T, size_t N>
constexpr static bool includes(const T e, const T (&l)[N], const size_t i = 0) {
return i < N && (l[i] == e || includes(e, l, i + 1));
}
public:

View File

@@ -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;
};

View File

@@ -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 = []{

View File

@@ -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);

View File

@@ -24,8 +24,8 @@ public:
class Instance {
public:
Instance(Operator op, std::vector<Value> &&values)
: op(op), values(values) {}
Instance(Operator op_, std::vector<Value> &&values_)
: op(op_), values(values_) {}
bool compare(const std::vector<Value> &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 <typename Extractor> inline bool compare(const Extractor &extractor) const;

View File

@@ -28,7 +28,7 @@ public:
public:
FilterExpression() = default;
FilterExpression(Operator op) : op(op) {};
FilterExpression(Operator op_) : op(op_) {};
bool empty() const;

View File

@@ -9,7 +9,7 @@ namespace mbgl {
template <typename T>
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 <typename T>
struct StopsFunction {
inline StopsFunction(const std::vector<std::pair<float, T>> &values, float base) : values(values), base(base) {}
inline StopsFunction(const std::vector<std::pair<float, T>> &values_, float base_) : values(values_), base(base_) {}
T evaluate(float z) const;
private:
@@ -36,7 +36,7 @@ using Function = mapbox::util::variant<
template <typename T>
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();

View File

@@ -61,7 +61,8 @@ enum class PropertyKey {
RasterFade,
BackgroundOpacity,
BackgroundColor
BackgroundColor,
BackgroundImage
};
}

View File

@@ -94,6 +94,7 @@ struct BackgroundProperties {
inline BackgroundProperties() {}
float opacity = 1.0f;
Color color = {{ 0, 0, 0, 1 }};
std::string image;
};
typedef mapbox::util::variant<

View File

@@ -36,8 +36,8 @@ public:
bool enabled = false;
util::ptr<Source> source;
StyleSource(const util::ptr<SourceInfo> &info)
: info(info)
StyleSource(const util::ptr<SourceInfo> &info_)
: info(info_)
{}
};

View File

@@ -5,6 +5,8 @@
#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

View File

@@ -30,9 +30,9 @@ struct GlyphMetrics {
struct Glyph {
inline explicit Glyph() : rect(0, 0, 0, 0), metrics() {}
inline explicit Glyph(const Rect<uint16_t> &rect,
const GlyphMetrics &metrics)
: rect(rect), metrics(metrics) {}
inline explicit Glyph(const Rect<uint16_t> &rect_,
const GlyphMetrics &metrics_)
: rect(rect_), metrics(metrics_) {}
operator bool() const {
return metrics || rect;
@@ -46,8 +46,8 @@ typedef std::map<uint32_t, Glyph> 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;

View File

@@ -3,11 +3,10 @@
#include <mbgl/util/vec.hpp>
#include <mbgl/util/rect.hpp>
#include <mbgl/util/optional.hpp>
#include <array>
#include <vector>
#include <boost/optional.hpp>
namespace mbgl {
typedef vec2<float> CollisionPoint;
@@ -29,31 +28,31 @@ 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;
float minScale = 0.0f;
float maxScale = std::numeric_limits<float>::infinity();
float padding = 0.0f;
boost::optional<CollisionRect> hBox;
mapbox::util::optional<CollisionRect> hBox;
};
typedef std::vector<GlyphBox> GlyphBoxes;
@@ -61,19 +60,19 @@ typedef std::vector<GlyphBox> GlyphBoxes;
// TODO: Transform the vec2<float>s to vec2<int16_t> to save bytes
struct PlacedGlyph {
explicit PlacedGlyph(const vec2<float> &tl, const vec2<float> &tr,
const vec2<float> &bl, const vec2<float> &br,
const Rect<uint16_t> &tex, float angle, const vec2<float> &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<float> &tl_, const vec2<float> &tr_,
const vec2<float> &bl_, const vec2<float> &br_,
const Rect<uint16_t> &tex_, float angle_, const vec2<float> &anchor_,
float minScale_, float maxScale_)
: tl(tl_),
tr(tr_),
bl(bl_),
br(br_),
tex(tex_),
angle(angle_),
anchor(anchor_),
minScale(minScale_),
maxScale(maxScale_) {}
vec2<float> tl, tr, bl, br;
Rect<uint16_t> tex;
@@ -88,7 +87,7 @@ typedef std::vector<PlacedGlyph> PlacedGlyphs;
struct PlacementBox {
CollisionAnchor anchor;
CollisionRect box;
boost::optional<CollisionRect> hBox;
mapbox::util::optional<CollisionRect> hBox;
PlacementRange placementRange = {{0.0f, 0.0f}};
float placementScale = 0.0f;
float maxScale = std::numeric_limits<float>::infinity();
@@ -97,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<float>::infinity() &&

View File

@@ -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<Type> 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<Type> 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<Type> 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<Type> 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)) {}

View File

@@ -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;

View File

@@ -32,6 +32,8 @@ typedef std::array<float, 9> mat3;
namespace matrix {
void identity(mat3& out);
void translate(mat3& out, const mat3& a, float x, float y);
void rotate(mat3& out, const mat3& a, float rad);
void scale(mat3& out, const mat3& a, float x, float y);
}

View File

@@ -0,0 +1,69 @@
#ifndef MAPBOX_UTIL_OPTIONAL_HPP
#define MAPBOX_UTIL_OPTIONAL_HPP
#include <type_traits>
#include "variant.hpp"
namespace mapbox
{
namespace util
{
template <typename T> class optional
{
static_assert(!std::is_reference<T>::value, "optional doesn't support references");
struct none_type
{
};
variant<none_type, T> 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>(); }
T const &get() const { return variant_.template get<T>(); }
T &get() { return variant_.template get<T>(); }
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 <typename... Args> void emplace(Args &&... args)
{
variant_ = T{std::forward<Args>(args)...};
}
void reset() { variant_ = none_type{}; }
};
}
}
#endif

View File

@@ -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) {
}

View File

@@ -6,7 +6,7 @@ namespace mbgl {
template <typename T>
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;

View File

@@ -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 <typename T>
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 <typename T>
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) {

View File

@@ -5,8 +5,7 @@
extern "C" {
#endif
typedef struct uv_messenger_s uv_messenger_t;
#include <mbgl/util/uv-messenger.h>
#include <mbgl/util/uv-channel.h>
#include <stdlib.h>

View File

@@ -23,13 +23,32 @@ private:
class loop {
public:
inline loop() : l(uv_loop_new()) {}
inline ~loop() { uv_loop_delete(l); }
inline loop() {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
l = uv_loop_new();
if (l == nullptr) {
#else
l = new uv_loop_t;
if (uv_loop_init(&l) != 0) {
#endif
throw std::runtime_error("failed to initialize loop");
}
}
inline ~loop() {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_loop_delete(l);
#else
uv_loop_close(l);
delete l;
#endif
}
inline uv_loop_t *operator*() { return l; }
private:
uv_loop_t *l;
uv_loop_t *l = nullptr;
};
class mutex {
@@ -49,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:
@@ -75,8 +94,8 @@ private:
class readlock {
public:
inline readlock(rwlock &mtx) : mtx(mtx) { mtx.rdlock(); }
inline readlock(const std::unique_ptr<rwlock> &mtx) : mtx(*mtx) { mtx->rdlock(); }
inline readlock(rwlock &mtx_) : mtx(mtx_) { mtx.rdlock(); }
inline readlock(const std::unique_ptr<rwlock> &mtx_) : mtx(*mtx_) { mtx.rdlock(); }
inline ~readlock() { mtx.rdunlock(); }
private:
@@ -85,8 +104,8 @@ private:
class writelock {
public:
inline writelock(rwlock &mtx) : mtx(mtx) { mtx.wrlock(); }
inline writelock(const std::unique_ptr<rwlock> &mtx) : mtx(*mtx) { mtx->wrlock(); }
inline writelock(rwlock &mtx_) : mtx(mtx_) { mtx.wrlock(); }
inline writelock(const std::unique_ptr<rwlock> &mtx_) : mtx(*mtx_) { mtx.wrlock(); }
inline ~writelock() { mtx.wrunlock(); }
private:
@@ -129,10 +148,10 @@ public:
typedef void (*after_work_callback)(T &object);
template<typename... Args>
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>(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);
}

View File

@@ -4,7 +4,6 @@
#include <utility>
#include <typeinfo>
#include <type_traits>
#include <algorithm> // std::move/swap
#include <stdexcept> // runtime_error
#include <new> // operator new
#include <cstddef> // 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 <typename T, class = typename std::enable_if<
detail::is_valid_type<T, Types...>::value>::type>
VARIANT_INLINE explicit variant(T const& val) noexcept
: type_index(detail::value_traits<T, Types...>::index)
{
constexpr std::size_t index = sizeof...(Types) - detail::value_traits<T, Types...>::index - 1;
using target_type = typename detail::select_type<index, Types...>::type;
new (&data) target_type(val);
}
template <typename T, class = typename std::enable_if<
detail::is_valid_type<T, Types...>::value>::type>
detail::is_valid_type<typename std::remove_reference<T>::type, Types...>::value>::type>
VARIANT_INLINE variant(T && val) noexcept
: type_index(detail::value_traits<T, Types...>::index)
: type_index(detail::value_traits<typename std::remove_reference<T>::type, Types...>::index)
{
constexpr std::size_t index = sizeof...(Types) - detail::value_traits<T, Types...>::index - 1;
constexpr std::size_t index = sizeof...(Types) - detail::value_traits<typename std::remove_reference<T>::type, Types...>::index - 1;
using target_type = typename detail::select_type<index, Types...>::type;
new (&data) target_type(std::forward<T>(val)); // nothrow
}
@@ -565,7 +555,7 @@ public:
template <typename T>
VARIANT_INLINE variant<Types...>& operator=(T && rhs) noexcept
{
variant<Types...> temp(std::move(rhs));
variant<Types...> temp(std::forward<T>(rhs));
swap(*this, temp);
return *this;
}

View File

@@ -29,7 +29,7 @@ struct vec2 {
template<typename U>
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;
}

View File

@@ -33,6 +33,7 @@
],
'OTHER_LDFLAGS': [
'<@(glfw3_libraries)',
'<@(curl_libraries)',
],
}
},
@@ -46,6 +47,7 @@
'link_settings': {
'libraries': [
'<@(glfw3_libraries)',
'<@(curl_libraries)',
'-lboost_regex'
],
},

View File

@@ -85,7 +85,7 @@ int main() {
// Notify map object when network reachability status changes.
Reachability* reachability = [Reachability reachabilityForInternetConnection];
reachability.reachableBlock = ^(Reachability *reachability) {
reachability.reachableBlock = ^(Reachability *) {
map_ptr->setReachability(true);
};
[reachability startNotifier];

View File

@@ -1,7 +1,6 @@
{
'includes': [
'./common.gypi',
'./config.gypi',
],
'targets': [
{
@@ -139,8 +138,8 @@
'OTHER_CPLUSPLUSFLAGS': [
'<@(png_cflags)',
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(sqlite3_cflags)',
'<@(zlib_cflags)',
'-I<(boost_root)/include',
],
'OTHER_CFLAGS': [
@@ -151,8 +150,8 @@
'cflags': [
'<@(png_cflags)',
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(sqlite3_cflags)',
'<@(zlib_cflags)',
'-I<(boost_root)/include',
],
}]
@@ -166,27 +165,23 @@
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS': [
'<@(uv_cflags)',
'<@(curl_cflags)',
'-I<(boost_root)/include',
],
'OTHER_LDFLAGS': [
'<@(png_libraries)',
'<@(uv_libraries)',
'<@(curl_libraries)',
'<@(sqlite3_libraries)',
'<@(zlib_libraries)',
]
}
}, {
'cflags': [
'<@(uv_cflags)',
'<@(curl_cflags)',
'-I<(boost_root)/include',
],
'libraries': [
'<@(png_libraries)',
'<@(uv_libraries)',
'<@(curl_libraries)',
'<@(sqlite3_libraries)',
'<@(zlib_libraries)',
]
}]
]
@@ -212,8 +207,7 @@
],
'xcode_settings': {
'SDKROOT': 'iphoneos',
'SUPPORTED_PLATFORMS': ['iphonesimulator','iphoneos'],
'ARCHS': [ "armv7", "armv7s", "arm64", "i386", "x86_64" ],
'SUPPORTED_PLATFORMS': 'iphonesimulator iphoneos',
'TARGETED_DEVICE_FAMILY': '1,2',
'CODE_SIGN_IDENTITY': 'iPhone Developer',
'IPHONEOS_DEPLOYMENT_TARGET': '7.0',
@@ -222,8 +216,8 @@
'OTHER_CPLUSPLUSFLAGS': [
'<@(png_cflags)',
'<@(uv_cflags)',
'<@(curl_cflags)',
'<@(sqlite3_cflags)',
'<@(zlib_cflags)',
'-I<(boost_root)/include',
],
},
@@ -238,8 +232,8 @@
'OTHER_LDFLAGS': [
'<@(png_libraries)',
'<@(uv_libraries)',
'<@(curl_libraries)',
'<@(sqlite3_libraries)',
'<@(zlib_libraries)',
],
'OTHER_CPLUSPLUSFLAGS': [
'<@(uv_cflags)',

View File

@@ -7,7 +7,8 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
# use g++ that supports c++11
if [[ ${CXX} == "g++" ]]; then
export CXX="g++-4.8" ;
export CXX="g++-4.8"
export CC="gcc-4.8"
fi
# If building in debug then turn on sanitizers.

View File

@@ -10,6 +10,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
if [[ `lsb_release -r` =~ "12.04" ]]; then
sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
fi
sudo add-apt-repository --yes ppa:boost-latest/ppa
mapbox_time "apt_update" \
sudo apt-get update -y
@@ -19,7 +20,9 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
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
libtool xutils-dev make cmake pkg-config python-pip \
libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \
libpng-dev libsqlite3-dev
mapbox_time "install_mesa_deps" \
sudo apt-get install -y libpthread-stubs0-dev \
@@ -40,7 +43,8 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then
mapbox_time "install_opengl" \
sudo apt-get -y install libxi-dev x11proto-randr-dev \
x11proto-xext-dev libxrandr-dev \
x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev
x11proto-xf86vidmode-dev libxxf86vm-dev \
libxcursor-dev libxinerama-dev
mapbox_time "install_awscli" \
sudo pip install awscli
@@ -49,7 +53,7 @@ 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
brew install autoconf automake libtool makedepend cmake pkg-config node git boost
mapbox_time "install_awscli" \
sudo pip install awscli

View File

@@ -1,62 +0,0 @@
#!/bin/bash
set -e -u
UNAME=$(uname -s);
MISSING_DEPS=""
function ensure_dep {
if [[ ! `which $1` ]]; then
MISSING_DEPS="$MISSING_DEPS $1"
fi
}
ensure_dep aclocal
ensure_dep cmake
ensure_dep automake
ensure_dep autoconf
ensure_dep pkg-config
ensure_dep node
ensure_dep libtool
ensure_dep gccmakedep
if [[ $MISSING_DEPS != "" ]]; then
if [ ${UNAME} = 'Darwin' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "brew install autoconf automake libtool makedepend cmake pkg-config node"'
echo 'and then re-run ./setup-libraries.sh'
elif [ ${UNAME} = 'Linux' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config nodejs-legacy libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev"'
echo 'and then re-run ./setup-libraries.sh'
fi
exit 1
fi
export SYSROOT=`pwd`/../rootfs
export SDK_PATH=`pwd`/../arm-linux-gnueabi-linaro_4.8.3-2014.04
export V=1
if [ ! -d 'mapnik-packaging/.git' ]; then
git clone --depth=1 https://github.com/mapnik/mapnik-packaging.git
fi
cd mapnik-packaging/osx/
# git pull
export CXX11=true
source Linaro-softfp.sh
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libglfw3.a ] ; then ./scripts/build_glfw.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/libboost_regex.a ] ; then ./scripts/build_boost.sh --with-regex ; fi
cd ../../
./configure \
--pkg-config-root=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp/lib/pkgconfig \
--boost=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-arm-linux-gnueabi-linaro-softfp \
--node=`which node`

View File

@@ -1,185 +0,0 @@
#!/bin/bash
set -e -u
UNAME=$(uname -s);
MISSING_DEPS=""
function ensure_dep {
if [[ ! `which $1` ]]; then
MISSING_DEPS="$MISSING_DEPS $1"
fi
}
ensure_dep aclocal
ensure_dep cmake
ensure_dep automake
ensure_dep autoconf
ensure_dep pkg-config
if [ ${UNAME} = 'Darwin' ]; then
ensure_dep makedepend
if [[ ! `which libtool` ]] && [[ ! `which glibtool` ]]; then
MISSING_DEPS="$MISSING_DEPS libtool"
fi
elif [ ${UNAME} = 'Linux' ]; then
ensure_dep libtool
ensure_dep gccmakedep
fi
if [[ $MISSING_DEPS != "" ]]; then
if [ ${UNAME} = 'Darwin' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "brew install autoconf automake libtool makedepend cmake pkg-config"'
echo 'and then re-run ./setup-libraries.sh'
elif [ ${UNAME} = 'Linux' ]; then
echo "Missing build deps: ${MISSING_DEPS}"
echo 'Please run "sudo apt-get install git build-essential zlib1g-dev automake libtool xutils-dev make cmake pkg-config libxi-dev libglu1-mesa-dev x11proto-randr-dev x11proto-xext-dev libxrandr-dev x11proto-xf86vidmode-dev libxxf86vm-dev libxcursor-dev"'
echo 'and then re-run ./setup-libraries.sh'
fi
exit 1
fi
# bootstrap node install
if [[ ! -d ~/.nvm ]]; then
git clone --depth 1 https://github.com/creationix/nvm.git ~/.nvm
fi
set +u
source ~/.nvm/nvm.sh
nvm install 0.10
set -u
NODE=$(which node)
NPM=$(which npm)
MP_HASH="f543fecbeb0982983593aa0847715d26c323b990"
DIR_HASH=$(echo `pwd` | git hash-object --stdin)
if [ ! -d 'mapnik-packaging/' ]; then
git clone https://github.com/mapnik/mapnik-packaging.git
fi
cd mapnik-packaging
git fetch
git checkout ${MP_HASH}
cd ./osx/
export CXX11=true
if [ ${UNAME} = 'Darwin' ]; then
if [[ ${TRAVIS:-} ]]; then
if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
if aws s3 cp s3://${AWS_S3_BUCKET}/dependencies/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz ./out/ ; then
rm -rf out/build-cpp11-libcpp-x86_64-macosx
rm -rf out/build-cpp11-libcpp-universal
tar -xzf out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz
tar -xzf out/build-cpp11-libcpp-ios_${MP_HASH}_${DIR_HASH}.tar.gz
fi
fi
fi
if test -z "${TRAVIS:-}" || ! test -d out/build-cpp11-libcpp-universal; 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
if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7-iphoneos/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source iPhoneOSs.sh
export LIBUV_VERSION=0.10.28
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-armv7s-iphoneoss/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
echo ' ...done'
source iPhoneOS64.sh
export LIBUV_VERSION=0.10.28
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libpng.a ] ; then ./scripts/build_png.sh ; fi
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libuv.a ] ; then ./scripts/build_libuv.sh ; fi
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-arm64-iphoneos64/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.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
if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-i386-iphonesimulator/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
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
if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-iphonesimulator/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
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
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
if [ ! -f out/build-cpp11-libcpp-x86_64-macosx/lib/libcurl.a ] ; then ./scripts/build_curl.sh ; fi
if [ ! -d out/build-cpp11-libcpp-x86_64-macosx/include/boost ] ; then ./scripts/build_boost.sh `pwd`/../../src/ `pwd`/../../include/ `pwd`/../../linux/ `pwd`/../../common/ ; fi
echo ' ...done'
# setup iOS universal libs
./scripts/make_universal.sh
patch -p0 --forward < patches/curl-ios.diff || true
echo "NOTE: One patch FAILURE is expected. The other should have been applied or ignored."
if [[ ${TRAVIS:-} && ${AWS_ACCESS_KEY_ID:-} && ${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
aws s3 cp --acl public-read out/build-cpp11-libcpp-osx_${MP_HASH}_${DIR_HASH}.tar.gz s3://${AWS_S3_BUCKET}/dependencies/
fi
fi
cd ../../
# default to OS X build product symlinking
./mapnik-packaging/osx/darwin_configure.sh osx
elif [ ${UNAME} = 'Linux' ]; then
if [[ ${TRAVIS:-} ]]; 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_${MP_HASH}_${DIR_HASH}.tar.gz
fi
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
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libsqlite3.a ] ; then ./scripts/build_sqlite.sh ; fi
if [ ! -f out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/libssl.a ] ; then ./scripts/build_openssl.sh ; fi
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 [[ ${TRAVIS:-} && ${AWS_ACCESS_KEY_ID:-} && ${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/
fi
fi
cd ../../
./configure \
--pkg-config-root=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-x86_64-linux/lib/pkgconfig \
--boost=`pwd`/mapnik-packaging/osx/out/build-cpp11-libstdcpp-gcc-x86_64-linux \
--npm=$NPM \
--node=$NODE
fi

View File

@@ -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;

View File

@@ -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;

View File

@@ -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) {
}

View File

@@ -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::dimension> SpriteAtlas::allocateImage(size_t width, size_t height) {
Rect<SpriteAtlas::dimension> 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<dimension> rect = bin.allocate(width + 2 * buffer, height + 2 * buffer);
Rect<dimension> rect = bin.allocate(pixel_width + 2 * buffer, pixel_height + 2 * buffer);
if (rect.w == 0) {
return rect;
}

View File

@@ -59,7 +59,7 @@ struct BucketAlloc
static int CreateBucket( struct BucketAlloc* ba )
{
size_t size;
unsigned int size;
Bucket* bucket;
void* freelist;
unsigned char* head;

View File

@@ -209,13 +209,13 @@ PQhandle pqHeapInsert( TESSalloc* alloc, PriorityQHeap *pq, PQkey keyNew )
// If the heap overflows, double its size.
pq->max <<= 1;
pq->nodes = (PQnode *)alloc->memrealloc( alloc->userData, pq->nodes,
(size_t)((pq->max + 1) * sizeof( pq->nodes[0] )));
(unsigned int)((pq->max + 1) * sizeof( pq->nodes[0] )));
if (pq->nodes == NULL) {
pq->nodes = saveNodes; // restore ptr to free upon return
return INV_HANDLE;
}
pq->handles = (PQhandleElem *)alloc->memrealloc( alloc->userData, pq->handles,
(size_t) ((pq->max + 1) * sizeof( pq->handles[0] )));
(unsigned int) ((pq->max + 1) * sizeof( pq->handles[0] )));
if (pq->handles == NULL) {
pq->handles = saveHandles; // restore ptr to free upon return
return INV_HANDLE;
@@ -351,7 +351,7 @@ int pqInit( TESSalloc* alloc, PriorityQ *pq )
(pq->size * sizeof(pq->order[0])) );
*/
pq->order = (PQkey **)alloc->memalloc( alloc->userData,
(size_t)((pq->size+1) * sizeof(pq->order[0])) );
(unsigned int)((pq->size+1) * sizeof(pq->order[0])) );
/* the previous line is a patch to compensate for the fact that IBM */
/* machines return a null on a malloc of zero bytes (unlike SGI), */
/* so we have to put in this defense to guard against a memory */
@@ -438,7 +438,7 @@ PQhandle pqInsert( TESSalloc* alloc, PriorityQ *pq, PQkey keyNew )
// If the heap overflows, double its size.
pq->max <<= 1;
pq->keys = (PQkey *)alloc->memrealloc( alloc->userData, pq->keys,
(size_t)(pq->max * sizeof( pq->keys[0] )));
(unsigned int)(pq->max * sizeof( pq->keys[0] )));
if (pq->keys == NULL) {
pq->keys = saveKey; // restore ptr to free upon return
return INV_HANDLE;

View File

@@ -428,6 +428,8 @@ static void VertexWeights( TESSvertex *isect, TESSvertex *org, TESSvertex *dst,
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
static void GetIntersectData( TESStesselator *tess, TESSvertex *isect,
TESSvertex *orgUp, TESSvertex *dstUp,
TESSvertex *orgLo, TESSvertex *dstLo )
@@ -444,6 +446,7 @@ static void GetIntersectData( TESStesselator *tess, TESSvertex *isect,
VertexWeights( isect, orgUp, dstUp, &weights[0] );
VertexWeights( isect, orgLo, dstLo, &weights[2] );
}
#pragma GCC diagnostic pop
static int CheckForRightSplice( TESStesselator *tess, ActiveRegion *regUp )
/*

View File

@@ -46,17 +46,6 @@
#define Dot(u,v) (u[0]*v[0] + u[1]*v[1] + u[2]*v[2])
static void Normalize( TESSreal v[3] )
{
TESSreal len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
assert( len > 0 );
len = sqrtf( len );
v[0] /= len;
v[1] /= len;
v[2] /= len;
}
#define ABS(x) ((x) < 0 ? -(x) : (x))
static int LongAxis( TESSreal v[3] )
@@ -436,6 +425,8 @@ int tessMeshSetWindingNumber( TESSmesh *mesh, int value,
return 1;
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
void* heapAlloc( void* userData, unsigned int size )
{
return malloc( size );
@@ -450,6 +441,7 @@ void heapFree( void* userData, void* ptr )
{
free( ptr );
}
#pragma GCC diagnostic pop
static TESSalloc defaulAlloc =
{

View File

@@ -30,17 +30,17 @@
using namespace mbgl;
Map::Map(View& view)
Map::Map(View& view_)
: loop(std::make_shared<uv::loop>()),
thread(std::make_unique<uv::thread>()),
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<GlyphAtlas>(1024, 1024)),
spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)),
texturepool(std::make_shared<Texturepool>()),
@@ -145,10 +145,6 @@ void Map::stop(stop_callback cb, void *data) {
async = false;
}
void Map::delete_async(uv_handle_t *handle, int status) {
delete (uv_async_t *)handle;
}
void Map::run() {
#ifndef NDEBUG
if (!async) {
@@ -202,7 +198,11 @@ void Map::cleanup() {
}
}
void Map::cleanup(uv_async_t *async, int status) {
#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<Map *>(async->data);
map->painter.cleanup();
@@ -223,7 +223,11 @@ void Map::setReachability(bool reachable) {
}
}
void Map::render(uv_async_t *async, int status) {
#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<Map *>(async->data);
assert(uv_thread_self() == map->map_thread);
@@ -243,7 +247,11 @@ void Map::render(uv_async_t *async, int status) {
}
}
void Map::terminate(uv_async_t *async, int status) {
#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<Map *>(async->data);
assert(uv_thread_self() == map->map_thread);
@@ -645,9 +653,6 @@ void Map::prepare() {
void Map::render() {
view.make_active();
#if defined(DEBUG)
std::vector<std::string> debug;
#endif
painter.clear();
painter.resize();

View File

@@ -18,10 +18,12 @@
#include <mbgl/map/vector_tile_data.hpp>
#include <mbgl/map/raster_tile_data.hpp>
#include <algorithm>
namespace mbgl {
Source::Source(const util::ptr<SourceInfo>& info)
: info(info)
Source::Source(const util::ptr<SourceInfo>& info_)
: info(info_)
{
}
@@ -219,15 +221,15 @@ std::forward_list<Tile::ID> Source::coveringTiles(const TransformState& state) c
box points = state.cornersToBox(z);
const vec2<double>& center = points.center;
std::forward_list<Tile::ID> tiles = Tile::cover(z, points);
std::forward_list<Tile::ID> covering_tiles = Tile::cover(z, points);
tiles.sort([&center](const Tile::ID& a, const Tile::ID& b) {
covering_tiles.sort([&center](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;
}
/**

View File

@@ -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> Sprite::Create(const std::string& base_url, float pixelRatio, const util::ptr<FileSource> &fileSource) {
@@ -28,11 +28,11 @@ util::ptr<Sprite> 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 {

View File

@@ -7,8 +7,8 @@ using namespace mbgl;
#include <iostream>
Tile::Tile(const ID& id)
: id(id) {
Tile::Tile(const ID& id_)
: id(id_) {
}
Tile::ID Tile::ID::parent(int8_t parent_z) const {

View File

@@ -9,14 +9,14 @@
using namespace mbgl;
TileData::TileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source)
: id(id),
TileData::TileData(Tile::ID id_, Map &map_, const util::ptr<SourceInfo> &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);
}

View File

@@ -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<const Style> &style_,
const util::ptr<GlyphAtlas> &glyphAtlas_,
const util::ptr<GlyphStore> &glyphStore_,
const util::ptr<SpriteAtlas> &spriteAtlas_,
const util::ptr<Sprite> &sprite_)
: vector_data(pbf((const uint8_t *)data.data(), data.size())),
tile(tile),
tile(tile_),
style(style_),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),

View File

@@ -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<uv::rwlock>()) {
Transform::Transform(View &view_) : view(view_), mtx(std::make_unique<uv::rwlock>()) {
setScale(current.scale);
setAngle(current.angle);
}

View File

@@ -83,11 +83,31 @@ const std::array<uint16_t, 2> TransformState::getFramebufferDimensions() const {
return framebuffer;
}
float TransformState::getPixelRatio() const {
return pixelRatio;
}
float TransformState::worldSize() const {
return scale * util::tileSize;
}
float TransformState::lngX(float lon) const {
return (180 + lon) * worldSize() / 360;
}
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;
}
std::array<float, 2> TransformState::locationCoordinate(float lon, float lat) const {
float k = std::pow(2, getIntegerZoom()) / worldSize();
return {{
lngX(lon) * k,
latY(lat) * k
}};
}
#pragma mark - Zoom
@@ -95,12 +115,16 @@ float TransformState::getNormalizedZoom() const {
return std::log(scale * util::tileSize / 512.0f) / M_LN2;
}
double TransformState::getZoom() const {
return std::log(scale) / M_LN2;
}
int32_t TransformState::getIntegerZoom() const {
return std::floor(getZoom());
}
double TransformState::getZoom() const {
return std::log(scale) / M_LN2;
double TransformState::getZoomFraction() const {
return getZoom() - getIntegerZoom();
}
double TransformState::getScale() const {

View File

@@ -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++();
}

View File

@@ -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<StyleLayer> /*layer_desc*/, const Tile::ID& /*id*/, const mat4 &matrix) {

View File

@@ -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<TESSreal> line;
std::vector<TESSreal> 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;

View File

@@ -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;
};

View File

@@ -7,6 +7,9 @@
#include <mbgl/util/time.hpp>
#include <mbgl/util/clip_ids.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/mat3.hpp>
#include <mbgl/geometry/sprite_atlas.hpp>
#if defined(DEBUG)
#include <mbgl/util/timer.hpp>
#endif
@@ -18,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() {
@@ -208,24 +211,66 @@ void Painter::renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc
void Painter::renderBackground(util::ptr<StyleLayer> layer_desc) {
const BackgroundProperties& properties = layer_desc->getProperties<BackgroundProperties>();
const std::shared_ptr<Sprite> sprite = map.getSprite();
Color color = properties.color;
color[0] *= properties.opacity;
color[1] *= properties.opacity;
color[2] *= properties.opacity;
color[3] *= properties.opacity;
if (properties.image.size() && sprite) {
if ((properties.opacity >= 1.0f) != (pass == RenderPass::Opaque))
return;
SpriteAtlas &spriteAtlas = *map.getSpriteAtlas();
SpriteAtlasPosition imagePos = spriteAtlas.getPosition(properties.image, *sprite, true);
float zoomFraction = map.getState().getZoomFraction();
useProgram(patternShader->program);
patternShader->u_matrix = identityMatrix;
patternShader->u_pattern_tl = imagePos.tl;
patternShader->u_pattern_br = imagePos.br;
patternShader->u_mix = zoomFraction;
patternShader->u_opacity = properties.opacity;
std::array<float, 2> size = imagePos.size;
double lon, lat;
map.getLonLat(lon, lat);
std::array<float, 2> center = map.getState().locationCoordinate(lon, lat);
float scale = 1 / std::pow(2, zoomFraction);
mat3 matrix;
matrix::identity(matrix);
matrix::scale(matrix, matrix,
1.0f / size[0],
1.0f / size[1]);
matrix::translate(matrix, matrix,
std::fmod(center[0] * 512, size[0]),
std::fmod(center[1] * 512, size[1]));
matrix::rotate(matrix, matrix, -map.getState().getAngle());
matrix::scale(matrix, matrix,
scale * map.getState().getWidth() / 2,
-scale * map.getState().getHeight() / 2);
patternShader->u_patternmatrix = matrix;
backgroundBuffer.bind();
patternShader->bind(0);
spriteAtlas.bind(true);
} else {
Color color = properties.color;
color[0] *= properties.opacity;
color[1] *= properties.opacity;
color[2] *= properties.opacity;
color[3] *= properties.opacity;
if ((color[3] >= 1.0f) != (pass == RenderPass::Opaque))
return;
if ((color[3] >= 1.0f) == (pass == RenderPass::Opaque)) {
useProgram(plainShader->program);
plainShader->u_matrix = identityMatrix;
plainShader->u_color = color;
backgroundArray.bind(*plainShader, backgroundBuffer, BUFFER_OFFSET(0));
glDisable(GL_STENCIL_TEST);
depthRange(strata + strata_epsilon, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glEnable(GL_STENCIL_TEST);
}
glDisable(GL_STENCIL_TEST);
depthRange(strata + strata_epsilon, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glEnable(GL_STENCIL_TEST);
}
mat4 Painter::translatedMatrix(const mat4& matrix, const std::array<float, 2> &translation, const Tile::ID &id, TranslateAnchorType anchor) {

View File

@@ -5,8 +5,8 @@
using namespace mbgl;
PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties)
: properties(properties) {
PrerenderedTexture::PrerenderedTexture(const StyleBucketRaster &properties_)
: properties(properties_) {
}
PrerenderedTexture::~PrerenderedTexture() {

View File

@@ -3,9 +3,9 @@
using namespace mbgl;
RasterBucket::RasterBucket(const util::ptr<Texturepool> &texturepool, const StyleBucketRaster& properties)
: properties(properties),
texture(properties),
RasterBucket::RasterBucket(const util::ptr<Texturepool> &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());

View File

@@ -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<StyleLayer> layer_desc,
const Tile::ID &id, const mat4 &matrix) {
@@ -52,12 +52,12 @@ std::vector<SymbolFeature> 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<SymbolFeature> features;
if (!text && !icon) {
if (!has_text && !has_icon) {
return features;
}
@@ -72,7 +72,7 @@ std::vector<SymbolFeature> 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<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
}
}
if (icon) {
if (has_icon) {
ft.sprite = util::replaceTokens(properties.icon.image, feature.properties);
}

View File

@@ -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);

View File

@@ -2,6 +2,8 @@
#include <mbgl/storage/file_request.hpp>
#include <mbgl/storage/response.hpp>
#include <limits>
namespace mbgl {
FileRequestBaton::FileRequestBaton(FileRequest *request_, const std::string &path, uv_loop_t *loop)
@@ -29,7 +31,11 @@ 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<Response>(new Response);
ptr->request->response->code = req->result == UV_ENOENT ? 404 : 500;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
ptr->request->response->message = uv_strerror(uv_last_error(req->loop));
#else
ptr->request->response->message = uv_strerror(int(req->result));
#endif
ptr->request->notify();
}
}
@@ -63,7 +69,7 @@ void FileRequestBaton::file_stated(uv_fs_t *req) {
FileRequestBaton *ptr = (FileRequestBaton *)req->data;
assert(ptr->thread_id == uv_thread_self());
if (req->result < 0 || ptr->canceled || !ptr->request) {
if (req->result != 0 || ptr->canceled || !ptr->request) {
// Stating failed or was canceled. We already have an open file handle
// though, which we'll have to close.
notify_error(req);
@@ -71,26 +77,37 @@ 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<const uv_statbuf_t *>(req->ptr)->st_size > std::numeric_limits<int>::max()) {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
const uv_statbuf_t *stat = static_cast<const uv_statbuf_t *>(req->ptr);
#else
const uv_stat_t *stat = static_cast<const uv_stat_t *>(req->ptr);
#endif
if (stat->st_size > std::numeric_limits<int>::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<Response>(new Response);
ptr->request->response->code = error.code;
ptr->request->response->message = uv_strerror(error);
ptr->request->response->code = UV_EFBIG;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
ptr->request->response->message = uv_strerror(uv_err_t {UV_EFBIG, 0});
#else
ptr->request->response->message = uv_strerror(UV_EFBIG);
#endif
ptr->request->notify();
}
uv_fs_req_cleanup(req);
uv_fs_close(req->loop, req, ptr->fd, file_closed);
} else {
const unsigned int size =
(unsigned int)(static_cast<const uv_statbuf_t *>(req->ptr)->st_size);
const unsigned int size = (unsigned int)(stat->st_size);
ptr->body.resize(size);
ptr->buffer = uv_buf_init(const_cast<char *>(ptr->body.data()), size);
uv_fs_req_cleanup(req);
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_fs_read(req->loop, req, ptr->fd, ptr->buffer.base, ptr->buffer.len, -1, file_read);
#else
uv_fs_read(req->loop, req, ptr->fd, &ptr->buffer, 1, 0, file_read);
#endif
}
}
}
@@ -118,8 +135,7 @@ void FileRequestBaton::file_read(uv_fs_t *req) {
}
void FileRequestBaton::file_closed(uv_fs_t *req) {
FileRequestBaton *ptr = (FileRequestBaton *)req->data;
assert(ptr->thread_id == uv_thread_self());
assert(((FileRequestBaton *)req->data)->thread_id == uv_thread_self());
if (req->result < 0) {
// Closing the file failed. But there isn't anything we can do.

View File

@@ -77,20 +77,24 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) {
http_baton->response = std::move(res);
http_baton->async->data = new util::ptr<HTTPRequestBaton>(http_baton);
uv_async_init(loop, http_baton->async, [](uv_async_t *async, int status) {
util::ptr<HTTPRequestBaton> &http_baton = *(util::ptr<HTTPRequestBaton> *)async->data;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_async_init(loop, http_baton->async, [](uv_async_t *async, int) {
#else
uv_async_init(loop, http_baton->async, [](uv_async_t *async) {
#endif
util::ptr<HTTPRequestBaton> &baton = *(util::ptr<HTTPRequestBaton> *)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<HTTPRequestBaton> *)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++;
@@ -193,7 +197,12 @@ void HTTPRequest::retryHTTPRequest(std::unique_ptr<Response> &&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, int status) {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
uv_timer_start(backoff_timer, [](uv_timer_t *timer, int) {
#else
uv_timer_start(backoff_timer, [](uv_timer_t *timer) {
#endif
std::unique_ptr<RetryBaton> pair { static_cast<RetryBaton *>(timer->data) };
pair->first->startHTTPRequest(std::move(pair->second));
pair->first->backoff_timer = nullptr;

View File

@@ -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;
});
}
}

View File

@@ -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 {

View File

@@ -18,10 +18,10 @@ template <typename T>
T StopsFunction<T>::evaluate(float z) const {
bool smaller = false;
float smaller_z = 0.0f;
T smaller_val {};
T smaller_val = T();
bool larger = false;
float larger_z = 0.0f;
T larger_val {};
T larger_val = T();
for (uint32_t i = 0; i < values.size(); i++) {
float stop_z = values[i].first;

View File

@@ -7,8 +7,8 @@
namespace mbgl {
StyleLayer::StyleLayer(const std::string &id, std::map<ClassID, ClassProperties> &&styles)
: id(id), styles(std::move(styles)) {}
StyleLayer::StyleLayer(const std::string &id_, std::map<ClassID, ClassProperties> &&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<PropertyKey, PropertyValue> &property_pair : properties) {
const ClassProperties &class_properties = style_it->second;
for (const std::pair<PropertyKey, PropertyValue> &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 <typename T>
struct PropertyEvaluator {
typedef T result_type;
PropertyEvaluator(float z) : z(z) {}
PropertyEvaluator(float z_) : z(z_) {}
template <typename P, typename std::enable_if<std::is_convertible<P, T>::value, int>::type = 0>
T operator()(const P &value) const {
@@ -235,6 +235,7 @@ void StyleLayer::applyStyleProperties<BackgroundProperties>(const float z, const
BackgroundProperties &background = properties.get<BackgroundProperties>();
applyTransitionedStyleProperty(PropertyKey::BackgroundOpacity, background.opacity, z, now);
applyTransitionedStyleProperty(PropertyKey::BackgroundColor, background.color, z, now);
applyStyleProperty(PropertyKey::BackgroundImage, background.image, z, now);
}
void StyleLayer::updateProperties(float z, const timestamp now) {
@@ -268,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;

View File

@@ -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<uint16_t>::max()) {
unsigned int int_value = property.GetUint();
if (int_value > std::numeric_limits<uint16_t>::max()) {
Log::Warning(Event::ParseStyle, "values for %s that are larger than %d are not supported", name, std::numeric_limits<uint16_t>::max());
return false;
}
target = value;
target = int_value;
return true;
} else {
Log::Warning(Event::ParseStyle, "%s must be an unsigned integer", name);
@@ -640,6 +640,7 @@ void StyleParser::parseStyle(JSVal value, ClassProperties &klass) {
parseOptionalProperty<Function<float>>("background-opacity", Key::BackgroundOpacity, klass, value);
parseOptionalProperty<Function<Color>>("background-color", Key::BackgroundColor, klass, value);
parseOptionalProperty<std::string>("background-image", Key::BackgroundImage, klass, value);
}
void StyleParser::parseReference(JSVal value, util::ptr<StyleLayer> &layer) {
@@ -762,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()) {

View File

@@ -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;

View File

@@ -228,7 +228,7 @@ void GlyphPBF::parse(FontStack &stack) {
data.clear();
}
GlyphStore::GlyphStore(const util::ptr<FileSource> &fileSource) : fileSource(fileSource) {}
GlyphStore::GlyphStore(const util::ptr<FileSource> &fileSource_) : fileSource(fileSource_) {}
void GlyphStore::setURL(const std::string &url) {
glyphURL = url;

View File

@@ -12,10 +12,10 @@ namespace mbgl {
const float Placement::globalMinScale = 0.5; // underscale by 1 zoom level
struct GlyphInstance {
explicit GlyphInstance(const vec2<float> &anchor) : anchor(anchor) {}
explicit GlyphInstance(const vec2<float> &anchor, float offset, float minScale, float maxScale,
float angle)
: anchor(anchor), offset(offset), minScale(minScale), maxScale(maxScale), angle(angle) {}
explicit GlyphInstance(const vec2<float> &anchor_) : anchor(anchor_) {}
explicit GlyphInstance(const vec2<float> &anchor_, float offset_, float minScale_, float maxScale_,
float angle_)
: anchor(anchor_), offset(offset_), minScale(minScale_), maxScale(maxScale_), angle(angle_) {}
const vec2<float> anchor;
const float offset = 0.0f;

View File

@@ -18,7 +18,7 @@ std::string compress(const std::string &raw) {
}
deflate_stream.next_in = (Bytef *)raw.data();
deflate_stream.avail_in = raw.size();
deflate_stream.avail_in = uInt(raw.size());
std::string result;
char out[16384];
@@ -53,7 +53,7 @@ std::string decompress(const std::string &raw) {
}
inflate_stream.next_in = (Bytef *)raw.data();
inflate_stream.avail_in = raw.size();
inflate_stream.avail_in = uInt(raw.size());
std::string result;
char out[15384];

View File

@@ -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<std::string *>(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<std::string *>(png_get_io_ptr(png_ptr_));
out->append(reinterpret_cast<char *>(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;

View File

@@ -38,7 +38,51 @@ void matrix::identity(mat3& out) {
out[8] = 1.0f;
}
void matrix::scale(mat3& out, const mat3& a, const float x, const float y) {
void matrix::translate(mat3& out, const mat3& a, float x, float y) {
float a00 = a[0], a01 = a[1], a02 = a[2],
a10 = a[3], a11 = a[4], a12 = a[5],
a20 = a[6], a21 = a[7], a22 = a[8];
out[0] = a00;
out[1] = a01;
out[2] = a02;
out[3] = a10;
out[4] = a11;
out[5] = a12;
out[6] = x * a00 + y * a10 + a20;
out[7] = x * a01 + y * a11 + a21;
out[8] = x * a02 + y * a12 + a22;
}
void matrix::rotate(mat3& out, const mat3& a, float rad) {
float s = std::sin(rad),
c = std::cos(rad),
a00 = a[0],
a01 = a[1],
a02 = a[2],
a10 = a[3],
a11 = a[4],
a12 = a[5],
a20 = a[6],
a21 = a[7],
a22 = a[8];
out[0] = c * a00 + s * a10;
out[1] = c * a01 + s * a11;
out[2] = c * a02 + s * a12;
out[3] = c * a10 - s * a00;
out[4] = c * a11 - s * a01;
out[5] = c * a12 - s * a02;
out[6] = a20;
out[7] = a21;
out[8] = a22;
};
void matrix::scale(mat3& out, const mat3& a, float x, float y) {
out[0] = x * a[0];
out[1] = x * a[1];
out[2] = x * a[2];

View File

@@ -208,7 +208,7 @@ int raw_equal(const char *first, const char *second)
int clamp_to_int(long slnum)
{
return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : slnum;
return slnum > INT_MAX ? INT_MAX : slnum < INT_MIN ? INT_MIN : (int)slnum;
}

View File

@@ -13,8 +13,8 @@
using namespace mbgl;
Raster::Raster(const util::ptr<Texturepool> &texturepool)
: texturepool(texturepool)
Raster::Raster(const util::ptr<Texturepool> &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;
}
}

View File

@@ -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;
}

View File

@@ -8,7 +8,14 @@ typedef struct {
void *queue[2];
} uv__messenger_item_t;
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-parameter"
void uv__messenger_callback(uv_async_t *async, int status) {
#pragma clang diagnostic pop
#else
void uv__messenger_callback(uv_async_t *async) {
#endif
uv_messenger_t *msgr = (uv_messenger_t *)async->data;
uv__messenger_item_t *item;

View File

@@ -5,15 +5,21 @@
namespace uv {
std::string cwd() {
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
char dir[512];
uv_cwd(dir, 512);
return dir;
#else
size_t max = 0;
std::string dir;
do {
max += 256;
dir.resize(max);
uv_cwd(const_cast<char *>(dir.data()), max);
uv_cwd(const_cast<char *>(dir.data()), &max);
} while (max == dir.size());
dir.resize(max - 1);
return dir;
#endif
}
void deleter::operator()(uv_async_t *async) {

View File

@@ -10,7 +10,7 @@
class MockExtractor {
public:
inline MockExtractor(const std::multimap<std::string, mbgl::Value> &values) : values(values) {}
inline MockExtractor(const std::multimap<std::string, mbgl::Value> &values_) : values(values_) {}
inline MockExtractor() {}
inline std::vector<mbgl::Value> getValues(const std::string &key) const {

View File

@@ -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"));
@@ -31,7 +29,7 @@ TEST(Enums, StyleLayerType) {
ASSERT_EQ(StyleLayerTypeClass(StyleLayerType::Raster), StyleLayerTypeClass(StyleLayerType::Raster));
ASSERT_EQ(StyleLayerTypeClass(StyleLayerType::Background), StyleLayerTypeClass(StyleLayerType::Background));
ASSERT_EQ(false, StyleLayerTypeClass("").valid());
ASSERT_EQ(false, StyleLayerTypeClass("Backgrund").valid());
ASSERT_FALSE(StyleLayerTypeClass("").valid());
ASSERT_FALSE(StyleLayerTypeClass("Backgrund").valid());
}

View File

@@ -3,8 +3,7 @@
#include <mbgl/platform/log.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <boost/optional.hpp>
#include <mbgl/util/optional.hpp>
#include <vector>
#include <cstdarg>
@@ -14,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) {}
inline LogMessage(EventSeverity severity, Event event, const std::string &msg)
: severity(severity), event(event), msg(msg) {}
inline LogMessage(EventSeverity severity, Event event)
: severity(severity), event(event) {}
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()) &&
@@ -30,10 +29,10 @@ public:
(!msg || !rhs.msg || msg.get() == rhs.msg.get());
}
const boost::optional<EventSeverity> severity;
const boost::optional<Event> event;
const boost::optional<int64_t> code;
const boost::optional<std::string> msg;
const mapbox::util::optional<EventSeverity> severity;
const mapbox::util::optional<Event> event;
const mapbox::util::optional<int64_t> code;
const mapbox::util::optional<std::string> msg;
mutable bool checked = false;
};

View File

@@ -36,11 +36,17 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &baton) {
const size_t size = ftell(file);
fseek(file, 0, SEEK_SET);
baton->response->data.resize(size);
fread(&baton->response->data[0], size, 1, file);
const size_t read = fread(&baton->response->data[0], 1, size, file);
fclose(file);
baton->response->code = 200;
baton->type = HTTPResponseType::Successful;
if (read == size) {
baton->response->code = 200;
baton->type = HTTPResponseType::Successful;
} else {
baton->response->code = 500;
baton->type = HTTPResponseType::PermanentError;
baton->response->message = "Read bytes differed from file size";
}
} else {
baton->type = HTTPResponseType::PermanentError;
baton->response->code = 404;
@@ -49,7 +55,7 @@ void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &baton) {
uv_async_send(baton->async);
}
void HTTPRequestBaton::stop(const util::ptr<HTTPRequestBaton> &baton) {
void HTTPRequestBaton::stop(const util::ptr<HTTPRequestBaton> &/*baton*/) {
fprintf(stderr, "HTTP request cannot be canceled because it is answered immediately");
abort();
}

Some files were not shown because too many files have changed in this diff Show More