diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-05-12 16:11:15 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-05-13 19:01:58 -0700 |
commit | 7d4f12434e393558344d053dc5809ce586d3fbbd (patch) | |
tree | 9a1f55c52fedbb2a5a8c76bbab44f920d7915918 /platform/default | |
parent | a2344c36c372445ee230832a0b742ac5ee739eb1 (diff) | |
download | qtlocation-mapboxgl-7d4f12434e393558344d053dc5809ce586d3fbbd.tar.gz |
Ensure call-once semantics inside InitializeExtensions
Diffstat (limited to 'platform/default')
-rw-r--r-- | platform/default/glfw_view.cpp | 7 | ||||
-rw-r--r-- | platform/default/headless_view.cpp | 30 |
2 files changed, 14 insertions, 23 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index ed499d374b..8265bb8bb6 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -4,9 +4,6 @@ #include <mbgl/util/gl_helper.hpp> #include <cassert> -#include <pthread.h> - -pthread_once_t loadGLExtensions = PTHREAD_ONCE_INIT; void glfwError(int error, const char *description) { mbgl::Log::Error(mbgl::Event::OpenGL, "GLFW error (%i): %s", error, description); @@ -61,9 +58,7 @@ GLFWView::GLFWView(bool fullscreen_) : fullscreen(fullscreen_) { glfwSetScrollCallback(window, onScroll); glfwSetKeyCallback(window, onKey); - pthread_once(&loadGLExtensions, [] { - mbgl::gl::InitializeExtensions(glfwGetProcAddress); - }); + mbgl::gl::InitializeExtensions(glfwGetProcAddress); glfwMakeContextCurrent(nullptr); } diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 357c6fac70..aa07706d84 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -13,8 +13,6 @@ #include <cstring> #include <cassert> -pthread_once_t loadGLExtensions = PTHREAD_ONCE_INIT; - #ifdef MBGL_USE_CGL #include <CoreFoundation/CoreFoundation.h> #elif MBGL_USE_GLX @@ -45,28 +43,26 @@ void HeadlessView::loadExtensions() { return; } - pthread_once(&loadGLExtensions, [] { #ifdef MBGL_USE_CGL - gl::InitializeExtensions([](const char * name) { - static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); - if (!framework) { - throw std::runtime_error("Failed to load OpenGL framework."); - } + gl::InitializeExtensions([](const char * name) { + static CFBundleRef framework = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl")); + if (!framework) { + throw std::runtime_error("Failed to load OpenGL framework."); + } - CFStringRef str = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII); - void* symbol = CFBundleGetFunctionPointerForName(framework, str); - CFRelease(str); + CFStringRef str = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingASCII); + void* symbol = CFBundleGetFunctionPointerForName(framework, str); + CFRelease(str); - return reinterpret_cast<gl::glProc>(symbol); - }); + return reinterpret_cast<gl::glProc>(symbol); + }); #endif #ifdef MBGL_USE_GLX - gl::InitializeExtensions([](const char * name) { - return glXGetProcAddress(reinterpret_cast<const GLubyte *>(name)); - }); -#endif + gl::InitializeExtensions([](const char * name) { + return glXGetProcAddress(reinterpret_cast<const GLubyte *>(name)); }); +#endif extensionsLoaded = true; } |