summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2016-12-06 17:24:32 +0100
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2016-12-12 09:05:23 -0500
commitc76a933514e4e1514a58ac0e668b13eebab37794 (patch)
treec369563359007d730f427e04d9fd4945f3f97fbc /platform
parentffd74c309e0b44bdf3ff09c6c1dc715ad97f64cd (diff)
downloadqtlocation-mapboxgl-c76a933514e4e1514a58ac0e668b13eebab37794.tar.gz
[core] use raii to guard backend deactivation
Diffstat (limited to 'platform')
-rwxr-xr-xplatform/android/src/native_map_view.cpp8
-rwxr-xr-xplatform/android/src/native_map_view.hpp6
2 files changed, 6 insertions, 8 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 83f351b7b3..8234b74af2 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -175,7 +175,7 @@ void NativeMapView::invalidate() {
}
void NativeMapView::render() {
- activate();
+ BackendScope guard(*this);
if (framebufferSizeChanged) {
getContext().viewport = { 0, 0, getFramebufferSize() };
@@ -214,8 +214,6 @@ void NativeMapView::render() {
} else {
mbgl::Log::Info(mbgl::Event::Android, "Not swapping as we are not ready");
}
-
- deactivate();
}
mbgl::Map &NativeMapView::getMap() { return *map; }
@@ -410,7 +408,7 @@ void NativeMapView::createSurface(ANativeWindow *window_) {
if (!firstTime) {
firstTime = true;
- activate();
+ BackendScope guard(*this);
if (!eglMakeCurrent(display, surface, surface, context)) {
mbgl::Log::Error(mbgl::Event::OpenGL, "eglMakeCurrent() returned error %d",
@@ -421,8 +419,6 @@ void NativeMapView::createSurface(ANativeWindow *window_) {
mbgl::gl::InitializeExtensions([] (const char * name) {
return reinterpret_cast<mbgl::gl::glProc>(eglGetProcAddress(name));
});
-
- deactivate();
}
}
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 35c0307539..e7379700a9 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -24,8 +24,6 @@ public:
void updateViewBinding();
void bind() override;
- void activate() override;
- void deactivate() override;
void invalidate() override;
void notifyMapChange(mbgl::MapChange) override;
@@ -54,6 +52,10 @@ public:
void scheduleTakeSnapshot();
+protected:
+ void activate() override;
+ void deactivate() override;
+
private:
EGLConfig chooseConfig(const EGLConfig configs[], EGLint numConfigs);