From bb70febc2ab905cc882e7e77eeb55196327aacc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 20 Aug 2003 07:45:02 +0000 Subject: [PATCH] - Store GDI object type in the handle itself - Rename remaining XX_HandleToPtr/XX_ReleasePtr funcs to XX_LockXx/XX_UnlockXx svn path=/trunk/; revision=5693 --- reactos/include/win32k/bitmaps.h | 15 +- reactos/include/win32k/brush.h | 13 +- reactos/include/win32k/cursoricon.h | 10 +- reactos/include/win32k/dc.h | 13 +- reactos/include/win32k/gdiobj.h | 117 ++--- reactos/include/win32k/pen.h | 14 +- reactos/include/win32k/region.h | 6 +- reactos/include/win32k/text.h | 8 +- reactos/subsys/win32k/eng/mouse.c | 10 +- reactos/subsys/win32k/eng/surface.c | 6 +- reactos/subsys/win32k/include/dce.h | 8 +- reactos/subsys/win32k/ntuser/windc.c | 6 +- reactos/subsys/win32k/ntuser/winpos.c | 23 +- reactos/subsys/win32k/objects/bitmaps.c | 23 +- reactos/subsys/win32k/objects/brush.c | 24 +- reactos/subsys/win32k/objects/cliprgn.c | 16 +- reactos/subsys/win32k/objects/color.c | 14 +- reactos/subsys/win32k/objects/coord.c | 66 +-- reactos/subsys/win32k/objects/cursoricon.c | 12 +- reactos/subsys/win32k/objects/dc.c | 253 +++++------ reactos/subsys/win32k/objects/dib.c | 49 +-- reactos/subsys/win32k/objects/fillshap.c | 32 +- reactos/subsys/win32k/objects/gdiobj.c | 483 +++++++++------------ reactos/subsys/win32k/objects/line.c | 56 +-- reactos/subsys/win32k/objects/objconv.c | 6 +- reactos/subsys/win32k/objects/path.c | 6 +- reactos/subsys/win32k/objects/region.c | 27 +- reactos/subsys/win32k/objects/text.c | 34 +- 28 files changed, 633 insertions(+), 717 deletions(-) diff --git a/reactos/include/win32k/bitmaps.h b/reactos/include/win32k/bitmaps.h index c3b472f37ca..02e71bec693 100644 --- a/reactos/include/win32k/bitmaps.h +++ b/reactos/include/win32k/bitmaps.h @@ -28,18 +28,11 @@ typedef struct _BITMAPOBJ /* Internal interface */ #define BITMAPOBJ_AllocBitmap() \ - ((HBITMAP) GDIOBJ_AllocObj (sizeof (BITMAPOBJ), GO_BITMAP_MAGIC)) + ((HBITMAP) GDIOBJ_AllocObj (sizeof (BITMAPOBJ), GDI_OBJECT_TYPE_BITMAP, (GDICLEANUPPROC) Bitmap_InternalDelete)) #define BITMAPOBJ_FreeBitmap(hBMObj) \ - GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC, GDIOBJFLAG_DEFAULT) -#define BITMAPOBJ_HandleToPtr(hBMObj) \ - ((PBITMAPOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC)) -#define BITMAPOBJ_ReleasePtr(hBMObj) \ - GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GO_BITMAP_MAGIC) - -/*#define BITMAPOBJ_PtrToHandle(hBMObj) \ - ((HBITMAP) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_BITMAP_MAGIC))*/ -#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObject ((HGDIOBJ) hBMObj) -#define BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObject ((HGDIOBJ) hBMObj) + GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP, GDIOBJFLAG_DEFAULT) +#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP) +#define BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP) INT FASTCALL BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp); HBITMAP FASTCALL BITMAPOBJ_CopyBitmap (HBITMAP hBitmap); diff --git a/reactos/include/win32k/brush.h b/reactos/include/win32k/brush.h index 1fe27866b01..5e419e507e2 100644 --- a/reactos/include/win32k/brush.h +++ b/reactos/include/win32k/brush.h @@ -8,15 +8,10 @@ #define NB_HATCH_STYLES 6 #define BRUSHOBJ_AllocBrush() \ - ((HBRUSH) GDIOBJ_AllocObj (sizeof (BRUSHOBJ), GO_BRUSH_MAGIC)) -#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GO_BRUSH_MAGIC, GDIOBJFLAG_DEFAULT) -/*#define BRUSHOBJ_HandleToPtr(hBrush) \ - ((PBRUSHOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBrush, GO_BRUSH_MAGIC)) -#define BRUSHOBJ_PtrToHandle(pBrushObj) \ - ((HBRUSH) GDIOBJ_PtrToHandle ((PGDIOBJ) pBrushObj, GO_BRUSH_MAGIC)) -*/ -#define BRUSHOBJ_LockBrush(hBrush) ((PBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GO_BRUSH_MAGIC)) -#define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GO_BRUSH_MAGIC) + ((HBRUSH) GDIOBJ_AllocObj (sizeof (BRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, NULL)) +#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT) +#define BRUSHOBJ_LockBrush(hBrush) ((PBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)) +#define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH) HBRUSH STDCALL diff --git a/reactos/include/win32k/cursoricon.h b/reactos/include/win32k/cursoricon.h index 8ccfb2dfd84..e7f0fde9e78 100644 --- a/reactos/include/win32k/cursoricon.h +++ b/reactos/include/win32k/cursoricon.h @@ -79,15 +79,15 @@ typedef struct _ICONCURSOROBJ /* Internal interfaces */ #define ICONCURSOROBJ_AllocIconCursor() \ - ((HICON) GDIOBJ_AllocObj (sizeof (ICONCURSOROBJ), GO_ICONCURSOR_MAGIC)) + ((HICON) GDIOBJ_AllocObj (sizeof (ICONCURSOROBJ), GDI_OBJECT_TYPE_ICONCURSOR, (GDICLEANUPPROC) IconCursor_InternalDelete)) -#define ICONCURSOROBJ_HandleToPtr(hICObj) \ - ((PICONCURSOROBJ) GDIOBJ_LockObj ((HGDIOBJ) hICObj, GO_ICONCURSOR_MAGIC)) +#define ICONCURSOROBJ_LockIconCursor(hICObj) \ + ((PICONCURSOROBJ) GDIOBJ_LockObj ((HGDIOBJ) hICObj, GDI_OBJECT_TYPE_ICONCURSOR)) -#define ICONCURSOROBJ_ReleasePtr(hICObj) GDIOBJ_UnlockObj ((HGDIOBJ) hICObj, GO_ICONCURSOR_MAGIC) +#define ICONCURSOROBJ_UnlockIconCursor(hICObj) GDIOBJ_UnlockObj ((HGDIOBJ) hICObj, GDI_OBJECT_TYPE_ICONCURSOR) -BOOL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor ); +BOOL FASTCALL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor ); /* User Entry Points */ HICON diff --git a/reactos/include/win32k/dc.h b/reactos/include/win32k/dc.h index 8d6d905dfdc..551cec1fea5 100644 --- a/reactos/include/win32k/dc.h +++ b/reactos/include/win32k/dc.h @@ -119,15 +119,10 @@ typedef struct /* Internal functions */ -/* -#define DC_PtrToHandle(pDC) \ - ((HDC) GDIOBJ_PtrToHandle ((PGDIOBJ) pDC, GO_DC_MAGIC)) -*/ - -#define DC_HandleToPtr(hDC) \ - ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GO_DC_MAGIC)) -#define DC_ReleasePtr(hDC) \ - GDIOBJ_UnlockObj ((HGDIOBJ) hDC, GO_DC_MAGIC) +#define DC_LockDc(hDC) \ + ((PDC) GDIOBJ_LockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC)) +#define DC_UnlockDc(hDC) \ + GDIOBJ_UnlockObj ((HGDIOBJ) hDC, GDI_OBJECT_TYPE_DC) HDC FASTCALL RetrieveDisplayHDC(VOID); HDC FASTCALL DC_AllocDC(LPCWSTR Driver); diff --git a/reactos/include/win32k/gdiobj.h b/reactos/include/win32k/gdiobj.h index 443c2ea049c..9037206a36c 100644 --- a/reactos/include/win32k/gdiobj.h +++ b/reactos/include/win32k/gdiobj.h @@ -9,58 +9,31 @@ #include -/*! \defgroup GDI Magic +/*! \defgroup GDI object types * - * GDI object magic numbers + * GDI object types * */ -//@{ -#define GO_PEN_MAGIC 0x4f47 -#define GO_BRUSH_MAGIC 0x4f48 -#define GO_FONT_MAGIC 0x4f49 -#define GO_PALETTE_MAGIC 0x4f4a -#define GO_BITMAP_MAGIC 0x4f4b -#define GO_REGION_MAGIC 0x4f4c -#define GO_DC_MAGIC 0x4f4d -#define GO_DISABLED_DC_MAGIC 0x4f4e -#define GO_META_DC_MAGIC 0x4f4f -#define GO_METAFILE_MAGIC 0x4f50 -#define GO_METAFILE_DC_MAGIC 0x4f51 -#define GO_ENHMETAFILE_MAGIC 0x4f52 -#define GO_ENHMETAFILE_DC_MAGIC 0x4f53 -#define GO_DCE_MAGIC 0x4f54 -#define GO_ICONCURSOR_MAGIC 0x4f55 -#define GO_MAGIC_DONTCARE 0xffff -//@} -/* (RJJ) swiped stock handles from wine */ - /* First handle possible for stock objects (must be >= GDI_HEAP_SIZE) */ -#define FIRST_STOCK_HANDLE 0xffffff00 - -/*! Stock object handles */ -//@{ -#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1) -#define STOCK_WHITE_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+WHITE_BRUSH)) -#define STOCK_LTGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+LTGRAY_BRUSH)) -#define STOCK_GRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+GRAY_BRUSH)) -#define STOCK_DKGRAY_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+DKGRAY_BRUSH)) -#define STOCK_BLACK_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+BLACK_BRUSH)) -#define STOCK_NULL_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+NULL_BRUSH)) -#define STOCK_HOLLOW_BRUSH ((HBRUSH)(FIRST_STOCK_HANDLE+HOLLOW_BRUSH)) -#define STOCK_WHITE_PEN ((HPEN)(FIRST_STOCK_HANDLE+WHITE_PEN)) -#define STOCK_BLACK_PEN ((HPEN)(FIRST_STOCK_HANDLE+BLACK_PEN)) -#define STOCK_NULL_PEN ((HPEN)(FIRST_STOCK_HANDLE+NULL_PEN)) -#define STOCK_OEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+OEM_FIXED_FONT)) -#define STOCK_ANSI_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_FIXED_FONT)) -#define STOCK_ANSI_VAR_FONT ((HFONT)(FIRST_STOCK_HANDLE+ANSI_VAR_FONT)) -#define STOCK_SYSTEM_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FONT)) -#define STOCK_DEVICE_DEFAULT_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEVICE_DEFAULT_FONT)) -#define STOCK_DEFAULT_PALETTE ((HPALETTE)(FIRST_STOCK_HANDLE+DEFAULT_PALETTE)) -#define STOCK_SYSTEM_FIXED_FONT ((HFONT)(FIRST_STOCK_HANDLE+SYSTEM_FIXED_FONT)) -#define STOCK_DEFAULT_GUI_FONT ((HFONT)(FIRST_STOCK_HANDLE+DEFAULT_GUI_FONT)) -#define FIRST_STOCK_FONT STOCK_OEM_FIXED_FONT -#define LAST_STOCK_FONT STOCK_DEFAULT_GUI_FONT -#define LAST_STOCK_HANDLE ((DWORD)STOCK_DEFAULT_GUI_FONT) -//@} +/*@{*/ +#define GDI_OBJECT_TYPE_DC 0x00010000 +#define GDI_OBJECT_TYPE_REGION 0x00040000 +#define GDI_OBJECT_TYPE_BITMAP 0x00050000 +#define GDI_OBJECT_TYPE_PALETTE 0x00080000 +#define GDI_OBJECT_TYPE_FONT 0x000a0000 +#define GDI_OBJECT_TYPE_BRUSH 0x00100000 +#define GDI_OBJECT_TYPE_EMF 0x00210000 +#define GDI_OBJECT_TYPE_PEN 0x00300000 +#define GDI_OBJECT_TYPE_EXTPEN 0x00500000 +/* Following object types made up for ROS */ +#define GDI_OBJECT_TYPE_METADC 0x00710000 +#define GDI_OBJECT_TYPE_METAFILE 0x00720000 +#define GDI_OBJECT_TYPE_ENHMETAFILE 0x00730000 +#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000 +#define GDI_OBJECT_TYPE_MEMDC 0x00750000 +#define GDI_OBJECT_TYPE_ICONCURSOR 0x00760000 +#define GDI_OBJECT_TYPE_DCE 0x00770000 +#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000 +/*@}*/ /*! * GDI object header. This is a part of any GDI object @@ -68,16 +41,18 @@ typedef struct _GDIOBJHDR { WORD wTableIndex; - DWORD dwCount; /// reference count for the object + DWORD dwCount; /* reference count for the object */ } GDIOBJHDR, *PGDIOBJHDR; typedef PVOID PGDIOBJ; +typedef BOOL (FASTCALL *GDICLEANUPPROC)(PGDIOBJ Obj); + typedef struct _GDI_HANDLE_ENTRY { - WORD wMagic; - HANDLE hProcessId; - PGDIOBJ pObject; + GDICLEANUPPROC CleanupProc; + HANDLE hProcessId; + PGDIOBJ pObject; const char* lockfile; int lockline; } GDI_HANDLE_ENTRY, *PGDI_HANDLE_ENTRY; @@ -90,35 +65,33 @@ typedef struct _GDI_HANDLE_TABLE typedef struct _GDIMULTILOCK { - HGDIOBJ hObj; - PGDIOBJ pObj; - WORD Magic; + HGDIOBJ hObj; + PGDIOBJ pObj; + DWORD ObjectType; } GDIMULTILOCK, *PGDIMULTILOCK; -HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, WORD Magic); -BOOL STDCALL GDIOBJ_FreeObj (HGDIOBJ Obj, WORD Magic, DWORD Flag); -PGDIOBJ FASTCALL GDIOBJ_LockObj (HGDIOBJ Obj, WORD Magic); -BOOL FASTCALL GDIOBJ_LockMultipleObj( PGDIMULTILOCK pList, INT nObj ); -BOOL FASTCALL GDIOBJ_UnlockObj (HGDIOBJ Obj, WORD Magic); -BOOL FASTCALL GDIOBJ_UnlockMultipleObj( PGDIMULTILOCK pList, INT nObj ); -WORD FASTCALL GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle); -VOID STDCALL IntDumpGdiObjects( INT Pid ); +HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProcPtr); +BOOL STDCALL GDIOBJ_FreeObj (HGDIOBJ Obj, DWORD ObjectType, DWORD Flag); +PGDIOBJ FASTCALL GDIOBJ_LockObj (HGDIOBJ Obj, DWORD ObjectType); +BOOL FASTCALL GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj); +BOOL FASTCALL GDIOBJ_UnlockObj (HGDIOBJ Obj, DWORD ObjectType); +BOOL FASTCALL GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj); +DWORD FASTCALL GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle); -// a couple macros for debugging GDIOBJ locking -#define GDIOBJ_LockObj(obj,mag) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,mag) -#define GDIOBJ_UnlockObj(obj,mag) GDIOBJ_UnlockObjDbg(__FILE__,__LINE__,obj,mag) +/* a couple macros for debugging GDIOBJ locking */ +#define GDIOBJ_LockObj(obj,ty) GDIOBJ_LockObjDbg(__FILE__,__LINE__,obj,ty) +#define GDIOBJ_UnlockObj(obj,ty) GDIOBJ_UnlockObjDbg(__FILE__,__LINE__,obj,ty) #ifdef GDIOBJ_LockObj -PGDIOBJ FASTCALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ Obj, WORD Magic); -#endif//GDIOBJ_LockObj +PGDIOBJ FASTCALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType); +#endif /* GDIOBJ_LockObj */ #ifdef GDIOBJ_UnlockObj -BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ Obj, WORD Magic); -#endif//GDIOBJ_UnlockObj +BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType); +#endif /* GDIOBJ_UnlockObj */ #define GDIOBJFLAG_DEFAULT (0x0) #define GDIOBJFLAG_IGNOREPID (0x1) #define GDIOBJFLAG_IGNORELOCK (0x2) #endif - diff --git a/reactos/include/win32k/pen.h b/reactos/include/win32k/pen.h index f114f771287..0d9a8143550 100644 --- a/reactos/include/win32k/pen.h +++ b/reactos/include/win32k/pen.h @@ -13,16 +13,10 @@ typedef struct /* Internal interface */ #define PENOBJ_AllocPen() \ - ((HPEN) GDIOBJ_AllocObj (sizeof (PENOBJ), GO_PEN_MAGIC)) -#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GO_PEN_MAGIC, GDIOBJFLAG_DEFAULT) -/* -#define PENOBJ_HandleToPtr(hBMObj) \ - ((PPENOBJ) GDIOBJ_HandleToPtr ((HGDIOBJ) hBMObj, GO_PEN_MAGIC)) -#define PENOBJ_PtrToHandle(hBMObj) \ - ((HPEN) GDIOBJ_PtrToHandle ((PGDIOBJ) hBMObj, GO_PEN_MAGIC)) -*/ -#define PENOBJ_LockPen(hBMObj) ((PPENOBJ)GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GO_PEN_MAGIC)) -#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GO_PEN_MAGIC) + ((HPEN) GDIOBJ_AllocObj (sizeof (PENOBJ), GDI_OBJECT_TYPE_PEN, NULL)) +#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT) +#define PENOBJ_LockPen(hBMObj) ((PPENOBJ)GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)) +#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN) HPEN STDCALL NtGdiCreatePen(INT PenStyle, INT Width, diff --git a/reactos/include/win32k/region.h b/reactos/include/win32k/region.h index 1f0406d8657..840a3c79474 100644 --- a/reactos/include/win32k/region.h +++ b/reactos/include/win32k/region.h @@ -11,9 +11,9 @@ typedef struct _ROSRGNDATA { } ROSRGNDATA, *PROSRGNDATA, *LPROSRGNDATA; -#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GO_REGION_MAGIC, GDIOBJFLAG_DEFAULT) -#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GO_REGION_MAGIC)) -#define RGNDATA_UnlockRgn(hRgn) GDIOBJ_UnlockObj((HGDIOBJ)hRgn, GO_REGION_MAGIC) +#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION, GDIOBJFLAG_DEFAULT) +#define RGNDATA_LockRgn(hRgn) ((PROSRGNDATA)GDIOBJ_LockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)) +#define RGNDATA_UnlockRgn(hRgn) GDIOBJ_UnlockObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION) HRGN FASTCALL RGNDATA_AllocRgn(INT n); BOOL FASTCALL RGNDATA_InternalDelete( PROSRGNDATA Obj ); diff --git a/reactos/include/win32k/text.h b/reactos/include/win32k/text.h index f47fa1376a1..4fd4a16fcab 100644 --- a/reactos/include/win32k/text.h +++ b/reactos/include/win32k/text.h @@ -12,10 +12,10 @@ typedef struct /* Internal interface */ #define TEXTOBJ_AllocText() \ - ((HFONT) GDIOBJ_AllocObj (sizeof (TEXTOBJ), GO_FONT_MAGIC)) -#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GO_FONT_MAGIC, GDIOBJFLAG_DEFAULT) -#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GO_FONT_MAGIC)) -#define TEXTOBJ_UnlockText(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GO_FONT_MAGIC) + ((HFONT) GDIOBJ_AllocObj (sizeof (TEXTOBJ), GDI_OBJECT_TYPE_FONT, NULL)) +#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT, GDIOBJFLAG_DEFAULT) +#define TEXTOBJ_LockText(hBMObj) ((PTEXTOBJ) GDIOBJ_LockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)) +#define TEXTOBJ_UnlockText(hBMObj) GDIOBJ_UnlockObj ((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT) NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle); NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont); diff --git a/reactos/subsys/win32k/eng/mouse.c b/reactos/subsys/win32k/eng/mouse.c index 80d40d86d0d..f18c72b5d5a 100644 --- a/reactos/subsys/win32k/eng/mouse.c +++ b/reactos/subsys/win32k/eng/mouse.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: mouse.c,v 1.28 2003/08/19 11:48:49 weiden Exp $ +/* $Id: mouse.c,v 1.29 2003/08/20 07:45:01 gvg Exp $ * * PROJECT: ReactOS kernel * PURPOSE: Mouse @@ -232,10 +232,10 @@ MouseGDICallBack(PMOUSE_INPUT_DATA Data, ULONG InputCount) return; } - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface); SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); /* Compile the total mouse movement change and dispatch button events. */ for (i = 0; i < InputCount; i++) @@ -324,10 +324,10 @@ EnableMouse(HDC hDisplayDC) if( hDisplayDC ) { - dc = DC_HandleToPtr(hDisplayDC); + dc = DC_LockDc(hDisplayDC); SurfObj = (PSURFOBJ)AccessUserObject((ULONG) dc->Surface); SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) dc->Surface); - DC_ReleasePtr( hDisplayDC ); + DC_UnlockDc( hDisplayDC ); /* Create the default mouse cursor. */ mouse_width = 32; diff --git a/reactos/subsys/win32k/eng/surface.c b/reactos/subsys/win32k/eng/surface.c index 6cdccc1ac24..6bd47bb82e7 100644 --- a/reactos/subsys/win32k/eng/surface.c +++ b/reactos/subsys/win32k/eng/surface.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: surface.c,v 1.22 2003/08/04 19:57:47 royce Exp $ +/* $Id: surface.c,v 1.23 2003/08/20 07:45:01 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -341,7 +341,7 @@ EngLockSurface(IN HSURF Surface) * FIXME - don't know if GDIOBJ_LockObj's return value is a SURFOBJ or not... * also, what is HSURF's correct magic #? */ - GDIOBJ_LockObj ( Surface, GO_MAGIC_DONTCARE ); + GDIOBJ_LockObj ( Surface, GDI_OBJECT_TYPE_DONTCARE ); return (SURFOBJ*)AccessUserObject((ULONG)Surface); } @@ -354,6 +354,6 @@ EngUnlockSurface(IN SURFOBJ *Surface) /* * FIXME what is HSURF's correct magic #? */ - GDIOBJ_UnlockObj ( Surface->hsurf, GO_MAGIC_DONTCARE ); + GDIOBJ_UnlockObj ( Surface->hsurf, GDI_OBJECT_TYPE_DONTCARE ); } /* EOF */ diff --git a/reactos/subsys/win32k/include/dce.h b/reactos/subsys/win32k/include/dce.h index cbbba925a1f..edb75eb3bd3 100644 --- a/reactos/subsys/win32k/include/dce.h +++ b/reactos/subsys/win32k/include/dce.h @@ -34,10 +34,10 @@ typedef struct tagDCE #define DCEOBJ_AllocDCE() \ - ((HDCE) GDIOBJ_AllocObj (sizeof (DCE), GO_DCE_MAGIC)) -#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj((HGDIOBJ)hDCE, GO_DCE_MAGIC, GDIOBJFLAG_DEFAULT) -#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GO_DCE_MAGIC)) -#define DCEOBJ_UnlockDCE(hDCE) GDIOBJ_UnlockObj((HGDIOBJ)hDCE, GO_DCE_MAGIC) + ((HDCE) GDIOBJ_AllocObj (sizeof (DCE), GDI_OBJECT_TYPE_DCE, (GDICLEANUPPROC) DCE_InternalDelete)) +#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE, GDIOBJFLAG_DEFAULT) +#define DCEOBJ_LockDCE(hDCE) ((PDCE)GDIOBJ_LockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)) +#define DCEOBJ_UnlockDCE(hDCE) GDIOBJ_UnlockObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE) PDCE FASTCALL DCE_AllocDCE(HWND hWnd, DCE_TYPE type); // ??? PDCE FASTCALL DceAllocDCE(HWND hWnd, DCE_TYPE Type); diff --git a/reactos/subsys/win32k/ntuser/windc.c b/reactos/subsys/win32k/ntuser/windc.c index 78174163c26..b5c3109d0ca 100644 --- a/reactos/subsys/win32k/ntuser/windc.c +++ b/reactos/subsys/win32k/ntuser/windc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: windc.c,v 1.21 2003/08/19 11:48:50 weiden Exp $ +/* $Id: windc.c,v 1.22 2003/08/20 07:45:01 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -170,7 +170,7 @@ VOID STATIC STDCALL DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags, BOOL SetClipOrigin) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); if (WindowObject == NULL) { dc->w.DCOrgX = 0; @@ -189,7 +189,7 @@ DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags, dc->w.DCOrgY = WindowObject->ClientRect.top; } } - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); } diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 36d9c06af34..016f4bad6ce 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: winpos.c,v 1.25 2003/08/19 11:48:50 weiden Exp $ +/* $Id: winpos.c,v 1.26 2003/08/20 07:45:01 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -42,6 +42,7 @@ #include #include #include +#include #define NDEBUG #include @@ -696,6 +697,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, RECT NewWindowRect; RECT NewClientRect; HRGN VisRgn = NULL; + HRGN VisibleRgn = NULL; ULONG WvrFlags = 0; RECT OldWindowRect, OldClientRect; UINT FlagsEx = 0; @@ -792,11 +794,13 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, { if (Window->Style & WS_CLIPCHILDREN) { - VisRgn = DceGetVisRgn(Wnd, DCX_WINDOW | DCX_CLIPSIBLINGS, 0, 0); + VisRgn = VIS_ComputeVisibleRegion(PsGetWin32Thread()->Desktop, + Window, FALSE, FALSE, TRUE); } else { - VisRgn = DceGetVisRgn(Wnd, DCX_WINDOW, 0, 0); + VisRgn = VIS_ComputeVisibleRegion(PsGetWin32Thread()->Desktop, + Window, FALSE, FALSE, FALSE); } NtGdiOffsetRgn(VisRgn, -Window->WindowRect.left, -Window->WindowRect.top); } @@ -863,7 +867,11 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, if (WinPos.flags & SWP_HIDEWINDOW) { + VisibleRgn = VIS_ComputeVisibleRegion(PsGetWin32Thread()->Desktop, Window, + FALSE, FALSE, FALSE); Window->Style &= ~WS_VISIBLE; + VIS_WindowLayoutChanged(PsGetWin32Thread()->Desktop, Window, VisibleRgn); + NtGdiDeleteObject(VisibleRgn); } /* FIXME: Hide or show the claret */ @@ -921,6 +929,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) UINT Swp = 0; RECT NewPos; BOOLEAN ShowFlag; + HRGN VisibleRgn; Status = ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation->HandleTable, @@ -1024,7 +1033,11 @@ WinPosShowWindow(HWND Wnd, INT Cmd) { if (Cmd == SW_HIDE) { + VisibleRgn = VIS_ComputeVisibleRegion(PsGetWin32Thread()->Desktop, Window, + FALSE, FALSE, FALSE); Window->Style &= ~WS_VISIBLE; + VIS_WindowLayoutChanged(PsGetWin32Thread()->Desktop, Window, VisibleRgn); + NtGdiDeleteObject(VisibleRgn); } else { @@ -1139,8 +1152,6 @@ WinPosSearchChildren(PWINDOW_OBJECT ScopeWin, POINT Point, Point.y >= Current->ClientRect.top && Point.y < Current->ClientRect.bottom) { - Point.x -= Current->ClientRect.left; - Point.y -= Current->ClientRect.top; ExReleaseFastMutexUnsafe(&ScopeWin->ChildrenListLock); return(WinPosSearchChildren(Current, Point, Window)); @@ -1164,7 +1175,7 @@ WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, POINT WinPoint, PWINDOW_OBJECT DesktopWindow; POINT Point = WinPoint; USHORT HitTest; - + *Window = NULL; if (ScopeWin->Style & WS_DISABLED) diff --git a/reactos/subsys/win32k/objects/bitmaps.c b/reactos/subsys/win32k/objects/bitmaps.c index 1e98a201e98..c1510397319 100644 --- a/reactos/subsys/win32k/objects/bitmaps.c +++ b/reactos/subsys/win32k/objects/bitmaps.c @@ -16,10 +16,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: bitmaps.c,v 1.33 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: bitmaps.c,v 1.34 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include +#include #include //#include #include "../eng/handle.h" @@ -40,7 +41,7 @@ BOOL STDCALL NtGdiBitBlt(HDC hDCDest, INT YSrc, DWORD ROP) { - GDIMULTILOCK Lock[2] = {{hDCDest, 0, GO_DC_MAGIC}, {hDCSrc, 0, GO_DC_MAGIC}}; + GDIMULTILOCK Lock[2] = {{hDCDest, 0, GDI_OBJECT_TYPE_DC}, {hDCSrc, 0, GDI_OBJECT_TYPE_DC}}; PDC DCDest = NULL; PDC DCSrc = NULL; PSURFOBJ SurfDest, SurfSrc; @@ -171,7 +172,7 @@ HBITMAP STDCALL NtGdiCreateBitmap(INT Width, return 0; } - bmp = BITMAPOBJ_HandleToPtr( hBitmap ); + bmp = BITMAPOBJ_LockBitmap( hBitmap ); DPRINT("NtGdiCreateBitmap:%dx%d, %d (%d BPP) colors returning %08x\n", Width, Height, 1 << (Planes * BitsPerPel), BitsPerPel, bmp); @@ -196,7 +197,7 @@ HBITMAP STDCALL NtGdiCreateBitmap(INT Width, NtGdiSetBitmapBits(hBitmap, Height * bmp->bitmap.bmWidthBytes, Bits); } - BITMAPOBJ_ReleasePtr( hBitmap ); + BITMAPOBJ_UnlockBitmap( hBitmap ); return hBitmap; } @@ -237,7 +238,7 @@ HBITMAP STDCALL NtGdiCreateCompatibleBitmap(HDC hDC, PDC dc; hbmpRet = 0; - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc(hDC); DPRINT("NtGdiCreateCompatibleBitmap(%04x,%d,%d, bpp:%d) = \n", hDC, Width, Height, dc->w.bitsPerPixel); @@ -262,7 +263,7 @@ HBITMAP STDCALL NtGdiCreateCompatibleBitmap(HDC hDC, } } DPRINT ("\t\t%04x\n", hbmpRet); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return hbmpRet; } @@ -305,7 +306,7 @@ BOOL STDCALL NtGdiGetBitmapDimensionEx(HBITMAP hBitmap, { PBITMAPOBJ bmp; - bmp = BITMAPOBJ_HandleToPtr (hBitmap); + bmp = BITMAPOBJ_LockBitmap(hBitmap); if (bmp == NULL) { return FALSE; @@ -313,6 +314,8 @@ BOOL STDCALL NtGdiGetBitmapDimensionEx(HBITMAP hBitmap, *Dimension = bmp->size; + BITMAPOBJ_UnlockBitmap(hBitmap); + return TRUE; } @@ -360,7 +363,7 @@ LONG STDCALL NtGdiSetBitmapBits(HBITMAP hBitmap, LONG height, ret; PBITMAPOBJ bmp; - bmp = BITMAPOBJ_HandleToPtr (hBitmap); + bmp = BITMAPOBJ_LockBitmap(hBitmap); if (bmp == NULL || Bits == NULL) { return 0; @@ -433,7 +436,7 @@ BOOL STDCALL NtGdiSetBitmapDimensionEx(HBITMAP hBitmap, { PBITMAPOBJ bmp; - bmp = BITMAPOBJ_HandleToPtr (hBitmap); + bmp = BITMAPOBJ_LockBitmap(hBitmap); if (bmp == NULL) { return FALSE; @@ -522,7 +525,7 @@ HBITMAP FASTCALL BITMAPOBJ_CopyBitmap(HBITMAP hBitmap) HBITMAP res; BITMAP bm; - bmp = BITMAPOBJ_HandleToPtr (hBitmap); + bmp = BITMAPOBJ_LockBitmap(hBitmap); if (bmp == NULL) { return 0; diff --git a/reactos/subsys/win32k/objects/brush.c b/reactos/subsys/win32k/objects/brush.c index 142a73665d6..4fbd2b6f852 100644 --- a/reactos/subsys/win32k/objects/brush.c +++ b/reactos/subsys/win32k/objects/brush.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: brush.c,v 1.24 2003/08/19 11:48:50 weiden Exp $ +/* $Id: brush.c,v 1.25 2003/08/20 07:45:02 gvg Exp $ */ @@ -134,15 +134,15 @@ HBRUSH STDCALL NtGdiCreateDIBPatternBrushPt(CONST VOID *PackedDIB, } size += DIB_BitmapInfoSize (info, Usage); - logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GO_MAGIC_DONTCARE); + logbrush.lbHatch = (LONG) GDIOBJ_AllocObj(size, GDI_OBJECT_TYPE_DONTCARE, NULL); if (logbrush.lbHatch == 0) { return 0; } - newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE); + newInfo = (PBITMAPINFO) GDIOBJ_LockObj ((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE); ASSERT(newInfo); memcpy(newInfo, info, size); - GDIOBJ_UnlockObj( (HGDIOBJ) logbrush.lbHatch, GO_MAGIC_DONTCARE ); + GDIOBJ_UnlockObj((HGDIOBJ) logbrush.lbHatch, GDI_OBJECT_TYPE_DONTCARE); return NtGdiCreateBrushIndirect (&logbrush); } @@ -258,7 +258,7 @@ BOOL STDCALL NtGdiPolyPatBlt(HDC hDC, int i; PATRECT r; PBRUSHOBJ BrushObj; - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); if (dc == NULL) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -267,12 +267,12 @@ BOOL STDCALL NtGdiPolyPatBlt(HDC hDC, for (i = 0;iw.hBrush, GO_BRUSH_MAGIC); + BrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); ret = IntPatBlt(dc,XLeft,YLeft,Width,Height,ROP,BrushObj); - GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC ); - DC_ReleasePtr( hDC ); + BRUSHOBJ_UnlockBrush(dc->w.hBrush); + DC_UnlockDc( hDC ); return(ret); } diff --git a/reactos/subsys/win32k/objects/cliprgn.c b/reactos/subsys/win32k/objects/cliprgn.c index 8572c9abb5c..80144632c82 100644 --- a/reactos/subsys/win32k/objects/cliprgn.c +++ b/reactos/subsys/win32k/objects/cliprgn.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: cliprgn.c,v 1.20 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: cliprgn.c,v 1.21 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include @@ -88,7 +88,7 @@ HRGN WINAPI SaveVisRgn(HDC hdc) { HRGN copy; PROSRGNDATA obj, copyObj; - PDC dc = DC_HandleToPtr(hdc); + PDC dc = DC_LockDc(hdc); if (!dc) return 0; @@ -97,7 +97,7 @@ HRGN WINAPI SaveVisRgn(HDC hdc) if(!(copy = NtGdiCreateRectRgn(0, 0, 0, 0))) { RGNDATA_UnlockRgn(dc->w.hVisRgn); - DC_ReleasePtr(hdc); + DC_UnlockDc(hdc); return 0; } NtGdiCombineRgn(copy, dc->w.hVisRgn, 0, RGN_COPY); @@ -116,7 +116,7 @@ NtGdiSelectVisRgn(HDC hdc, HRGN hrgn) if (!hrgn) return ERROR; - if (!(dc = DC_HandleToPtr(hdc))) + if (!(dc = DC_LockDc(hdc))) return ERROR; dc->w.flags &= ~DC_DIRTY; @@ -128,7 +128,7 @@ NtGdiSelectVisRgn(HDC hdc, HRGN hrgn) retval = NtGdiCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY); CLIPPING_UpdateGCRegion(dc); - DC_ReleasePtr( hdc ); + DC_UnlockDc( hdc ); return retval; } @@ -155,7 +155,7 @@ int STDCALL NtGdiGetClipBox(HDC hDC, int retval; DC *dc; - if (!(dc = DC_HandleToPtr(hDC))) + if (!(dc = DC_LockDc(hDC))) return ERROR; retval = UnsafeIntGetRgnBox(dc->w.hGCClipRgn, rc); rc->left -= dc->w.DCOrgX; @@ -163,7 +163,7 @@ int STDCALL NtGdiGetClipBox(HDC hDC, rc->top -= dc->w.DCOrgY; rc->bottom -= dc->w.DCOrgY; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); NtGdiDPtoLP(hDC, (LPPOINT)rc, 2); return(retval); } @@ -216,7 +216,7 @@ int STDCALL NtGdiSelectClipRgn(HDC hDC, PDC dc; HRGN Copy; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (NULL == dc) { SetLastWin32Error(ERROR_INVALID_HANDLE); diff --git a/reactos/subsys/win32k/objects/color.c b/reactos/subsys/win32k/objects/color.c index 9c9f38e74a2..4e39d9293a4 100644 --- a/reactos/subsys/win32k/objects/color.c +++ b/reactos/subsys/win32k/objects/color.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: color.c,v 1.20 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: color.c,v 1.21 2003/08/20 07:45:02 gvg Exp $ */ // FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping @@ -198,7 +198,7 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC, PDC dc; PPALOBJ palObj; - if( (dc = DC_HandleToPtr(hDC) ) ) + if( (dc = DC_LockDc(hDC) ) ) { HPALETTE hpal = (dc->w.hPalette)? dc->w.hPalette : NtGdiGetStockObject(DEFAULT_PALETTE); palObj = (PPALOBJ)AccessUserObject((ULONG)hpal); @@ -211,7 +211,7 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC, palObj->logpalette->palNumEntries, Color); // FIXME: release hpal!! // GDI_ReleaseObj( hpal ); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); } return nearest; @@ -330,13 +330,13 @@ UINT STDCALL NtGdiRealizePalette(HDC hDC) PSURFGDI SurfGDI; BOOLEAN success; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) return 0; palPtr = (PPALOBJ)AccessUserObject((ULONG)dc->w.hPalette); SurfGDI = (PSURFGDI)AccessInternalObjectFromUserObject(dc->Surface); - systemPalette = NtGdiGetStockObject((INT)STOCK_DEFAULT_PALETTE); + systemPalette = NtGdiGetStockObject((INT)DEFAULT_PALETTE); sysPtr = (PPALOBJ)AccessInternalObject((ULONG)systemPalette); palGDI = (PPALGDI)AccessInternalObject((ULONG)dc->w.hPalette); sysGDI = (PPALGDI)AccessInternalObject((ULONG)systemPalette); @@ -436,11 +436,11 @@ HPALETTE STDCALL NtGdiSelectPalette(HDC hDC, HPALETTE oldPal; // FIXME: mark the palette as a [fore\back]ground pal - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if( dc ){ oldPal = dc->w.hPalette; dc->w.hPalette = hpal; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); } return oldPal; diff --git a/reactos/subsys/win32k/objects/coord.c b/reactos/subsys/win32k/objects/coord.c index 7f717b847a1..45d9e92bde7 100644 --- a/reactos/subsys/win32k/objects/coord.c +++ b/reactos/subsys/win32k/objects/coord.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: coord.c,v 1.16 2003/08/19 11:48:50 weiden Exp $ +/* $Id: coord.c,v 1.17 2003/08/20 07:45:02 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -101,7 +101,7 @@ NtGdiDPtoLP(HDC hDC, ASSERT(Points); MmCopyFromCaller( Points, UnsafePoints, Count*sizeof(POINT) ); - Dc = DC_HandleToPtr (hDC); + Dc = DC_LockDc (hDC); if (Dc == NULL || !Dc->w.vport2WorldValid) { return(FALSE); @@ -111,7 +111,7 @@ NtGdiDPtoLP(HDC hDC, { CoordDPtoLP(Dc, &Points[i]); } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); MmCopyToCaller( UnsafePoints, Points, Count*sizeof(POINT) ); return(TRUE); @@ -129,13 +129,13 @@ int STDCALL NtGdiGetGraphicsMode ( HDC hDC ) { - PDC dc = DC_HandleToPtr ( hDC ); + PDC dc = DC_LockDc ( hDC ); int GraphicsMode = 0; // default to failure if ( dc ) { GraphicsMode = dc->w.GraphicsMode; - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); } return GraphicsMode; @@ -148,7 +148,7 @@ NtGdiGetWorldTransform(HDC hDC, { PDC dc; - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc (hDC); if (!dc) { return FALSE; @@ -158,7 +158,7 @@ NtGdiGetWorldTransform(HDC hDC, return FALSE; } *XForm = dc->w.xformWorld2Wnd; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; } @@ -196,7 +196,7 @@ IntLPtoDP ( PDC dc, LPPOINT Points, INT Count ) BOOL STDCALL NtGdiLPtoDP ( HDC hDC, LPPOINT UnsafePoints, INT Count ) { - PDC dc = DC_HandleToPtr ( hDC ); + PDC dc = DC_LockDc ( hDC ); LPPOINT Points; if ( !dc ) @@ -214,7 +214,7 @@ NtGdiLPtoDP ( HDC hDC, LPPOINT UnsafePoints, INT Count ) ExFreePool ( Points ); - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); return TRUE; } @@ -232,7 +232,7 @@ NtGdiModifyWorldTransform(HDC hDC, MmCopyFromCaller( XForm, UnsafeXForm, sizeof( XFORM ) ); - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc (hDC); if (!dc) { // SetLastError( ERROR_INVALID_HANDLE ); @@ -268,11 +268,11 @@ NtGdiModifyWorldTransform(HDC hDC, break; default: - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return FALSE; } DC_UpdateXforms (dc); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; } @@ -287,7 +287,7 @@ NtGdiOffsetViewportOrgEx(HDC hDC, POINT Point; NTSTATUS Status; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (NULL == dc) { return FALSE; @@ -324,7 +324,7 @@ NtGdiOffsetWindowOrgEx(HDC hDC, { PDC dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return FALSE; @@ -339,7 +339,7 @@ NtGdiOffsetWindowOrgEx(HDC hDC, dc->wndOrgX += XOffset; dc->wndOrgY += YOffset; - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return TRUE; } @@ -376,7 +376,7 @@ NtGdiSetGraphicsMode(HDC hDC, INT ret; PDC dc; - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc (hDC); if (!dc) { return 0; @@ -390,13 +390,13 @@ NtGdiSetGraphicsMode(HDC hDC, if ((Mode != GM_COMPATIBLE) && (Mode != GM_ADVANCED)) { - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return 0; } ret = dc->w.GraphicsMode; dc->w.GraphicsMode = Mode; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return ret; } @@ -408,7 +408,7 @@ NtGdiSetMapMode(HDC hDC, int PrevMapMode; PDC dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return FALSE; @@ -429,7 +429,7 @@ NtGdiSetViewportExtEx(HDC hDC, { PDC dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return FALSE; @@ -443,7 +443,7 @@ NtGdiSetViewportExtEx(HDC hDC, case MM_LOMETRIC: case MM_TEXT: case MM_TWIPS: - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return FALSE; case MM_ISOTROPIC: @@ -461,7 +461,7 @@ NtGdiSetViewportExtEx(HDC hDC, dc->vportExtX = XExtent; dc->vportExtY = YExtent; - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return TRUE; } @@ -475,7 +475,7 @@ NtGdiSetViewportOrgEx(HDC hDC, { PDC dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return FALSE; @@ -490,7 +490,7 @@ NtGdiSetViewportOrgEx(HDC hDC, dc->vportOrgX = X; dc->vportOrgY = Y; - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return TRUE; } @@ -504,7 +504,7 @@ NtGdiSetWindowExtEx(HDC hDC, { PDC dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return FALSE; @@ -518,7 +518,7 @@ NtGdiSetWindowExtEx(HDC hDC, case MM_LOMETRIC: case MM_TEXT: case MM_TWIPS: - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return FALSE; } @@ -531,7 +531,7 @@ NtGdiSetWindowExtEx(HDC hDC, dc->wndExtX = XExtent; dc->wndExtY = YExtent; - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return TRUE; } @@ -545,7 +545,7 @@ NtGdiSetWindowOrgEx(HDC hDC, { PDC dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return FALSE; @@ -560,7 +560,7 @@ NtGdiSetWindowOrgEx(HDC hDC, dc->wndOrgX = X; dc->wndOrgY = Y; - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return TRUE; } @@ -572,26 +572,26 @@ NtGdiSetWorldTransform(HDC hDC, { PDC dc; - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc (hDC); if (!dc) { return FALSE; } if (!XForm) { - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return FALSE; } /* Check that graphics mode is GM_ADVANCED */ if (dc->w.GraphicsMode != GM_ADVANCED) { - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return FALSE; } dc->w.xformWorld2Wnd = *XForm; DC_UpdateXforms (dc); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; } diff --git a/reactos/subsys/win32k/objects/cursoricon.c b/reactos/subsys/win32k/objects/cursoricon.c index fbf0ede8bab..24aab0d21e0 100644 --- a/reactos/subsys/win32k/objects/cursoricon.c +++ b/reactos/subsys/win32k/objects/cursoricon.c @@ -7,7 +7,7 @@ #define NDEBUG #include -BOOL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor ) +BOOL FASTCALL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor ) { ASSERT( pIconCursor ); if( pIconCursor->ANDBitmap.bmBits ) @@ -52,7 +52,7 @@ HICON STDCALL NtGdiCreateIcon(BOOL fIcon, return 0; } - icon = ICONCURSOROBJ_HandleToPtr(hIcon); + icon = ICONCURSOROBJ_LockIconCursor(hIcon); /* Set up the basic icon stuff */ icon->fIcon = TRUE; @@ -92,7 +92,7 @@ HICON STDCALL NtGdiCreateIcon(BOOL fIcon, memcpy(icon->XORBitmap.bmBits, (PVOID)XORBits, Height * icon->XORBitmap.bmWidthBytes); } - ICONCURSOROBJ_ReleasePtr( hIcon ); + ICONCURSOROBJ_UnlockIconCursor( hIcon ); return hIcon; } @@ -109,11 +109,11 @@ NtUserGetIconInfo( { PICONCURSOROBJ icon; - icon = ICONCURSOROBJ_HandleToPtr(hIcon); + icon = ICONCURSOROBJ_LockIconCursor(hIcon); if (!icon) { - DbgPrint("NtUserGetIconInfo: ICONCURSOROBJ_HandleToPtr() returned 0\n"); + DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor() returned 0\n"); return FALSE; } @@ -133,7 +133,7 @@ NtUserGetIconInfo( icon->XORBitmap.bmBitsPixel, icon->XORBitmap.bmBits); - ICONCURSOROBJ_ReleasePtr(hIcon); + ICONCURSOROBJ_UnlockIconCursor(hIcon); if (!*hbmMask || !*hbmColor) return FALSE; diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index c0badd61d14..83c27f543dd 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dc.c,v 1.72 2003/08/19 11:48:50 weiden Exp $ +/* $Id: dc.c,v 1.73 2003/08/20 07:45:02 gvg Exp $ * * DC.C - Device context functions * @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -60,13 +61,13 @@ static BOOL PrimarySurfaceCreated = FALSE; func_type STDCALL func_name( HDC hdc ) \ { \ func_type ft; \ - PDC dc = DC_HandleToPtr( hdc ); \ + PDC dc = DC_LockDc( hdc ); \ if (!dc) \ { \ return 0; \ } \ ft = dc->dc_field; \ - DC_ReleasePtr( hdc ); \ + DC_UnlockDc( hdc ); \ return ft; \ } @@ -84,11 +85,11 @@ VOID FASTCALL IntFuncName ( PDC dc, LP##type pt ) \ } \ BOOL STDCALL NtGdiFuncName ( HDC hdc, LP##type pt ) \ { \ - PDC dc = DC_HandleToPtr ( hdc ); \ + PDC dc = DC_LockDc ( hdc ); \ if ( !dc ) \ return FALSE; \ IntFuncName ( dc, pt ); \ - DC_ReleasePtr ( hdc ); \ + DC_UnlockDc ( hdc ); \ return TRUE; \ } @@ -99,12 +100,12 @@ INT STDCALL func_name( HDC hdc, INT mode ) \ PDC dc; \ if ((mode < min_val) || (mode > max_val)) \ return 0; \ - dc = DC_HandleToPtr ( hdc ); \ + dc = DC_LockDc ( hdc ); \ if ( !dc ) \ return 0; \ prevMode = dc->dc_field; \ dc->dc_field = mode; \ - DC_ReleasePtr ( hdc ); \ + DC_UnlockDc ( hdc ); \ return prevMode; \ } @@ -130,19 +131,19 @@ NtGdiCreateCompatableDC(HDC hDC) HDC hNewDC; HRGN hVisRgn; - OrigDC = DC_HandleToPtr(hDC); + OrigDC = DC_LockDc(hDC); if (OrigDC == NULL) { hNewDC = DC_AllocDC(L"DISPLAY"); if( hNewDC ) - NewDC = DC_HandleToPtr( hNewDC ); + NewDC = DC_LockDc( hNewDC ); } else { /* Allocate a new DC based on the original DC's device */ hNewDC = DC_AllocDC(OrigDC->DriverName); if( hNewDC ) - NewDC = DC_HandleToPtr( hNewDC ); + NewDC = DC_LockDc( hNewDC ); } if (NewDC == NULL) @@ -189,7 +190,7 @@ NtGdiCreateCompatableDC(HDC hDC) /* Create default bitmap */ if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, 1, NULL ))) { - DC_ReleasePtr( hNewDC ); + DC_UnlockDc( hNewDC ); DC_FreeDC( hNewDC ); return NULL; } @@ -197,7 +198,7 @@ NtGdiCreateCompatableDC(HDC hDC) NewDC->w.bitsPerPixel = 1; NewDC->w.hBitmap = hBitmap; NewDC->w.hFirstBitmap = hBitmap; - NewDC->Surface = BitmapToSurf(BITMAPOBJ_HandleToPtr(hBitmap)); + NewDC->Surface = BitmapToSurf(BITMAPOBJ_LockBitmap(hBitmap)); if(OrigDC != NULL) { @@ -205,8 +206,8 @@ NtGdiCreateCompatableDC(HDC hDC) NewDC->w.textColor = OrigDC->w.textColor; NewDC->w.textAlign = OrigDC->w.textAlign; } - DC_ReleasePtr( hDC ); - DC_ReleasePtr( hNewDC ); + DC_UnlockDc( hDC ); + DC_UnlockDc( hNewDC ); hVisRgn = NtGdiCreateRectRgn(0, 0, 1, 1); NtGdiSelectVisRgn(hNewDC, hVisRgn); @@ -429,7 +430,7 @@ NtGdiCreateDC(LPCWSTR Driver, return NULL; } - NewDC = DC_HandleToPtr( hNewDC ); + NewDC = DC_LockDc( hNewDC ); ASSERT( NewDC ); if (! PrimarySurfaceCreated) @@ -438,7 +439,7 @@ NtGdiCreateDC(LPCWSTR Driver, if (!NtGdiCreatePrimarySurface(Driver, Device)) { PrimarySurfaceCreated = FALSE; - DC_ReleasePtr( hNewDC ); + DC_UnlockDc( hNewDC ); DC_FreeDC(hNewDC); return NULL; } @@ -471,7 +472,7 @@ NtGdiCreateDC(LPCWSTR Driver, DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel); - DC_ReleasePtr( hNewDC ); + DC_UnlockDc( hNewDC ); hVisRgn = NtGdiCreateRectRgn(0, 0, SurfGDI->SurfObj.sizlBitmap.cx, SurfGDI->SurfObj.sizlBitmap.cy); @@ -501,7 +502,7 @@ NtGdiDeleteDC(HDC DCHandle) { PDC DCToDelete; - DCToDelete = DC_HandleToPtr(DCHandle); + DCToDelete = DC_LockDc(DCHandle); if (DCToDelete == NULL) { return FALSE; @@ -541,14 +542,14 @@ NtGdiDeleteDC(HDC DCHandle) HDC savedHDC; savedHDC = DC_GetNextDC (DCToDelete); - savedDC = DC_HandleToPtr (savedHDC); + savedDC = DC_LockDc (savedHDC); if (savedDC == NULL) { break; } DC_SetNextDC (DCToDelete, DC_GetNextDC (savedDC)); DCToDelete->saveLevel--; - DC_ReleasePtr( savedHDC ); + DC_UnlockDc( savedHDC ); NtGdiDeleteDC (savedHDC); } @@ -562,7 +563,7 @@ NtGdiDeleteDC(HDC DCHandle) DC_LockDC (DCHandle); NtGdiSelectObject does not recognize stock objects yet */ if ( DCToDelete->w.hBitmap != NULL ) { - BITMAPOBJ_ReleasePtr(DCToDelete->w.hBitmap); + BITMAPOBJ_UnlockBitmap(DCToDelete->w.hBitmap); } if (DCToDelete->w.flags & DC_MEMORY) { @@ -589,7 +590,7 @@ NtGdiDeleteDC(HDC DCHandle) #if 0 /* FIXME */ PATH_DestroyGdiPath (&DCToDelete->w.path); #endif - DC_ReleasePtr( DCHandle ); + DC_UnlockDc( DCHandle ); DC_FreeDC ( DCHandle ); return TRUE; @@ -635,7 +636,7 @@ NtGdiGetDCOrgEx(HDC hDC, LPPOINT Point) { return FALSE; } - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (dc == NULL) { return FALSE; @@ -645,7 +646,7 @@ NtGdiGetDCOrgEx(HDC hDC, LPPOINT Point) Point->x += dc->w.DCOrgX; Point->y += dc->w.DCOrgY; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; } @@ -655,7 +656,7 @@ NtGdiGetDCState16(HDC hDC) PDC newdc, dc; HDC hnewdc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (dc == NULL) { return 0; @@ -664,10 +665,10 @@ NtGdiGetDCState16(HDC hDC) hnewdc = DC_AllocDC(NULL); if (hnewdc == NULL) { - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return 0; } - newdc = DC_HandleToPtr( hnewdc ); + newdc = DC_LockDc( hnewdc ); ASSERT( newdc ); newdc->w.flags = dc->w.flags | DC_SAVED; @@ -743,7 +744,7 @@ NtGdiGetDCState16(HDC hDC) { newdc->w.hClipRgn = 0; } - DC_ReleasePtr( hnewdc ); + DC_UnlockDc( hnewdc ); return hnewdc; } @@ -755,7 +756,7 @@ NtGdiGetDeviceCaps(HDC hDC, INT ret; POINT pt; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (dc == NULL) { return 0; @@ -949,7 +950,7 @@ NtGdiGetDeviceCaps(HDC hDC, DPRINT("(%04x,%d): returning %d\n", hDC, Index, ret); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return ret; } @@ -961,27 +962,27 @@ NtGdiGetObjectA(HANDLE handle, INT count, LPVOID buffer) { PGDIOBJ gdiObject; INT result = 0; - WORD magic; + DWORD objectType; if (!count) return 0; - gdiObject = GDIOBJ_LockObj (handle, GO_MAGIC_DONTCARE); + gdiObject = GDIOBJ_LockObj (handle, GDI_OBJECT_TYPE_DONTCARE); if (gdiObject == 0) return 0; - magic = GDIOBJ_GetHandleMagic (handle); - switch(magic) + objectType = GDIOBJ_GetObjectType(handle); + switch(objectType) { -/* case GO_PEN_MAGIC: +/* case GDI_OBJECT_TYPE_PEN: result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer); break; - case GO_BRUSH_MAGIC: + case GDI_OBJECT_TYPE_BRUSH: result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer); break; */ - case GO_BITMAP_MAGIC: + case GDI_OBJECT_TYPE_BITMAP: result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer); break; -/* case GO_FONT_MAGIC: +/* case GDI_OBJECT_TYPE_FONT: result = FONT_GetObjectA((FONTOBJ *)gdiObject, count, buffer); // FIXME: Fix the LOGFONT structure for the stock fonts @@ -989,27 +990,26 @@ NtGdiGetObjectA(HANDLE handle, INT count, LPVOID buffer) if ( (handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE) ) FixStockFontSizeA(handle, count, buffer); break; - case GO_PALETTE_MAGIC: + case GDI_OBJECT_TYPE_PALETTE: result = PALETTE_GetObject((PALETTEOBJ *)gdiObject, count, buffer); break; */ - case GO_REGION_MAGIC: - case GO_DC_MAGIC: - case GO_DISABLED_DC_MAGIC: - case GO_META_DC_MAGIC: - case GO_METAFILE_MAGIC: - case GO_METAFILE_DC_MAGIC: - case GO_ENHMETAFILE_MAGIC: - case GO_ENHMETAFILE_DC_MAGIC: - // FIXME("Magic %04x not implemented\n", magic); + case GDI_OBJECT_TYPE_REGION: + case GDI_OBJECT_TYPE_DC: + case GDI_OBJECT_TYPE_METADC: + case GDI_OBJECT_TYPE_METAFILE: + case GDI_OBJECT_TYPE_ENHMETADC: + case GDI_OBJECT_TYPE_EMF: + DPRINT1("GDI object type 0x%08x not implemented\n", objectType); break; default: - DbgPrint("Invalid GDI Magic %04x\n", magic); + DPRINT1("Invalid GDI object type 0x%08x\n", objectType); break; } - GDIOBJ_UnlockObj (handle, GO_MAGIC_DONTCARE); - return result; + GDIOBJ_UnlockObj(handle, GDI_OBJECT_TYPE_DONTCARE); + + return result; } INT STDCALL @@ -1017,27 +1017,27 @@ NtGdiGetObjectW(HANDLE handle, INT count, LPVOID buffer) { PGDIOBJHDR gdiObject; INT result = 0; - WORD magic; + DWORD objectType; if (!count) return 0; - gdiObject = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE); + gdiObject = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE); if (gdiObject == 0) return 0; - magic = GDIOBJ_GetHandleMagic (handle); - switch(magic) + objectType = GDIOBJ_GetObjectType(handle); + switch(objectType) { -/* case GO_PEN_MAGIC: +/* case GDI_OBJECT_TYPE_PEN: result = PEN_GetObject((PENOBJ *)gdiObject, count, buffer); break; - case GO_BRUSH_MAGIC: + case GDI_OBJECT_TYPE_BRUSH: result = BRUSH_GetObject((BRUSHOBJ *)gdiObject, count, buffer); break; */ - case GO_BITMAP_MAGIC: + case GDI_OBJECT_TYPE_BITMAP: result = BITMAP_GetObject((BITMAPOBJ *)gdiObject, count, buffer); break; -/* case GO_FONT_MAGIC: +/* case GDI_OBJECT_TYPE_FONT: result = FONT_GetObjectW((FONTOBJ *)gdiObject, count, buffer); // Fix the LOGFONT structure for the stock fonts @@ -1045,15 +1045,17 @@ NtGdiGetObjectW(HANDLE handle, INT count, LPVOID buffer) if ( (handle >= FIRST_STOCK_HANDLE) && (handle <= LAST_STOCK_HANDLE) ) FixStockFontSizeW(handle, count, buffer); break; - case GO_PALETTE_MAGIC: + case GDI_OBJECT_TYPE_PALETTE: result = PALETTE_GetObject((PALETTEOBJ *)gdiObject, count, buffer); break; */ default: - // FIXME("Magic %04x not implemented\n", gdiObject->magic); + DPRINT1("GDI object type 0x%08x not implemented\n", objectType); break; } - GDIOBJ_UnlockObj(handle, GO_MAGIC_DONTCARE); - return result; + + GDIOBJ_UnlockObj(handle, GDI_OBJECT_TYPE_DONTCARE); + + return result; } INT STDCALL @@ -1067,56 +1069,59 @@ NtGdiGetObjectType(HANDLE handle) { GDIOBJHDR * ptr; INT result = 0; - WORD magic; + DWORD objectType; - ptr = GDIOBJ_LockObj(handle, GO_MAGIC_DONTCARE); + ptr = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE); if (ptr == 0) return 0; - magic = GDIOBJ_GetHandleMagic (handle); - switch(magic) + objectType = GDIOBJ_GetObjectType(handle); + switch(objectType) { - case GO_PEN_MAGIC: + case GDI_OBJECT_TYPE_PEN: result = OBJ_PEN; break; - case GO_BRUSH_MAGIC: + case GDI_OBJECT_TYPE_BRUSH: result = OBJ_BRUSH; break; - case GO_BITMAP_MAGIC: + case GDI_OBJECT_TYPE_BITMAP: result = OBJ_BITMAP; break; - case GO_FONT_MAGIC: + case GDI_OBJECT_TYPE_FONT: result = OBJ_FONT; break; - case GO_PALETTE_MAGIC: + case GDI_OBJECT_TYPE_PALETTE: result = OBJ_PAL; break; - case GO_REGION_MAGIC: + case GDI_OBJECT_TYPE_REGION: result = OBJ_REGION; break; - case GO_DC_MAGIC: + case GDI_OBJECT_TYPE_DC: result = OBJ_DC; break; - case GO_META_DC_MAGIC: + case GDI_OBJECT_TYPE_METADC: result = OBJ_METADC; break; - case GO_METAFILE_MAGIC: + case GDI_OBJECT_TYPE_METAFILE: result = OBJ_METAFILE; break; - case GO_METAFILE_DC_MAGIC: - result = OBJ_METADC; - break; - case GO_ENHMETAFILE_MAGIC: + case GDI_OBJECT_TYPE_ENHMETAFILE: result = OBJ_ENHMETAFILE; break; - case GO_ENHMETAFILE_DC_MAGIC: + case GDI_OBJECT_TYPE_ENHMETADC: result = OBJ_ENHMETADC; break; + case GDI_OBJECT_TYPE_EXTPEN: + result = OBJ_EXTPEN; + break; + case GDI_OBJECT_TYPE_MEMDC: + result = OBJ_MEMDC; + break; default: - // FIXME("Magic %04x not implemented\n", magic); + DPRINT1("Magic 0x%08x not implemented\n", objectType); break; } - GDIOBJ_UnlockObj(handle, GO_MAGIC_DONTCARE); + GDIOBJ_UnlockObj(handle, GDI_OBJECT_TYPE_DONTCARE); return result; } @@ -1142,7 +1147,7 @@ NtGdiRestoreDC(HDC hDC, INT SaveLevel) PDC dc, dcs; BOOL success; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if(!dc) { return FALSE; @@ -1163,7 +1168,7 @@ NtGdiRestoreDC(HDC hDC, INT SaveLevel) { HDC hdcs = DC_GetNextDC (dc); - dcs = DC_HandleToPtr (hdcs); + dcs = DC_LockDc (hdcs); if (dcs == NULL) { return FALSE; @@ -1181,10 +1186,10 @@ NtGdiRestoreDC(HDC hDC, INT SaveLevel) } #endif } - DC_ReleasePtr( hdcs ); + DC_UnlockDc( hdcs ); NtGdiDeleteDC (hdcs); } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return success; } @@ -1195,7 +1200,7 @@ NtGdiSaveDC(HDC hDC) PDC dc, dcs; INT ret; - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc (hDC); if (dc == NULL) { return 0; @@ -1205,7 +1210,7 @@ NtGdiSaveDC(HDC hDC) { return 0; } - dcs = DC_HandleToPtr (hdcs); + dcs = DC_LockDc (hdcs); #if 0 /* Copy path. The reason why path saving / restoring is in SaveDC/ @@ -1224,8 +1229,8 @@ NtGdiSaveDC(HDC hDC) DC_SetNextDC (dcs, DC_GetNextDC (dc)); DC_SetNextDC (dc, hdcs); ret = ++dc->saveLevel; - DC_ReleasePtr( hdcs ); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hdcs ); + DC_UnlockDc( hDC ); return ret; } @@ -1241,24 +1246,24 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) PBRUSHOBJ brush; PXLATEOBJ XlateObj; PPALGDI PalGDI; - WORD objectMagic; + DWORD objectType; COLORREF *ColorMap; ULONG NumColors, Index; HRGN hVisRgn; if(!hDC || !hGDIObj) return NULL; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); ASSERT ( dc ); - objectMagic = GDIOBJ_GetHandleMagic (hGDIObj); + objectType = GDIOBJ_GetObjectType(hGDIObj); // GdiObjHdr = hGDIObj; // FIXME: Get object handle from GDIObj and use it instead of GDIObj below? - switch ( objectMagic ) + switch (objectType) { - case GO_PEN_MAGIC: + case GDI_OBJECT_TYPE_PEN: objOrg = (HGDIOBJ)dc->w.hPen; dc->w.hPen = hGDIObj; @@ -1268,17 +1273,17 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) { XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL); ASSERT ( XlateObj ); - pen = GDIOBJ_LockObj(dc->w.hPen, GO_PEN_MAGIC); + pen = PENOBJ_LockPen(dc->w.hPen); if( pen ) { pen->logpen.lopnColor = XLATEOBJ_iXlate(XlateObj, pen->logpen.lopnColor); - GDIOBJ_UnlockObj( dc->w.hPen, GO_PEN_MAGIC); + PENOBJ_UnlockPen(dc->w.hPen); } EngDeleteXlate(XlateObj); } break; - case GO_BRUSH_MAGIC: + case GDI_OBJECT_TYPE_BRUSH: objOrg = (HGDIOBJ)dc->w.hBrush; dc->w.hBrush = (HBRUSH) hGDIObj; @@ -1288,32 +1293,32 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) { XlateObj = (PXLATEOBJ)IntEngCreateXlate(PalGDI->Mode, PAL_RGB, dc->w.hPalette, NULL); ASSERT(XlateObj); - brush = GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + brush = BRUSHOBJ_LockBrush(dc->w.hBrush); if( brush ) { brush->iSolidColor = XLATEOBJ_iXlate(XlateObj, brush->logbrush.lbColor); } - GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC); + BRUSHOBJ_UnlockBrush(dc->w.hBrush); EngDeleteXlate(XlateObj); } break; - case GO_FONT_MAGIC: + case GDI_OBJECT_TYPE_FONT: objOrg = (HGDIOBJ)dc->w.hFont; dc->w.hFont = (HFONT) hGDIObj; TextIntRealizeFont(dc->w.hFont); break; - case GO_BITMAP_MAGIC: + case GDI_OBJECT_TYPE_BITMAP: // must be memory dc to select bitmap if (!(dc->w.flags & DC_MEMORY)) return NULL; objOrg = (HGDIOBJ)dc->w.hBitmap; /* Release the old bitmap, lock the new one and convert it to a SURF */ EngDeleteSurface(dc->Surface); - BITMAPOBJ_ReleasePtr(objOrg); + BITMAPOBJ_UnlockBitmap(objOrg); dc->w.hBitmap = hGDIObj; - pb = BITMAPOBJ_HandleToPtr(hGDIObj); + pb = BITMAPOBJ_LockBitmap(hGDIObj); ASSERT(pb); dc->Surface = BitmapToSurf(pb); @@ -1353,7 +1358,7 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) dc->w.bitsPerPixel = pb->bitmap.bmBitsPixel; } - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); hVisRgn = NtGdiCreateRectRgn ( 0, 0, pb->size.cx, pb->size.cy ); NtGdiSelectVisRgn ( hDC, hVisRgn ); NtGdiDeleteObject ( hVisRgn ); @@ -1361,15 +1366,15 @@ NtGdiSelectObject(HDC hDC, HGDIOBJ hGDIObj) return objOrg; #if UPDATEREGIONS - case GO_REGION_MAGIC: - DC_ReleasePtr ( hDC ); + case GDI_OBJECT_TYPE_REGION: + DC_UnlockDc ( hDC ); SelectClipRgn(hDC, (HRGN)hGDIObj); return NULL; #endif default: break; } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return objOrg; } @@ -1383,14 +1388,14 @@ COLORREF STDCALL NtGdiSetBkColor(HDC hDC, COLORREF color) { COLORREF oldColor; - PDC dc = DC_HandleToPtr(hDC); + PDC dc = DC_LockDc(hDC); if ( !dc ) return 0x80000000; oldColor = dc->w.backgroundColor; dc->w.backgroundColor = color; - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); return oldColor; } @@ -1401,10 +1406,10 @@ NtGdiSetDCState16 ( HDC hDC, HDC hDCSave ) { PDC dc, dcs; - dc = DC_HandleToPtr ( hDC ); + dc = DC_LockDc ( hDC ); if ( dc ) { - dcs = DC_HandleToPtr ( hDCSave ); + dcs = DC_LockDc ( hDCSave ); if ( dcs ) { if ( dcs->w.flags & DC_SAVED ) @@ -1498,9 +1503,9 @@ NtGdiSetDCState16 ( HDC hDC, HDC hDCSave ) #endif } - DC_ReleasePtr ( hDCSave ); + DC_UnlockDc ( hDCSave ); } - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); } } @@ -1512,13 +1517,13 @@ DC_AllocDC(LPCWSTR Driver) PDC NewDC; HDC hDC; - hDC = (HDC) GDIOBJ_AllocObj(sizeof(DC), GO_DC_MAGIC); + hDC = (HDC) GDIOBJ_AllocObj(sizeof(DC), GDI_OBJECT_TYPE_DC, (GDICLEANUPPROC) DC_InternalDeleteDC); if (hDC == NULL) { return NULL; } - NewDC = (PDC) GDIOBJ_LockObj( hDC, GO_DC_MAGIC ); + NewDC = DC_LockDc(hDC); if (Driver != NULL) { @@ -1539,7 +1544,8 @@ DC_AllocDC(LPCWSTR Driver) NewDC->w.hFont = NtGdiGetStockObject(SYSTEM_FONT); TextIntRealizeFont(NewDC->w.hFont); - GDIOBJ_UnlockObj( hDC, GO_DC_MAGIC ); + DC_UnlockDc(hDC); + return hDC; } @@ -1568,7 +1574,7 @@ DC_InitDC(HDC DCHandle) VOID FASTCALL DC_FreeDC(HDC DCToFree) { - if (!GDIOBJ_FreeObj(DCToFree, GO_DC_MAGIC, GDIOBJFLAG_DEFAULT)) + if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC, GDIOBJFLAG_DEFAULT)) { DPRINT("DC_FreeDC failed\n"); } @@ -1577,9 +1583,12 @@ DC_FreeDC(HDC DCToFree) BOOL FASTCALL DC_InternalDeleteDC( PDC DCToDelete ) { - if( DCToDelete->DriverName ) - ExFreePool(DCToDelete->DriverName); - return TRUE; + if( DCToDelete->DriverName ) + { + ExFreePool(DCToDelete->DriverName); + } + + return TRUE; } HDC FASTCALL diff --git a/reactos/subsys/win32k/objects/dib.c b/reactos/subsys/win32k/objects/dib.c index f6a847ada62..2014b545157 100644 --- a/reactos/subsys/win32k/objects/dib.c +++ b/reactos/subsys/win32k/objects/dib.c @@ -1,5 +1,5 @@ /* - * $Id: dib.c,v 1.27 2003/08/19 11:48:50 weiden Exp $ + * $Id: dib.c,v 1.28 2003/08/20 07:45:02 gvg Exp $ * * ReactOS W32 Subsystem * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team @@ -113,12 +113,12 @@ NtGdiSetDIBits( INT scanDirection = 1, DIBWidth; // Check parameters - if (!(dc = DC_HandleToPtr(hDC))) + if (!(dc = DC_LockDc(hDC))) return 0; - if (!(bitmap = (BITMAPOBJ *)GDIOBJ_LockObj(hBitmap, GO_BITMAP_MAGIC))) + if (!(bitmap = BITMAPOBJ_LockBitmap(hBitmap))) { - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return 0; } @@ -193,9 +193,8 @@ NtGdiSetDIBits( // if (ColorUse == DIB_PAL_COLORS) // WinFree((LPSTR)lpRGB); -// GDI_ReleaseObj(hBitmap); unlock? - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); - DC_ReleasePtr(hDC); + BITMAPOBJ_UnlockBitmap(hBitmap); + DC_UnlockDc(hDC); return result; } @@ -251,7 +250,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, DWORD *BitField; DWORD InfoSize; - BitmapObj = (PBITMAPOBJ) GDIOBJ_LockObj(hBitmap, GO_BITMAP_MAGIC); + BitmapObj = BITMAPOBJ_LockBitmap(hBitmap); if (NULL == BitmapObj) { SetLastWin32Error(ERROR_INVALID_HANDLE); @@ -265,7 +264,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } @@ -276,7 +275,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, NULL != Bits)) { SetLastWin32Error(ERROR_INVALID_PARAMETER); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } @@ -286,7 +285,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } @@ -324,7 +323,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } Result = 1; @@ -341,18 +340,18 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } RtlZeroMemory(&InfoWithBitFields, sizeof(InfoWithBitFields)); RtlCopyMemory(&(InfoWithBitFields.Info), &Info, sizeof(BITMAPINFO)); if (BI_BITFIELDS == Info.bmiHeader.biCompression) { - DCObj = DC_HandleToPtr(hDC); + DCObj = DC_LockDc(hDC); if (NULL == DCObj) { SetLastWin32Error(ERROR_INVALID_HANDLE); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } PalGdi = (PPALGDI) AccessInternalObject((ULONG) DCObj->w.hPalette); @@ -361,7 +360,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, BitField[1] = PalGdi->GreenMask; BitField[2] = PalGdi->BlueMask; InfoSize = InfoWithBitFields.Info.bmiHeader.biSize + 3 * sizeof(DWORD); - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); } else { @@ -371,7 +370,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, if (! NT_SUCCESS(Status)) { SetLastNtError(Status); - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return 0; } } @@ -380,7 +379,7 @@ INT STDCALL NtGdiGetDIBits(HDC hDC, UNIMPLEMENTED; } - GDIOBJ_UnlockObj(hBitmap, GO_BITMAP_MAGIC); + BITMAPOBJ_UnlockBitmap(hBitmap); return Result; } @@ -409,7 +408,7 @@ LONG STDCALL NtGdiGetBitmapBits(HBITMAP hBitmap, PBITMAPOBJ bmp; LONG height, ret; - bmp = BITMAPOBJ_HandleToPtr (hBitmap); + bmp = BITMAPOBJ_LockBitmap (hBitmap); if (!bmp) { return 0; @@ -580,11 +579,11 @@ HBITMAP STDCALL NtGdiCreateDIBSection(HDC hDC, bDesktopDC = TRUE; } - if ((dc = DC_HandleToPtr(hDC))) + if ((dc = DC_LockDc(hDC))) { hbitmap = DIB_CreateDIBSection ( dc, (BITMAPINFO*)bmi, Usage, Bits, hSection, dwOffset, 0); - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); } if (bDesktopDC) @@ -692,7 +691,7 @@ DIB_CreateDIBSection( res = NtGdiCreateDIBitmap(dc->hSelf, bi, 0, NULL, bmi, usage); if (res) { - bmp = BITMAPOBJ_HandleToPtr (res); + bmp = BITMAPOBJ_LockBitmap(res); if (bmp) { bmp->dib = (DIBSECTION *) dib; @@ -727,12 +726,12 @@ DIB_CreateDIBSection( if (dib) { ExFreePool(dib); dib = NULL; } if (bmp) { bmp = NULL; } - if (res) { GDIOBJ_FreeObj(res, GO_BITMAP_MAGIC, GDIOBJFLAG_DEFAULT); res = 0; } + if (res) { BITMAPOBJ_FreeBitmap(res); res = 0; } } if (bmp) { - BITMAPOBJ_ReleasePtr(res); + BITMAPOBJ_UnlockBitmap(res); } // Return BITMAP handle and storage location @@ -860,7 +859,7 @@ PBITMAPOBJ FASTCALL DIBtoDDB(HGLOBAL hPackedDIB, HDC hdc) // FIXME: This should // GlobalUnlock(hPackedDIB); // Retrieve the internal Pixmap from the DDB - pBmp = (BITMAPOBJ *)GDIOBJ_LockObj(hBmp, GO_BITMAP_MAGIC); + pBmp = BITMAPOBJ_LockBitmap(hBmp); return pBmp; } diff --git a/reactos/subsys/win32k/objects/fillshap.c b/reactos/subsys/win32k/objects/fillshap.c index 3659b7bc68e..fd986be7b70 100644 --- a/reactos/subsys/win32k/objects/fillshap.c +++ b/reactos/subsys/win32k/objects/fillshap.c @@ -16,14 +16,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: fillshap.c,v 1.26 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: fillshap.c,v 1.27 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include #include +#include #include #include +#include #include #include #include @@ -140,7 +142,7 @@ IntPolygon(PDC dc, Points[CurrentPoint].y += dc->w.DCOrgY; } - RectBounds = GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC); + RectBounds = (PRECTL) RGNDATA_LockRgn(dc->w.hGCClipRgn); //ei not yet implemented ASSERT(RectBounds); if (PATH_IsPathOpen(dc->w.path)) @@ -162,11 +164,11 @@ IntPolygon(PDC dc, #if 1 /* Now fill the polygon with the current brush. */ - FillBrushObj = (BRUSHOBJ*) GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); ASSERT(FillBrushObj); if ( FillBrushObj->logbrush.lbStyle != BS_NULL ) ret = FillPolygon ( dc, SurfObj, FillBrushObj, dc->w.ROPmode, Points, Count, DestRect ); - GDIOBJ_UnlockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + BRUSHOBJ_UnlockBrush(dc->w.hBrush); #endif /* make BRUSHOBJ from current pen. */ @@ -203,15 +205,15 @@ IntPolygon(PDC dc, } #if 0 /* Now fill the polygon with the current brush. */ - FillBrushObj = (BRUSHOBJ*) GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); ASSERT(FillBrushObj); if ( FillBrushObj->logbrush.lbStyle != BS_NULL ) ret = FillPolygon ( dc, SurfObj, FillBrushObj, dc->w.ROPmode, Points, Count, DestRect ); - GDIOBJ_UnlockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + BRUSHOBJ_UnlockBrush(dc->w.hBrush); #endif } - GDIOBJ_UnlockObj ( dc->w.hGCClipRgn, GO_REGION_MAGIC ); + RGNDATA_UnlockRgn(dc->w.hGCClipRgn); } ExFreePool ( Points ); } @@ -230,14 +232,14 @@ NtGdiPolygon(HDC hDC, //DPRINT("In NtGdiPolygon()\n"); - dc = DC_HandleToPtr ( hDC ); + dc = DC_LockDc ( hDC ); if ( !dc ) SetLastWin32Error(ERROR_INVALID_PARAMETER); else { ret = IntPolygon ( dc, UnsafePoints, Count ); - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); } return ret; @@ -270,7 +272,7 @@ IntRectangle(PDC dc, ASSERT ( dc ); // caller's responsibility to set this up - RectBounds = GDIOBJ_LockObj ( dc->w.hGCClipRgn, GO_REGION_MAGIC ); + RectBounds = (PRECTL) RGNDATA_LockRgn(dc->w.hGCClipRgn); //ei not yet implemented ASSERT(RectBounds); if ( PATH_IsPathOpen(dc->w.path) ) @@ -284,7 +286,7 @@ IntRectangle(PDC dc, TopRect += dc->w.DCOrgY; BottomRect += dc->w.DCOrgY - 1; - FillBrushObj = (BRUSHOBJ*) GDIOBJ_LockObj(dc->w.hBrush, GO_BRUSH_MAGIC); + FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush); ASSERT(FillBrushObj); // FIXME - I *think* this should always happen... // it would be nice to remove the following if statement if that proves to be true @@ -310,7 +312,7 @@ IntRectangle(PDC dc, } } - GDIOBJ_UnlockObj( dc->w.hBrush, GO_BRUSH_MAGIC ); + BRUSHOBJ_UnlockBrush(dc->w.hBrush); /* make BRUSHOBJ from current pen. */ HPenToBrushObj ( &PenBrushObj, dc->w.hPen ); @@ -352,7 +354,7 @@ IntRectangle(PDC dc, } // FIXME: Move current position in DC? - GDIOBJ_UnlockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC); + RGNDATA_UnlockRgn(dc->w.hGCClipRgn); return TRUE; } @@ -364,13 +366,13 @@ NtGdiRectangle(HDC hDC, int RightRect, int BottomRect) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); BOOL ret = FALSE; // default to failure if ( dc ) { ret = IntRectangle ( dc, LeftRect, TopRect, RightRect, BottomRect ); - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); } return ret; diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index d6f49b54057..4be351883e5 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -19,7 +19,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.37 2003/08/19 11:48:50 weiden Exp $ + * $Id: gdiobj.c,v 1.38 2003/08/20 07:45:02 gvg Exp $ * */ @@ -41,10 +41,18 @@ #define NDEBUG #include -#define GDI_HANDLE2INDEX(h) (((WORD)(size_t)(h)) & 0xffff) -#define GDI_INDEX2HANDLE(i) ((HANDLE) (((size_t)(i))&0xffff) ) +#define GDI_HANDLE_INDEX_MASK 0x00000fff +#define GDI_HANDLE_TYPE_MASK 0x007f0000 +#define GDI_HANDLE_STOCK_MASK 0x00800000 -// GDI stock objects +#define GDI_HANDLE_CREATE(i, t) ((HANDLE)(((i) & GDI_HANDLE_INDEX_MASK) | ((t) & GDI_HANDLE_TYPE_MASK))) +#define GDI_HANDLE_GET_INDEX(h) (((DWORD)(h)) & GDI_HANDLE_INDEX_MASK) +#define GDI_HANDLE_GET_TYPE(h) (((DWORD)(h)) & GDI_HANDLE_TYPE_MASK) +#define GDI_HANDLE_IS_TYPE(h, t) ((t) == (((DWORD)(h)) & GDI_HANDLE_TYPE_MASK)) +#define GDI_HANDLE_IS_STOCKOBJ(h) (0 != (((DWORD)(h)) & GDI_HANDLE_STOCK_MASK)) +#define GDI_HANDLE_SET_STOCKOBJ(h) ((h) = (HANDLE)(((DWORD)(h)) | GDI_HANDLE_STOCK_MASK)) + +/* GDI stock objects */ static LOGBRUSH WhiteBrush = { BS_SOLID, RGB(255,255,255), 0 }; @@ -81,60 +89,40 @@ static LOGFONTW OEMFixedFont = { 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET, 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" }; -/* Filler to make the location counter dword aligned again. This is necessary - since (a) LOGFONT is packed, (b) gcc places initialised variables in the code - segment, and (c) Solaris assembler is stupid. */ -//static UINT align_OEMFixedFont = 1; - static LOGFONTW AnsiFixedFont = { 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" }; -//static UINT align_AnsiFixedFont = 1; - -//static LOGFONTW AnsiVarFont = -//{ 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, -// 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" }; - -//static UINT align_AnsiVarFont = 1; +/*static LOGFONTW AnsiVarFont = + *{ 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, + * 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" }; */ static LOGFONTW SystemFont = { 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"System" }; -//static UINT align_SystemFont = 1; - static LOGFONTW DeviceDefaultFont = { 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"" }; -//static UINT align_DeviceDefaultFont = 1; - static LOGFONTW SystemFixedFont = { 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"" }; -//static UINT align_SystemFixedFont = 1; - /* FIXME: Is this correct? */ static LOGFONTW DefaultGuiFont = { 14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"MS Sans Serif" }; -//static UINT align_DefaultGuiFont = 1; - -static HGDIOBJ *StockObjects[NB_STOCK_OBJECTS]; // we dont assign these statically as WINE does because we might redesign - // the way handles work, so it's more dynamic now - - -HBITMAP hPseudoStockBitmap; /*! 1x1 bitmap for memory DCs */ +#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1) +static HGDIOBJ *StockObjects[NB_STOCK_OBJECTS]; static PGDI_HANDLE_TABLE HandleTable = 0; static FAST_MUTEX HandleTableMutex; static FAST_MUTEX RefCountHandling; /*! Size of the GDI handle table - * per http://www.wd-mag.com/articles/1999/9902/9902b/9902b.htm?topic=articles + * http://www.windevnet.com/documents/s=7290/wdj9902b/9902b.htm * gdi handle table can hold 0x4000 handles */ #define GDI_HANDLE_NUMBER 0x4000 @@ -168,9 +156,9 @@ GDIOBJ_iAllocHandleTable (WORD Size) static PGDI_HANDLE_ENTRY FASTCALL GDIOBJ_iGetHandleEntryForIndex (WORD TableIndex) { - //DPRINT("GDIOBJ_iGetHandleEntryForIndex: TableIndex: %d,\n handle: %x, ptr: %x\n", TableIndex, HandleTable->Handles [TableIndex], &(HandleTable->Handles [TableIndex]) ); - //DPRINT("GIG: HandleTable: %x, Handles: %x, \n TableIndex: %x, pt: %x\n", HandleTable, HandleTable->Handles, TableIndex, ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex)); - //DPRINT("GIG: Hndl: %x, mag: %x\n", ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex), ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex)->wMagic); + /*DPRINT("GDIOBJ_iGetHandleEntryForIndex: TableIndex: %d,\n handle: %x, ptr: %x\n", TableIndex, HandleTable->Handles [TableIndex], &(HandleTable->Handles [TableIndex]) );*/ + /*DPRINT("GIG: HandleTable: %x, Handles: %x, \n TableIndex: %x, pt: %x\n", HandleTable, HandleTable->Handles, TableIndex, ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex));*/ + /*DPRINT("GIG: Hndl: %x\n", ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex));*/ return ((PGDI_HANDLE_ENTRY)HandleTable->Handles+TableIndex); } @@ -181,17 +169,17 @@ GDIOBJ_iGetHandleEntryForIndex (WORD TableIndex) static WORD FASTCALL GDIOBJ_iGetNextOpenHandleIndex (void) { - WORD tableIndex; + WORD tableIndex; ExAcquireFastMutexUnsafe (&HandleTableMutex); for (tableIndex = 1; tableIndex < HandleTable->wTableSize; tableIndex++) - { - if (HandleTable->Handles [tableIndex].wMagic == 0) { - HandleTable->Handles [tableIndex].wMagic = GO_MAGIC_DONTCARE; - break; + if (NULL == HandleTable->Handles[tableIndex].pObject) + { + HandleTable->Handles[tableIndex].pObject = (PGDIOBJ) -1; + break; + } } - } ExReleaseFastMutexUnsafe (&HandleTableMutex); return (tableIndex < HandleTable->wTableSize) ? tableIndex : 0; @@ -202,19 +190,20 @@ GDIOBJ_iGetNextOpenHandleIndex (void) * * \param Size - size of the GDI object. This shouldn't to include the size of GDIOBJHDR. * The actual amount of allocated memory is sizeof(GDIOBJHDR)+Size - * \param Magic - object magic (see GDI Magic) + * \param ObjectType - type of object \ref GDI object types + * \param CleanupProcPtr - Routine to be called on destruction of object * * \return Handle of the allocated object. * * \note Use GDIOBJ_Lock() to obtain pointer to the new object. */ HGDIOBJ FASTCALL -GDIOBJ_AllocObj(WORD Size, WORD Magic) +GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) { PGDIOBJHDR newObject; PGDI_HANDLE_ENTRY handleEntry; - DPRINT("GDIOBJ_AllocObj: size: %d, magic: %x\n", Size, Magic); + DPRINT("GDIOBJ_AllocObj: size: %d, type: 0x%08x\n", Size, ObjectType); newObject = ExAllocatePool (PagedPool, Size + sizeof (GDIOBJHDR)); if (newObject == NULL) { @@ -226,22 +215,23 @@ GDIOBJ_AllocObj(WORD Size, WORD Magic) newObject->wTableIndex = GDIOBJ_iGetNextOpenHandleIndex (); newObject->dwCount = 0; handleEntry = GDIOBJ_iGetHandleEntryForIndex (newObject->wTableIndex); - handleEntry->wMagic = Magic; + handleEntry->CleanupProc = CleanupProc; handleEntry->hProcessId = PsGetCurrentProcessId (); handleEntry->pObject = newObject; handleEntry->lockfile = NULL; handleEntry->lockline = 0; DPRINT("GDIOBJ_AllocObj: object handle %d\n", newObject->wTableIndex ); - return GDI_INDEX2HANDLE(newObject->wTableIndex); + return GDI_HANDLE_CREATE(newObject->wTableIndex, ObjectType); } /*! * Free memory allocated for the GDI object. For each object type this function calls the * appropriate cleanup routine. * - * \param hObj - handle of the object to be deleted. - * \param Magic - object magic or GO_MAGIC_DONTCARE. - * \param Flag - if set to GDIOBJFLAG_IGNOREPID then the routine doesn't check if the process that + * \param hObj - handle of the object to be deleted. + * \param ObjectType - one of the \ref GDI object types + * or GDI_OBJECT_TYPE_DONTCARE. + * \param Flag - if set to GDIOBJFLAG_IGNOREPID then the routine doesn't check if the process that * tries to delete the object is the same one that created it. * * \return Returns TRUE if succesful. @@ -250,114 +240,94 @@ GDIOBJ_AllocObj(WORD Size, WORD Magic) * \note This function deferres object deletion if it is still in use. */ BOOL STDCALL -GDIOBJ_FreeObj(HGDIOBJ hObj, WORD Magic, DWORD Flag) +GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType, DWORD Flag) { - PGDIOBJHDR objectHeader; - PGDI_HANDLE_ENTRY handleEntry; - PGDIOBJ Obj; - BOOL bRet = TRUE; + PGDIOBJHDR objectHeader; + PGDI_HANDLE_ENTRY handleEntry; + PGDIOBJ Obj; + BOOL bRet = TRUE; - handleEntry = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(hObj) ); - DPRINT("GDIOBJ_FreeObj: hObj: %d, magic: %x, handleEntry: %x\n", (WORD)hObj & 0xffff, Magic, handleEntry ); + handleEntry = GDIOBJ_iGetHandleEntryForIndex(GDI_HANDLE_GET_INDEX(hObj)); + DPRINT("GDIOBJ_FreeObj: hObj: 0x%08x, handleEntry: %x\n", hObj, handleEntry ); - if (handleEntry == 0 || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE ) - || ((handleEntry->hProcessId != PsGetCurrentProcessId()) && !(Flag & GDIOBJFLAG_IGNOREPID))){ + if (NULL == handleEntry + || (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE) + || ((handleEntry->hProcessId != PsGetCurrentProcessId()) && !(Flag & GDIOBJFLAG_IGNOREPID))) + { + DPRINT("Can't Delete hObj: 0x%08x, type: 0x%08x, pid:%d\n currpid:%d, flag:%d, hmm:%d\n", hObj, ObjectType, handleEntry->hProcessId, PsGetCurrentProcessId(), (Flag&GDIOBJFLAG_IGNOREPID), ((handleEntry->hProcessId != PsGetCurrentProcessId()) && !(Flag&GDIOBJFLAG_IGNOREPID)) ); + return FALSE; + } - DPRINT("Can't Delete hObj: %d, magic: %x, pid:%d\n currpid:%d, flag:%d, hmm:%d\n",(WORD)hObj & 0xffff, handleEntry->wMagic, handleEntry->hProcessId, PsGetCurrentProcessId(), (Flag&GDIOBJFLAG_IGNOREPID), ((handleEntry->hProcessId != PsGetCurrentProcessId()) && !(Flag&GDIOBJFLAG_IGNOREPID)) ); - return FALSE; + objectHeader = handleEntry->pObject; + ASSERT(objectHeader); + DPRINT("FreeObj: locks: %x\n", objectHeader->dwCount ); + if (!(Flag & GDIOBJFLAG_IGNORELOCK)) + { + /* check that the reference count is zero. if not then set flag + * and delete object when releaseobj is called */ + ExAcquireFastMutex(&RefCountHandling); + if ((objectHeader->dwCount & ~0x80000000) > 0 ) + { + DPRINT("GDIOBJ_FreeObj: delayed object deletion: count %d\n", objectHeader->dwCount); + objectHeader->dwCount |= 0x80000000; + ExReleaseFastMutex(&RefCountHandling); + return TRUE; } + ExReleaseFastMutex(&RefCountHandling); + } - objectHeader = handleEntry->pObject; - ASSERT(objectHeader); - DPRINT("FreeObj: locks: %x\n", objectHeader->dwCount ); - if( !(Flag & GDIOBJFLAG_IGNORELOCK) ){ - // check that the reference count is zero. if not then set flag - // and delete object when releaseobj is called - ExAcquireFastMutex(&RefCountHandling); - if( ( objectHeader->dwCount & ~0x80000000 ) > 0 ){ - DPRINT("GDIOBJ_FreeObj: delayed object deletion: count %d\n", objectHeader->dwCount); - objectHeader->dwCount |= 0x80000000; - ExReleaseFastMutex(&RefCountHandling); - return TRUE; - } - ExReleaseFastMutex(&RefCountHandling); - } + /* allow object to delete internal data */ + if (NULL != handleEntry->CleanupProc) + { + Obj = (PGDIOBJ)((PCHAR)handleEntry->pObject + sizeof(GDIOBJHDR)); + bRet = (*(handleEntry->CleanupProc))(Obj); + } + ExFreePool (handleEntry->pObject); + memset(handleEntry, 0, sizeof(GDI_HANDLE_ENTRY)); - //allow object to delete internal data - Obj = (PGDIOBJ)((PCHAR)handleEntry->pObject + sizeof(GDIOBJHDR)); - switch( handleEntry->wMagic ){ - case GO_REGION_MAGIC: - bRet = RGNDATA_InternalDelete( (PROSRGNDATA) Obj ); - break; - case GO_BITMAP_MAGIC: - bRet = Bitmap_InternalDelete( (PBITMAPOBJ) Obj ); - break; - case GO_DC_MAGIC: - bRet = DC_InternalDeleteDC( (PDC) Obj ); - break; - case GO_PEN_MAGIC: - case GO_PALETTE_MAGIC: - case GO_DISABLED_DC_MAGIC: - case GO_META_DC_MAGIC: - case GO_METAFILE_MAGIC: - case GO_METAFILE_DC_MAGIC: - case GO_ENHMETAFILE_MAGIC: - case GO_ENHMETAFILE_DC_MAGIC: - - case GO_BRUSH_MAGIC: - case GO_FONT_MAGIC: - break; - case GO_DCE_MAGIC: - bRet = DCE_InternalDelete( (PDCE) Obj ); - break; - case GO_ICONCURSOR_MAGIC: - bRet = IconCursor_InternalDelete( (PICONCURSOROBJ) Obj ); - break; - } - ExFreePool (handleEntry->pObject); - memset ( handleEntry, 0, sizeof(GDI_HANDLE_ENTRY) ); - - return TRUE; + return bRet; } /*! * Lock multiple objects. Use this function when you need to lock multiple objects and some of them may be * duplicates. You should use this function to avoid trying to lock the same object twice! * - * \param pList pointer to the list that contains handles to the objects. You should set hObj and Magic fields. + * \param pList pointer to the list that contains handles to the objects. You should set hObj and ObjectType fields. * \param nObj number of objects to lock * \return for each entry in pList this function sets pObj field to point to the object. * * \note this function uses an O(n^2) algoritm because we shouldn't need to call it with more than 3 or 4 objects. */ BOOL FASTCALL -GDIOBJ_LockMultipleObj( PGDIMULTILOCK pList, INT nObj ) +GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj) { INT i, j; ASSERT( pList ); - // FIXME - check for "invalid" handles - //go through the list checking for duplicate objects - for( i = 0; i < nObj; i++ ) + /* FIXME - check for "invalid" handles */ + /* go through the list checking for duplicate objects */ + for (i = 0; i < nObj; i++) { - (pList+i)->pObj = NULL; - for( j = 0; j < i; j++ ) + pList[i].pObj = NULL; + for (j = 0; j < i; j++) { - if( ((pList+i)->hObj == (pList+j)->hObj) - && ((pList+i)->Magic == (pList+j)->Magic) - ) + if (pList[i].hObj == pList[j].hObj) { - //already locked, so just copy the pointer to the object - (pList+i)->pObj = (pList+j)->pObj; + /* already locked, so just copy the pointer to the object */ + pList[i].pObj = pList[j].pObj; break; } } - if( (pList+i)->pObj == NULL ) - { - //object hasn't been locked, so lock it. - if ( (pList+i)->hObj ) - (pList+i)->pObj = GDIOBJ_LockObj( (pList+i)->hObj, (pList+i)->Magic ); - } + + if (NULL == pList[i].pObj) + { + /* object hasn't been locked, so lock it. */ + if (NULL != pList[i].hObj) + { + pList[i].pObj = GDIOBJ_LockObj(pList[i].hObj, pList[i].ObjectType); + } + } } + return TRUE; } @@ -365,33 +335,35 @@ GDIOBJ_LockMultipleObj( PGDIMULTILOCK pList, INT nObj ) * Unlock multiple objects. Use this function when you need to unlock multiple objects and some of them may be * duplicates. * - * \param pList pointer to the list that contains handles to the objects. You should set hObj and Magic fields. + * \param pList pointer to the list that contains handles to the objects. You should set hObj and ObjectType fields. * \param nObj number of objects to lock * * \note this function uses O(n^2) algoritm because we shouldn't need to call it with more than 3 or 4 objects. */ BOOL FASTCALL -GDIOBJ_UnlockMultipleObj( PGDIMULTILOCK pList, INT nObj ) +GDIOBJ_UnlockMultipleObj(PGDIMULTILOCK pList, INT nObj) { INT i, j; - ASSERT( pList ); - //go through the list checking for duplicate objects - for( i = 0; i < nObj; i++ ) + ASSERT(pList); + + /* go through the list checking for duplicate objects */ + for (i = 0; i < nObj; i++) { - if( (pList+i)->pObj != NULL ) + if (NULL != pList[i].pObj) { - for( j = i+1; j < nObj; j++ ) + for (j = i + 1; j < nObj; j++) { - if( ((pList+i)->pObj == (pList+j)->pObj) ) + if ((pList[i].pObj == pList[j].pObj)) { - //set the pointer to zero for all duplicates - (pList+j)->pObj = NULL; + /* set the pointer to zero for all duplicates */ + pList[j].pObj = NULL; } } - GDIOBJ_UnlockObj( (pList+i)->hObj, (pList+i)->Magic ); - (pList+i)->pObj = NULL; + GDIOBJ_UnlockObj(pList[i].hObj, pList[i].ObjectType); + pList[i].pObj = NULL; } } + return TRUE; } @@ -407,36 +379,29 @@ GDIOBJ_MarkObjectGlobal(HGDIOBJ ObjectHandle) { PGDI_HANDLE_ENTRY handleEntry; - if (ObjectHandle == NULL) - return; + if (NULL == ObjectHandle) + { + return; + } - handleEntry = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(ObjectHandle) ); - if (handleEntry == 0) - return; + handleEntry = GDIOBJ_iGetHandleEntryForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle)); + if (NULL == handleEntry) + { + return; + } handleEntry->hProcessId = (HANDLE)0xFFFFFFFF; } /*! - * Get the type (magic value) of the object. + * Get the type of the object. * \param ObjectHandle - handle of the object. - * \return GDI Magic value. + * \return One of the \ref GDI object types */ -WORD FASTCALL -GDIOBJ_GetHandleMagic (HGDIOBJ ObjectHandle) +DWORD FASTCALL +GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle) { - PGDI_HANDLE_ENTRY handleEntry; - - if (ObjectHandle == NULL) - return 0; - - handleEntry = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(ObjectHandle) ); - if (handleEntry == 0 || - (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF && - handleEntry->hProcessId != PsGetCurrentProcessId ())) - return 0; - - return handleEntry->wMagic; + return GDI_HANDLE_GET_TYPE(ObjectHandle); } /*! @@ -461,42 +426,35 @@ InitGdiObjectHandleTable (VOID) VOID FASTCALL CreateStockObjects(void) { - // Create GDI Stock Objects from the logical structures we've defined + unsigned Object; + + /* Create GDI Stock Objects from the logical structures we've defined */ StockObjects[WHITE_BRUSH] = NtGdiCreateBrushIndirect(&WhiteBrush); - GDIOBJ_MarkObjectGlobal(StockObjects[WHITE_BRUSH]); StockObjects[LTGRAY_BRUSH] = NtGdiCreateBrushIndirect(&LtGrayBrush); - GDIOBJ_MarkObjectGlobal(StockObjects[LTGRAY_BRUSH]); StockObjects[GRAY_BRUSH] = NtGdiCreateBrushIndirect(&GrayBrush); - GDIOBJ_MarkObjectGlobal(StockObjects[GRAY_BRUSH]); StockObjects[DKGRAY_BRUSH] = NtGdiCreateBrushIndirect(&DkGrayBrush); - GDIOBJ_MarkObjectGlobal(StockObjects[DKGRAY_BRUSH]); StockObjects[BLACK_BRUSH] = NtGdiCreateBrushIndirect(&BlackBrush); - GDIOBJ_MarkObjectGlobal(StockObjects[BLACK_BRUSH]); StockObjects[NULL_BRUSH] = NtGdiCreateBrushIndirect(&NullBrush); - GDIOBJ_MarkObjectGlobal(StockObjects[NULL_BRUSH]); StockObjects[WHITE_PEN] = NtGdiCreatePenIndirect(&WhitePen); - GDIOBJ_MarkObjectGlobal(StockObjects[WHITE_PEN]); StockObjects[BLACK_PEN] = NtGdiCreatePenIndirect(&BlackPen); - GDIOBJ_MarkObjectGlobal(StockObjects[BLACK_PEN]); StockObjects[NULL_PEN] = NtGdiCreatePenIndirect(&NullPen); - GDIOBJ_MarkObjectGlobal(StockObjects[NULL_PEN]); (void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]); - GDIOBJ_MarkObjectGlobal(StockObjects[OEM_FIXED_FONT]); (void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]); - GDIOBJ_MarkObjectGlobal(StockObjects[ANSI_FIXED_FONT]); (void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]); - GDIOBJ_MarkObjectGlobal(StockObjects[SYSTEM_FONT]); (void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]); - GDIOBJ_MarkObjectGlobal(StockObjects[DEVICE_DEFAULT_FONT]); (void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]); - GDIOBJ_MarkObjectGlobal(StockObjects[SYSTEM_FIXED_FONT]); (void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]); - GDIOBJ_MarkObjectGlobal(StockObjects[DEFAULT_GUI_FONT]); StockObjects[DEFAULT_PALETTE] = (HGDIOBJ*)PALETTE_Init(); + + for (Object = 0; Object < NB_STOCK_OBJECTS; Object++) + { + GDIOBJ_MarkObjectGlobal(StockObjects[Object]); + GDI_HANDLE_SET_STOCKOBJ(StockObjects[Object]); + } } /*! @@ -505,12 +463,9 @@ CreateStockObjects(void) * \return Handle to the object. */ HGDIOBJ STDCALL -NtGdiGetStockObject(INT Object) +NtGdiGetStockObject(INT Object) { - // check when adding new objects - if( (Object < 0) || (Object >= NB_STOCK_OBJECTS) ) - return NULL; - return StockObjects[Object]; + return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object]; } /*! @@ -521,7 +476,7 @@ NtGdiGetStockObject(INT Object) BOOL STDCALL NtGdiDeleteObject(HGDIOBJ hObject) { - return GDIOBJ_FreeObj( hObject, GO_MAGIC_DONTCARE, GDIOBJFLAG_DEFAULT ); + return GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE, GDIOBJFLAG_DEFAULT); } /*! @@ -535,7 +490,6 @@ CleanupForProcess (struct _EPROCESS *Process, INT Pid) PGDI_HANDLE_ENTRY handleEntry; PGDIOBJHDR objectHeader; PEPROCESS CurrentProcess; - //NTSTATUS Status; CurrentProcess = PsGetCurrentProcess(); if (CurrentProcess != Process) @@ -545,13 +499,15 @@ CleanupForProcess (struct _EPROCESS *Process, INT Pid) for(i = 1; i < GDI_HANDLE_NUMBER; i++) { - handleEntry = GDIOBJ_iGetHandleEntryForIndex((WORD) i & 0xffff); - if (NULL != handleEntry && 0 != handleEntry->wMagic && + handleEntry = GDIOBJ_iGetHandleEntryForIndex(i); + if (NULL != handleEntry && NULL != handleEntry->pObject && (INT)handleEntry->hProcessId == Pid) { objectHeader = (PGDIOBJHDR) handleEntry->pObject; - DPRINT("\nNtGdiCleanup: %d, magic: %x \n process: %d, locks: %d", i, handleEntry->wMagic, handleEntry->hProcessId, objectHeader->dwCount); - GDIOBJ_FreeObj( GDI_INDEX2HANDLE(i), GO_MAGIC_DONTCARE, GDIOBJFLAG_IGNOREPID|GDIOBJFLAG_IGNORELOCK ); + DPRINT("\nNtGdiCleanup: %d, process: %d, locks: %d", i, handleEntry->hProcessId, objectHeader->dwCount); + GDIOBJ_FreeObj(GDI_HANDLE_CREATE(i, GDI_OBJECT_TYPE_DONTCARE), + GDI_OBJECT_TYPE_DONTCARE, + GDIOBJFLAG_IGNOREPID|GDIOBJFLAG_IGNORELOCK ); } } @@ -563,72 +519,57 @@ CleanupForProcess (struct _EPROCESS *Process, INT Pid) return TRUE; } -/*! - * Internal function. Dumps all the objects for the given process. - * \param If process == 0 dump all the objects. - * -*/ -VOID STDCALL -NtGdiDumpGdiObjects( INT Process ) -{ - DWORD i; - PGDI_HANDLE_ENTRY handleEntry; - PGDIOBJHDR objectHeader; - - for( i=1; i < GDI_HANDLE_NUMBER; i++ ){ - handleEntry = GDIOBJ_iGetHandleEntryForIndex ((WORD) i & 0xffff); - if( handleEntry && handleEntry->wMagic != 0 ){ - objectHeader = (PGDIOBJHDR) handleEntry->pObject; - DPRINT("\nHandle: %d, magic: %x \n process: %d, locks: %d", i, handleEntry->wMagic, handleEntry->hProcessId, objectHeader->dwCount); - } - } - -} - #define GDIOBJ_TRACKLOCKS #ifdef GDIOBJ_LockObj #undef GDIOBJ_LockObj PGDIOBJ FASTCALL -GDIOBJ_LockObjDbg ( const char* file, int line, HGDIOBJ hObj, WORD Magic ) +GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType) { PGDIOBJ rc; PGDI_HANDLE_ENTRY handleEntry - = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(hObj) ); - if ( handleEntry == 0 - || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE ) - || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF - && handleEntry->hProcessId != PsGetCurrentProcessId () - ) + = GDIOBJ_iGetHandleEntryForIndex(GDI_HANDLE_GET_INDEX(hObj)); + if (NULL == handleEntry + || (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE) + || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF + && handleEntry->hProcessId != PsGetCurrentProcessId () + ) ) { int reason = 0; - if ( handleEntry == 0 ) - reason = 1; - else if ( handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE ) - reason = 2; - else if ( handleEntry->hProcessId != (HANDLE)0xFFFFFFFF - && handleEntry->hProcessId != PsGetCurrentProcessId () ) - reason = 3; + if (NULL == handleEntry) + { + reason = 1; + } + else if (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE) + { + reason = 2; + } + else if (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF + && handleEntry->hProcessId != PsGetCurrentProcessId()) + { + reason = 3; + } - DPRINT1("GDIOBJ_LockObj failed for %d, magic: %d, reqMagic %d reason %d\n", - (WORD)((size_t)hObj&0xffff), handleEntry->wMagic, Magic, reason ); + DPRINT1("GDIOBJ_LockObj failed for 0x%08x, reqtype 0x%08x reason %d\n", + hObj, ObjectType, reason ); DPRINT1("\tcalled from: %s:%i\n", file, line ); - return NULL; + return NULL; } - if ( handleEntry->lockfile ) + if (NULL != handleEntry->lockfile) { DPRINT1("Caution! GDIOBJ_LockObj trying to lock object (0x%x) second time\n", hObj ); DPRINT1("\tcalled from: %s:%i\n", file, line ); DPRINT1("\tpreviously locked from: %s:%i\n", handleEntry->lockfile, handleEntry->lockline ); } - //DbgPrint("(%s:%i) GDIOBJ_LockObj(0x%x,0x%x)\n", file, line, hObj, Magic ); - rc = GDIOBJ_LockObj(hObj,Magic); - if ( rc && !handleEntry->lockfile ) + DPRINT("(%s:%i) GDIOBJ_LockObj(0x%08x,0x%08x)\n", file, line, hObj, ObjectType); + rc = GDIOBJ_LockObj(hObj, ObjectType); + if (rc && NULL == handleEntry->lockfile) { handleEntry->lockfile = file; handleEntry->lockline = line; } + return rc; } #endif//GDIOBJ_LockObj @@ -636,26 +577,26 @@ GDIOBJ_LockObjDbg ( const char* file, int line, HGDIOBJ hObj, WORD Magic ) #ifdef GDIOBJ_UnlockObj #undef GDIOBJ_UnlockObj BOOL FASTCALL -GDIOBJ_UnlockObjDbg ( const char* file, int line, HGDIOBJ hObj, WORD Magic ) +GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType) { PGDI_HANDLE_ENTRY handleEntry - = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(hObj) ); - if ( handleEntry == 0 - || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE ) - || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF - && handleEntry->hProcessId != PsGetCurrentProcessId () - ) + = GDIOBJ_iGetHandleEntryForIndex (GDI_HANDLE_GET_INDEX(hObj)); + if (NULL == handleEntry + || (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE) + || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF + && handleEntry->hProcessId != PsGetCurrentProcessId () + ) ) { - DPRINT1("GDIBOJ_UnlockObj failed for %d, magic: %d, reqMagic\n", - (WORD)((size_t)hObj & 0xffff), handleEntry->wMagic, Magic ); - DPRINT1("\tcalled from: %s:%i\n", file, line ); + DPRINT1("GDIBOJ_UnlockObj failed for 0x%08x, reqtype 0x%08x\n", + hObj, ObjectType); + DPRINT1("\tcalled from: %s:%i\n", file, line); return FALSE; } - //DbgPrint("(%s:%i) GDIOBJ_UnlockObj(0x%x,0x%x)\n", file, line, hObj, Magic ); + DPRINT("(%s:%i) GDIOBJ_UnlockObj(0x%08x,0x%08x)\n", file, line, hObj, ObjectType); handleEntry->lockfile = NULL; handleEntry->lockline = 0; - return GDIOBJ_UnlockObj(hObj,Magic); + return GDIOBJ_UnlockObj(hObj, ObjectType); } #endif//GDIOBJ_LockObj @@ -663,39 +604,39 @@ GDIOBJ_UnlockObjDbg ( const char* file, int line, HGDIOBJ hObj, WORD Magic ) * Return pointer to the object by handle. * * \param hObj Object handle - * \param Magic one of the magic numbers defined in \ref GDI Magic - * \return Pointer to the object. + * \param ObjectType one of the object types defined in \ref GDI object types + * \return Pointer to the object. * * \note Process can only get pointer to the objects it created or global objects. * * \todo Don't allow to lock the objects twice! Synchronization! */ PGDIOBJ FASTCALL -GDIOBJ_LockObj( HGDIOBJ hObj, WORD Magic ) +GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ObjectType) { PGDI_HANDLE_ENTRY handleEntry - = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(hObj) ); + = GDIOBJ_iGetHandleEntryForIndex(GDI_HANDLE_GET_INDEX(hObj)); PGDIOBJHDR objectHeader; - DPRINT("GDIOBJ_LockObj: hObj: %d, magic: %x, \n handleEntry: %x, mag %x\n", hObj, Magic, handleEntry, handleEntry->wMagic); - if ( handleEntry == 0 - || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE ) - || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF - && handleEntry->hProcessId != PsGetCurrentProcessId () - ) + DPRINT("GDIOBJ_LockObj: hObj: 0x%08x, type: 0x%08x, handleEntry: %x\n", hObj, ObjectType, handleEntry); + if (NULL == handleEntry + || (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE) + || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF + && handleEntry->hProcessId != PsGetCurrentProcessId() + ) ) { - DPRINT1("GDIBOJ_LockObj failed for %d, magic: %d, reqMagic\n", - (WORD)((size_t)hObj & 0xffff), handleEntry->wMagic, Magic); + DPRINT1("GDIBOJ_LockObj failed for 0x%08x, type 0x%08x\n", + hObj, ObjectType); return NULL; } objectHeader = (PGDIOBJHDR) handleEntry->pObject; ASSERT(objectHeader); - if( objectHeader->dwCount > 0 ) + if(0 < objectHeader->dwCount) { - DbgPrint("Caution! GDIOBJ_LockObj trying to lock object (0x%x) second time\n", hObj ); - DbgPrint("\t called from: %x\n", __builtin_return_address(0)); + DPRINT1("Caution! GDIOBJ_LockObj trying to lock object (0x%x) second time\n", hObj); + DPRINT1("\t called from: %x\n", __builtin_return_address(0)); } ExAcquireFastMutex(&RefCountHandling); @@ -709,7 +650,7 @@ GDIOBJ_LockObj( HGDIOBJ hObj, WORD Magic ) * as soon as you don't need to have access to it's data. * \param hObj Object handle - * \param Magic one of the magic numbers defined in \ref GDI Magic + * \param ObjectType one of the object types defined in \ref GDI object types * * \note This function performs delayed cleanup. If the object is locked when GDI_FreeObj() is called * then \em this function frees the object when reference count is zero. @@ -718,18 +659,18 @@ GDIOBJ_LockObj( HGDIOBJ hObj, WORD Magic ) */ #undef GDIOBJ_UnlockObj BOOL FASTCALL -GDIOBJ_UnlockObj( HGDIOBJ hObj, WORD Magic ) +GDIOBJ_UnlockObj(HGDIOBJ hObj, DWORD ObjectType) { PGDI_HANDLE_ENTRY handleEntry - = GDIOBJ_iGetHandleEntryForIndex ( GDI_HANDLE2INDEX(hObj) ); + = GDIOBJ_iGetHandleEntryForIndex(GDI_HANDLE_GET_INDEX(hObj)); PGDIOBJHDR objectHeader; - DPRINT("GDIOBJ_UnlockObj: hObj: %d, magic: %x, \n handleEntry: %x\n", hObj, Magic, handleEntry); - if ( handleEntry == 0 - || (handleEntry->wMagic != Magic && Magic != GO_MAGIC_DONTCARE ) - || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF - && handleEntry->hProcessId != PsGetCurrentProcessId () - ) + DPRINT("GDIOBJ_UnlockObj: hObj: 0x%08x, type: 0x%08x, handleEntry: %x\n", hObj, ObjectType, handleEntry); + if (NULL == handleEntry + || (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE) + || (handleEntry->hProcessId != (HANDLE)0xFFFFFFFF + && handleEntry->hProcessId != PsGetCurrentProcessId () + ) ) { DPRINT1( "GDIOBJ_UnLockObj: failed\n"); @@ -740,26 +681,26 @@ GDIOBJ_UnlockObj( HGDIOBJ hObj, WORD Magic ) ASSERT(objectHeader); ExAcquireFastMutex(&RefCountHandling); - if( ( objectHeader->dwCount & ~0x80000000 ) == 0 ) + if (0 == (objectHeader->dwCount & ~0x80000000)) { ExReleaseFastMutex(&RefCountHandling); - DPRINT( "GDIOBJ_UnLockObj: unlock object (0x%x) that is not locked\n", hObj ); + DPRINT1( "GDIOBJ_UnLockObj: unlock object (0x%x) that is not locked\n", hObj ); return FALSE; } - objectHeader = (PGDIOBJHDR) handleEntry->pObject; - ASSERT(objectHeader); objectHeader->dwCount--; - if( objectHeader->dwCount == 0x80000000 ) + if( objectHeader->dwCount == 0x80000000 ) { //delayed object release objectHeader->dwCount = 0; ExReleaseFastMutex(&RefCountHandling); DPRINT("GDIOBJ_UnlockObj: delayed delete\n"); - return GDIOBJ_FreeObj( hObj, Magic, GDIOBJFLAG_DEFAULT ); + return GDIOBJ_FreeObj(hObj, ObjectType, GDIOBJFLAG_DEFAULT); } ExReleaseFastMutex(&RefCountHandling); + return TRUE; } + /* EOF */ diff --git a/reactos/subsys/win32k/objects/line.c b/reactos/subsys/win32k/objects/line.c index dceebefb92f..04c8c776e5a 100644 --- a/reactos/subsys/win32k/objects/line.c +++ b/reactos/subsys/win32k/objects/line.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: line.c,v 1.20 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: line.c,v 1.21 2003/08/20 07:45:02 gvg Exp $ */ // Some code from the WINE project source (www.winehq.com) @@ -62,12 +62,12 @@ NtGdiArc(HDC hDC, int XEndArc, int YEndArc) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); if(!dc) return FALSE; if(PATH_IsPathOpen(dc->w.path)) { - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); return PATH_Arc(hDC, LeftRect, TopRect, RightRect, BottomRect, XStartArc, YStartArc, XEndArc, YEndArc); } @@ -76,7 +76,7 @@ NtGdiArc(HDC hDC, // EngArc(dc, LeftRect, TopRect, RightRect, BottomRect, UNIMPLEMENTED // XStartArc, YStartArc, XEndArc, YEndArc); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; } @@ -99,7 +99,7 @@ NtGdiArcTo(HDC hDC, if ( !NtGdiLineTo(hDC, XRadial1, YRadial1) ) return FALSE; - //dc = DC_HandleToPtr(hDC); + //dc = DC_LockDc(hDC); //if(!dc) return FALSE; @@ -107,7 +107,7 @@ NtGdiArcTo(HDC hDC, result = NtGdiArc(hDC, LeftRect, TopRect, RightRect, BottomRect, XRadial1, YRadial1, XRadial2, YRadial2); - //DC_ReleasePtr( hDC ); + //DC_UnlockDc( hDC ); // If no error occured, the current position is moved to the ending point of the arc. if(result) @@ -128,13 +128,13 @@ INT STDCALL NtGdiGetArcDirection(HDC hDC) { - PDC dc = DC_HandleToPtr (hDC); + PDC dc = DC_LockDc (hDC); int ret = 0; // default to failure if ( dc ) { ret = IntGetArcDirection ( dc ); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); } return ret; @@ -146,7 +146,7 @@ NtGdiLineTo(HDC hDC, int XEnd, int YEnd) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); SURFOBJ *SurfObj; BOOL Ret; BRUSHOBJ PenBrushObj; @@ -162,15 +162,15 @@ NtGdiLineTo(HDC hDC, if (PATH_IsPathOpen(dc->w.path)) { - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); Ret = PATH_LineTo(hDC, XEnd, YEnd); if (Ret) { // FIXME - PATH_LineTo should maybe do this... - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); dc->w.CursPosX = XEnd; dc->w.CursPosY = YEnd; - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); } return Ret; } @@ -218,7 +218,7 @@ NtGdiLineTo(HDC hDC, dc->w.CursPosX = XEnd; dc->w.CursPosY = YEnd; } - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); return Ret; } @@ -230,7 +230,7 @@ NtGdiMoveToEx(HDC hDC, int Y, LPPOINT Point) { - DC *dc = DC_HandleToPtr( hDC ); + DC *dc = DC_LockDc( hDC ); BOOL PathIsOpen; if ( !dc ) return FALSE; @@ -245,7 +245,7 @@ NtGdiMoveToEx(HDC hDC, PathIsOpen = PATH_IsPathOpen(dc->w.path); - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); if ( PathIsOpen ) return PATH_MoveTo ( hDC ); @@ -259,14 +259,14 @@ NtGdiPolyBezier(HDC hDC, CONST LPPOINT pt, DWORD Count) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); BOOL ret = FALSE; // default to FAILURE if ( !dc ) return FALSE; if ( PATH_IsPathOpen(dc->w.path) ) { - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return PATH_PolyBezier ( hDC, pt, Count ); } @@ -283,7 +283,7 @@ NtGdiPolyBezier(HDC hDC, ExFreePool(Pts); } } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return ret; } @@ -293,7 +293,7 @@ NtGdiPolyBezierTo(HDC hDC, CONST LPPOINT pt, DWORD Count) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); BOOL ret = FALSE; // default to failure if ( !dc ) return ret; @@ -318,7 +318,7 @@ NtGdiPolyBezierTo(HDC hDC, dc->w.CursPosX = pt[Count-1].x; dc->w.CursPosY = pt[Count-1].y; } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return ret; } @@ -351,7 +351,7 @@ IntPolyline(PDC dc, if ( PATH_IsPathOpen ( dc->w.path ) ) return PATH_Polyline ( dc, pt, Count ); - reg = (PROSRGNDATA)GDIOBJ_LockObj(dc->w.hGCClipRgn, GO_REGION_MAGIC); + reg = RGNDATA_LockRgn(dc->w.hGCClipRgn); //FIXME: Do somthing with reg... @@ -385,7 +385,7 @@ IntPolyline(PDC dc, } //Clean up - GDIOBJ_UnlockObj ( dc->w.hGCClipRgn, GO_REGION_MAGIC ); + RGNDATA_UnlockRgn(dc->w.hGCClipRgn); return ret; } @@ -396,14 +396,14 @@ NtGdiPolyline(HDC hDC, CONST LPPOINT pt, int Count) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); BOOL ret = FALSE; // default to failure if ( dc ) { ret = IntPolyline ( dc, pt, Count ); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); } return ret; @@ -415,7 +415,7 @@ NtGdiPolylineTo(HDC hDC, CONST LPPOINT pt, DWORD Count) { - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); BOOL ret = FALSE; // default to failure if ( !dc ) return ret; @@ -441,7 +441,7 @@ NtGdiPolylineTo(HDC hDC, dc->w.CursPosX = pt[Count-1].x; dc->w.CursPosY = pt[Count-1].y; } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return ret; } @@ -463,7 +463,7 @@ NtGdiSetArcDirection(HDC hDC, PDC dc; INT nOldDirection = 0; // default to FAILURE - dc = DC_HandleToPtr (hDC); + dc = DC_LockDc (hDC); if ( !dc ) return 0; if ( ArcDirection == AD_COUNTERCLOCKWISE || ArcDirection == AD_CLOCKWISE ) @@ -472,7 +472,7 @@ NtGdiSetArcDirection(HDC hDC, dc->w.ArcDirection = ArcDirection; } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return nOldDirection; } /* EOF */ diff --git a/reactos/subsys/win32k/objects/objconv.c b/reactos/subsys/win32k/objects/objconv.c index c08c20a4317..1f66557c0fd 100644 --- a/reactos/subsys/win32k/objects/objconv.c +++ b/reactos/subsys/win32k/objects/objconv.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: objconv.c,v 1.11 2003/08/17 17:32:58 royce Exp $ */ +/* $Id: objconv.c,v 1.12 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include @@ -60,10 +60,10 @@ HPenToBrushObj ( BRUSHOBJ *brush, HPEN hpen ) PENOBJ *pen; ASSERT ( hpen ); ASSERT ( brush ); - pen = (PPENOBJ)GDIOBJ_LockObj ( hpen, GO_PEN_MAGIC ); + pen = PENOBJ_LockPen(hpen); ASSERT ( pen ); PenToBrushObj ( brush, pen ); - GDIOBJ_UnlockObj ( hpen, GO_PEN_MAGIC ); + PENOBJ_UnlockPen(hpen); return brush; } diff --git a/reactos/subsys/win32k/objects/path.c b/reactos/subsys/win32k/objects/path.c index aef4b62df64..3b2185d458c 100644 --- a/reactos/subsys/win32k/objects/path.c +++ b/reactos/subsys/win32k/objects/path.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: path.c,v 1.14 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: path.c,v 1.15 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -69,13 +69,13 @@ BOOL STDCALL NtGdiCloseFigure ( HDC hDC ) { - PDC dc = DC_HandleToPtr ( hDC ); + PDC dc = DC_LockDc ( hDC ); BOOL ret = FALSE; // default to failure if ( dc ) { ret = IntCloseFigure ( dc ); - DC_ReleasePtr ( hDC ); + DC_UnlockDc ( hDC ); } return ret; diff --git a/reactos/subsys/win32k/objects/region.c b/reactos/subsys/win32k/objects/region.c index 5004e70cac7..b8313a5124a 100644 --- a/reactos/subsys/win32k/objects/region.c +++ b/reactos/subsys/win32k/objects/region.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: region.c,v 1.34 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: region.c,v 1.35 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -338,7 +338,7 @@ HRGN STDCALL REGION_CropRgn(HRGN hDst, HRGN hSrc, const PRECT lpRect, PPOINT lpP { PROSRGNDATA objSrc, rgnDst; HRGN hNewDst, hRet = NULL; - GDIMULTILOCK Lock[2] = {{hDst, 0, GO_REGION_MAGIC}, {hSrc, 0, GO_REGION_MAGIC}}; + GDIMULTILOCK Lock[2] = {{hDst, 0, GDI_OBJECT_TYPE_REGION}, {hSrc, 0, GDI_OBJECT_TYPE_REGION}}; if( !hDst ) { @@ -1381,7 +1381,7 @@ BOOL STDCALL REGION_LPTODP(HDC hdc, HRGN hDest, HRGN hSrc) PROSRGNDATA srcObj = NULL; PROSRGNDATA destObj = NULL; - DC * dc = DC_HandleToPtr(hdc); + DC * dc = DC_LockDc(hdc); RECT tmpRect; BOOL ret = FALSE; @@ -1429,7 +1429,7 @@ BOOL STDCALL REGION_LPTODP(HDC hdc, HRGN hDest, HRGN hSrc) RGNDATA_UnlockRgn( hDest ); done: - DC_ReleasePtr( hdc ); + DC_UnlockDc( hdc ); return ret; } @@ -1439,8 +1439,9 @@ HRGN FASTCALL RGNDATA_AllocRgn(INT n) PROSRGNDATA pReg; BOOL bRet; - if((hReg = (HRGN)GDIOBJ_AllocObj(sizeof(ROSRGNDATA), GO_REGION_MAGIC))){ - if( (pReg = GDIOBJ_LockObj( hReg, GO_REGION_MAGIC )) ){ + if((hReg = (HRGN)GDIOBJ_AllocObj(sizeof(ROSRGNDATA), GDI_OBJECT_TYPE_REGION, + (GDICLEANUPPROC) RGNDATA_InternalDelete))){ + if( (pReg = RGNDATA_LockRgn(hReg)) ){ if ((pReg->Buffer = ExAllocatePool(PagedPool, n * sizeof(RECT)))){ EMPTY_REGION(pReg); @@ -1448,7 +1449,7 @@ HRGN FASTCALL RGNDATA_AllocRgn(INT n) pReg->rdh.nCount = n; pReg->rdh.nRgnSize = n*sizeof(RECT); - bRet = GDIOBJ_UnlockObj( hReg, GO_REGION_MAGIC ); + bRet = RGNDATA_UnlockRgn(hReg); ASSERT(bRet); return hReg; @@ -1456,7 +1457,7 @@ HRGN FASTCALL RGNDATA_AllocRgn(INT n) } else - GDIOBJ_FreeObj( hReg, GO_REGION_MAGIC, GDIOBJFLAG_DEFAULT ); + RGNDATA_FreeRgn(hReg); } return NULL; } @@ -1478,7 +1479,7 @@ NtGdiCombineRgn(HRGN hDest, INT CombineMode) { INT result = ERROR; - GDIMULTILOCK Lock[3] = {{hDest, 0, GO_REGION_MAGIC}, {hSrc1, 0, GO_REGION_MAGIC}, {hSrc2, 0, GO_REGION_MAGIC}}; + GDIMULTILOCK Lock[3] = {{hDest, 0, GDI_OBJECT_TYPE_REGION}, {hSrc1, 0, GDI_OBJECT_TYPE_REGION}, {hSrc2, 0, GDI_OBJECT_TYPE_REGION}}; PROSRGNDATA destRgn, src1Rgn, src2Rgn; if ( !GDIOBJ_LockMultipleObj(Lock, sizeof(Lock)/sizeof(Lock[0])) ) @@ -1838,7 +1839,7 @@ NtGdiPaintRgn(HDC hDC, { //RECT box; HRGN tmpVisRgn; //, prevVisRgn; - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); PROSRGNDATA visrgn; CLIPOBJ* ClipRegion; BOOL bRet = FALSE; @@ -1850,7 +1851,7 @@ NtGdiPaintRgn(HDC hDC, return FALSE; if(!(tmpVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0))){ - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return FALSE; } @@ -1858,7 +1859,7 @@ NtGdiPaintRgn(HDC hDC, // Transform region into device co-ords if(!REGION_LPTODP(hDC, tmpVisRgn, hRgn) || NtGdiOffsetRgn(tmpVisRgn, dc->w.DCOrgX, dc->w.DCOrgY) == ERROR) { NtGdiDeleteObject( tmpVisRgn ); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return FALSE; } */ @@ -1887,7 +1888,7 @@ NtGdiPaintRgn(HDC hDC, RGNDATA_UnlockRgn( tmpVisRgn ); // Fill the region - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; } diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index 633d82e2da2..80970e99dfd 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: text.c,v 1.43 2003/08/19 11:48:50 weiden Exp $ */ +/* $Id: text.c,v 1.44 2003/08/20 07:45:02 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN @@ -719,7 +719,7 @@ NtGdiGetTextExtentExPoint(HDC hDC, return FALSE; } - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (NULL == dc) { if (NULL != Dx) @@ -731,7 +731,7 @@ NtGdiGetTextExtentExPoint(HDC hDC, return FALSE; } TextObj = TEXTOBJ_LockText(dc->w.hFont); - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); Result = TextIntGetTextExtentPoint(TextObj, String, Count, MaxExtent, NULL == UnsafeFit ? NULL : &Fit, Dx, &Size); TEXTOBJ_UnlockText(dc->w.hFont); @@ -812,7 +812,7 @@ NtGdiGetTextExtentPoint32(HDC hDC, BOOLEAN Result; PTEXTOBJ TextObj; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (NULL == dc) { @@ -852,7 +852,7 @@ NtGdiGetTextExtentPoint32(HDC hDC, return FALSE; } - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (NULL == dc) { ExFreePool(String); @@ -860,13 +860,13 @@ NtGdiGetTextExtentPoint32(HDC hDC, return FALSE; } TextObj = TEXTOBJ_LockText(dc->w.hFont); - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); Result = TextIntGetTextExtentPoint ( TextObj, String, Count, 0, NULL, NULL, &Size); - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); ASSERT(dc); // it succeeded earlier, it should now, too TEXTOBJ_UnlockText(dc->w.hFont); - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); ExFreePool(String); if (! Result) @@ -906,7 +906,7 @@ NtGdiGetTextMetrics(HDC hDC, FT_Face Face; ULONG Error; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (NULL == dc || NULL == tm) { Status = STATUS_INVALID_PARAMETER; @@ -948,7 +948,7 @@ NtGdiGetTextMetrics(HDC hDC, ASSERT(FALSE); Status = STATUS_INVALID_HANDLE; } - DC_ReleasePtr(hDC); + DC_UnlockDc(hDC); } return NT_SUCCESS(Status); @@ -986,14 +986,14 @@ NtGdiSetTextAlign(HDC hDC, UINT prevAlign; DC *dc; - dc = DC_HandleToPtr(hDC); + dc = DC_LockDc(hDC); if (!dc) { return 0; } prevAlign = dc->w.textAlign; dc->w.textAlign = Mode; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return prevAlign; } @@ -1003,7 +1003,7 @@ NtGdiSetTextColor(HDC hDC, COLORREF color) { COLORREF oldColor; - PDC dc = DC_HandleToPtr(hDC); + PDC dc = DC_LockDc(hDC); if (!dc) { @@ -1012,7 +1012,7 @@ NtGdiSetTextColor(HDC hDC, oldColor = dc->w.textColor; dc->w.textColor = color; - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return oldColor; } @@ -1035,7 +1035,7 @@ NtGdiTextOut(HDC hDC, { // Fixme: Call EngTextOut, which does the real work (calling DrvTextOut where appropriate) - DC *dc = DC_HandleToPtr(hDC); + DC *dc = DC_LockDc(hDC); SURFOBJ *SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface); int error, glyph_index, n, i; FT_Face face; @@ -1202,7 +1202,7 @@ NtGdiTextOut(HDC hDC, TEXTOBJ_UnlockText( dc->w.hFont ); BRUSHOBJ_UnlockBrush(hBrush); NtGdiDeleteObject( hBrush ); - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return TRUE; fail: @@ -1211,7 +1211,7 @@ fail: BRUSHOBJ_UnlockBrush(hBrush); NtGdiDeleteObject( hBrush ); } - DC_ReleasePtr( hDC ); + DC_UnlockDc( hDC ); return FALSE; }