diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-07-13 15:35:02 +0300 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-07-18 10:45:12 +0200 |
commit | 9ebf727f56819f259a7a0771b1ed58b14c3adea3 (patch) | |
tree | 0fa580307dda6cbc63674c5b8b351455fe94a318 /include | |
parent | a5a0558bde5d67617b6f305179063cd4e0ac329e (diff) | |
download | qtlocation-mapboxgl-9ebf727f56819f259a7a0771b1ed58b14c3adea3.tar.gz |
[core] BackendScope prevent double (de-)activation
- Guards against duplicate activations by checking wether the backend of the prior scope is the same as the current ones
- Makes sure that only the most outer backend scope deactivates by tracking activation state
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/renderer/backend_scope.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/renderer/renderer_backend.hpp | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/mbgl/renderer/backend_scope.hpp b/include/mbgl/renderer/backend_scope.hpp index f8a258f3df..73bafc84c7 100644 --- a/include/mbgl/renderer/backend_scope.hpp +++ b/include/mbgl/renderer/backend_scope.hpp @@ -22,10 +22,14 @@ public: static bool exists(); private: + void activate(); + void deactivate(); + BackendScope* priorScope; BackendScope* nextScope; RendererBackend& backend; const ScopeType scopeType; + bool activated = false; }; } // namespace mbgl diff --git a/include/mbgl/renderer/renderer_backend.hpp b/include/mbgl/renderer/renderer_backend.hpp index 9d967fd51b..a383329395 100644 --- a/include/mbgl/renderer/renderer_backend.hpp +++ b/include/mbgl/renderer/renderer_backend.hpp @@ -4,6 +4,7 @@ #include <mbgl/renderer/backend_scope.hpp> #include <mbgl/util/image.hpp> #include <mbgl/util/size.hpp> +#include <mbgl/util/util.hpp> #include <memory> #include <mutex> @@ -81,4 +82,8 @@ private: friend class BackendScope; }; +MBGL_CONSTEXPR bool operator==(const RendererBackend& a, const RendererBackend& b) { + return &a == &b; +} + } // namespace mbgl |