diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-05-22 15:56:05 +0200 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-06-26 10:32:06 -0700 |
commit | 84e2ea886dc55917a1d6b665337fff6d3862984a (patch) | |
tree | 75d7411f09f48aa8b35be9348bc3687cb4efb1f8 /platform | |
parent | 740281cc89e99fbbedf07fcf62253ada84f60776 (diff) | |
download | qtlocation-mapboxgl-84e2ea886dc55917a1d6b665337fff6d3862984a.tar.gz |
drive map rendering from main thread
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/glfw_view.cpp | 12 | ||||
-rw-r--r-- | platform/default/headless_view.cpp | 8 | ||||
-rw-r--r-- | platform/ios/MGLMapView.mm | 7 |
3 files changed, 22 insertions, 5 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 61d553ae3d..756b842695 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -282,6 +282,10 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { void GLFWView::run() { while (!glfwWindowShouldClose(window)) { glfwWaitEvents(); + const bool dirty = !clean.test_and_set(); + if (dirty) { + map->renderSync(); + } } } @@ -297,8 +301,12 @@ void GLFWView::notify() { glfwPostEmptyEvent(); } -void GLFWView::invalidate(std::function<void()> render) { - render(); +void GLFWView::invalidate() { + clean.clear(); + glfwPostEmptyEvent(); +} + +void GLFWView::swap() { glfwSwapBuffers(window); fps(); } diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 0f00c7563d..f4411bb2ee 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -280,8 +280,12 @@ void HeadlessView::deactivate() { #endif } -void HeadlessView::invalidate(std::function<void()> render) { - render(); +void HeadlessView::invalidate() { + // no-op +} + +void HeadlessView::swap() { + // no-op } } diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 50f5a1f867..e70f6c7c60 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -2755,13 +2755,18 @@ class MBGLView : public mbgl::View [EAGLContext setCurrentContext:nil]; } - void invalidate(std::function<void()>) override + void invalidate() override { [nativeView performSelectorOnMainThread:@selector(invalidate) withObject:nil waitUntilDone:NO]; } + void swap() override + { + // no-op + } + private: __weak MGLMapView *nativeView = nullptr; }; |