Authors: Alexandre Julliard <julliard@codeweavers.com> (for Corel), Albert den Haan <albertd@corel.com>
Added syslevel locking for GDI operations.
Propagate the changes through the graphics code.

diff --git a/include/dc.h b/include/dc.h
index 95903e0..313de44 100644
--- a/include/dc.h
+++ b/include/dc.h
@@ -16,6 +16,7 @@
 
 extern DC * DC_AllocDC( const DC_FUNCTIONS *funcs );
 extern DC * DC_GetDCPtr( HDC hdc );
+extern DC * DC_GetDCUpdate( HDC hdc );
 extern void DC_InitDC( DC * dc );
 extern void DC_UpdateXforms( DC * dc );
 
diff --git a/include/gdi.h b/include/gdi.h
index 6cd7a95..91b5fd1 100644
--- a/include/gdi.h
+++ b/include/gdi.h
@@ -193,7 +193,7 @@
     INT      (*pEndDoc)(DC*);
     INT      (*pEndPage)(DC*);
     BOOL     (*pEndPath)(DC*);
-    BOOL     (*pEnumDeviceFonts)(DC*,LPLOGFONT16,DEVICEFONTENUMPROC,LPARAM);
+    BOOL     (*pEnumDeviceFonts)(HDC,LPLOGFONT16,DEVICEFONTENUMPROC,LPARAM);
     INT      (*pEscape)(DC*,INT,INT,SEGPTR,SEGPTR);
     INT      (*pExcludeClipRect)(DC*,INT,INT,INT,INT);
     INT      (*pExtDeviceMode)(LPSTR,HWND,LPDEVMODEA,LPSTR,LPSTR,LPDEVMODEA,
@@ -444,30 +444,12 @@
 
   /* GDI local heap */
 
-extern WORD GDI_HeapSel;
-
-#define GDI_HEAP_ALLOC(size) \
-            LOCAL_Alloc( GDI_HeapSel, LMEM_FIXED, (size) )
-#define GDI_HEAP_ALLOC_MOVEABLE(size) \
-            LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, (size) )
-#define GDI_HEAP_REALLOC(handle,size) \
-            LOCAL_ReAlloc( GDI_HeapSel, (handle), (size), LMEM_FIXED )
-#define GDI_HEAP_FREE(handle) \
-            LOCAL_Free( GDI_HeapSel, (handle) )
-
-#define GDI_HEAP_LOCK(handle) \
-            LOCAL_Lock( GDI_HeapSel, (handle) )
-#define GDI_HEAP_LOCK_SEGPTR(handle) \
-            LOCAL_LockSegptr( GDI_HeapSel, (handle) )
-#define GDI_HEAP_UNLOCK(handle) \
-    ((((HGDIOBJ16)(handle) >= FIRST_STOCK_HANDLE) && \
-      ((HGDIOBJ16)(handle)<=LAST_STOCK_HANDLE)) ? \
-      0 : LOCAL_Unlock( GDI_HeapSel, (handle) ))
-
 extern BOOL GDI_Init(void);
-extern HGDIOBJ GDI_AllocObject( WORD, WORD );
-extern BOOL GDI_FreeObject( HGDIOBJ );
-extern GDIOBJHDR * GDI_GetObjPtr( HGDIOBJ, WORD );
+extern void *GDI_AllocObject( WORD, WORD, HGDIOBJ * );
+extern void *GDI_ReallocObject( WORD, HGDIOBJ, void *obj );
+extern BOOL GDI_FreeObject( HGDIOBJ, void *obj );
+extern void *GDI_GetObjPtr( HGDIOBJ, WORD );
+extern void GDI_ReleaseObj( HGDIOBJ );
 
 extern BOOL DRIVER_RegisterDriver( LPCSTR name, const DC_FUNCTIONS *funcs );
 extern const DC_FUNCTIONS *DRIVER_FindDriver( LPCSTR name );
diff --git a/include/global.h b/include/global.h
index 45557b8..b1e530f 100644
--- a/include/global.h
+++ b/include/global.h
@@ -19,8 +19,6 @@
                                BOOL16 isCode, BOOL16 is32Bit,
                                BOOL16 isReadOnly );
 
-extern WORD WINAPI GlobalHandleToSel16( HGLOBAL16 handle );
-
 /* memory/virtual.c */
 extern DWORD VIRTUAL_GetPageSize(void);
 extern DWORD VIRTUAL_GetGranularity(void);
diff --git a/include/path.h b/include/path.h
index c75d356..db3f197 100644
--- a/include/path.h
+++ b/include/path.h
@@ -42,22 +42,24 @@
 extern BOOL PATH_AssignGdiPath(GdiPath *pPathDest,
    const GdiPath *pPathSrc);
 
