From 2c40e299873f37f04e10fabd51d25f15f23b8f56 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 25 Sep 2002 00:29:56 +0000 Subject: [PATCH] Import wine_tsx11_lock/unlock directly from x11drv in opengl32 and ddraw, so that they don't need to link with libwine_tsx11. Removed header wine_gl.h. --- dlls/ddraw/Makefile.in | 2 +- dlls/ddraw/main.c | 13 +++++++ dlls/ddraw/mesa_private.h | 31 +++++++++++++++- dlls/opengl32/Makefile.in | 2 +- dlls/opengl32/make_opengl | 6 ++-- dlls/opengl32/opengl_ext.c | 4 +-- dlls/opengl32/opengl_ext.h | 31 ++++++++++++++++ dlls/opengl32/opengl_norm.c | 2 +- dlls/opengl32/wgl.c | 10 ++++-- dlls/x11drv/x11drv.spec | 4 +++ dlls/x11drv/x11drv_main.c | 52 +++++++-------------------- graphics/x11drv/opengl.c | 70 +++++++++++++++++++++++++++++++------ include/wine_gl.h | 60 ------------------------------- include/x11drv.h | 1 + 14 files changed, 165 insertions(+), 123 deletions(-) delete mode 100644 include/wine_gl.h diff --git a/dlls/ddraw/Makefile.in b/dlls/ddraw/Makefile.in index 3370155fdb3..9e022d46efb 100644 --- a/dlls/ddraw/Makefile.in +++ b/dlls/ddraw/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = ddraw.dll IMPORTS = user32 gdi32 kernel32 -EXTRALIBS = $(LIBUUID) $(LIBTSX11) $(X_LIBS) $(XLIB) +EXTRALIBS = $(LIBUUID) $(X_LIBS) $(XLIB) LDDLLFLAGS = @LDDLLFLAGS@ SYMBOLFILE = $(MODULE).tmp.o diff --git a/dlls/ddraw/main.c b/dlls/ddraw/main.c index d3f1a5ab867..fbb4260ba28 100644 --- a/dlls/ddraw/main.c +++ b/dlls/ddraw/main.c @@ -43,6 +43,9 @@ static const ddraw_driver* DDRAW_drivers[MAX_DDRAW_DRIVERS]; static int DDRAW_num_drivers; /* = 0 */ static int DDRAW_default_driver; +void (*wine_tsx11_lock_ptr)(void) = NULL; +void (*wine_tsx11_unlock_ptr)(void) = NULL; + WINE_DEFAULT_DEBUG_CHANNEL(ddraw); /**********************************************************************/ @@ -503,6 +506,16 @@ BOOL WINAPI DDRAW_DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) DDRAW_HAL_Init(hInstDLL, fdwReason, lpv); DDRAW_User_Init(hInstDLL, fdwReason, lpv); + if (fdwReason == DLL_PROCESS_ATTACH) + { + HMODULE mod = GetModuleHandleA( "x11drv.dll" ); + if (mod) + { + wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); + wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); + } + } + if (DDRAW_num_drivers > 0) DDRAW_default_driver = DDRAW_ChooseDefaultDriver(); diff --git a/dlls/ddraw/mesa_private.h b/dlls/ddraw/mesa_private.h index 1120d62de8a..daad8f307be 100644 --- a/dlls/ddraw/mesa_private.h +++ b/dlls/ddraw/mesa_private.h @@ -24,7 +24,36 @@ #include "d3d_private.h" -#include "wine_gl.h" +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */ +#include +#include +#ifdef HAVE_GL_GLEXT_H +# include +#endif +#undef XMD_H + +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +/* Redefines the constants */ +#define CALLBACK __stdcall +#define WINAPI __stdcall +#define APIENTRY WINAPI + +/* X11 locking */ + +extern void (*wine_tsx11_lock_ptr)(void); +extern void (*wine_tsx11_unlock_ptr)(void); + +/* As GLX relies on X, this is needed */ +#define ENTER_GL() wine_tsx11_lock_ptr() +#define LEAVE_GL() wine_tsx11_unlock_ptr() + /***************************************************************************** * IDirect3DLight MESA private structure diff --git a/dlls/opengl32/Makefile.in b/dlls/opengl32/Makefile.in index f280b08e478..9cc0b4a9af9 100644 --- a/dlls/opengl32/Makefile.in +++ b/dlls/opengl32/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = opengl32.dll IMPORTS = user32 gdi32 kernel32 -EXTRALIBS = $(LIBTSX11) $(X_LIBS) $(XLIB) +EXTRALIBS = $(X_LIBS) $(XLIB) LDDLLFLAGS = @LDDLLFLAGS@ SYMBOLFILE = $(MODULE).tmp.o diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index 268c5878d01..990e9c0c49d 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -544,7 +544,7 @@ print NORM " /* Auto-generated file... Do not edit ! */ #include \"config.h\" -#include \"wine_gl.h\" +#include \"opengl_ext.h\" #include \"wine/debug.h\" typedef const GLubyte * GLstring; @@ -567,13 +567,11 @@ print EXT " /* Auto-generated file... Do not edit ! */ #include \"config.h\" -#include \"wine_gl.h\" +#include \"opengl_ext.h\" #include \"wine/debug.h\" typedef const GLubyte * GLstring; -#include \"opengl_ext.h\" - WINE_DEFAULT_DEBUG_CHANNEL(opengl); "; diff --git a/dlls/opengl32/opengl_ext.c b/dlls/opengl32/opengl_ext.c index 30ec036315d..8720e89b5ae 100644 --- a/dlls/opengl32/opengl_ext.c +++ b/dlls/opengl32/opengl_ext.c @@ -2,13 +2,11 @@ /* Auto-generated file... Do not edit ! */ #include "config.h" -#include "wine_gl.h" +#include "opengl_ext.h" #include "wine/debug.h" typedef const GLubyte * GLstring; -#include "opengl_ext.h" - WINE_DEFAULT_DEBUG_CHANNEL(opengl); void (*func_glActiveTexture)( GLenum ) = (void *) 0xdeadbeef; diff --git a/dlls/opengl32/opengl_ext.h b/dlls/opengl32/opengl_ext.h index e0f3d4d4e9d..32e81a24adc 100644 --- a/dlls/opengl32/opengl_ext.h +++ b/dlls/opengl32/opengl_ext.h @@ -19,6 +19,37 @@ #ifndef __DLLS_OPENGL32_OPENGL_EXT_H #define __DLLS_OPENGL32_OPENGL_EXT_H +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */ +#include +#include +#ifdef HAVE_GL_GLEXT_H +# include +#endif +#undef XMD_H + +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +/* Redefines the constants */ +#define CALLBACK __stdcall +#define WINAPI __stdcall +#define APIENTRY WINAPI + +/* X11 locking */ + +extern void (*wine_tsx11_lock_ptr)(void); +extern void (*wine_tsx11_unlock_ptr)(void); + +/* As GLX relies on X, this is needed */ +#define ENTER_GL() wine_tsx11_lock_ptr() +#define LEAVE_GL() wine_tsx11_unlock_ptr() + + typedef struct { char *name; /* name of the extension */ char *glx_name; /* name used on Unix's libGL */ diff --git a/dlls/opengl32/opengl_norm.c b/dlls/opengl32/opengl_norm.c index 92e9cadb881..62dda47ed9f 100644 --- a/dlls/opengl32/opengl_norm.c +++ b/dlls/opengl32/opengl_norm.c @@ -2,7 +2,7 @@ /* Auto-generated file... Do not edit ! */ #include "config.h" -#include "wine_gl.h" +#include "opengl_ext.h" #include "wine/debug.h" typedef const GLubyte * GLstring; diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 94efd66d2d4..c092d6cb7fe 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -26,7 +26,6 @@ #include "winbase.h" #include "winuser.h" #include "winerror.h" -#include "wine_gl.h" #include "x11drv.h" #include "wgl.h" @@ -35,6 +34,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(opengl); +void (*wine_tsx11_lock_ptr)(void) = NULL; +void (*wine_tsx11_unlock_ptr)(void) = NULL; + static GLXContext default_cx = NULL; static Display *default_display; /* display to use for default context */ @@ -586,13 +588,17 @@ static BOOL process_attach(void) HDC hdc; XVisualInfo *vis = NULL; Window root = (Window)GetPropA( GetDesktopWindow(), "__wine_x11_whole_window" ); + HMODULE mod = GetModuleHandleA( "x11drv.dll" ); - if (!root) + if (!root || !mod) { ERR("X11DRV not loaded. Cannot create default context.\n"); return FALSE; } + wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); + wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); + hdc = GetDC(0); default_display = get_display( hdc ); ReleaseDC( 0, hdc ); diff --git a/dlls/x11drv/x11drv.spec b/dlls/x11drv/x11drv.spec index c9bd61f0e30..1a03265ca55 100644 --- a/dlls/x11drv/x11drv.spec +++ b/dlls/x11drv/x11drv.spec @@ -99,3 +99,7 @@ init X11DRV_Init @ cdecl GetClipboardFormatName(long str long) X11DRV_GetClipboardFormatName @ cdecl IsSelectionOwner() X11DRV_IsSelectionOwner @ cdecl ResetSelectionOwner(ptr long) X11DRV_ResetSelectionOwner + +# X11 locks +@ cdecl -norelay wine_tsx11_lock() X11DRV_tsx11_lock +@ cdecl -norelay wine_tsx11_unlock() X11DRV_tsx11_unlock diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c index aaa93bd064f..f0852113295 100644 --- a/dlls/x11drv/x11drv_main.c +++ b/dlls/x11drv/x11drv_main.c @@ -41,7 +41,6 @@ #include "gdi.h" #include "user.h" #include "win.h" -#include "wine_gl.h" #include "x11drv.h" #include "xvidmode.h" #include "dga2.h" @@ -137,17 +136,17 @@ static int error_handler( Display *display, XErrorEvent *error_evt ) } /*********************************************************************** - * lock_tsx11 + * X11DRV_tsx11_lock (X11DRV.@) */ -static void lock_tsx11(void) +void X11DRV_tsx11_lock(void) { EnterCriticalSection( &X11DRV_CritSection ); } /*********************************************************************** - * unlock_tsx11 + * X11DRV_tsx11_unlock (X11DRV.@) */ -static void unlock_tsx11(void) +void X11DRV_tsx11_unlock(void) { LeaveCriticalSection( &X11DRV_CritSection ); } @@ -261,36 +260,6 @@ static void setup_options(void) } -/*********************************************************************** - * setup_opengl_visual - * - * Setup the default visual used for OpenGL and Direct3D, and the desktop - * window (if it exists). If OpenGL isn't available, the visual is simply - * set to the default visual for the display - */ -#ifdef HAVE_OPENGL -static void setup_opengl_visual( Display *display ) -{ - int err_base, evt_base; - - /* In order to support OpenGL or D3D, we require a double-buffered - * visual */ - wine_tsx11_lock(); - if (glXQueryExtension(display, &err_base, &evt_base) == True) { - int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None}; - - desktop_vi = glXChooseVisual(display, DefaultScreen(display), dblBuf); - } - wine_tsx11_unlock(); - - if (desktop_vi != NULL) { - visual = desktop_vi->visual; - screen = ScreenOfDisplay(display, desktop_vi->screen); - screen_depth = desktop_vi->depth; - } -} -#endif /* HAVE_OPENGL */ - /*********************************************************************** * X11DRV process initialisation routine */ @@ -304,8 +273,8 @@ static void process_attach(void) /* setup TSX11 locking */ old_tsx11_lock = wine_tsx11_lock; old_tsx11_unlock = wine_tsx11_unlock; - wine_tsx11_lock = lock_tsx11; - wine_tsx11_unlock = unlock_tsx11; + wine_tsx11_lock = X11DRV_tsx11_lock; + wine_tsx11_unlock = X11DRV_tsx11_unlock; /* Open display */ @@ -338,9 +307,12 @@ static void process_attach(void) else screen_depth = DefaultDepthOfScreen( screen ); /* If OpenGL is available, change the default visual, etc as necessary */ -#ifdef HAVE_OPENGL - setup_opengl_visual( display ); -#endif /* HAVE_OPENGL */ + if ((desktop_vi = X11DRV_setup_opengl_visual( display ))) + { + visual = desktop_vi->visual; + screen = ScreenOfDisplay(display, desktop_vi->screen); + screen_depth = desktop_vi->depth; + } /* tell the libX11 that we will do input method handling ourselves * that keep libX11 from doing anything whith dead keys, allowing Wine diff --git a/graphics/x11drv/opengl.c b/graphics/x11drv/opengl.c index 7b837890c2c..2fdff5fd6db 100644 --- a/graphics/x11drv/opengl.c +++ b/graphics/x11drv/opengl.c @@ -25,15 +25,36 @@ #include #include -#include "wine/debug.h" #include "gdi.h" #include "x11drv.h" -#include "wine_gl.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(opengl); #ifdef HAVE_OPENGL +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +#define XMD_H /* This is to prevent the Xmd.h inclusion bug :-/ */ +#include +#include +#ifdef HAVE_GL_GLEXT_H +# include +#endif +#undef XMD_H + +#undef APIENTRY +#undef CALLBACK +#undef WINAPI + +/* Redefines the constants */ +#define CALLBACK __stdcall +#define WINAPI __stdcall +#define APIENTRY WINAPI + + static void dump_PIXELFORMATDESCRIPTOR(PIXELFORMATDESCRIPTOR *ppfd) { DPRINTF(" - size / version : %d / %d\n", ppfd->nSize, ppfd->nVersion); DPRINTF(" - dwFlags : "); @@ -123,7 +144,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev, /* ADD2(GLX_AUX_BUFFERS, ppfd->cAuxBuffers); */ att_list[att_pos] = None; - ENTER_GL(); { + wine_tsx11_lock(); { /* This command cannot be used as we need to use the default visual... Let's hope it at least contains some OpenGL functionnalities @@ -138,7 +159,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev, TRACE("Found visual : %p - returns %d\n", vis, physDev->used_visuals + 1); } - LEAVE_GL(); + wine_tsx11_unlock(); if (vis == NULL) { ERR("No visual found !\n"); @@ -199,9 +220,9 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev, int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None}; /* Create a 'standard' X Visual */ - ENTER_GL(); + wine_tsx11_lock(); vis = glXChooseVisual(gdi_display, DefaultScreen(gdi_display), dblBuf); - LEAVE_GL(); + wine_tsx11_unlock(); WARN("Uninitialized Visual. Creating standard (%p) !\n", vis); @@ -222,7 +243,7 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev, /* These flags are always the same... */ ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_GENERIC_ACCELERATED; /* Now the flags extraced from the Visual */ - ENTER_GL(); + wine_tsx11_lock(); glXGetConfig(gdi_display, vis, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER; glXGetConfig(gdi_display, vis, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO; @@ -272,7 +293,7 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev, glXGetConfig( gdi_display, vis, GLX_STENCIL_SIZE, &value ); ppfd->cStencilBits = value; - LEAVE_GL(); + wine_tsx11_unlock(); /* Aux : to do ... */ @@ -316,13 +337,37 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev, BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) { TRACE("(%p)\n", physDev); - ENTER_GL(); + wine_tsx11_lock(); glXSwapBuffers(gdi_display, physDev->drawable); - LEAVE_GL(); + wine_tsx11_unlock(); return TRUE; } +/*********************************************************************** + * X11DRV_setup_opengl_visual + * + * Setup the default visual used for OpenGL and Direct3D, and the desktop + * window (if it exists). If OpenGL isn't available, the visual is simply + * set to the default visual for the display + */ +XVisualInfo *X11DRV_setup_opengl_visual( Display *display ) +{ + int err_base, evt_base; + XVisualInfo *visual = NULL; + + /* In order to support OpenGL or D3D, we require a double-buffered + * visual */ + wine_tsx11_lock(); + if (glXQueryExtension(display, &err_base, &evt_base) == True) + { + int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None}; + visual = glXChooseVisual(display, DefaultScreen(display), dblBuf); + } + wine_tsx11_unlock(); + return visual; +} + #else /* defined(HAVE_OPENGL) */ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev, @@ -361,4 +406,9 @@ BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) { return FALSE; } +XVisualInfo *X11DRV_setup_opengl_visual( Display *display ) +{ + return NULL; +} + #endif /* defined(HAVE_OPENGL) */ diff --git a/include/wine_gl.h b/include/wine_gl.h deleted file mode 100644 index 555272e5143..00000000000 --- a/include/wine_gl.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Wrapper for OpenGL includes... - * Copyright 1998 - Lionel Ulmer - * - * This wrapper is needed because Mesa uses also the CALLBACK / WINAPI - * constants. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __WINE_WINE_GL_H -#define __WINE_WINE_GL_H - -#ifndef __WINE_CONFIG_H -# error You must include config.h to use this header -#endif - -#if defined(HAVE_OPENGL) - -#include "ts_xlib.h" - -/* As GLX relies on X, this is needed */ -#define ENTER_GL() wine_tsx11_lock() -#define LEAVE_GL() wine_tsx11_unlock() - -#undef APIENTRY -#undef CALLBACK -#undef WINAPI - -#define XMD_H /* This is to prevent the Xmd.h inclusion bug to happen :-/ */ -#include -#include -#ifdef HAVE_GL_GLEXT_H -# include -#endif -#undef XMD_H - -#undef APIENTRY -#undef CALLBACK -#undef WINAPI - -/* Redefines the constants */ -#define CALLBACK __stdcall -#define WINAPI __stdcall -#define APIENTRY WINAPI - -#endif /* HAVE_OPENGL */ - -#endif /* __WINE_WINE_GL_H */ diff --git a/include/x11drv.h b/include/x11drv.h index b22fe730c65..278601db3e3 100644 --- a/include/x11drv.h +++ b/include/x11drv.h @@ -436,5 +436,6 @@ extern void X11DRV_sync_window_style( Display *display, WND *win ); extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder ); extern int X11DRV_sync_client_window_position( Display *display, WND *win ); extern void X11DRV_set_wm_hints( Display *display, WND *win ); +extern XVisualInfo *X11DRV_setup_opengl_visual( Display *display ); #endif /* __WINE_X11DRV_H */