summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2015-01-27 07:23:43 +1100
committerLeith Bade <leith@mapbox.com>2015-01-27 07:23:43 +1100
commit8193acdf30e61e1b7d4af30df7e78d7d7dc649f1 (patch)
tree2888e2c2544f256f5c8d8cde3ddb9bba6cdf4ee0 /src
parent60035d77283bded4513b1ff5d45a41673405692a (diff)
parentfb525cde3977d22e888b7f1d138efa015362d1d6 (diff)
downloadqtlocation-mapboxgl-8193acdf30e61e1b7d4af30df7e78d7d7dc649f1.tar.gz
Merge pull request #676 from mapbox/android-mason
Android GL mega-merge
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/geometry/glyph_atlas.cpp2
-rw-r--r--src/mbgl/map/map.cpp107
-rw-r--r--src/mbgl/platform/gl.cpp4
-rw-r--r--src/mbgl/shader/shader.cpp12
-rw-r--r--src/mbgl/storage/asset_request.hpp27
-rw-r--r--src/mbgl/storage/base_request.cpp10
-rw-r--r--src/mbgl/storage/base_request.hpp2
-rw-r--r--src/mbgl/storage/caching_http_file_source.cpp13
-rw-r--r--src/mbgl/storage/http_request.cpp111
-rw-r--r--src/mbgl/storage/http_request.hpp10
-rw-r--r--src/mbgl/storage/http_request_baton.cpp2
-rw-r--r--src/mbgl/style/style.cpp2
12 files changed, 213 insertions, 89 deletions
diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp
index fe78bdfd6b..fd429d41a3 100644
--- a/src/mbgl/geometry/glyph_atlas.cpp
+++ b/src/mbgl/geometry/glyph_atlas.cpp
@@ -161,7 +161,7 @@ void GlyphAtlas::bind() {
dirty = false;
#if defined(DEBUG)
- // platform::show_debug_image("Glyph Atlas", data, width, height);
+ // platform::showDebugImage("Glyph Atlas", data, width, height);
#endif
}
};
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index b6da256657..ff584c54ba 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -24,6 +24,7 @@
#include <mbgl/storage/file_source.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/string.hpp>
+#include <mbgl/util/uv.hpp>
#include <algorithm>
#include <iostream>
@@ -133,7 +134,7 @@ uv::worker &Map::getWorker() {
return *workers;
}
-void Map::start() {
+void Map::start(bool startPaused) {
assert(std::this_thread::get_id() == mainThread);
assert(mode == Mode::None);
@@ -155,6 +156,8 @@ void Map::start() {
fileSource.clearLoop();
+ terminating = true;
+
// Closes all open handles on the loop. This means that the loop will automatically terminate.
asyncRender.reset();
asyncTerminate.reset();
@@ -179,6 +182,11 @@ void Map::start() {
}
});
+ // Do we need to pause first?
+ if (startPaused) {
+ pause();
+ }
+
thread = std::thread([this]() {
#ifndef NDEBUG
mapThread = std::this_thread::get_id();
@@ -207,6 +215,8 @@ void Map::stop(std::function<void ()> callback) {
asyncTerminate->send();
+ resume();
+
if (callback) {
// Wait until the render thread stopped. We are using this construct instead of plainly
// relying on the thread_join because the system might need to run things in the current
@@ -226,6 +236,34 @@ void Map::stop(std::function<void ()> callback) {
mode = Mode::None;
}
+void Map::pause(bool waitForPause) {
+ assert(std::this_thread::get_id() == mainThread);
+ assert(mode == Mode::Continuous);
+ mutexRun.lock();
+ pausing = true;
+ mutexRun.unlock();
+
+ uv_stop(**loop);
+ rerender(); // Needed to ensure uv_stop is seen and uv_run exits, otherwise we deadlock on wait_for_pause
+
+ if (waitForPause) {
+ std::unique_lock<std::mutex> lockPause (mutexPause);
+ while (!isPaused) {
+ condPause.wait(lockPause);
+ }
+ }
+}
+
+void Map::resume() {
+ assert(std::this_thread::get_id() == mainThread);
+ assert(mode == Mode::Continuous);
+
+ mutexRun.lock();
+ pausing = false;
+ condRun.notify_all();
+ mutexRun.unlock();
+}
+
void Map::run() {
if (mode == Mode::None) {
#ifndef NDEBUG
@@ -235,9 +273,23 @@ void Map::run() {
}
assert(std::this_thread::get_id() == mapThread);
+ if (mode == Mode::Continuous) {
+ checkForPause();
+ }
+
+ view.activate();
setup();
prepare();
- uv_run(**loop, UV_RUN_DEFAULT);
+
+ if (mode == Mode::Continuous) {
+ terminating = false;
+ while(!terminating) {
+ uv_run(**loop, UV_RUN_DEFAULT);
+ checkForPause();
+ }
+ } else {
+ uv_run(**loop, UV_RUN_DEFAULT);
+ }
// Run the event loop once more to make sure our async delete handlers are called.
uv_run(**loop, UV_RUN_ONCE);
@@ -252,6 +304,28 @@ void Map::run() {
mode = Mode::None;
fileSource.clearLoop();
}
+
+ view.deactivate();
+}
+
+void Map::checkForPause() {
+ std::unique_lock<std::mutex> lockRun (mutexRun);
+ while (pausing) {
+ view.deactivate();
+
+ mutexPause.lock();
+ isPaused = true;
+ condPause.notify_all();
+ mutexPause.unlock();
+
+ condRun.wait(lockRun);
+
+ view.activate();
+ }
+
+ mutexPause.lock();
+ isPaused = false;
+ mutexPause.unlock();
}
void Map::rerender() {
@@ -282,7 +356,6 @@ void Map::swapped() {
void Map::terminate() {
assert(painter);
- view.activate();
painter->terminate();
view.deactivate();
}
@@ -292,14 +365,17 @@ void Map::terminate() {
void Map::setup() {
assert(std::this_thread::get_id() == mapThread);
assert(painter);
- view.activate();
painter->setup();
- view.deactivate();
}
void Map::setStyleURL(const std::string &url) {
// TODO: Make threadsafe.
+
styleURL = url;
+ if (mode == Mode::Continuous) {
+ stop();
+ start();
+ }
}
@@ -310,10 +386,14 @@ void Map::setStyleJSON(std::string newStyleJSON, const std::string &base) {
if (!style) {
style = std::make_shared<Style>();
}
+
style->loadJSON((const uint8_t *)styleJSON.c_str());
style->cascadeClasses(classes);
fileSource.setBase(base);
glyphStore->setURL(style->glyph_url);
+
+ style->setDefaultTransitionDuration(defaultTransitionDuration);
+
update();
}
@@ -338,8 +418,8 @@ void Map::resize(uint16_t width, uint16_t height, float ratio) {
resize(width, height, ratio, width * ratio, height * ratio);
}
-void Map::resize(uint16_t width, uint16_t height, float ratio, uint16_t fb_width, uint16_t fb_height) {
- if (transform.resize(width, height, ratio, fb_width, fb_height)) {
+void Map::resize(uint16_t width, uint16_t height, float ratio, uint16_t fbWidth, uint16_t fbHeight) {
+ if (transform.resize(width, height, ratio, fbWidth, fbHeight)) {
update();
}
}
@@ -539,7 +619,14 @@ std::vector<std::string> Map::getClasses() const {
}
void Map::setDefaultTransitionDuration(uint64_t milliseconds) {
- style->setDefaultTransitionDuration(milliseconds);
+ defaultTransitionDuration = milliseconds;
+ if (style) {
+ style->setDefaultTransitionDuration(milliseconds);
+ }
+}
+
+uint64_t Map::getDefaultTransitionDuration() {
+ return defaultTransitionDuration;
}
void Map::updateSources() {
@@ -636,8 +723,6 @@ void Map::prepare() {
}
void Map::render() {
- view.activate();
-
assert(painter);
painter->render(*style, activeSources,
state, animationTime);
@@ -645,6 +730,4 @@ void Map::render() {
if (transform.needsTransition() || style->hasTransitions()) {
update();
}
-
- view.deactivate();
}
diff --git a/src/mbgl/platform/gl.cpp b/src/mbgl/platform/gl.cpp
index 95fad969f7..91565f12c3 100644
--- a/src/mbgl/platform/gl.cpp
+++ b/src/mbgl/platform/gl.cpp
@@ -70,6 +70,10 @@ PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays = nullptr;
PFNGLGENVERTEXARRAYSPROC GenVertexArrays = nullptr;
PFNGLISVERTEXARRAYPROC IsVertexArray = nullptr;
+bool isPackedDepthStencilSupported = false;
+
+bool isDepth24Supported = false;
+
PFNGLGETPROGRAMBINARYPROC GetProgramBinary = nullptr;
PFNGLPROGRAMBINARYPROC ProgramBinary = nullptr;
PFNGLPROGRAMPARAMETERIPROC ProgramParameteri = nullptr;
diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp
index 32e10a6400..d47723db49 100644
--- a/src/mbgl/shader/shader.cpp
+++ b/src/mbgl/shader/shader.cpp
@@ -8,6 +8,7 @@
#include <cassert>
#include <iostream>
#include <fstream>
+#include <cstdio>
using namespace mbgl;
@@ -66,8 +67,7 @@ Shader::Shader(const char *name_, const GLchar *vertSource, const GLchar *fragSo
if (status == GL_TRUE) {
skipCompile = true;
}
-
- } catch(std::exception& e) {
+ } catch(const std::exception& e) {
Log::Error(Event::Shader, "Loading binary shader failed!");
// Delete the bad file
@@ -169,7 +169,7 @@ bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) {
*shader = MBGL_CHECK_ERROR(glCreateShader(type));
const GLchar *strings[] = { source };
- const GLsizei lengths[] = { (GLsizei)std::strlen(source) };
+ const GLsizei lengths[] = { static_cast<GLsizei>(std::strlen(source)) };
MBGL_CHECK_ERROR(glShaderSource(*shader, 1, strings, lengths));
MBGL_CHECK_ERROR(glCompileShader(*shader));
@@ -208,7 +208,9 @@ Shader::~Shader() {
MBGL_CHECK_ERROR(glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binaryLength));
if (binaryLength > 0) {
std::unique_ptr<char[]> binary = mbgl::util::make_unique<char[]>(binaryLength);
- MBGL_CHECK_ERROR(gl::GetProgramBinary(program, binaryLength, NULL, &binaryFormat, binary.get()));
+ MBGL_CHECK_ERROR(gl::GetProgramBinary(program, binaryLength, nullptr, &binaryFormat, binary.get()));
+
+ Log::Error(Event::OpenGL, "glGetProgramBinary(%u, %u, nullptr, %u, %u)", program, binaryLength, binaryFormat, binary.get());
try {
// Write the binary to a file
@@ -219,7 +221,7 @@ Shader::~Shader() {
binaryFile.write(reinterpret_cast<char *>(&binaryFormat), sizeof(binaryFormat));
binaryFile.write(binary.get(), binaryLength);
- } catch(std::exception& e) {
+ } catch(const std::exception& e) {
Log::Error(Event::Shader, "Saving binary shader failed!");
// Delete the bad file
diff --git a/src/mbgl/storage/asset_request.hpp b/src/mbgl/storage/asset_request.hpp
new file mode 100644
index 0000000000..3114d41ad2
--- /dev/null
+++ b/src/mbgl/storage/asset_request.hpp
@@ -0,0 +1,27 @@
+#ifndef MBGL_STORAGE_ASSET_REQUEST
+#define MBGL_STORAGE_ASSET_REQUEST
+
+#include <mbgl/storage/base_request.hpp>
+
+namespace mbgl {
+
+typedef struct uv_loop_s uv_loop_t;
+
+struct AssetRequestBaton;
+
+class AssetRequest : public BaseRequest {
+public:
+ AssetRequest(const std::string &path, uv_loop_t *loop);
+ ~AssetRequest();
+
+ void cancel();
+
+private:
+ AssetRequestBaton *ptr = nullptr;
+
+ friend struct AssetRequestBaton;
+};
+
+}
+
+#endif
diff --git a/src/mbgl/storage/base_request.cpp b/src/mbgl/storage/base_request.cpp
index 5ce206996c..510bd7bf1c 100644
--- a/src/mbgl/storage/base_request.cpp
+++ b/src/mbgl/storage/base_request.cpp
@@ -19,13 +19,13 @@ void invoke(const std::forward_list<std::unique_ptr<Callback>> &list, Args&& ...
}
}
-BaseRequest::BaseRequest(const std::string &path_) : thread_id(std::this_thread::get_id()), path(path_) {
+BaseRequest::BaseRequest(const std::string &path_) : threadId(std::this_thread::get_id()), path(path_) {
}
// A base request can only be "canceled" by destroying the object. In that case, we'll have to
// notify all cancel callbacks.
BaseRequest::~BaseRequest() {
- assert(thread_id == std::this_thread::get_id());
+ assert(std::this_thread::get_id() == threadId);
notify();
}
@@ -34,7 +34,7 @@ void BaseRequest::retryImmediately() {
}
void BaseRequest::notify() {
- assert(thread_id == std::this_thread::get_id());
+ assert(std::this_thread::get_id() == threadId);
// The parameter exists solely so that any calls to ->remove()
// are not going to cause deallocation of this object while this call is in progress.
@@ -55,7 +55,7 @@ void BaseRequest::notify() {
}
Callback *BaseRequest::add(Callback &&callback, const util::ptr<BaseRequest> &request) {
- assert(thread_id == std::this_thread::get_id());
+ assert(std::this_thread::get_id() == threadId);
assert(this == request.get());
if (response) {
@@ -75,7 +75,7 @@ Callback *BaseRequest::add(Callback &&callback, const util::ptr<BaseRequest> &re
}
void BaseRequest::remove(Callback *callback) {
- assert(thread_id == std::this_thread::get_id());
+ assert(std::this_thread::get_id() == threadId);
callbacks.remove_if([=](const std::unique_ptr<Callback> &cb) {
return cb.get() == callback;
});
diff --git a/src/mbgl/storage/base_request.hpp b/src/mbgl/storage/base_request.hpp
index 2913c5eae5..5119c343e9 100644
--- a/src/mbgl/storage/base_request.hpp
+++ b/src/mbgl/storage/base_request.hpp
@@ -46,7 +46,7 @@ public:
virtual void retryImmediately();
public:
- const std::thread::id thread_id;
+ const std::thread::id threadId;
const std::string path;
std::unique_ptr<Response> response;
diff --git a/src/mbgl/storage/caching_http_file_source.cpp b/src/mbgl/storage/caching_http_file_source.cpp
index eed3bdd051..634a56f9c4 100644
--- a/src/mbgl/storage/caching_http_file_source.cpp
+++ b/src/mbgl/storage/caching_http_file_source.cpp
@@ -2,6 +2,7 @@
#include <mbgl/storage/asset_request.hpp>
#include <mbgl/storage/http_request.hpp>
#include <mbgl/storage/sqlite_store.hpp>
+#include <mbgl/storage/asset_request.hpp>
#include <mbgl/util/uv-messenger.h>
#include <mbgl/util/mapbox.hpp>
#include <mbgl/util/std.hpp>
@@ -19,7 +20,7 @@ CachingHTTPFileSource::~CachingHTTPFileSource() {
void CachingHTTPFileSource::setLoop(uv_loop_t* loop_) {
assert(!loop);
- thread_id = std::this_thread::get_id();
+ threadId = std::this_thread::get_id();
store = !path.empty() ? util::ptr<SQLiteStore>(new SQLiteStore(loop_, path)) : nullptr;
loop = loop_;
queue = new uv_messenger_t;
@@ -36,7 +37,7 @@ bool CachingHTTPFileSource::hasLoop() {
}
void CachingHTTPFileSource::clearLoop() {
- assert(thread_id == std::this_thread::get_id());
+ assert(std::this_thread::get_id() == threadId);
assert(loop);
uv_messenger_stop(queue, [](uv_messenger_t *msgr) {
@@ -67,8 +68,12 @@ void CachingHTTPFileSource::setAccessToken(std::string value) {
accessToken.swap(value);
}
+std::string CachingHTTPFileSource::getAccessToken() const {
+ return accessToken;
+}
+
std::unique_ptr<Request> CachingHTTPFileSource::request(ResourceType type, const std::string& url_) {
- assert(thread_id == std::this_thread::get_id());
+ assert(std::this_thread::get_id() == threadId);
std::string url = url_;
@@ -108,7 +113,7 @@ std::unique_ptr<Request> CachingHTTPFileSource::request(ResourceType type, const
}
void CachingHTTPFileSource::prepare(std::function<void()> fn) {
- if (thread_id == std::this_thread::get_id()) {
+ if (std::this_thread::get_id() == threadId) {
fn();
} else {
uv_messenger_send(queue, new std::function<void()>(std::move(fn)));
diff --git a/src/mbgl/storage/http_request.cpp b/src/mbgl/storage/http_request.cpp
index ebb9a84823..57e6c260ef 100644
--- a/src/mbgl/storage/http_request.cpp
+++ b/src/mbgl/storage/http_request.cpp
@@ -1,6 +1,7 @@
#include <mbgl/storage/http_request.hpp>
#include <mbgl/storage/sqlite_store.hpp>
#include <mbgl/storage/http_request_baton.hpp>
+#include <mbgl/platform/log.hpp>
#include <uv.h>
@@ -21,7 +22,7 @@ struct CacheRequestBaton {
};
HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path_, uv_loop_t *loop_, util::ptr<SQLiteStore> store_)
- : BaseRequest(path_), thread_id(std::this_thread::get_id()), loop(loop_), store(store_), type(type_) {
+ : BaseRequest(path_), threadId(std::this_thread::get_id()), loop(loop_), store(store_), type(type_) {
if (store) {
startCacheRequest();
} else {
@@ -30,24 +31,24 @@ HTTPRequest::HTTPRequest(ResourceType type_, const std::string &path_, uv_loop_t
}
void HTTPRequest::startCacheRequest() {
- assert(std::this_thread::get_id() == thread_id);
+ assert(std::this_thread::get_id() == threadId);
- cache_baton = new CacheRequestBaton;
- cache_baton->request = this;
- cache_baton->path = path;
- cache_baton->store = store;
+ cacheBaton = new CacheRequestBaton;
+ cacheBaton->request = this;
+ cacheBaton->path = path;
+ cacheBaton->store = store;
store->get(path, [](std::unique_ptr<Response> &&response_, void *ptr) {
// Wrap in a unique_ptr, so it'll always get auto-destructed.
std::unique_ptr<CacheRequestBaton> baton((CacheRequestBaton *)ptr);
if (baton->request) {
- baton->request->cache_baton = nullptr;
+ baton->request->cacheBaton = nullptr;
baton->request->handleCacheResponse(std::move(response_));
}
- }, cache_baton);
+ }, cacheBaton);
}
void HTTPRequest::handleCacheResponse(std::unique_ptr<Response> &&res) {
- assert(std::this_thread::get_id() == thread_id);
+ assert(std::this_thread::get_id() == threadId);
if (res) {
// This entry was stored in the cache. Now determine if we need to revalidate.
@@ -68,25 +69,25 @@ void HTTPRequest::handleCacheResponse(std::unique_ptr<Response> &&res) {
}
void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) {
- assert(std::this_thread::get_id() == thread_id);
- assert(!http_baton);
+ assert(std::this_thread::get_id() == threadId);
+ assert(!httpBaton);
- http_baton = std::make_shared<HTTPRequestBaton>(path);
- http_baton->request = this;
- http_baton->async = new uv_async_t;
- http_baton->response = std::move(res);
- http_baton->async->data = new util::ptr<HTTPRequestBaton>(http_baton);
+ httpBaton = std::make_shared<HTTPRequestBaton>(path);
+ httpBaton->request = this;
+ httpBaton->async = new uv_async_t;
+ httpBaton->response = std::move(res);
+ httpBaton->async->data = new util::ptr<HTTPRequestBaton>(httpBaton);
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
- uv_async_init(loop, http_baton->async, [](uv_async_t *async, int) {
+ uv_async_init(loop, httpBaton->async, [](uv_async_t *async, int) {
#else
- uv_async_init(loop, http_baton->async, [](uv_async_t *async) {
+ uv_async_init(loop, httpBaton->async, [](uv_async_t *async) {
#endif
util::ptr<HTTPRequestBaton> &baton = *(util::ptr<HTTPRequestBaton> *)async->data;
if (baton->request) {
HTTPRequest *request = baton->request;
- request->http_baton.reset();
+ request->httpBaton.reset();
baton->request = nullptr;
request->handleHTTPResponse(baton->type, std::move(baton->response));
}
@@ -98,14 +99,14 @@ void HTTPRequest::startHTTPRequest(std::unique_ptr<Response> &&res) {
});
});
attempts++;
- HTTPRequestBaton::start(http_baton);
+ HTTPRequestBaton::start(httpBaton);
}
void HTTPRequest::handleHTTPResponse(HTTPResponseType responseType, std::unique_ptr<Response> &&res) {
- assert(std::this_thread::get_id() == thread_id);
- assert(!http_baton);
+ assert(std::this_thread::get_id() == threadId);
+ assert(!httpBaton);
assert(!response);
switch (responseType) {
@@ -192,76 +193,76 @@ void HTTPRequest::handleHTTPResponse(HTTPResponseType responseType, std::unique_
using RetryBaton = std::pair<HTTPRequest *, std::unique_ptr<Response>>;
void HTTPRequest::retryHTTPRequest(std::unique_ptr<Response> &&res, uint64_t timeout) {
- assert(std::this_thread::get_id() == thread_id);
- assert(!backoff_timer);
- backoff_timer = new uv_timer_t();
- uv_timer_init(loop, backoff_timer);
- backoff_timer->data = new RetryBaton(this, std::move(res));
+ assert(std::this_thread::get_id() == threadId);
+ assert(!backoffTimer);
+ backoffTimer = new uv_timer_t();
+ uv_timer_init(loop, backoffTimer);
+ backoffTimer->data = new RetryBaton(this, std::move(res));
#if UV_VERSION_MAJOR == 0 && UV_VERSION_MINOR <= 10
- uv_timer_start(backoff_timer, [](uv_timer_t *timer, int) {
+ uv_timer_start(backoffTimer, [](uv_timer_t *timer, int) {
#else
- uv_timer_start(backoff_timer, [](uv_timer_t *timer) {
+ uv_timer_start(backoffTimer, [](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;
+ pair->first->backoffTimer = nullptr;
uv_timer_stop(timer);
uv_close((uv_handle_t *)timer, [](uv_handle_t *handle) { delete (uv_timer_t *)handle; });
}, timeout, 0);
}
void HTTPRequest::removeHTTPBaton() {
- assert(std::this_thread::get_id() == thread_id);
- if (http_baton) {
- http_baton->request = nullptr;
- HTTPRequestBaton::stop(http_baton);
- http_baton.reset();
+ assert(std::this_thread::get_id() == threadId);
+ if (httpBaton) {
+ httpBaton->request = nullptr;
+ HTTPRequestBaton::stop(httpBaton);
+ httpBaton.reset();
}
}
void HTTPRequest::removeCacheBaton() {
- assert(std::this_thread::get_id() == thread_id);
- if (cache_baton) {
+ assert(std::this_thread::get_id() == threadId);
+ if (cacheBaton) {
// Make sre that this object doesn't accidentally get accessed when it is destructed before
// the callback returned. They are being run in the same thread, so just setting it to
// null is sufficient.
// Note: We don't manually delete the CacheRequestBaton since it'll be deleted by the
// callback.
- cache_baton->request = nullptr;
- cache_baton = nullptr;
+ cacheBaton->request = nullptr;
+ cacheBaton = nullptr;
}
}
void HTTPRequest::removeBackoffTimer() {
- assert(std::this_thread::get_id() == thread_id);
- if (backoff_timer) {
- delete static_cast<RetryBaton *>(backoff_timer->data);
- uv_timer_stop(backoff_timer);
- uv_close((uv_handle_t *)backoff_timer, [](uv_handle_t *handle) { delete (uv_timer_t *)handle; });
- backoff_timer = nullptr;
+ assert(std::this_thread::get_id() == threadId);
+ if (backoffTimer) {
+ delete static_cast<RetryBaton *>(backoffTimer->data);
+ uv_timer_stop(backoffTimer);
+ uv_close((uv_handle_t *)backoffTimer, [](uv_handle_t *handle) { delete (uv_timer_t *)handle; });
+ backoffTimer = nullptr;
}
}
void HTTPRequest::retryImmediately() {
- assert(std::this_thread::get_id() == thread_id);
- if (!cache_baton && !http_baton) {
- if (backoff_timer) {
+ assert(std::this_thread::get_id() == threadId);
+ if (!cacheBaton && !httpBaton) {
+ if (backoffTimer) {
// Retry immediately.
- uv_timer_stop(backoff_timer);
- std::unique_ptr<RetryBaton> pair { static_cast<RetryBaton *>(backoff_timer->data) };
+ uv_timer_stop(backoffTimer);
+ std::unique_ptr<RetryBaton> pair { static_cast<RetryBaton *>(backoffTimer->data) };
assert(pair->first == this);
startHTTPRequest(std::move(pair->second));
- uv_close((uv_handle_t *)backoff_timer, [](uv_handle_t *handle) { delete (uv_timer_t *)handle; });
- backoff_timer = nullptr;
+ uv_close((uv_handle_t *)backoffTimer, [](uv_handle_t *handle) { delete (uv_timer_t *)handle; });
+ backoffTimer = nullptr;
} else {
- assert(!"We should always have a backoff_timer when there are no batons");
+ assert(!"We should always have a backoffTimer when there are no batons");
}
}
}
void HTTPRequest::cancel() {
- assert(std::this_thread::get_id() == thread_id);
+ assert(std::this_thread::get_id() == threadId);
removeCacheBaton();
removeHTTPBaton();
removeBackoffTimer();
@@ -270,7 +271,7 @@ void HTTPRequest::cancel() {
HTTPRequest::~HTTPRequest() {
- assert(std::this_thread::get_id() == thread_id);
+ assert(std::this_thread::get_id() == threadId);
cancel();
}
diff --git a/src/mbgl/storage/http_request.hpp b/src/mbgl/storage/http_request.hpp
index 71d6e8814c..7cc72101d5 100644
--- a/src/mbgl/storage/http_request.hpp
+++ b/src/mbgl/storage/http_request.hpp
@@ -41,11 +41,11 @@ private:
void removeBackoffTimer();
private:
- const std::thread::id thread_id;
+ const std::thread::id threadId;
uv_loop_t *const loop;
- CacheRequestBaton *cache_baton = nullptr;
- util::ptr<HTTPRequestBaton> http_baton;
- uv_timer_t *backoff_timer = nullptr;
+ CacheRequestBaton *cacheBaton = nullptr;
+ util::ptr<HTTPRequestBaton> httpBaton;
+ uv_timer_t *backoffTimer = nullptr;
util::ptr<SQLiteStore> store;
const ResourceType type;
uint8_t attempts = 0;
@@ -55,4 +55,4 @@ private:
}
-#endif \ No newline at end of file
+#endif
diff --git a/src/mbgl/storage/http_request_baton.cpp b/src/mbgl/storage/http_request_baton.cpp
index 315708f4e0..d781a3bdf4 100644
--- a/src/mbgl/storage/http_request_baton.cpp
+++ b/src/mbgl/storage/http_request_baton.cpp
@@ -3,7 +3,7 @@
namespace mbgl {
-HTTPRequestBaton::HTTPRequestBaton(const std::string &path_) : thread_id(std::this_thread::get_id()), path(path_) {
+HTTPRequestBaton::HTTPRequestBaton(const std::string &path_) : threadId(std::this_thread::get_id()), path(path_) {
}
HTTPRequestBaton::~HTTPRequestBaton() {
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index c9b06d7676..ecff6fb5ff 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -8,6 +8,7 @@
#include <mbgl/util/error.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/uv_detail.hpp>
+#include <mbgl/platform/log.hpp>
#include <csscolorparser/csscolorparser.hpp>
#include <rapidjson/document.h>
@@ -69,6 +70,7 @@ void Style::loadJSON(const uint8_t *const data) {
rapidjson::Document doc;
doc.Parse<0>((const char *const)data);
if (doc.HasParseError()) {
+ Log::Error(Event::ParseStyle, "Error parsing style JSON at %i: %s", doc.GetErrorOffset(), doc.GetParseError());
throw error::style_parse(doc.GetErrorOffset(), doc.GetParseError());
}