Commit 0e4f742f authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Don't bother freeing graphics drivers.

parent 1af17844
...@@ -674,7 +674,6 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output, ...@@ -674,7 +674,6 @@ HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
error: error:
if (dc) free_dc_ptr( dc ); if (dc) free_dc_ptr( dc );
DRIVER_release_driver( funcs );
return 0; return 0;
} }
...@@ -759,7 +758,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) ...@@ -759,7 +758,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
physDev = origDC->physDev; physDev = origDC->physDev;
} }
release_dc_ptr( origDC ); release_dc_ptr( origDC );
if (funcs) funcs = DRIVER_get_driver( funcs );
} }
if (!funcs && !(funcs = DRIVER_load_driver( displayW ))) return 0; if (!funcs && !(funcs = DRIVER_load_driver( displayW ))) return 0;
...@@ -790,7 +788,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc ) ...@@ -790,7 +788,6 @@ HDC WINAPI CreateCompatibleDC( HDC hdc )
error: error:
if (dc) free_dc_ptr( dc ); if (dc) free_dc_ptr( dc );
DRIVER_release_driver( funcs );
return 0; return 0;
} }
...@@ -800,7 +797,6 @@ error: ...@@ -800,7 +797,6 @@ error:
*/ */
BOOL WINAPI DeleteDC( HDC hdc ) BOOL WINAPI DeleteDC( HDC hdc )
{ {
const DC_FUNCTIONS *funcs = NULL;
DC * dc; DC * dc;
TRACE("%p\n", hdc ); TRACE("%p\n", hdc );
...@@ -838,13 +834,11 @@ BOOL WINAPI DeleteDC( HDC hdc ) ...@@ -838,13 +834,11 @@ BOOL WINAPI DeleteDC( HDC hdc )
SelectObject( hdc, GetStockObject(WHITE_BRUSH) ); SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
SelectObject( hdc, GetStockObject(SYSTEM_FONT) ); SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) ); SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
funcs = dc->funcs;
if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc->physDev); if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc->physDev);
dc->physDev = NULL; dc->physDev = NULL;
} }
free_dc_ptr( dc ); free_dc_ptr( dc );
if (funcs) DRIVER_release_driver( funcs ); /* do that after releasing the GDI lock */
return TRUE; return TRUE;
} }
......
...@@ -42,7 +42,6 @@ struct graphics_driver ...@@ -42,7 +42,6 @@ struct graphics_driver
{ {
struct list entry; struct list entry;
HMODULE module; /* module handle */ HMODULE module; /* module handle */
unsigned int count; /* reference count */
DC_FUNCTIONS funcs; DC_FUNCTIONS funcs;
}; };
...@@ -69,7 +68,6 @@ static struct graphics_driver *create_driver( HMODULE module ) ...@@ -69,7 +68,6 @@ static struct graphics_driver *create_driver( HMODULE module )
if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL; if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
driver->module = module; driver->module = module;
driver->count = 1;
/* fill the function table */ /* fill the function table */
if (module) if (module)
...@@ -227,11 +225,7 @@ static struct graphics_driver *load_display_driver(void) ...@@ -227,11 +225,7 @@ static struct graphics_driver *load_display_driver(void)
HMODULE module = 0; HMODULE module = 0;
HKEY hkey; HKEY hkey;
if (display_driver) /* already loaded */ if (display_driver) return display_driver; /* already loaded */
{
display_driver->count++;
return display_driver;
}
strcpy( buffer, "x11" ); /* default value */ strcpy( buffer, "x11" ); /* default value */
/* @@ Wine registry key: HKCU\Software\Wine\Drivers */ /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
...@@ -260,7 +254,6 @@ static struct graphics_driver *load_display_driver(void) ...@@ -260,7 +254,6 @@ static struct graphics_driver *load_display_driver(void)
ExitProcess(1); ExitProcess(1);
} }
display_driver->count++; /* we don't want to free it */
return display_driver; return display_driver;
} }
...@@ -278,7 +271,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) ...@@ -278,7 +271,7 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
EnterCriticalSection( &driver_section ); EnterCriticalSection( &driver_section );
/* display driver is a special case */ /* display driver is a special case */
if (!strcmpiW( name, displayW ) || if (!strcmpiW( name, displayW ) ||
!strcmpiW( name, display1W )) !strcmpiW( name, display1W ))
{ {
driver = load_display_driver(); driver = load_display_driver();
...@@ -292,7 +285,6 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) ...@@ -292,7 +285,6 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
{ {
if (driver->module == module) if (driver->module == module)
{ {
driver->count++;
LeaveCriticalSection( &driver_section ); LeaveCriticalSection( &driver_section );
return &driver->funcs; return &driver->funcs;
} }
...@@ -318,50 +310,6 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) ...@@ -318,50 +310,6 @@ const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name )
} }
/**********************************************************************
* DRIVER_get_driver
*
* Get a new copy of an existing driver.
*/
const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs )
{
struct graphics_driver *driver;
EnterCriticalSection( &driver_section );
LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
if (&driver->funcs == funcs) break;
if (&driver->entry == &drivers) ERR( "driver not found, trouble ahead\n" );
driver->count++;
LeaveCriticalSection( &driver_section );
return funcs;
}
/**********************************************************************
* DRIVER_release_driver
*
* Release a driver by decrementing ref count and freeing it if needed.
*/
void DRIVER_release_driver( const DC_FUNCTIONS *funcs )
{
struct graphics_driver *driver;
EnterCriticalSection( &driver_section );
LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
{
if (&driver->funcs != funcs) continue;
if (--driver->count) break;
list_remove( &driver->entry );
if (driver == display_driver) display_driver = NULL;
FreeLibrary( driver->module );
HeapFree( GetProcessHeap(), 0, driver );
break;
}
LeaveCriticalSection( &driver_section );
}
/***************************************************************************** /*****************************************************************************
* DRIVER_GetDriverName * DRIVER_GetDriverName
* *
......
...@@ -386,8 +386,6 @@ extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width, ...@@ -386,8 +386,6 @@ extern int DIB_GetBitmapInfo( const BITMAPINFOHEADER *header, LONG *width,
/* driver.c */ /* driver.c */
extern const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) DECLSPEC_HIDDEN; extern const DC_FUNCTIONS *DRIVER_load_driver( LPCWSTR name ) DECLSPEC_HIDDEN;
extern const DC_FUNCTIONS *DRIVER_get_driver( const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN;
extern void DRIVER_release_driver( const DC_FUNCTIONS *funcs ) DECLSPEC_HIDDEN;
extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size ) DECLSPEC_HIDDEN; extern BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size ) DECLSPEC_HIDDEN;
/* enhmetafile.c */ /* enhmetafile.c */
......
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