this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CGS and CGEvent progress

+15 -28
+15 -28
src/frameworks/OpenGL/OpenGL.c
··· 6 6 #include <OpenGL/OpenGL.h> 7 7 #include <OpenGL/CGLInternal.h> 8 8 #include <CoreFoundation/CFDictionary.h> 9 + #include <pthread.h> 9 10 10 11 // Try to get the right (generic) type definitions. 11 12 // In particular, we really want EGLNativeDisplayType to be void *, ··· 41 42 }; 42 43 43 44 static CFMutableDictionaryRef g_displays; 45 + static pthread_mutex_t g_displaysMutex = PTHREAD_MUTEX_INITIALIZER; 44 46 45 47 struct _CGLContextObj { 46 48 GLuint retain_count; ··· 107 109 108 110 static struct _CGLDisplay* getCGLDisplay(CGSConnectionID cid) 109 111 { 110 - struct _CGLDisplay* rv = (struct _CGLDisplay*) CFDictionaryGetValue(g_displays, (const void*)(unsigned long) cid); 112 + struct _CGLDisplay* rv; 113 + 114 + pthread_mutex_lock(&g_displaysMutex); 115 + rv = (struct _CGLDisplay*) CFDictionaryGetValue(g_displays, (const void*)(unsigned long) cid); 116 + pthread_mutex_unlock(&g_displaysMutex); 111 117 112 118 if (!rv) 113 119 { ··· 123 129 124 130 eglBindAPI(EGL_OPENGL_API); 125 131 132 + pthread_mutex_lock(&g_displaysMutex); 126 133 CFDictionaryAddValue(g_displays, (const void*)(unsigned long) cid, rv); 134 + pthread_mutex_unlock(&g_displaysMutex); 127 135 } 128 136 129 137 return rv; ··· 135 143 if (!disp) 136 144 return kCGLBadConnection; 137 145 138 - EGLNativeWindowType window = (EGLNativeWindowType) _CGSNativeWindowForSurfaceID(cid, wid, sid); 146 + EGLNativeWindowType window; 147 + if (sid) 148 + window = (EGLNativeWindowType) _CGSNativeWindowForSurfaceID(cid, wid, sid); 149 + else 150 + window = (EGLNativeWindowType) _CGSNativeWindowForID(cid, wid); 151 + 139 152 if (!window) 140 153 return kCGLBadWindow; 141 154 ··· 143 156 if (gl->egl_surface == EGL_NO_SURFACE) 144 157 return kCGLBadState; 145 158 return kCGLNoError; 146 - } 147 - 148 - CGLContextObj CGWindowContextCreate(CGSConnectionID cid, CGSWindowID wid, CFDictionaryRef options) 149 - { 150 - struct _CGLDisplay* disp = getCGLDisplay(cid); 151 - if (!disp) 152 - return NULL; 153 - 154 - EGLNativeWindowType window = (EGLNativeWindowType) _CGSNativeWindowForID(cid, wid); 155 - if (!window) 156 - return NULL; 157 - 158 - CGLContextObj context; 159 - CGLError err = CGLCreateContext(NULL, NULL, &context); 160 - 161 - if (err != kCGLNoError) 162 - return NULL; 163 - 164 - context->egl_surface = eglCreateWindowSurface(disp->display, disp->config, window, NULL); 165 - if (context->egl_surface == EGL_NO_SURFACE) 166 - { 167 - CGLReleaseContext(context); 168 - return NULL; 169 - } 170 - 171 - return context; 172 159 } 173 160 174 161 CGLWindowRef CGLGetWindow(void *native_window) {