Commit ca30176c authored by Dimi Paun's avatar Dimi Paun Committed by Alexandre Julliard

Remove the LOCAL_*() functions from GDI.

parent 0a308f2d
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
#include "wingdi.h" #include "wingdi.h"
#include "winreg.h" #include "winreg.h"
#include "winerror.h" #include "winerror.h"
#include "winternl.h"
#include "local.h"
#include "gdi.h" #include "gdi.h"
#include "gdi_private.h" #include "gdi_private.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -709,7 +709,7 @@ inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle ) ...@@ -709,7 +709,7 @@ inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle )
*/ */
void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_obj_funcs *funcs ) void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_obj_funcs *funcs )
{ {
GDIOBJHDR *obj; GDIOBJHDR *obj = NULL;
HLOCAL16 hlocal; HLOCAL16 hlocal;
_EnterSysLevel( &GDI_level ); _EnterSysLevel( &GDI_level );
...@@ -719,10 +719,18 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_ ...@@ -719,10 +719,18 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle, const struct gdi_
case BRUSH_MAGIC: case BRUSH_MAGIC:
if (GDI_HeapSel) if (GDI_HeapSel)
{ {
if (!(hlocal = LOCAL_Alloc( GDI_HeapSel, LMEM_MOVEABLE, size ))) goto error; STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
assert( hlocal & 2 ); HANDLE16 oldDS = stack16->ds;
obj = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, hlocal );
*handle = (HGDIOBJ)(ULONG_PTR)hlocal; stack16->ds = GDI_HeapSel;
if ((hlocal = LocalAlloc16( LMEM_MOVEABLE, size )))
{
assert( hlocal & 2 );
obj = MapSL(LocalLock16( hlocal ));
*handle = (HGDIOBJ)(ULONG_PTR)hlocal;
}
stack16->ds = oldDS;
if (!hlocal) goto error;
break; break;
} }
/* fall through */ /* fall through */
...@@ -755,34 +763,39 @@ error: ...@@ -755,34 +763,39 @@ error:
void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object ) void *GDI_ReallocObject( WORD size, HGDIOBJ handle, void *object )
{ {
HGDIOBJ new_handle; HGDIOBJ new_handle;
void *new_ptr = NULL;
if ((UINT_PTR)handle & 2) /* GDI heap handle */ if ((UINT_PTR)handle & 2) /* GDI heap handle */
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
HANDLE16 oldDS = stack16->ds;
HLOCAL16 h = LOWORD(handle); HLOCAL16 h = LOWORD(handle);
LOCAL_Unlock( GDI_HeapSel, h );
if ((new_handle = (HGDIOBJ)(ULONG_PTR)LOCAL_ReAlloc( GDI_HeapSel, h, size, LMEM_MOVEABLE ))) stack16->ds = GDI_HeapSel;
LocalUnlock16( h );
if ((new_handle = (HGDIOBJ)(ULONG_PTR)LocalReAlloc16( h, size, LMEM_MOVEABLE )))
{ {
assert( new_handle == handle ); /* moveable handle cannot change */ assert( new_handle == handle ); /* moveable handle cannot change */
return LOCAL_Lock( GDI_HeapSel, h ); new_ptr = MapSL(LocalLock16( h ));
} }
stack16->ds = oldDS;
} }
else else
{ {
int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE; int i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i]) if (i >= 0 && i < MAX_LARGE_HANDLES && large_handles[i])
{ {
void *new_ptr = HeapReAlloc( GetProcessHeap(), 0, large_handles[i], size ); new_ptr = HeapReAlloc( GetProcessHeap(), 0, large_handles[i], size );
if (new_ptr) if (new_ptr) large_handles[i] = new_ptr;
{
large_handles[i] = new_ptr;
return new_ptr;
}
} }
else ERR( "Invalid handle %p\n", handle ); else ERR( "Invalid handle %p\n", handle );
} }
TRACE("(%p): leave %ld\n", handle, GDI_level.crst.RecursionCount); if (!new_ptr)
_LeaveSysLevel( &GDI_level ); {
return NULL; TRACE("(%p): leave %ld\n", handle, GDI_level.crst.RecursionCount);
_LeaveSysLevel( &GDI_level );
}
return new_ptr;
} }
...@@ -797,9 +810,14 @@ BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr ) ...@@ -797,9 +810,14 @@ BOOL GDI_FreeObject( HGDIOBJ handle, void *ptr )
object->funcs = NULL; object->funcs = NULL;
if ((UINT_PTR)handle & 2) /* GDI heap handle */ if ((UINT_PTR)handle & 2) /* GDI heap handle */
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
HANDLE16 oldDS = stack16->ds;
HLOCAL16 h = LOWORD(handle); HLOCAL16 h = LOWORD(handle);
LOCAL_Unlock( GDI_HeapSel, h );
LOCAL_Free( GDI_HeapSel, h ); stack16->ds = GDI_HeapSel;
LocalUnlock16( h );
LocalFree16( h );
stack16->ds = oldDS;
} }
else /* large heap handle */ else /* large heap handle */
{ {
...@@ -832,18 +850,23 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic ) ...@@ -832,18 +850,23 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
if ((UINT_PTR)handle & 2) /* GDI heap handle */ if ((UINT_PTR)handle & 2) /* GDI heap handle */
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
HANDLE16 oldDS = stack16->ds;
HLOCAL16 h = LOWORD(handle); HLOCAL16 h = LOWORD(handle);
ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, h );
stack16->ds = GDI_HeapSel;
ptr = MapSL(LocalLock16( h ));
if (ptr) if (ptr)
{ {
if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) || if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ||
(GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) || (GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) ||
(GDIMAGIC(ptr->wMagic) > LAST_MAGIC)) (GDIMAGIC(ptr->wMagic) > LAST_MAGIC))
{ {
LOCAL_Unlock( GDI_HeapSel, h ); LocalUnlock16( h );
ptr = NULL; ptr = NULL;
} }
} }
stack16->ds = oldDS;
} }
else /* large heap handle */ else /* large heap handle */
{ {
...@@ -872,7 +895,15 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic ) ...@@ -872,7 +895,15 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD magic )
*/ */
void GDI_ReleaseObj( HGDIOBJ handle ) void GDI_ReleaseObj( HGDIOBJ handle )
{ {
if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, LOWORD(handle) ); if ((UINT_PTR)handle & 2)
{
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
HANDLE16 oldDS = stack16->ds;
stack16->ds = GDI_HeapSel;
LocalUnlock16( LOWORD(handle) );
stack16->ds = oldDS;
}
TRACE("(%p): leave %ld\n", handle, GDI_level.crst.RecursionCount); TRACE("(%p): leave %ld\n", handle, GDI_level.crst.RecursionCount);
_LeaveSysLevel( &GDI_level ); _LeaveSysLevel( &GDI_level );
} }
...@@ -1448,20 +1479,31 @@ DWORD WINAPI GdiSetBatchLimit( DWORD limit ) ...@@ -1448,20 +1479,31 @@ DWORD WINAPI GdiSetBatchLimit( DWORD limit )
DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2, DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2,
WORD wParam3 ) WORD wParam3 )
{ {
STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
HANDLE16 oldDS = stack16->ds;
DWORD ret = ~0UL;
stack16->ds = GDI_HeapSel;
switch (wReqType) switch (wReqType)
{ {
case 0x0001: /* LocalAlloc */ case 0x0001: /* LocalAlloc */
return LOCAL_Alloc( GDI_HeapSel, wParam1, wParam3 ); ret = LocalAlloc16( wParam1, wParam3 );
break;
case 0x0002: /* LocalFree */ case 0x0002: /* LocalFree */
return LOCAL_Free( GDI_HeapSel, wParam1 ); ret = LocalFree16( wParam1 );
break;
case 0x0003: /* LocalCompact */ case 0x0003: /* LocalCompact */
return LOCAL_Compact( GDI_HeapSel, wParam3 ); ret = LocalCompact16( wParam3 );
break;
case 0x0103: /* LocalHeap */ case 0x0103: /* LocalHeap */
return GDI_HeapSel; ret = GDI_HeapSel;
break;
default: default:
WARN("(wReqType=%04x): Unknown\n", wReqType); WARN("(wReqType=%04x): Unknown\n", wReqType);
return ~0UL; break;
} }
stack16->ds = oldDS;
return ret;
} }
/*********************************************************************** /***********************************************************************
...@@ -1477,11 +1519,12 @@ WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID, ...@@ -1477,11 +1519,12 @@ WORD WINAPI GdiSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
* GdiInit2 (GDI.403) * GdiInit2 (GDI.403)
* *
* See "Undocumented Windows" * See "Undocumented Windows"
*
* PARAMS
* h1 [I] GDI object
* h2 [I] global data
*/ */
HANDLE16 WINAPI GdiInit216( HANDLE16 WINAPI GdiInit216( HANDLE16 h1, HANDLE16 h2 )
HANDLE16 h1, /* [in] GDI object */
HANDLE16 h2 /* [in] global data */
)
{ {
FIXME("(%04x, %04x), stub.\n", h1, h2); FIXME("(%04x, %04x), stub.\n", h1, h2);
if (h2 == 0xffff) if (h2 == 0xffff)
...@@ -1501,8 +1544,15 @@ void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */ ...@@ -1501,8 +1544,15 @@ void WINAPI FinalGdiInit16( HBRUSH16 hPattern /* [in] fill pattern of desktop */
*/ */
WORD WINAPI GdiFreeResources16( DWORD reserve ) WORD WINAPI GdiFreeResources16( DWORD reserve )
{ {
return (WORD)( (int)LOCAL_CountFree( GDI_HeapSel ) * 100 / STACK16FRAME* stack16 = MapSL((SEGPTR)NtCurrentTeb()->WOW32Reserved);
(int)LOCAL_HeapSize( GDI_HeapSel ) ); HANDLE16 oldDS = stack16->ds;
WORD ret;
stack16->ds = GDI_HeapSel;
ret = (WORD)( (int)LocalCountFree16() * 100 / (int)LocalHeapSize16() );
stack16->ds = oldDS;
return ret;
} }
......
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