summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-02-13 16:11:42 -0800
committerKonstantin Käfer <mail@kkaefer.com>2015-03-06 15:42:34 +0100
commite8389d82cdd84d470deb072d82ee9a613cd15df8 (patch)
tree211e461c0956147cf9fcf04e829dca719219c017 /android
parentc30bb1a9f80a7a772578d8742e122c013a56202d (diff)
downloadqtlocation-mapboxgl-e8389d82cdd84d470deb072d82ee9a613cd15df8.tar.gz
guard against concurrent OpenGL extension loading
Diffstat (limited to 'android')
-rw-r--r--android/cpp/native_map_view.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/android/cpp/native_map_view.cpp b/android/cpp/native_map_view.cpp
index 599f245989..35bb6b88a9 100644
--- a/android/cpp/native_map_view.cpp
+++ b/android/cpp/native_map_view.cpp
@@ -16,6 +16,9 @@
#include <mbgl/platform/gl.hpp>
#include <mbgl/util/std.hpp>
+
+pthread_once_t loadGLExtensions = PTHREAD_ONCE_INIT;
+
namespace mbgl {
namespace android {
@@ -296,6 +299,8 @@ void NativeMapView::terminateContext() {
context = EGL_NO_CONTEXT;
}
+void loadExtensions();
+
void NativeMapView::createSurface(ANativeWindow *window_) {
mbgl::Log::Debug(mbgl::Event::Android, "NativeMapView::createSurface");
@@ -337,7 +342,7 @@ void NativeMapView::createSurface(ANativeWindow *window_) {
}
log_gl_string(GL_EXTENSIONS, "Extensions");
- loadExtensions();
+ pthread_once(&loadGLExtensions, loadExtensions);
if (!eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
mbgl::Log::Error(mbgl::Event::OpenGL,
@@ -553,7 +558,6 @@ EGLConfig NativeMapView::chooseConfig(const EGLConfig configs[], EGLint numConfi
// Sort the configs to find the best one
configList.sort();
- usingDepth24 = std::get<1>(configList.front()) == Format24Depth8Stencil;
bool isConformant = !std::get<2>(configList.front());
bool isCaveat = std::get<3>(configList.front());
int configNum = std::get<4>(configList.front());
@@ -588,7 +592,7 @@ void NativeMapView::start() {
map.start(true);
}
-void NativeMapView::loadExtensions() {
+void loadExtensions() {
const GLubyte *str = glGetString(GL_EXTENSIONS);
if (str == nullptr) {
mbgl::Log::Error(mbgl::Event::OpenGL, "glGetString(GL_EXTENSIONS) returned error %d",
@@ -620,12 +624,7 @@ void NativeMapView::loadExtensions() {
}
if (extensions.find("GL_OES_depth24") != std::string::npos) {
- mbgl::Log::Info(mbgl::Event::OpenGL, "Using GL_OES_depth24.");
- if (usingDepth24) {
- gl::isDepth24Supported = true;
- } else {
- mbgl::Log::Info(mbgl::Event::OpenGL, "Preferring 16 bit depth.");
- }
+ gl::isDepth24Supported = true;
}
if (extensions.find("GL_KHR_debug") != std::string::npos) {