-extern BOOL PATH_MoveTo(HDC hdc);
-extern BOOL PATH_LineTo(HDC hdc, INT x, INT y);
-extern BOOL PATH_Rectangle(HDC hdc, INT x1, INT y1,
+struct tagDC;
+
+extern BOOL PATH_MoveTo(struct tagDC *dc);
+extern BOOL PATH_LineTo(struct tagDC *dc, INT x, INT y);
+extern BOOL PATH_Rectangle(struct tagDC *dc, INT x1, INT y1,
    INT x2, INT y2);
-extern BOOL PATH_Ellipse(HDC hdc, INT x1, INT y1,
+extern BOOL PATH_Ellipse(struct tagDC *dc, INT x1, INT y1,
    INT x2, INT y2);
-extern BOOL PATH_Arc(HDC hdc, INT x1, INT y1, INT x2, INT y2,
+extern BOOL PATH_Arc(struct tagDC *dc, INT x1, INT y1, INT x2, INT y2,
    INT xStart, INT yStart, INT xEnd, INT yEnd);
-extern BOOL PATH_PolyBezierTo(HDC hdc, const POINT *pt, DWORD cbCount);
-extern BOOL PATH_PolyBezier(HDC hdc, const POINT *pt, DWORD cbCount);
-extern BOOL PATH_PolylineTo(HDC hdc, const POINT *pt, DWORD cbCount);
-extern BOOL PATH_Polyline(HDC hdc, const POINT *pt, DWORD cbCount);
-extern BOOL PATH_Polygon(HDC hdc, const POINT *pt, DWORD cbCount);
-extern BOOL PATH_PolyPolyline(HDC hdc, const POINT *pt, const DWORD *counts,
+extern BOOL PATH_PolyBezierTo(struct tagDC *dc, const POINT *pt, DWORD cbCount);
+extern BOOL PATH_PolyBezier(struct tagDC *dc, const POINT *pt, DWORD cbCount);
+extern BOOL PATH_PolylineTo(struct tagDC *dc, const POINT *pt, DWORD cbCount);
+extern BOOL PATH_Polyline(struct tagDC *dc, const POINT *pt, DWORD cbCount);
+extern BOOL PATH_Polygon(struct tagDC *dc, const POINT *pt, DWORD cbCount);
+extern BOOL PATH_PolyPolyline(struct tagDC *dc, const POINT *pt, const DWORD *counts,
 			      DWORD polylines);
-extern BOOL PATH_PolyPolygon(HDC hdc, const POINT *pt, const INT *counts,
+extern BOOL PATH_PolyPolygon(struct tagDC *dc, const POINT *pt, const INT *counts,
 			     UINT polygons);
 #endif /* __WINE_PATH_H */
 
diff --git a/include/win.h b/include/win.h
index 2de2471..5e8e31f 100644
--- a/include/win.h
+++ b/include/win.h
@@ -54,7 +54,6 @@
 
 struct tagCLASS;
 struct tagDCE;
-struct tagDC;
 struct tagMESSAGEQUEUE;
 struct tagWND_DRIVER;
 
diff --git a/include/win16drv.h b/include/win16drv.h
index f5e7fb2..102042d 100644
--- a/include/win16drv.h
+++ b/include/win16drv.h
@@ -225,7 +225,7 @@
 extern BOOL WIN16DRV_PatBlt( struct tagDC *dc, INT left, INT top,
                                INT width, INT height, DWORD rop );
 extern BOOL WIN16DRV_Ellipse(DC *dc, INT left, INT top, INT right, INT bottom);
-extern BOOL WIN16DRV_EnumDeviceFonts( DC* dc, LPLOGFONT16 plf, 
+extern BOOL WIN16DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf, 
 				        DEVICEFONTENUMPROC proc, LPARAM lp );
 
 extern INT WIN16DRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd,
diff --git a/include/wine/winbase16.h b/include/wine/winbase16.h
index a0ce055..5b9d72c 100644
--- a/include/wine/winbase16.h
+++ b/include/wine/winbase16.h
@@ -71,6 +71,7 @@
 WORD        WINAPI GlobalDOSFree16(WORD);
 void        WINAPI GlobalFreeAll16(HGLOBAL16);
 DWORD       WINAPI GlobalHandleNoRIP16(WORD);
+WORD        WINAPI GlobalHandleToSel16(HGLOBAL16);
 HGLOBAL16   WINAPI GlobalLRUNewest16(HGLOBAL16);
 HGLOBAL16   WINAPI GlobalLRUOldest16(HGLOBAL16);
 VOID        WINAPI GlobalNotify16(FARPROC16);
diff --git a/include/x11drv.h b/include/x11drv.h
index adbaa88..ac9680f 100644
--- a/include/x11drv.h
+++ b/include/x11drv.h
@@ -90,7 +90,7 @@
 extern BOOL X11DRV_BitBlt( struct tagDC *dcDst, INT xDst, INT yDst,
                              INT width, INT height, struct tagDC *dcSrc,
                              INT xSrc, INT ySrc, DWORD rop );
-extern BOOL X11DRV_EnumDeviceFonts( struct tagDC *dc, LPLOGFONT16 plf,
+extern BOOL X11DRV_EnumDeviceFonts( HDC hdc, LPLOGFONT16 plf,
 				      DEVICEFONTENUMPROC dfeproc, LPARAM lp );
 extern BOOL X11DRV_GetCharWidth( struct tagDC *dc, UINT firstChar,
                                    UINT lastChar, LPINT buffer );