[core] fix backend scope handling on render, cleanup and lowmemory

- Make renderer frontend responsible for creating a BackendScope on render
- encapsulate backend scope handling on cleanup and low memory in renderer impl
This commit is contained in:
Ivo van Dongen
2017-07-25 10:44:19 +03:00
committed by Ivo van Dongen
parent 906fc0421a
commit 27343c6a75
2 changed files with 4 additions and 8 deletions

View File

@@ -30,10 +30,6 @@ public:
// Called prior to rendering to update the internally assumed OpenGL state.
virtual void updateAssumedState() = 0;
virtual BackendScope::ScopeType getScopeType() const {
return BackendScope::ScopeType::Explicit;
}
protected:
// Called with the name of an OpenGL extension that should be loaded. RendererBackend implementations
// must call the API-specific version that obtains the function pointer for this function,

View File

@@ -35,7 +35,7 @@ Renderer::Impl::Impl(RendererBackend& backend_,
}
Renderer::Impl::~Impl() {
BackendScope guard { backend, backend.getScopeType()};
BackendScope guard { backend };
renderStyle.reset();
staticData.reset();
};
@@ -47,8 +47,8 @@ void Renderer::Impl::setObserver(RendererObserver* observer_) {
void Renderer::Impl::render(View& view, const UpdateParameters& updateParameters) {
// Don't load/render anyting in still mode until explicitly requested.
if (updateParameters.mode == MapMode::Still && !updateParameters.stillImageRequest) return;
BackendScope guard { backend, backend.getScopeType() };
assert(BackendScope::exists());
renderStyle->update(updateParameters);
transformState = updateParameters.transformState;
@@ -348,7 +348,7 @@ void Renderer::Impl::onResourceError(std::exception_ptr ptr) {
}
void Renderer::Impl::onLowMemory() {
BackendScope guard { backend, backend.getScopeType() };
BackendScope guard { backend };
backend.getContext().performCleanup();
renderStyle->onLowMemory();
observer->onInvalidate();