Commit 7aaa88f8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wineandroid: Use pthread for locking in opengl.c.

parent 47847a20
EXTRADEFS = -DWINE_NO_LONG_TYPES
MODULE = wineandroid.drv
IMPORTS = user32 ntoskrnl win32u
MODULE = wineandroid.drv
IMPORTS = user32 ntoskrnl win32u
EXTRALIBS = $(PTHREAD_LIBS)
EXTRADLLFLAGS = -mcygwin
......
......@@ -24,6 +24,7 @@
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <pthread.h>
#include <jni.h>
#include <android/log.h>
#include <android/input.h>
......@@ -51,6 +52,7 @@ DECL_FUNCPTR( ANativeWindow_release );
* OpenGL driver
*/
extern pthread_mutex_t drawable_mutex DECLSPEC_HIDDEN;
extern void update_gl_drawable( HWND hwnd ) DECLSPEC_HIDDEN;
extern void destroy_gl_drawable( HWND hwnd ) DECLSPEC_HIDDEN;
extern struct opengl_funcs *get_wgl_driver( UINT version ) DECLSPEC_HIDDEN;
......
......@@ -558,6 +558,7 @@ unsigned short *p_java_gdt_sel = NULL;
static BOOL process_attach(void)
{
pthread_mutexattr_t attr;
jclass class;
jobject object;
JNIEnv *jni_env;
......@@ -574,6 +575,11 @@ static BOOL process_attach(void)
load_hardware_libs();
pthread_mutexattr_init( &attr );
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( &drawable_mutex, &attr );
pthread_mutexattr_destroy( &attr );
if ((java_vm = *p_java_vm)) /* running under Java */
{
#ifdef __i386__
......
......@@ -105,14 +105,7 @@ static struct list gl_drawables = LIST_INIT( gl_drawables );
static void (*pglFinish)(void);
static void (*pglFlush)(void);
static CRITICAL_SECTION drawable_section;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &drawable_section,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": drawable_section") }
};
static CRITICAL_SECTION drawable_section = { &critsect_debug, -1, 0, 0, 0, 0 };
pthread_mutex_t drawable_mutex;
static inline BOOL is_onscreen_pixel_format( int format )
{
......@@ -130,7 +123,7 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, HDC hdc, int format )
gl->window = create_ioctl_window( hwnd, TRUE, 1.0f );
gl->surface = 0;
gl->pbuffer = p_eglCreatePbufferSurface( display, pixel_formats[gl->format - 1].config, attribs );
EnterCriticalSection( &drawable_section );
pthread_mutex_lock( &drawable_mutex );
list_add_head( &gl_drawables, &gl->entry );
return gl;
}
......@@ -139,26 +132,26 @@ static struct gl_drawable *get_gl_drawable( HWND hwnd, HDC hdc )
{
struct gl_drawable *gl;
EnterCriticalSection( &drawable_section );
pthread_mutex_lock( &drawable_mutex );
LIST_FOR_EACH_ENTRY( gl, &gl_drawables, struct gl_drawable, entry )
{
if (hwnd && gl->hwnd == hwnd) return gl;
if (hdc && gl->hdc == hdc) return gl;
}
LeaveCriticalSection( &drawable_section );
pthread_mutex_unlock( &drawable_mutex );
return NULL;
}
static void release_gl_drawable( struct gl_drawable *gl )
{
if (gl) LeaveCriticalSection( &drawable_section );
if (gl) pthread_mutex_unlock( &drawable_mutex );
}
void destroy_gl_drawable( HWND hwnd )
{
struct gl_drawable *gl;
EnterCriticalSection( &drawable_section );
pthread_mutex_lock( &drawable_mutex );
LIST_FOR_EACH_ENTRY( gl, &gl_drawables, struct gl_drawable, entry )
{
if (gl->hwnd != hwnd) continue;
......@@ -169,7 +162,7 @@ void destroy_gl_drawable( HWND hwnd )
HeapFree( GetProcessHeap(), 0, gl );
break;
}
LeaveCriticalSection( &drawable_section );
pthread_mutex_unlock( &drawable_mutex );
}
static BOOL refresh_context( struct wgl_context *ctx )
......@@ -439,9 +432,9 @@ static struct wgl_context * WINAPI android_wglCreateContext( HDC hdc )
*/
static BOOL WINAPI android_wglDeleteContext( struct wgl_context *ctx )
{
EnterCriticalSection( &drawable_section );
pthread_mutex_lock( &drawable_mutex );
list_remove( &ctx->entry );
LeaveCriticalSection( &drawable_section );
pthread_mutex_unlock( &drawable_mutex );
p_eglDestroyContext( display, ctx->context );
return HeapFree( GetProcessHeap(), 0, ctx );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment