[core] Ensure that a BackendScope exists when doing GL calls

This commit is contained in:
Konstantin Käfer
2017-02-27 18:33:16 +01:00
committed by John Firebaugh
parent d7227e13a7
commit 8e5214144e
20 changed files with 73 additions and 9 deletions

View File

@@ -8,15 +8,19 @@ namespace mbgl {
static util::ThreadLocal<BackendScope> currentScope;
BackendScope::BackendScope(Backend& backend_)
BackendScope::BackendScope(Backend& backend_, ScopeType scopeType_)
: priorScope(currentScope.get()),
nextScope(nullptr),
backend(backend_) {
backend(backend_),
scopeType(scopeType_) {
if (priorScope) {
assert(priorScope->nextScope == nullptr);
priorScope->nextScope = this;
}
backend.activate();
if (scopeType == ScopeType::Explicit) {
backend.activate();
}
currentScope.set(this);
}
@@ -28,9 +32,16 @@ BackendScope::~BackendScope() {
assert(priorScope->nextScope == this);
priorScope->nextScope = nullptr;
} else {
backend.deactivate();
if (scopeType == ScopeType::Explicit) {
backend.deactivate();
}
currentScope.set(nullptr);
}
}
bool BackendScope::exists() {
return currentScope.get();
}
} // namespace mbgl