summaryrefslogtreecommitdiff
path: root/include/mbgl/map/map.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-03-11 19:43:13 +0100
committerKonstantin Käfer <mail@kkaefer.com>2015-03-12 12:16:38 +0100
commit47ede853c4c0dd8e953f3ee98b807f044d178d76 (patch)
tree75d56f01853cb64b200d8977069dfe992266e9de /include/mbgl/map/map.hpp
parentba9d2420699507c6d32b12272151529663c8d2fd (diff)
downloadqtlocation-mapboxgl-47ede853c4c0dd8e953f3ee98b807f044d178d76.tar.gz
fixes black flicker on rotating the device
fixes #838 instead of rendering ad libitum on the map thread, we are now driving rendering from the UI thread on iOS via the map.renderSync() function. There are still white bars during the rotation, but the general content of the view is kept visible. - upgrades GLFW to 3.1 - removes swapped/needsSwap in favor of a more explicit scheme - View#invalidate() now replaces View#swap() and is called whenever the View needs to trigger a rerender. GLFW and Android to this right away, while iOS goes back to the main thread and does the Map redrawing as part of the GLKView update - sets all iOS deployment targets to 7.0 - disables SQLite3 version check, since the library version changed on iOS 8.2
Diffstat (limited to 'include/mbgl/map/map.hpp')
-rw-r--r--include/mbgl/map/map.hpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 00719aa382..44a560a468 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -65,19 +65,22 @@ public:
// frame is completely rendered.
void run();
- // Triggers a lazy rerender: only performs a render when the map is not clean.
- void rerender();
+ // Triggers a synchronous or asynchronous render.
+ void renderSync();
- // Forces a map update: always triggers a rerender.
- void update();
+ // Unconditionally performs a render with the current map state. May only be called from the Map
+ // thread.
+ void render();
+
+ // Notifies the Map thread that the state has changed and an update might be necessary.
+ void triggerUpdate();
+
+ // Triggers a render. Can be called from any thread.
+ void triggerRender();
// Releases resources immediately
void terminate();
- // Controls buffer swapping.
- bool needsSwap();
- void swapped();
-
// Styling
void addClass(const std::string&);
void removeClass(const std::string&);
@@ -167,9 +170,6 @@ private:
// the stylesheet.
void prepare();
- // Unconditionally performs a render with the current map state.
- void render();
-
enum class Mode : uint8_t {
None, // we're not doing any processing
Continuous, // continually updating map
@@ -185,6 +185,7 @@ private:
std::unique_ptr<uv::worker> workers;
std::thread thread;
std::unique_ptr<uv::async> asyncTerminate;
+ std::unique_ptr<uv::async> asyncUpdate;
std::unique_ptr<uv::async> asyncRender;
bool terminating = false;
@@ -195,17 +196,10 @@ private:
std::mutex mutexPause;
std::condition_variable condPause;
- // If cleared, the next time the render thread attempts to render the map, it will *actually*
- // render the map.
- std::atomic_flag isClean = ATOMIC_FLAG_INIT;
-
- // If this flag is cleared, the current back buffer is ready for being swapped with the front
- // buffer (i.e. it has rendered data).
- std::atomic_flag isSwapped = ATOMIC_FLAG_INIT;
-
- // This is cleared once the current front buffer has been presented and the back buffer is
- // ready for rendering.
- std::atomic_flag isRendered = ATOMIC_FLAG_INIT;
+ // Used to signal that rendering completed.
+ bool rendered = false;
+ std::condition_variable condRendered;
+ std::mutex mutexRendered;
// Stores whether the map thread has been stopped already.
std::atomic_bool isStopped;