Delay OpenGL and GDI initialization until they are needed.

This commit is contained in:
Alexandre Julliard 2005-06-29 19:28:06 +00:00
parent 34a9ab04b2
commit 8ba32b3f9b
4 changed files with 25 additions and 21 deletions

View File

@ -41,6 +41,7 @@ static int log_pixels_y; /* pixels per logical inch in y direction */
static int horz_size; /* horz. size of screen in millimeters */
static int vert_size; /* vert. size of screen in millimeters */
static int palette_size;
static int device_init_done;
unsigned int text_caps = (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
TC_CR_ANY | TC_SA_DOUBLE | TC_SA_INTEGER |
TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE);
@ -77,11 +78,13 @@ static DWORD get_dpi( void )
}
/**********************************************************************
* X11DRV_GDI_Initialize
* device_init
*
* Perform initializations needed upon creation of the first device.
*/
void X11DRV_GDI_Initialize( Display *display )
static void device_init(void)
{
gdi_display = display;
device_init_done = TRUE;
/* Initialize XRender */
X11DRV_XRender_Init();
@ -117,6 +120,8 @@ BOOL X11DRV_CreateDC( HDC hdc, X11DRV_PDEVICE **pdev, LPCWSTR driver, LPCWSTR de
{
X11DRV_PDEVICE *physDev;
if (!device_init_done) device_init();
physDev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physDev) );
if (!physDev) return FALSE;

View File

@ -112,8 +112,6 @@ static void dump_PIXELFORMATDESCRIPTOR(const PIXELFORMATDESCRIPTOR *ppfd) {
#define SONAME_LIBGL "libGL.so"
#endif
static void *opengl_handle;
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
MAKE_FUNCPTR(glGetError)
MAKE_FUNCPTR(glXChooseVisual)
@ -126,11 +124,18 @@ MAKE_FUNCPTR(glXChooseFBConfig)
MAKE_FUNCPTR(glXGetFBConfigAttrib)
#undef MAKE_FUNCPTR
void X11DRV_OpenGL_Init(Display *display) {
static BOOL has_opengl(void)
{
static int init_done;
static void *opengl_handle;
int error_base, event_base;
if (init_done) return (opengl_handle != NULL);
init_done = 1;
opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, NULL, 0);
if (opengl_handle == NULL) return;
if (opengl_handle == NULL) return FALSE;
#define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(opengl_handle, #f, NULL, 0)) == NULL) goto sym_not_found;
LOAD_FUNCPTR(glGetError)
@ -145,18 +150,19 @@ LOAD_FUNCPTR(glXGetFBConfigAttrib)
#undef LOAD_FUNCPTR
wine_tsx11_lock();
if (pglXQueryExtension(display, &event_base, &error_base) == True) {
if (pglXQueryExtension(gdi_display, &event_base, &error_base) == True) {
TRACE("GLX is up and running error_base = %d\n", error_base);
} else {
wine_dlclose(opengl_handle, NULL, 0);
opengl_handle = NULL;
}
wine_tsx11_unlock();
return;
return (opengl_handle != NULL);
sym_not_found:
wine_dlclose(opengl_handle, NULL, 0);
opengl_handle = NULL;
return FALSE;
}
#define TEST_AND_ADD1(t,a) if (t) att_list[att_pos++] = (a)
@ -176,7 +182,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
GLXFBConfig* cfgs = NULL;
int ret = 0;
if (opengl_handle == NULL) {
if (!has_opengl()) {
ERR("No libGL on this box - disabling OpenGL support !\n");
return 0;
}
@ -298,7 +304,7 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
int nCfgs = 0;
int ret = 0;
if (opengl_handle == NULL) {
if (!has_opengl()) {
ERR("No libGL on this box - disabling OpenGL support !\n");
return 0;
}
@ -444,7 +450,7 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
* Swap the buffers of this DC
*/
BOOL X11DRV_SwapBuffers(X11DRV_PDEVICE *physDev) {
if (opengl_handle == NULL) {
if (!has_opengl()) {
ERR("No libGL on this box - disabling OpenGL support !\n");
return 0;
}
@ -470,7 +476,7 @@ XVisualInfo *X11DRV_setup_opengl_visual( Display *display )
XVisualInfo *visual = NULL;
int dblBuf[]={GLX_RGBA,GLX_DEPTH_SIZE,16,GLX_DOUBLEBUFFER,None};
if (opengl_handle == NULL) return NULL;
if (!has_opengl()) return NULL;
/* In order to support OpenGL or D3D, we require a double-buffered visual */
wine_tsx11_lock();

View File

@ -274,7 +274,6 @@ extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UIN
UINT count, const INT *lpDx, INT breakExtra);
extern void X11DRV_XRender_UpdateDrawable(X11DRV_PDEVICE *physDev);
extern void X11DRV_OpenGL_Init(Display *display);
extern XVisualInfo *X11DRV_setup_opengl_visual(Display *display);
/* XIM support */
@ -441,7 +440,6 @@ extern INT X11DRV_DCICommand(INT cbInput, const struct _DCICMD *lpCmd, LPVOID lp
* X11 GDI driver
*/
extern void X11DRV_GDI_Initialize( Display *display );
extern void X11DRV_GDI_Finalize(void);
extern Display *gdi_display; /* display to use for all GDI functions */

View File

@ -336,6 +336,7 @@ static BOOL process_attach(void)
screen = DefaultScreenOfDisplay( display );
visual = DefaultVisual( display, DefaultScreen(display) );
root_window = DefaultRootWindow( display );
gdi_display = display;
old_error_handler = XSetErrorHandler( error_handler );
/* Initialize screen depth */
@ -355,9 +356,6 @@ static BOOL process_attach(void)
}
if (!screen_depth) screen_depth = DefaultDepthOfScreen( screen );
/* Initialize OpenGL */
X11DRV_OpenGL_Init(display);
/* If OpenGL is available, change the default visual, etc as necessary */
if (desktop_dbl_buf && (desktop_vi = X11DRV_setup_opengl_visual( display )))
{
@ -379,9 +377,6 @@ static BOOL process_attach(void)
using_wine_desktop = 1;
}
/* initialize GDI */
X11DRV_GDI_Initialize( display );
#ifdef HAVE_LIBXXF86VM
/* initialize XVidMode */
X11DRV_XF86VM_Init();