summaryrefslogtreecommitdiff
path: root/include/mbgl/map/backend_scope.hpp
blob: 4985cd197fc86f953d3e77f8ad4d4263e857efd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once

namespace mbgl {

class Backend;

class BackendScope {
public:
    // There are two types of scopes: Creating an "Implicit" scope tells Mapbox GL that the
    // supporting windowing system has already activated the GL Backend and that no further actions
    // are required. Creating an "Explicit" scope actually enables the GL Backend, and disables it
    // when the BackendScope is destroyed.
    enum class ScopeType : bool {
        Implicit,
        Explicit,
    };

    BackendScope(Backend&, ScopeType = ScopeType::Explicit);
    ~BackendScope();

    // Returns true when there is currently a BackendScope active in this thread.
    static bool exists();

private:
    BackendScope* priorScope;
    BackendScope* nextScope;
    Backend& backend;
    const ScopeType scopeType;
};

} // namespace mbgl