1 #pragma once 2 3 namespace mbgl { 4 5 class RendererBackend; 6 7 class BackendScope { 8 public: 9 // There are two types of scopes: Creating an "Implicit" scope tells Mapbox GL that the 10 // supporting windowing system has already activated the GL Backend and that no further actions 11 // are required. Creating an "Explicit" scope actually enables the GL Backend, and disables it 12 // when the BackendScope is destroyed. 13 enum class ScopeType : bool { 14 Implicit, 15 Explicit, 16 }; 17 18 BackendScope(RendererBackend&, ScopeType = ScopeType::Explicit); 19 ~BackendScope(); 20 21 // Returns true when there is currently a BackendScope active in this thread. 22 static bool exists(); 23 24 private: 25 void activate(); 26 void deactivate(); 27 28 BackendScope* priorScope; 29 BackendScope* nextScope; 30 RendererBackend& backend; 31 const ScopeType scopeType; 32 bool activated = false; 33 }; 34 35 } // namespace mbgl 36