summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-05-22 15:56:05 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-06-26 10:32:06 -0700
commit84e2ea886dc55917a1d6b665337fff6d3862984a (patch)
tree75d7411f09f48aa8b35be9348bc3687cb4efb1f8 /include
parent740281cc89e99fbbedf07fcf62253ada84f60776 (diff)
downloadqtlocation-mapboxgl-84e2ea886dc55917a1d6b665337fff6d3862984a.tar.gz
drive map rendering from main thread
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/android/native_map_view.hpp3
-rw-r--r--include/mbgl/map/view.hpp8
-rw-r--r--include/mbgl/platform/default/glfw_view.hpp6
-rw-r--r--include/mbgl/platform/default/headless_view.hpp3
4 files changed, 14 insertions, 6 deletions
diff --git a/include/mbgl/android/native_map_view.hpp b/include/mbgl/android/native_map_view.hpp
index fae239e070..8c632fb1fe 100644
--- a/include/mbgl/android/native_map_view.hpp
+++ b/include/mbgl/android/native_map_view.hpp
@@ -23,7 +23,8 @@ public:
void activate() override;
void deactivate() override;
void notify() override;
- void invalidate(std::function<void()> render) override;
+ void invalidate() override;
+ void swap() override;
void notifyMapChange(mbgl::MapChange change, Duration delay = Duration::zero()) override;
diff --git a/include/mbgl/map/view.hpp b/include/mbgl/map/view.hpp
index 41d57bdc91..84ccc89679 100644
--- a/include/mbgl/map/view.hpp
+++ b/include/mbgl/map/view.hpp
@@ -44,9 +44,11 @@ public:
virtual void resize(uint16_t width, uint16_t height, float pixelRatio);
// Called from the render thread. The implementation must trigger a rerender.
- // (i.e. either the passed render() function for rendering immediately on the map thread,
- // or map->renderSync() from the main thread must be called as a result of this)
- virtual void invalidate(std::function<void()> render) = 0;
+ // (map->renderSync() from the main thread must be called as a result of this)
+ virtual void invalidate() = 0;
+
+ // Called from the render thread after the render is complete.
+ virtual void swap() = 0;
// Reads the pixel data from the current framebuffer. If your View implementation
// doesn't support reading from the framebuffer, return a null pointer.
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp
index 9a7e29fe29..6e03953cbd 100644
--- a/include/mbgl/platform/default/glfw_view.hpp
+++ b/include/mbgl/platform/default/glfw_view.hpp
@@ -8,6 +8,8 @@
#endif
#include <GLFW/glfw3.h>
+#include <atomic>
+
class GLFWView : public mbgl::View {
public:
GLFWView(bool fullscreen = false);
@@ -17,7 +19,8 @@ public:
void activate() override;
void deactivate() override;
void notify() override;
- void invalidate(std::function<void()> render) override;
+ void invalidate() override;
+ void swap() override;
static void onKey(GLFWwindow *window, int key, int scancode, int action, int mods);
static void onScroll(GLFWwindow *window, double xoffset, double yoffset);
@@ -62,6 +65,7 @@ private:
std::function<void()> changeStyleCallback;
GLFWwindow *window = nullptr;
+ std::atomic_flag clean = ATOMIC_FLAG_INIT;
};
#endif
diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp
index 66f13cf5bf..61e60ebaff 100644
--- a/include/mbgl/platform/default/headless_view.hpp
+++ b/include/mbgl/platform/default/headless_view.hpp
@@ -33,7 +33,8 @@ public:
void deactivate() override;
void notify() override;
void resize(uint16_t width, uint16_t height, float pixelRatio) override;
- void invalidate(std::function<void()> render) override;
+ void invalidate() override;
+ void swap() override;
std::unique_ptr<StillImage> readStillImage() override;
private: