Commit 5e6461b6 authored by Alexandre Julliard's avatar Alexandre Julliard

Explicitly store the stack of saved DCs in the DC structure instead of

using the 16-bit hNext field in the object header.
parent 0afa832f
...@@ -64,6 +64,7 @@ DC *DC_AllocDC( const DC_FUNCTIONS *funcs, WORD magic ) ...@@ -64,6 +64,7 @@ DC *DC_AllocDC( const DC_FUNCTIONS *funcs, WORD magic )
dc->funcs = funcs; dc->funcs = funcs;
dc->physDev = NULL; dc->physDev = NULL;
dc->saveLevel = 0; dc->saveLevel = 0;
dc->saved_dc = 0;
dc->dwHookData = 0; dc->dwHookData = 0;
dc->hookProc = NULL; dc->hookProc = NULL;
dc->hookThunk = NULL; dc->hookThunk = NULL;
...@@ -335,6 +336,7 @@ HDC WINAPI GetDCState( HDC hdc ) ...@@ -335,6 +336,7 @@ HDC WINAPI GetDCState( HDC hdc )
newdc->hSelf = (HDC)handle; newdc->hSelf = (HDC)handle;
newdc->saveLevel = 0; newdc->saveLevel = 0;
newdc->saved_dc = 0;
PATH_InitGdiPath( &newdc->path ); PATH_InitGdiPath( &newdc->path );
...@@ -506,8 +508,8 @@ INT WINAPI SaveDC( HDC hdc ) ...@@ -506,8 +508,8 @@ INT WINAPI SaveDC( HDC hdc )
return 0; return 0;
} }
dcs->header.hNext = dc->header.hNext; dcs->saved_dc = dc->saved_dc;
dc->header.hNext = HDC_16(hdcs); dc->saved_dc = hdcs;
TRACE("(%p): returning %d\n", hdc, dc->saveLevel+1 ); TRACE("(%p): returning %d\n", hdc, dc->saveLevel+1 );
ret = ++dc->saveLevel; ret = ++dc->saveLevel;
GDI_ReleaseObj( hdcs ); GDI_ReleaseObj( hdcs );
...@@ -550,13 +552,14 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level ) ...@@ -550,13 +552,14 @@ BOOL WINAPI RestoreDC( HDC hdc, INT level )
success=TRUE; success=TRUE;
while (dc->saveLevel >= level) while (dc->saveLevel >= level)
{ {
HDC hdcs = HDC_32(dc->header.hNext); HDC hdcs = dc->saved_dc;
if (!(dcs = DC_GetDCPtr( hdcs ))) if (!(dcs = DC_GetDCPtr( hdcs )))
{ {
GDI_ReleaseObj( hdc ); GDI_ReleaseObj( hdc );
return FALSE; return FALSE;
} }
dc->header.hNext = dcs->header.hNext; dc->saved_dc = dcs->saved_dc;
dcs->saved_dc = 0;
if (--dc->saveLevel < level) if (--dc->saveLevel < level)
{ {
SetDCState( hdc, hdcs ); SetDCState( hdc, hdcs );
...@@ -768,11 +771,11 @@ BOOL WINAPI DeleteDC( HDC hdc ) ...@@ -768,11 +771,11 @@ BOOL WINAPI DeleteDC( HDC hdc )
while (dc->saveLevel) while (dc->saveLevel)
{ {
DC * dcs; DC * dcs;
HDC hdcs = HDC_32(dc->header.hNext); HDC hdcs = dc->saved_dc;
if (!(dcs = DC_GetDCPtr( hdcs ))) break; if (!(dcs = DC_GetDCPtr( hdcs ))) break;
dc->header.hNext = dcs->header.hNext; dc->saved_dc = dcs->saved_dc;
dc->saveLevel--; dc->saveLevel--;
if (dcs->hClipRgn) DeleteObject( dcs->hClipRgn ); if (dcs->hClipRgn) DeleteObject( dcs->hClipRgn );
if (dcs->hVisRgn) DeleteObject( dcs->hVisRgn ); if (dcs->hVisRgn) DeleteObject( dcs->hVisRgn );
PATH_DestroyGdiPath(&dcs->path); PATH_DestroyGdiPath(&dcs->path);
......
...@@ -209,6 +209,7 @@ typedef struct tagDC ...@@ -209,6 +209,7 @@ typedef struct tagDC
const struct tagDC_FUNCS *funcs; /* DC function table */ const struct tagDC_FUNCS *funcs; /* DC function table */
PHYSDEV physDev; /* Physical device (driver-specific) */ PHYSDEV physDev; /* Physical device (driver-specific) */
INT saveLevel; INT saveLevel;
HDC saved_dc;
DWORD dwHookData; DWORD dwHookData;
FARPROC16 hookProc; /* the original SEGPTR ... */ FARPROC16 hookProc; /* the original SEGPTR ... */
DCHOOKPROC hookThunk; /* ... and the thunk to call it */ DCHOOKPROC hookThunk; /* ... and the thunk to call it */
......
...@@ -723,7 +723,8 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_ ...@@ -723,7 +723,8 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_
_EnterSysLevel( &GDI_level ); _EnterSysLevel( &GDI_level );
switch(magic) switch(magic)
{ {
default: case PEN_MAGIC:
case BRUSH_MAGIC:
if (GDI_HeapSel) if (GDI_HeapSel)
{ {
if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error; if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error;
...@@ -733,23 +734,11 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_ ...@@ -733,23 +734,11 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_
break; break;
} }
/* fall through */ /* fall through */
case DC_MAGIC: default:
case DISABLED_DC_MAGIC:
case META_DC_MAGIC:
case METAFILE_MAGIC:
case METAFILE_DC_MAGIC:
case ENHMETAFILE_MAGIC:
case ENHMETAFILE_DC_MAGIC:
case MEMORY_DC_MAGIC:
case BITMAP_MAGIC:
case PALETTE_MAGIC:
case FONT_MAGIC:
case REGION_MAGIC:
if (!(obj = alloc_large_heap( size, handle ))) goto error; if (!(obj = alloc_large_heap( size, handle ))) goto error;
break; break;
} }
obj->hNext = 0;
obj->wMagic = magic|OBJECT_NOSYSTEM; obj->wMagic = magic|OBJECT_NOSYSTEM;
obj->dwCount = 0; obj->dwCount = 0;
obj->funcs = funcs; obj->funcs = funcs;
......
...@@ -59,7 +59,6 @@ struct hdc_list; ...@@ -59,7 +59,6 @@ struct hdc_list;
typedef struct tagGDIOBJHDR typedef struct tagGDIOBJHDR
{ {
HANDLE16 hNext;
WORD wMagic; WORD wMagic;
DWORD dwCount; DWORD dwCount;
const struct gdi_obj_funcs *funcs; const struct gdi_obj_funcs *funcs;
......
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