2 added + 3 removed + 58 modified, total 63 files
reactos/include/napi
diff -u -r1.18 -r1.19
--- win32.h 22 May 2004 21:12:14 -0000 1.18
+++ win32.h 12 Sep 2004 19:21:05 -0000 1.19
@@ -34,8 +34,8 @@
struct _WINSTATION_OBJECT* WindowStation;
HANDLE hWindowStation;
ULONG Flags;
- WORD GDIObjects;
- WORD UserObjects;
+ LONG GDIObjects;
+ LONG UserObjects;
} W32PROCESS, *PW32PROCESS;
PW32THREAD STDCALL
reactos/include/win32k
diff -u -r1.24 -r1.25
--- bitmaps.h 3 Jul 2004 13:55:35 -0000 1.24
+++ bitmaps.h 12 Sep 2004 19:21:05 -0000 1.25
@@ -26,11 +26,12 @@
/* Internal interface */
#define BITMAPOBJ_AllocBitmap() \
- ((HBITMAP) GDIOBJ_AllocObj (sizeof (BITMAPOBJ), GDI_OBJECT_TYPE_BITMAP, (GDICLEANUPPROC) Bitmap_InternalDelete))
+ ((HBITMAP) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BITMAP))
#define BITMAPOBJ_FreeBitmap(hBMObj) \
- GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP, GDIOBJFLAG_DEFAULT)
+ GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
#define BITMAPOBJ_LockBitmap(hBMObj) GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
-#define BITMAPOBJ_UnlockBitmap(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)
+#define BITMAPOBJ_UnlockBitmap(BMObj) GDIOBJ_UnlockObj((PGDIOBJ) BMObj)
+BOOL FASTCALL BITMAP_Cleanup(PBITMAPOBJ pBmp);
INT FASTCALL BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp);
HBITMAP FASTCALL BITMAPOBJ_CopyBitmap (HBITMAP hBitmap);
@@ -38,7 +39,6 @@
int STDCALL DIB_GetDIBImageBytes (INT width, INT height, INT depth);
INT FASTCALL DIB_BitmapInfoSize (const BITMAPINFO * info, WORD coloruse);
INT STDCALL BITMAP_GetObject(BITMAPOBJ * bmp, INT count, LPVOID buffer);
-BOOL FASTCALL Bitmap_InternalDelete( PBITMAPOBJ pBmp );
HBITMAP FASTCALL BitmapToSurf(PBITMAPOBJ BitmapObj, HDEV GDIDevice);
HBITMAP FASTCALL IntCreateCompatibleBitmap(PDC Dc, INT Width, INT Height);
reactos/include/win32k
diff -u -r1.16 -r1.17
--- brush.h 14 Jul 2004 20:48:56 -0000 1.16
+++ brush.h 12 Sep 2004 19:21:05 -0000 1.17
@@ -68,10 +68,11 @@
#define GDIBRUSH_IS_MASKING 0x8000 /* Pattern bitmap is used as transparent mask (?) */
#define GDIBRUSH_CACHED_IS_SOLID 0x80000000
-#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_BRUSH, (GDICLEANUPPROC) Brush_InternalDelete))
-#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH, GDIOBJFLAG_DEFAULT)
+#define BRUSHOBJ_AllocBrush() ((HBRUSH) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_BRUSH))
+#define BRUSHOBJ_FreeBrush(hBrush) GDIOBJ_FreeObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
#define BRUSHOBJ_LockBrush(hBrush) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH))
-#define BRUSHOBJ_UnlockBrush(hBrush) GDIOBJ_UnlockObj((HGDIOBJ)hBrush, GDI_OBJECT_TYPE_BRUSH)
+#define BRUSHOBJ_UnlockBrush(BrushObj) GDIOBJ_UnlockObj((PGDIOBJ)BrushObj)
+BOOL FASTCALL BRUSH_Cleanup(PGDIBRUSHOBJ pBrush);
#ifdef __USE_W32API
typedef struct _PATRECT {
reactos/include/win32k
diff -u -r1.37 -r1.38
--- dc.h 14 Jul 2004 20:48:56 -0000 1.37
+++ dc.h 12 Sep 2004 19:21:05 -0000 1.38
@@ -140,17 +140,17 @@
#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)
+#define DC_UnlockDc(DC) \
+ GDIOBJ_UnlockObj ((PGDIOBJ) DC)
HDC FASTCALL RetrieveDisplayHDC(VOID);
HDC FASTCALL DC_AllocDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_InitDC(HDC DCToInit);
HDC FASTCALL DC_FindOpenDC(PUNICODE_STRING Driver);
VOID FASTCALL DC_FreeDC(HDC DCToFree);
+BOOL FASTCALL DC_Cleanup(PDC pDc);
HDC FASTCALL DC_GetNextDC (PDC pDC);
VOID FASTCALL DC_SetNextDC (PDC pDC, HDC hNextDC);
-BOOL FASTCALL DC_InternalDeleteDC( PDC DCToDelete );
VOID FASTCALL DC_SetOwnership(HDC DC, PEPROCESS Owner);
VOID FASTCALL DC_UpdateXforms(PDC dc);
reactos/include/win32k
diff -u -r1.24 -r1.25
--- gdiobj.h 4 Jul 2004 12:00:37 -0000 1.24
+++ gdiobj.h 12 Sep 2004 19:21:05 -0000 1.25
@@ -8,6 +8,25 @@
#include <ddk/ntddk.h>
+/* base address where the handle table is mapped to */
+#define GDI_HANDLE_TABLE_BASE_ADDRESS (0x400000)
+
+/* gdi handle table can hold 0x4000 handles */
+#define GDI_HANDLE_COUNT 0x4000
+
+#define GDI_GLOBAL_PROCESS (0x0)
+
+#define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1)
+#define GDI_HANDLE_TYPE_MASK 0x007f0000
+#define GDI_HANDLE_STOCK_MASK 0x00800000
+
+#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))
+
/*! \defgroup GDI object types
*
* GDI object types
@@ -37,26 +56,18 @@
typedef BOOL (FASTCALL *GDICLEANUPPROC)(PGDIOBJ Obj);
-#define GDIOBJ_USE_FASTMUTEX
-
/*!
* GDI object header. This is a part of any GDI object
*/
typedef struct _GDIOBJHDR
{
- DWORD dwCount; /* reference count for the object */
- HANDLE hProcessId;
- GDICLEANUPPROC CleanupProc;
- WORD wTableIndex;
- WORD Magic;
+ LONG RefCount; /* reference count for the object */
+ struct _W32THREAD *LockingThread; /* only assigned if a thread is holding the lock! */
+ ULONG Type;
+ PPAGED_LOOKASIDE_LIST LookasideList; /* FIXME - remove this */
+#ifdef GDI_DEBUG
const char* lockfile;
int lockline;
-#ifdef GDIOBJ_USE_FASTMUTEX
- FAST_MUTEX Lock;
- DWORD RecursiveLockCount;
-#else
- DWORD LockTid;
- DWORD LockCount;
#endif
} GDIOBJHDR, *PGDIOBJHDR;
@@ -67,32 +78,39 @@
DWORD ObjectType;
} GDIMULTILOCK, *PGDIMULTILOCK;
-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);
+HGDIOBJ FASTCALL GDIOBJ_AllocObj(ULONG ObjectType);
+BOOL FASTCALL GDIOBJ_FreeObj (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);
BOOL FASTCALL GDIOBJ_OwnedByCurrentProcess(HGDIOBJ ObjectHandle);
void FASTCALL GDIOBJ_SetOwnership(HGDIOBJ ObjectHandle, PEPROCESS Owner);
void FASTCALL GDIOBJ_CopyOwnership(HGDIOBJ CopyFrom, HGDIOBJ CopyTo);
+BOOL FASTCALL GDIOBJ_ConvertToStockObj(HGDIOBJ *hObj);
BOOL FASTCALL GDIOBJ_LockMultipleObj(PGDIMULTILOCK pList, INT nObj);
+#define GDIOBJ_GetObjectType(Handle) \
+ GDI_HANDLE_GET_TYPE(Handle)
+
+#ifdef GDI_DEBUG
+
/* 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)
+#define GDIOBJ_UnlockObj(obj) GDIOBJ_UnlockObjDbg(__FILE__,__LINE__,obj)
-#ifdef GDIOBJ_LockObj
PGDIOBJ FASTCALL GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType);
-#endif /* GDIOBJ_LockObj */
+BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, PGDIOBJ Object);
+
+#else /* !GDI_DEBUG */
-#ifdef GDIOBJ_UnlockObj
-BOOL FASTCALL GDIOBJ_UnlockObjDbg (const char* file, int line, HGDIOBJ Obj, DWORD ObjectType);
-#endif /* GDIOBJ_UnlockObj */
+PGDIOBJ FASTCALL GDIOBJ_LockObj (HGDIOBJ Obj, DWORD ObjectType);
+BOOL FASTCALL GDIOBJ_UnlockObj (PGDIOBJ Object);
+
+#endif /* GDI_DEBUG */
#define GDIOBJFLAG_DEFAULT (0x0)
#define GDIOBJFLAG_IGNOREPID (0x1)
#define GDIOBJFLAG_IGNORELOCK (0x2)
+PVOID FASTCALL GDI_MapHandleTable(HANDLE hProcess);
+
#endif
reactos/include/win32k
diff -u -r1.137.4.4 -r1.137.4.5
--- ntuser.h 1 Sep 2004 22:14:49 -0000 1.137.4.4
+++ ntuser.h 12 Sep 2004 19:21:05 -0000 1.137.4.5
@@ -163,6 +163,7 @@
#define NOPARAM_ROUTINE_GETMESSAGEEXTRAINFO 0xffff0005
#define NOPARAM_ROUTINE_ANYPOPUP 0xffff0006
#define NOPARAM_ROUTINE_CSRSS_INITIALIZED 0xffff0007
+#define NOPARAM_ROUTINE_GDI_QUERY_TABLE 0xffff0008
DWORD
STDCALL
NtUserCallNoParam(
@@ -211,6 +212,10 @@
#define TWOPARAM_ROUTINE_SETCARETPOS 0x60
#define TWOPARAM_ROUTINE_GETWINDOWINFO 0x61
#define TWOPARAM_ROUTINE_REGISTERLOGONPROC 0x62
+#define TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES 0x63
+#define TWOPARAM_ROUTINE_GETSYSCOLORPENS 0x64
+#define TWOPARAM_ROUTINE_GETSYSCOLORS 0x65
+#define TWOPARAM_ROUTINE_SETSYSCOLORS 0x66
DWORD
STDCALL
NtUserCallTwoParam(
@@ -1770,6 +1775,14 @@
} Value;
} KMDDELPARAM, *PKMDDELPARAM;
+typedef struct _GDI_TABLE_ENTRY
+{
+ PVOID KernelData; /* Points to the kernel mode structure */
+ LONG ProcessId; /* process id that created the object, 0 for stock objects */
+ LONG Type; /* the first 16 bit is the object type including the stock obj flag, the last 16 bits is just the object type */
+ PVOID UserData; /* Points to the user mode structure, usually NULL though */
+} GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY;
+
#endif /* __WIN32K_NTUSER_H */
/* EOF */
reactos/include/win32k
diff -u -r1.9 -r1.10
--- pen.h 5 Apr 2004 21:26:24 -0000 1.9
+++ pen.h 12 Sep 2004 19:21:05 -0000 1.10
@@ -6,10 +6,10 @@
/* Internal interface */
-#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(sizeof(GDIBRUSHOBJ), GDI_OBJECT_TYPE_PEN, NULL))
-#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN, GDIOBJFLAG_DEFAULT)
+#define PENOBJ_AllocPen() ((HPEN)GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PEN))
+#define PENOBJ_FreePen(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
#define PENOBJ_LockPen(hBMObj) ((PGDIBRUSHOBJ)GDIOBJ_LockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN))
-#define PENOBJ_UnlockPen(hBMObj) GDIOBJ_UnlockObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_PEN)
+#define PENOBJ_UnlockPen(BMObj) GDIOBJ_UnlockObj((PGDIOBJ) BMObj)
HPEN STDCALL
NtGdiCreatePen(
reactos/include/win32k
diff -u -r1.23 -r1.24
--- region.h 28 Jun 2004 21:03:08 -0000 1.23
+++ region.h 12 Sep 2004 19:21:05 -0000 1.24
@@ -11,12 +11,11 @@
} ROSRGNDATA, *PROSRGNDATA, *LPROSRGNDATA;
-#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION, GDIOBJFLAG_DEFAULT)
+#define RGNDATA_FreeRgn(hRgn) GDIOBJ_FreeObj((HGDIOBJ)hRgn, GDI_OBJECT_TYPE_REGION)
#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)
+#define RGNDATA_UnlockRgn(Rgn) GDIOBJ_UnlockObj((PGDIOBJ)Rgn)
HRGN FASTCALL RGNDATA_AllocRgn(INT n);
-
-BOOL FASTCALL RGNDATA_InternalDelete( PROSRGNDATA Obj );
+BOOL FASTCALL RGNDATA_Cleanup(PROSRGNDATA pRgn);
/* User entry points */
HRGN STDCALL
reactos/include/win32k
diff -u -r1.21 -r1.22
--- text.h 23 Mar 2004 07:59:47 -0000 1.21
+++ text.h 12 Sep 2004 19:21:05 -0000 1.22
@@ -6,16 +6,16 @@
typedef struct
{
LOGFONTW logfont;
- HFONT GDIFontHandle;
+ FONTOBJ *Font;
} TEXTOBJ, *PTEXTOBJ;
/* Internal interface */
#define TEXTOBJ_AllocText() \
- ((HFONT) GDIOBJ_AllocObj (sizeof (TEXTOBJ), GDI_OBJECT_TYPE_FONT, NULL))
-#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT, GDIOBJFLAG_DEFAULT)
+ ((HFONT) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_FONT))
+#define TEXTOBJ_FreeText(hBMObj) GDIOBJ_FreeObj((HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_FONT)
#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)
+#define TEXTOBJ_UnlockText(BMObj) GDIOBJ_UnlockObj ((PGDIOBJ) BMObj)
NTSTATUS FASTCALL TextIntRealizeFont(HFONT FontHandle);
NTSTATUS FASTCALL TextIntCreateFontIndirect(CONST LPLOGFONTW lf, HFONT *NewFont);
reactos/lib/user32/include
diff -u -r1.29 -r1.30
--- user32.h 15 Aug 2004 21:36:27 -0000 1.29
+++ user32.h 12 Sep 2004 19:21:05 -0000 1.30
@@ -30,10 +30,21 @@
BYTE Showing;
} THRDCARETINFO, *PTHRDCARETINFO;
+void InitStockObjects(void);
VOID CreateFrameBrushes(VOID);
VOID DeleteFrameBrushes(VOID);
void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo);
+LONG WINAPI RegCloseKey(HKEY);
+LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY);
+LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
+
+#ifdef __USE_W32API
+NTSTATUS STDCALL ZwCallbackReturn(PVOID Result,
+ ULONG ResultLength,
+ NTSTATUS Status);
+#endif
+
#define NtUserAnyPopup() \
(BOOL)NtUserCallNoParam(NOPARAM_ROUTINE_ANYPOPUP)
@@ -61,6 +72,18 @@
#define NtUserRegisterLogonProcess(hproc, x) \
(BOOL)NtUserCallTwoParam((DWORD)hproc, (DWORD)x, TWOPARAM_ROUTINE_REGISTERLOGONPROC)
+#define NtUserGetSysColorBrushes(HBrushes, count) \
+ (BOOL)NtUserCallTwoParam((DWORD)(HBrushes), (DWORD)(count), TWOPARAM_ROUTINE_GETSYSCOLORBRUSHES)
+
+#define NtUserGetSysColorPens(HPens, count) \
+ (BOOL)NtUserCallTwoParam((DWORD)(HPens), (DWORD)(count), TWOPARAM_ROUTINE_GETSYSCOLORPENS)
+
+#define NtUserGetSysColors(ColorRefs, count) \
+ (BOOL)NtUserCallTwoParam((DWORD)(ColorRefs), (DWORD)(count), TWOPARAM_ROUTINE_GETSYSCOLORS)
+
+#define NtUserSetSysColors(ColorRefs, count) \
+ (BOOL)NtUserCallTwoParam((DWORD)(ColorRefs), (DWORD)(count), TWOPARAM_ROUTINE_SETSYSCOLORS)
+
#define NtUserSetCaretBlinkTime(uMSeconds) \
(BOOL)NtUserCallOneParam((DWORD)uMSeconds, ONEPARAM_ROUTINE_SETCARETBLINKTIME)
@@ -100,12 +123,3 @@
#define NtUserEnableProcessWindowGhosting(bEnable) \
NtUserCallOneParam((DWORD)bEnable, ONEPARAM_ROUTINE_ENABLEPROCWNDGHSTING)
-LONG WINAPI RegCloseKey(HKEY);
-LONG WINAPI RegOpenKeyExW(HKEY,LPCWSTR,DWORD,REGSAM,PHKEY);
-LONG WINAPI RegQueryValueExW(HKEY,LPCWSTR,LPDWORD,LPDWORD,LPBYTE,LPDWORD);
-
-#ifdef __USE_W32API
-NTSTATUS STDCALL ZwCallbackReturn(PVOID Result,
- ULONG ResultLength,
- NTSTATUS Status);
-#endif
reactos/lib/user32/include
diff -u -r1.10 -r1.11
--- window.h 15 Mar 2004 23:49:28 -0000 1.10
+++ window.h 12 Sep 2004 19:21:05 -0000 1.11
@@ -7,14 +7,37 @@
#include <windows.h>
#include <user32/wininternal.h>
+extern COLORREF SysColors[];
+extern HPEN SysPens[];
+extern HBRUSH SysBrushes[];
+
+#define NUM_SYSCOLORS 31
+
#define IS_ATOM(x) \
(((ULONG_PTR)(x) > 0x0) && ((ULONG_PTR)(x) < 0x10000))
+#define UserHasAnyFrameStyle(Style, ExStyle) \
+ (((Style) & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) || \
+ ((ExStyle) & WS_EX_DLGMODALFRAME) || \
+ (!((Style) & (WS_CHILD | WS_POPUP))))
+
+#define UserHasDlgFrameStyle(Style, ExStyle) \
+ (((ExStyle) & WS_EX_DLGMODALFRAME) || \
+ (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME))))
+
+#define UserHasThickFrameStyle(Style, ExStyle) \
+ (((Style) & WS_THICKFRAME) && \
+ (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)))
+
+#define UserHasThinFrameStyle(Style, ExStyle) \
+ (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP))))
+
+#define UserHasBigFrameStyle(Style, ExStyle) \
+ (((Style) & (WS_THICKFRAME | WS_DLGFRAME)) || \
+ ((ExStyle) & WS_EX_DLGMODALFRAME))
+
+
BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down );
-ULONG
-UserHasDlgFrameStyle(ULONG Style, ULONG ExStyle);
-ULONG
-UserHasThickFrameStyle(ULONG Style, ULONG ExStyle);
void
UserGetFrameSize(ULONG Style, ULONG ExStyle, SIZE *Size);
void
reactos/lib/user32/misc
diff -u -r1.43 -r1.44
--- dllmain.c 16 Aug 2004 17:28:46 -0000 1.43
+++ dllmain.c 12 Sep 2004 19:21:05 -0000 1.44
@@ -76,6 +76,7 @@
InitializeCriticalSection(&gcsMPH);
GdiDllInitialize(NULL, DLL_PROCESS_ATTACH, NULL);
+ InitStockObjects();
}
VOID
reactos/lib/user32/misc
diff -u -r1.65 -r1.66
--- stubs.c 15 Aug 2004 21:36:28 -0000 1.65
+++ stubs.c 12 Sep 2004 19:21:05 -0000 1.66
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.65 2004/08/15 21:36:28 chorns Exp $
+/* $Id: stubs.c,v 1.66 2004/09/12 19:21:05 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -190,21 +190,6 @@
*/
BOOL
STDCALL
-SetSysColors(
- int cElements,
- CONST INT *lpaElements,
- CONST COLORREF *lpaRgbValues)
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
-
-/*
- * @unimplemented
- */
-BOOL
-STDCALL
TrackMouseEvent(
LPTRACKMOUSEEVENT lpEventTrack)
{
reactos/lib/user32/windows
diff -u -r1.144 -r1.145
--- defwnd.c 15 Aug 2004 21:36:29 -0000 1.144
+++ defwnd.c 12 Sep 2004 19:21:06 -0000 1.145
@@ -1,4 +1,4 @@
-/* $Id: defwnd.c,v 1.144 2004/08/15 21:36:29 chorns Exp $
+/* $Id: defwnd.c,v 1.145 2004/09/12 19:21:06 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -41,70 +41,46 @@
/* GLOBALS *******************************************************************/
-/* TODO: widgets will be cached here.
-static HBITMAP hbClose;
-static HBITMAP hbCloseD;
-static HBITMAP hbMinimize;
-static HBITMAP hbMinimizeD;
-static HBITMAP hbRestore;
-static HBITMAP hbRestoreD;
-static HBITMAP hbMaximize;
-static HBITMAP hbScrUp;
-static HBITMAP hbScrDwn;
-static HBITMAP hbScrLeft;
-static HBITMAP hbScrRight;
-*/
-
-
-static COLORREF SysColors[] =
-{
- RGB(212, 208, 200), /* COLOR_SCROLLBAR */
- RGB(58, 110, 165), /* COLOR_BACKGROUND */
- RGB(10, 36, 106), /* COLOR_ACTIVECAPTION */
- RGB(128, 128, 128), /* COLOR_INACTIVECAPTION */
- RGB(212, 208, 200), /* COLOR_MENU */
- RGB(255, 255, 255), /* COLOR_WINDOW */
- RGB(0, 0, 0), /* COLOR_WINDOWFRAME */
- RGB(0, 0, 0), /* COLOR_MENUTEXT */
- RGB(0, 0, 0), /* COLOR_WINDOWTEXT */
- RGB(255, 255, 255), /* COLOR_CAPTIONTEXT */
- RGB(212, 208, 200), /* COLOR_ACTIVEBORDER */
- RGB(212, 208, 200), /* COLOR_INACTIVEBORDER */
- RGB(128, 128, 128), /* COLOR_APPWORKSPACE */
- RGB(10, 36, 106), /* COLOR_HIGHLIGHT */
- RGB(255, 255, 255), /* COLOR_HIGHLIGHTTEXT */
- RGB(212, 208, 200), /* COLOR_BTNFACE */
- RGB(128, 128, 128), /* COLOR_BTNSHADOW */
- RGB(128, 128, 128), /* COLOR_GRAYTEXT */
- RGB(0, 0, 0), /* COLOR_BTNTEXT */
- RGB(212, 208, 200), /* COLOR_INACTIVECAPTIONTEXT */
- RGB(255, 255, 255), /* COLOR_BTNHIGHLIGHT */
- RGB(64, 64, 64), /* COLOR_3DDKSHADOW */
- RGB(212, 208, 200), /* COLOR_3DLIGHT */
- RGB(0, 0, 0), /* COLOR_INFOTEXT */
- RGB(255, 255, 225), /* COLOR_INFOBK */
- RGB(181, 181, 181), /* COLOR_UNKNOWN */
- RGB(0, 0, 128), /* COLOR_HOTLIGHT */
- RGB(166, 202, 240), /* COLOR_GRADIENTACTIVECAPTION */
- RGB(192, 192, 192), /* COLOR_GRADIENTINACTIVECAPTION */
- RGB(49, 106, 197), /* COLOR_MENUHILIGHT */
- RGB(236, 233, 216) /* COLOR_MENUBAR */
-};
-
-#define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
+static COLORREF SysColors[NUM_SYSCOLORS] = {0};
+static HPEN SysPens[NUM_SYSCOLORS] = {0};
+static HBRUSH SysBrushes[NUM_SYSCOLORS] = {0};
/* Bits in the dwKeyData */
#define KEYDATA_ALT 0x2000
/* FUNCTIONS *****************************************************************/
+void
+InitStockObjects(void)
+{
+ /* FIXME - Instead of copying the stuff to usermode we should map the tables to
+ userland. The current implementation has one big flaw: the system color
+ table doesn't get updated when another process changes them. That's why
+ we should rather map the table into usermode. But it only affects the
+ SysColors table - the pens, brushes and stock objects are not affected
+ as their handles never change. But it'd be faster to map them, too. */
+ if(SysBrushes[0] == NULL)
+ {
+ /* only initialize once */
+ NtUserGetSysColors(SysColors, NUM_SYSCOLORS);
+ NtUserGetSysColorPens(SysPens, NUM_SYSCOLORS);
+ NtUserGetSysColorBrushes(SysBrushes, NUM_SYSCOLORS);
+ }
+}
+
/*
* @implemented
*/
DWORD STDCALL
GetSysColor(int nIndex)
{
+ if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+ {
return SysColors[nIndex];
+ }
+
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return 0;
}
/*
@@ -113,22 +89,13 @@
HPEN STDCALL
GetSysColorPen(int nIndex)
{
- static HPEN SysPens[NUM_SYSCOLORS];
-
- if (nIndex < 0 || NUM_SYSCOLORS < nIndex)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- /* FIXME should register this object with DeleteObject() so it
- can't be deleted */
- if (NULL == SysPens[nIndex])
- {
- SysPens[nIndex] = CreatePen(PS_SOLID, 1, SysColors[nIndex]);
- }
+ if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+ {
+ return SysPens[nIndex];
+ }
- return SysPens[nIndex];
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
}
/*
@@ -137,89 +104,51 @@
HBRUSH STDCALL
GetSysColorBrush(int nIndex)
{
- static HBRUSH SysBrushes[NUM_SYSCOLORS];
-
- if (nIndex < 0 || NUM_SYSCOLORS < nIndex)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- /* FIXME should register this object with DeleteObject() so it
- can't be deleted */
- if (NULL == SysBrushes[nIndex])
- {
- SysBrushes[nIndex] = (HBRUSH) ((DWORD) CreateSolidBrush(SysColors[nIndex]) | 0x00800000);
- }
+ if(nIndex >= 0 && nIndex <= NUM_SYSCOLORS)
+ {
+ return SysBrushes[nIndex];
+ }
- return SysBrushes[nIndex];
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
}
/*
- * @unimplemented
- */
-/*
-LRESULT STDCALL
-DefFrameProcA( HWND hWnd,
- HWND hWndMDIClient,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam )
-{
- UNIMPLEMENTED;
- return ((LRESULT)0);
-}
-*/
-
-/*
- * @unimplemented
+ * @implemented
*/
-/*
-LRESULT STDCALL
-DefFrameProcW(HWND hWnd,
- HWND hWndMDIClient,
- UINT uMsg,
- WPARAM wParam,
- LPARAM lParam)
+BOOL
+STDCALL
+SetSysColors(
+ int cElements,
+ CONST INT *lpaElements,
+ CONST COLORREF *lpaRgbValues)
{
- UNIMPLEMENTED;
- return ((LRESULT)0);
-}
-*/
-
-ULONG
-UserHasAnyFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & (WS_THICKFRAME | WS_DLGFRAME | WS_BORDER)) ||
- (ExStyle & WS_EX_DLGMODALFRAME) ||
- (!(Style & (WS_CHILD | WS_POPUP))));
-}
-
-ULONG
-UserHasDlgFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((ExStyle & WS_EX_DLGMODALFRAME) ||
- ((Style & WS_DLGFRAME) && (!(Style & WS_THICKFRAME))));
-}
-
-ULONG
-UserHasThickFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & WS_THICKFRAME) &&
- (!((Style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)));
-}
-
-ULONG
-UserHasThinFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & WS_BORDER) || (!(Style & (WS_CHILD | WS_POPUP))));
-}
+ BOOL Ret;
+ struct
+ {
+ INT *Elements;
+ COLORREF *Colors;
+ } ChangeSysColors;
-ULONG
-UserHasBigFrameStyle(ULONG Style, ULONG ExStyle)
-{
- return ((Style & (WS_THICKFRAME | WS_DLGFRAME)) ||
- (ExStyle & WS_EX_DLGMODALFRAME));
+ ChangeSysColors.Elements = (INT*)lpaElements;
+ ChangeSysColors.Colors = (COLORREF*)lpaRgbValues;
+
+ if(cElements > 0)
+ {
+ Ret = NtUserSetSysColors(&ChangeSysColors, cElements);
+ if(Ret)
+ {
+ /* FIXME - just change it in the usermode structure, too, instead of asking win32k again */
+ NtUserGetSysColors(SysColors, NUM_SYSCOLORS);
+ }
+ }
+ else
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ Ret = FALSE;
+ }
+
+ return Ret;
}
void
reactos/ntoskrnl/include/internal
diff -u -r1.39.2.2.2.2 -r1.39.2.2.2.3
--- ex.h 18 Jul 2004 23:48:42 -0000 1.39.2.2.2.2
+++ ex.h 12 Sep 2004 19:21:06 -0000 1.39.2.2.2.3
@@ -106,5 +106,9 @@
IN struct _KEVENT_PAIR* EventPair
);
+LONGLONG
+FASTCALL
+ExfpInterlockedExchange64(LONGLONG volatile * Destination,
+ PLONGLONG Exchange);
#endif /* __NTOSKRNL_INCLUDE_INTERNAL_EXECUTIVE_H */
reactos/subsys/win32k/eng
diff -u -r1.58 -r1.58.2.1
--- bitblt.c 14 Jul 2004 20:48:57 -0000 1.58
+++ bitblt.c 12 Sep 2004 19:21:06 -0000 1.58.2.1
@@ -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: bitblt.c,v 1.58 2004/07/14 20:48:57 navaraf Exp $
+/* $Id: bitblt.c,v 1.58.2.1 2004/09/12 19:21:06 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -89,8 +89,9 @@
static BYTE maskbit[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
/* Pattern brushes */
PGDIBRUSHINST GdiBrush = NULL;
- HBITMAP PatternSurface = NULL;
+ HBITMAP PatternSurface;
SURFOBJ *PatternObj = NULL;
+ PBITMAPOBJ PatternBitmap;
ULONG PatternWidth = 0, PatternHeight = 0, PatternY = 0;
if (Mask == NULL)
@@ -103,8 +104,6 @@
if (Brush->iSolidColor == 0xFFFFFFFF)
{
- PBITMAPOBJ PatternBitmap;
-
GdiBrush = CONTAINING_RECORD(
Brush,
GDIBRUSHINST,
@@ -112,11 +111,15 @@
PatternSurface = GdiBrush->GdiBrushObject->hbmPattern;
PatternBitmap = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern);
-
- PatternObj = &PatternBitmap->SurfObj;
- PatternWidth = PatternObj->sizlBitmap.cx;
- PatternHeight = PatternObj->sizlBitmap.cy;
+ if(PatternBitmap != NULL)
+ {
+ PatternObj = &PatternBitmap->SurfObj;
+ PatternWidth = PatternObj->sizlBitmap.cx;
+ PatternHeight = PatternObj->sizlBitmap.cy;
+ }
}
+ else
+ PatternBitmap = NULL;
tMask = Mask->pvScan0 + SourcePoint->y * Mask->lDelta + (SourcePoint->x >> 3);
for (j = 0; j < dy; j++)
@@ -124,14 +127,14 @@
lMask = tMask;
c8 = SourcePoint->x & 0x07;
- if(PatternSurface)
+ if(PatternBitmap != NULL)
PatternY = (DestRect->top + j) % PatternHeight;
for (i = 0; i < dx; i++)
{
if (0 != (*lMask & maskbit[c8]))
{
- if (PatternSurface == NULL)
+ if (PatternBitmap == NULL)
{
DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_PutPixel(
Dest, DestRect->left + i, DestRect->top + j, Brush->iSolidColor);
@@ -153,8 +156,8 @@
tMask += Mask->lDelta;
}
- if (PatternSurface != NULL)
- BITMAPOBJ_UnlockBitmap(PatternSurface);
+ if (PatternBitmap != NULL)
+ BITMAPOBJ_UnlockBitmap(PatternBitmap);
return TRUE;
}
@@ -222,17 +225,27 @@
if (ROP_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
{
GdiBrush = CONTAINING_RECORD(Brush, GDIBRUSHINST, BrushObject);
- bmPattern = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern);
- BltInfo.PatternSurface = &bmPattern->SurfObj;
+ if((bmPattern = BITMAPOBJ_LockBitmap(GdiBrush->GdiBrushObject->hbmPattern)))
+ {
+ BltInfo.PatternSurface = &bmPattern->SurfObj;
+ }
+ else
+ {
+ /* FIXME - What to do here? */
+ }
BltInfo.XlatePatternToDest = GdiBrush->XlateObject;
}
+ else
+ {
+ bmPattern = NULL;
+ }
Result = DibFunctionsForBitmapFormat[OutputObj->iBitmapFormat].DIB_BitBlt(&BltInfo);
/* Pattern brush */
- if (ROP_USES_PATTERN(Rop4) && Brush->iSolidColor == 0xFFFFFFFF)
+ if (bmPattern != NULL)
{
- BITMAPOBJ_UnlockBitmap(BltInfo.PatternSurface->hsurf);
+ BITMAPOBJ_UnlockBitmap(bmPattern);
}
return Result;
reactos/subsys/win32k/eng
diff -u -r1.22 -r1.22.10.1
--- clip.c 30 May 2004 14:01:12 -0000 1.22
+++ clip.c 12 Sep 2004 19:21:06 -0000 1.22.10.1
@@ -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: clip.c,v 1.22 2004/05/30 14:01:12 weiden Exp $
+/* $Id: clip.c,v 1.22.10.1 2004/09/12 19:21:06 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -28,83 +28,7 @@
*/
#include <w32k.h>
-VOID STDCALL IntEngDeleteClipRegion(CLIPOBJ *ClipObj)
-{
- HCLIP HClip = AccessHandleFromUserObject(ClipObj);
- FreeGDIHandle(HClip);
-}
-
-CLIPOBJ* STDCALL
-IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
-{
- HCLIP hClip;
- CLIPGDI* clipInt;
- CLIPOBJ* clipUser;
-
- DPRINT("IntEngCreateClipRegion count: %d\n", count);
- if (1 < count)
- {
- hClip = (HCLIP) CreateGDIHandle(sizeof(CLIPGDI) + count * sizeof(RECTL),
- sizeof(CLIPOBJ), (PVOID*)&clipInt, (PVOID*)&clipUser);
-
- if (hClip)
- {
- RtlCopyMemory(clipInt->EnumRects.arcl, pRect, count * sizeof(RECTL));
- clipInt->EnumRects.c = count;
- clipInt->EnumOrder = CD_ANY;
-
- clipUser->iDComplexity = DC_COMPLEX;
- clipUser->iFComplexity = (count <= 4) ? FC_RECT4: FC_COMPLEX;
- clipUser->iMode = TC_RECTANGLES;
- RtlCopyMemory(&(clipUser->rclBounds), rcBounds, sizeof(RECTL));
-
- return clipUser;
- }
- }
- else
- {
- hClip = (HCLIP) CreateGDIHandle(sizeof(CLIPGDI),
- sizeof(CLIPOBJ),
- (PVOID)&clipInt, (PVOID)&clipUser);
- if (hClip)
- {
- RtlCopyMemory(clipInt->EnumRects.arcl, rcBounds, sizeof(RECTL));
- clipInt->EnumRects.c = 1;
- clipInt->EnumOrder = CD_ANY;
-
- clipUser->iDComplexity = ((rcBounds->top==rcBounds->bottom)
- && (rcBounds->left==rcBounds->right))
- ? DC_TRIVIAL : DC_RECT;
- clipUser->iFComplexity = FC_RECT;
- clipUser->iMode = TC_RECTANGLES;
- DPRINT("IntEngCreateClipRegion: iDComplexity: %d\n", clipUser->iDComplexity);
- RtlCopyMemory(&(clipUser->rclBounds), rcBounds, sizeof(RECTL));
- return clipUser;
- }
- }
-
- return NULL;
-}
-
-/*
- * @implemented
- */
-CLIPOBJ * STDCALL
-EngCreateClip(VOID)
-{
- return EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPOBJ), 0);
-}
-
-/*
- * @implemented
- */
-VOID STDCALL
-EngDeleteClip(CLIPOBJ *ClipRegion)
-{
- EngFreeMem(ClipRegion);
-}
-
-static int
+static inline int
CompareRightDown(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -117,7 +41,7 @@
{
Cmp = +1;
}
- else
+ else
{
ASSERT(r1->bottom == r2->bottom);
if (r1->left < r2->left)
@@ -138,7 +62,7 @@
return Cmp;
}
-static int
+static inline int
CompareRightUp(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -151,7 +75,7 @@
{
Cmp = -1;
}
- else
+ else
{
ASSERT(r1->top == r2->top);
if (r1->left < r2->left)
@@ -172,7 +96,7 @@
return Cmp;
}
-static int
+static inline int
CompareLeftDown(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -185,7 +109,7 @@
{
Cmp = +1;
}
- else
+ else
{
ASSERT(r1->bottom == r2->bottom);
if (r1->right < r2->right)
@@ -206,7 +130,7 @@
return Cmp;
}
-static int
+static inline int
CompareLeftUp(const PRECT r1, const PRECT r2)
{
int Cmp;
@@ -219,7 +143,7 @@
{
Cmp = -1;
}
- else
+ else
{
ASSERT(r1->top == r2->top);
if (r1->right < r2->right)
@@ -240,6 +164,122 @@
return Cmp;
}
+static inline int
+CompareSpans(const PSPAN Span1, const PSPAN Span2)
+{
+ int Cmp;
+
+ if (Span1->Y < Span2->Y)
+ {
+ Cmp = -1;
+ }
+ else if (Span2->Y < Span1->Y)
+ {
+ Cmp = +1;
+ }
+ else
+ {
+ if (Span1->X < Span2->X)
+ {
+ Cmp = -1;
+ }
+ else if (Span2->X < Span1->X)
+ {
+ Cmp = +1;
+ }
+ else
+ {
+ Cmp = 0;
+ }
+ }
+
+ return Cmp;
+}
+
+VOID FASTCALL
+IntEngDeleteClipRegion(CLIPOBJ *ClipObj)
+{
+ EngFreeMem(ObjToGDI(ClipObj, CLIP));
+}
+
+CLIPOBJ* FASTCALL
+IntEngCreateClipRegion(ULONG count, PRECTL pRect, PRECTL rcBounds)
+{
+ CLIPGDI *Clip;
+
+ if(count > 1)
+ {
+ RECTL *dest;
+
+ Clip = EngAllocMem(0, sizeof(CLIPGDI) + ((count - 1) * sizeof(RECTL)), TAG_CLIPOBJ);
+
+ if(Clip != NULL)
+ {
+ Clip->EnumRects.c = count;
+ Clip->EnumOrder = CD_ANY;
+ for(dest = Clip->EnumRects.arcl;
+ count > 0;
+ count--, dest++, pRect++)
+ {
+ *dest = *pRect;
+ }
+
+ Clip->ClipObj.iDComplexity = DC_COMPLEX;
+ Clip->ClipObj.iFComplexity = ((Clip->EnumRects.c <= 4) ? FC_RECT4 : FC_COMPLEX);
+ Clip->ClipObj.iMode = TC_RECTANGLES;
+ Clip->ClipObj.rclBounds = *rcBounds;
+
+ return GDIToObj(Clip, CLIP);
+ }
+ }
+ else
+ {
+ Clip = EngAllocMem(0, sizeof(CLIPGDI), TAG_CLIPOBJ);
+
+ if(Clip != NULL)
+ {
+ Clip->EnumRects.c = 1;
+ Clip->EnumOrder = CD_ANY;
+ Clip->EnumRects.arcl[0] = *rcBounds;
+
+ Clip->ClipObj.iDComplexity = (((rcBounds->top == rcBounds->bottom) &&
+ (rcBounds->left == rcBounds->right))
+ ? DC_TRIVIAL : DC_RECT);
+ Clip->ClipObj.iFComplexity = FC_RECT;
+ Clip->ClipObj.iMode = TC_RECTANGLES;
+ Clip->ClipObj.rclBounds = *rcBounds;
+
+ return GDIToObj(Clip, CLIP);
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * @implemented
+ */
+CLIPOBJ * STDCALL
+EngCreateClip(VOID)
+{
+ CLIPGDI *Clip = EngAllocMem(FL_ZERO_MEMORY, sizeof(CLIPOBJ), TAG_CLIPOBJ);
+ if(Clip != NULL)
+ {
+ return GDIToObj(Clip, CLIP);
+ }
+
+ return NULL;
+}
+
+/*
+ * @implemented
+ */
+VOID STDCALL
+EngDeleteClip(CLIPOBJ *ClipRegion)
+{
+ EngFreeMem(ObjToGDI(ClipRegion, CLIP));
+}
+
/*
* @implemented
*/
@@ -250,7 +290,7 @@
IN ULONG BuildOrder,
IN ULONG MaxRects)
{
- CLIPGDI *ClipGDI = (CLIPGDI*)AccessInternalObjectFromUserObject(ClipObj);
+ CLIPGDI *ClipGDI = ObjToGDI(ClipObj, CLIP);
SORTCOMP CompareFunc;
ClipGDI->EnumPos = 0;
@@ -305,8 +345,9 @@
IN ULONG ObjSize,
OUT ULONG *EnumRects)
{
- CLIPGDI *ClipGDI = (CLIPGDI*)AccessInternalObjectFromUserObject(ClipObj);
- ULONG nCopy;
+ RECTL *dest, *src;
+ CLIPGDI *ClipGDI = ObjToGDI(ClipObj, CLIP);
+ ULONG nCopy, i;
ENUMRECTS* pERects = (ENUMRECTS*)EnumRects;
//calculate how many rectangles we should copy
@@ -317,8 +358,16 @@
{
return FALSE;
}
- RtlCopyMemory( pERects->arcl, ClipGDI->EnumRects.arcl + ClipGDI->EnumPos,
- nCopy * sizeof(RECTL) );
+
+ /* copy rectangles */
+ src = ClipGDI->EnumRects.arcl + ClipGDI->EnumPos;
+ for(i = 0, dest = pERects->arcl;
+ i < nCopy;
+ i++, dest++, src++)
+ {
+ *dest = *src;
+ }
+
pERects->c = nCopy;
ClipGDI->EnumPos+=nCopy;
@@ -326,38 +375,6 @@
return ClipGDI->EnumPos < ClipGDI->EnumRects.c;
}
-static int
-CompareSpans(const PSPAN Span1, const PSPAN Span2)
-{
- int Cmp;
-
- if (Span1->Y < Span2->Y)
- {
- Cmp = -1;
- }
- else if (Span2->Y < Span1->Y)
- {
- Cmp = +1;
- }
- else
- {
- if (Span1->X < Span2->X)
- {
- Cmp = -1;
- }
- else if (Span2->X < Span1->X)
- {
- Cmp = +1;
- }
- else
- {
- Cmp = 0;
- }
- }
-
- return Cmp;
-}
-
BOOLEAN FASTCALL
ClipobjToSpans(PSPAN *Spans, UINT *Count, CLIPOBJ *ClipRegion, PRECTL Boundary)
{
@@ -418,7 +435,14 @@
}
if (0 != *Count)
{
- RtlCopyMemory(NewSpans, *Spans, *Count * sizeof(SPAN));
+ PSPAN dest, src;
+ UINT i = *Count;
+ for(dest = NewSpans, src = *Spans;
+ i > 0;
+ i--)
+ {
+ *dest++ = *src++;
+ }
ExFreePool(*Spans);
}
*Spans = NewSpans;
reactos/subsys/win32k/eng
diff -u -r1.76.2.2 -r1.76.2.3
--- mouse.c 27 Aug 2004 15:56:04 -0000 1.76.2.2
+++ mouse.c 12 Sep 2004 19:21:06 -0000 1.76.2.3
@@ -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.76.2.2 2004/08/27 15:56:04 weiden Exp $
+/* $Id: mouse.c,v 1.76.2.3 2004/09/12 19:21:06 weiden Exp $
*
* PROJECT: ReactOS kernel
* PURPOSE: Mouse
@@ -50,8 +50,10 @@
}
dc = DC_LockDc(hDisplayDC);
+ /* FIXME - dc can be NULL!! Don't assert here! */
ASSERT(dc);
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Don't assert here! */
ASSERT(BitmapObj);
/* Move the cursor to the screen center */
@@ -62,8 +64,8 @@
ExReleaseFastMutex(&CurInfo->CursorMutex);
GdiDev = GDIDEV(&BitmapObj->SurfObj);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- DC_UnlockDc( hDisplayDC );
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ DC_UnlockDc( dc );
IntSetCursor(NULL, TRUE);
@@ -494,18 +496,14 @@
HPALETTE BWPalette, DestPalette;
ULONG BWColors[] = {0, 0xFFFFFF};
PDC Dc;
- PPALGDI PalObj;
- LONG DestMode;
BWPalette = EngCreatePalette(PAL_INDEXED, sizeof(BWColors) / sizeof(ULONG),
BWColors, 0, 0, 0);
Dc = DC_LockDc(IntGetScreenDC());
+ /* FIXME - Handle DC == NULL!!!!! */
DestPalette = Dc->w.hPalette;
- PalObj = PALETTE_LockPalette(DestPalette);
- DestMode = PalObj->Mode;
- PALETTE_UnlockPalette(DestPalette);
- DC_UnlockDc(IntGetScreenDC());
- ppdev->PointerXlateObject = IntEngCreateXlate(DestMode, PAL_INDEXED,
+ DC_UnlockDc(Dc);
+ ppdev->PointerXlateObject = IntEngCreateXlate(0, PAL_INDEXED,
DestPalette, BWPalette);
EngDeletePalette(BWPalette);
}
reactos/subsys/win32k/eng
diff -u -r1.32 -r1.32.4.1
--- objects.h 3 Jul 2004 13:55:35 -0000 1.32
+++ objects.h 12 Sep 2004 19:21:06 -0000 1.32.4.1
@@ -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: objects.h,v 1.32 2004/07/03 13:55:35 navaraf Exp $
+/* $Id: objects.h,v 1.32.4.1 2004/09/12 19:21:06 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -34,8 +34,6 @@
/* Structure of internal gdi objects that win32k manages for ddi engine:
|---------------------------------|
- | EngObj |
- |---------------------------------|
| Public part |
| accessed from engine |
|---------------------------------|
@@ -45,21 +43,8 @@
---------------------------------------------------------------------------*/
-typedef struct _ENGOBJ {
- ULONG hObj;
- ULONG InternalSize;
- ULONG UserSize;
-} ENGOBJ, *PENGOBJ;
-
typedef struct _CLIPGDI {
- ENGOBJ Header;
- CLIPOBJ ClipObj;
- /* ei what were these for?
- ULONG NumRegionRects;
- ULONG NumIntersectRects;
- RECTL *RegionRects;
- RECTL *IntersectRects;
- */
+ CLIPOBJ ClipObj;
ULONG EnumPos;
ULONG EnumOrder;
ULONG EnumMax;
@@ -73,12 +58,11 @@
} DRVFUNCTIONSGDI;
typedef struct _FLOATGDI {
-
+ ULONG Dummy;
} FLOATGDI;
typedef struct _FONTGDI {
- ENGOBJ Header;
- FONTOBJ FontObj;
+ FONTOBJ FontObj;
LPCWSTR Filename;
FT_Face face;
@@ -86,13 +70,11 @@
} FONTGDI, *PFONTGDI;
typedef struct _PATHGDI {
- ENGOBJ Header;
- PATHOBJ PathObj;
+ PATHOBJ PathObj;
} PATHGDI;
typedef struct _STRGDI {
- ENGOBJ Header;
- STROBJ StrObj;
+ STROBJ StrObj;
} STRGDI;
typedef BOOL STDCALL (*PFN_BitBlt)(SURFOBJ *, SURFOBJ *, SURFOBJ *, CLIPOBJ *,
@@ -141,12 +123,11 @@
typedef BOOL STDCALL (*PFN_GradientFill)(SURFOBJ*, CLIPOBJ*, XLATEOBJ*, TRIVERTEX*, ULONG, PVOID, ULONG, RECTL*, POINTL*, ULONG);
typedef struct _XFORMGDI {
- ENGOBJ Header;
+ ULONG Dummy;
/* XFORMOBJ has no public members */
} XFORMGDI;
typedef struct _XLATEGDI {
- ENGOBJ Header;
XLATEOBJ XlateObj;
HPALETTE DestPal;
HPALETTE SourcePal;
@@ -170,4 +151,10 @@
// };
} XLATEGDI;
+/* as the *OBJ structures are located at the beginning of the *GDI structures
+ we can simply typecast the pointer */
+#define ObjToGDI(ClipObj, Type) (Type##GDI *)(ClipObj)
+#define GDIToObj(ClipGDI, Type) (Type##OBJ *)(ClipGDI)
+
+
#endif //__ENG_OBJECTS_H
reactos/subsys/win32k/eng
diff -u -r1.44 -r1.44.4.1
--- surface.c 7 Jul 2004 16:33:44 -0000 1.44
+++ surface.c 12 Sep 2004 19:21:06 -0000 1.44.4.1
@@ -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.44 2004/07/07 16:33:44 navaraf Exp $
+/* $Id: surface.c,v 1.44.4.1 2004/09/12 19:21:06 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -280,7 +280,7 @@
}
if (SurfObj->pvBits == NULL)
{
- BITMAPOBJ_UnlockBitmap(NewBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
BITMAPOBJ_FreeBitmap(NewBitmap);
return 0;
}
@@ -314,7 +314,7 @@
BitmapObj->dimension.cy = 0;
BitmapObj->dib = NULL;
- BITMAPOBJ_UnlockBitmap(NewBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return NewBitmap;
}
@@ -368,7 +368,7 @@
BitmapObj->flHooks = 0;
- BITMAPOBJ_UnlockBitmap(NewSurface);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return NewSurface;
}
@@ -410,7 +410,7 @@
/* Hook up specified functions */
BitmapObj->flHooks = Hooks;
- BITMAPOBJ_UnlockBitmap(Surface);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return TRUE;
}
@@ -490,6 +490,10 @@
VOID STDCALL
EngUnlockSurface(IN SURFOBJ *Surface)
{
- BITMAPOBJ_UnlockBitmap ( Surface->hsurf );
+ /* FIXME - Determine the address of the PBITMAPOBJ structure, this is just a hack
+ as we know that the PSURFOBJ is the first field so we can just typecast it.
+ But it might change some day, so please fix this! */
+
+ BITMAPOBJ_UnlockBitmap ( (BITMAPOBJ*)Surface );
}
/* EOF */
reactos/subsys/win32k/eng
diff -u -r1.41.2.1 -r1.41.2.2
--- xlate.c 18 Jul 2004 23:44:00 -0000 1.41.2.1
+++ xlate.c 12 Sep 2004 19:21:06 -0000 1.41.2.2
@@ -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: xlate.c,v 1.41.2.1 2004/07/18 23:44:00 weiden Exp $
+/* $Id: xlate.c,v 1.41.2.2 2004/09/12 19:21:06 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -29,7 +29,8 @@
#include <w32k.h>
-static ULONG FASTCALL ShiftAndMask(XLATEGDI *XlateGDI, ULONG Color)
+static inline ULONG
+ShiftAndMask(XLATEGDI *XlateGDI, ULONG Color)
{
ULONG TranslatedColor;
@@ -50,62 +51,65 @@
}
-ULONG STDCALL
+static inline ULONG
ClosestColorMatch(XLATEGDI *XlateGDI, LPPALETTEENTRY SourceColor,
PALETTEENTRY *DestColors, ULONG NumColors)
{
ULONG SourceRed, SourceGreen, SourceBlue;
- ULONG cxRed, cxGreen, cxBlue, Rating, BestMatch = 16777215;
+ ULONG cxRed, cxGreen, cxBlue, Rating, BestMatch = 0xFFFFFF;
ULONG CurrentIndex, BestIndex = 0;
SourceRed = SourceColor->peRed;
SourceGreen = SourceColor->peGreen;
SourceBlue = SourceColor->peBlue;
- for (CurrentIndex = 0; CurrentIndex < NumColors; CurrentIndex++)
+ for (CurrentIndex = 0; CurrentIndex < NumColors; CurrentIndex++, DestColors++)
{
- cxRed = abs((SHORT)SourceRed - (SHORT)DestColors[CurrentIndex].peRed);
+ cxRed = abs((SHORT)SourceRed - (SHORT)DestColors->peRed);
cxRed *= cxRed;
- cxGreen = abs((SHORT)SourceGreen - (SHORT)DestColors[CurrentIndex].peGreen);
+ cxGreen = abs((SHORT)SourceGreen - (SHORT)DestColors->peGreen);
cxGreen *= cxGreen;
- cxBlue = abs((SHORT)SourceBlue - (SHORT)DestColors[CurrentIndex].peBlue);
+ cxBlue = abs((SHORT)SourceBlue - (SHORT)DestColors->peBlue);
cxBlue *= cxBlue;
Rating = cxRed + cxGreen + cxBlue;
+
+ if (Rating == 0)
+ {
+ /* Exact match */
+ BestIndex = CurrentIndex;
+ break;
+ }
if (Rating < BestMatch)
{
BestIndex = CurrentIndex;
BestMatch = Rating;
}
-
- /* Exact match */
- if (Rating == 0)
- break;
}
return BestIndex;
}
-static VOID STDCALL
+static inline VOID
BitMasksFromPal(USHORT PalType, PPALGDI Palette,
PULONG RedMask, PULONG BlueMask, PULONG GreenMask)
{
- static const union { PALETTEENTRY Color; ULONG Mask; } Red = {{255, 0, 0}};
- static const union { PALETTEENTRY Color; ULONG Mask; } Green = {{0, 255, 0}};
- static const union { PALETTEENTRY Color; ULONG Mask; } Blue = {{0, 0, 255}};
+ static const union { PALETTEENTRY Color; ULONG Mask; } Red = {{0xFF, 0x00, 0x00}};
+ static const union { PALETTEENTRY Color; ULONG Mask; } Green = {{0x00, 0xFF, 0x00}};
+ static const union { PALETTEENTRY Color; ULONG Mask; } Blue = {{0x00, 0x00, 0xFF}};
switch (PalType)
{
case PAL_RGB:
- *RedMask = RGB(255, 0, 0);
- *GreenMask = RGB(0, 255, 0);
- *BlueMask = RGB(0, 0, 255);
+ *RedMask = RGB(0xFF, 0x00, 0x00);
+ *GreenMask = RGB(0x00, 0xFF, 0x00);
+ *BlueMask = RGB(0x00, 0x00, 0xFF);
break;
case PAL_BGR:
- *RedMask = RGB(0, 0, 255);
- *GreenMask = RGB(0, 255, 0);
- *BlueMask = RGB(255, 0, 0);
+ *RedMask = RGB(0x00, 0x00, 0xFF);
+ *GreenMask = RGB(0x00, 0xFF, 0x00);
+ *BlueMask = RGB(0xFF, 0x00, 0x00);
break;
case PAL_BITFIELDS:
*RedMask = Palette->RedMask;
@@ -124,7 +128,8 @@
* Calculate the number of bits Mask must be shift to the left to get a
* 1 in the most significant bit position
*/
-static INT FASTCALL CalculateShift(ULONG Mask)
+static inline INT
+CalculateShift(ULONG Mask)
{
ULONG Shift = 0;
ULONG LeftmostBit = 1 << (8 * sizeof(ULONG) - 1);
@@ -138,11 +143,10 @@
return Shift;
}
-XLATEOBJ* STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateXlate(USHORT DestPalType, USHORT SourcePalType,
HPALETTE PaletteDest, HPALETTE PaletteSource)
{
- ULONG NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *SourcePalGDI = 0;
@@ -151,9 +155,13 @@
ULONG DestRedMask, DestGreenMask, DestBlueMask;
ULONG i;
- NewXlate = CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
- if (!ValidEngHandle(NewXlate))
+ XlateGDI = EngAllocMem(0, sizeof(XLATEGDI), TAG_XLATEOBJ);
+ if (XlateGDI == NULL)
+ {
+ DPRINT1("Failed to allocate memory for a XLATE structure!\n");
return NULL;
+ }
+ XlateObj = GDIToObj(XlateGDI, XLATE);
if (PaletteSource != NULL)
SourcePalGDI = PALETTE_LockPalette(PaletteSource);
@@ -263,27 +271,32 @@
*/
end:
- if (PaletteSource != NULL)
- PALETTE_UnlockPalette(PaletteSource);
- if (PaletteDest != NULL && PaletteDest != PaletteSource)
- PALETTE_UnlockPalette(PaletteDest);
+ if (SourcePalGDI != NULL)
+ PALETTE_UnlockPalette(SourcePalGDI);
+ if (DestPalGDI != NULL && DestPalGDI != SourcePalGDI)
+ PALETTE_UnlockPalette(DestPalGDI);
return XlateObj;
}
-XLATEOBJ * STDCALL IntEngCreateMonoXlate(
+XLATEOBJ* FASTCALL
+IntEngCreateMonoXlate(
USHORT SourcePalType, HPALETTE PaletteDest, HPALETTE PaletteSource,
ULONG BackgroundColor)
{
- ULONG NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *SourcePalGDI;
- NewXlate = CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
- if (!ValidEngHandle(NewXlate))
+ XlateGDI = EngAllocMem(0, sizeof(XLATEGDI), TAG_XLATEOBJ);
+ if (XlateGDI == NULL)
+ {
+ DPRINT1("Failed to allocate memory for a XLATE structure!\n");
return NULL;
+ }
+ XlateObj = GDIToObj(XlateGDI, XLATE);
SourcePalGDI = PALETTE_LockPalette(PaletteSource);
+ /* FIXME - SourcePalGDI can be NULL!!! Handle this case instead of ASSERT! */
ASSERT(SourcePalGDI);
if (SourcePalType == 0)
@@ -324,17 +337,16 @@
break;
}
- PALETTE_UnlockPalette(PaletteSource);
+ PALETTE_UnlockPalette(SourcePalGDI);
return XlateObj;
}
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
ULONG ForegroundColor,
ULONG BackgroundColor)
{
- ULONG NewXlate;
XLATEOBJ *XlateObj;
XLATEGDI *XlateGDI;
PALGDI *DestPalGDI;
@@ -343,14 +355,20 @@
if (DestPalGDI == NULL)
return NULL;
- NewXlate = CreateGDIHandle(sizeof(XLATEGDI), sizeof(XLATEOBJ), (PVOID*)&XlateGDI, (PVOID*)&XlateObj);
- if (!ValidEngHandle(NewXlate))
+ XlateGDI = EngAllocMem(0, sizeof(XLATEGDI), TAG_XLATEOBJ);
+ if (XlateGDI == NULL)
+ {
+ PALETTE_UnlockPalette(DestPalGDI);
+ DPRINT1("Failed to allocate memory for a XLATE structure!\n");
return NULL;
+ }
+ XlateObj = GDIToObj(XlateGDI, XLATE);
XlateGDI->translationTable = EngAllocMem(0, sizeof(ULONG) * 2, 0);
if (XlateGDI->translationTable == NULL)
{
- FreeGDIHandle(NewXlate);
+ PALETTE_UnlockPalette(DestPalGDI);
+ EngFreeMem(XlateGDI);
return NULL;
}
@@ -368,9 +386,9 @@
BitMasksFromPal(DestPalGDI->Mode, DestPalGDI, &XlateGDI->RedMask,
&XlateGDI->BlueMask, &XlateGDI->GreenMask);
- XlateGDI->RedShift = CalculateShift(RGB(255, 0, 0)) - CalculateShift(XlateGDI->RedMask);
- XlateGDI->GreenShift = CalculateShift(RGB(0, 255, 0)) - CalculateShift(XlateGDI->GreenMask);
- XlateGDI->BlueShift = CalculateShift(RGB(0, 0, 255)) - CalculateShift(XlateGDI->BlueMask);
+ XlateGDI->RedShift = CalculateShift(RGB(0xFF, 0x00, 0x00)) - CalculateShift(XlateGDI->RedMask);
+ XlateGDI->GreenShift = CalculateShift(RGB(0x00, 0xFF, 0x00)) - CalculateShift(XlateGDI->GreenMask);
+ XlateGDI->BlueShift = CalculateShift(RGB(0x00, 0x00, 0xFF)) - CalculateShift(XlateGDI->BlueMask);
XlateGDI->translationTable[0] = ShiftAndMask(XlateGDI, BackgroundColor);
XlateGDI->translationTable[1] = ShiftAndMask(XlateGDI, ForegroundColor);
@@ -389,7 +407,7 @@
DestPalGDI->NumColors);
}
- PALETTE_UnlockPalette(PaletteDest);
+ PALETTE_UnlockPalette(DestPalGDI);
return XlateObj;
}
@@ -403,7 +421,6 @@
EngDeleteXlate(XLATEOBJ *XlateObj)
{
XLATEGDI *XlateGDI;
- HANDLE HXlate;
if (XlateObj == NULL)
{
@@ -411,8 +428,7 @@
return;
}
- XlateGDI = (XLATEGDI *)AccessInternalObjectFromUserObject(XlateObj);
- HXlate = (HANDLE)AccessHandleFromUserObject(XlateObj);
+ XlateGDI = ObjToGDI(XlateObj, XLATE);
if ((XlateObj->flXlate & XO_TABLE) &&
XlateGDI->translationTable != NULL)
@@ -420,7 +436,7 @@
EngFreeMem(XlateGDI->translationTable);
}
- FreeGDIHandle((ULONG)HXlate);
+ EngFreeMem(XlateGDI);
}
/*
@@ -429,7 +445,7 @@
PULONG STDCALL
XLATEOBJ_piVector(XLATEOBJ *XlateObj)
{
- XLATEGDI *XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
+ XLATEGDI *XlateGDI = ObjToGDI(XlateObj, XLATE);
if (XlateObj->iSrcType == PAL_INDEXED)
{
@@ -459,7 +475,7 @@
if (XlateObj->flXlate & XO_TABLE)
return XlateObj->pulXlate[Color];
- XlateGDI = (XLATEGDI *)AccessInternalObjectFromUserObject(XlateObj);
+ XlateGDI = ObjToGDI(XlateObj, XLATE);
if (XlateObj->flXlate & XO_TO_MONO)
return Color == XlateGDI->BackgroundColor;
@@ -472,17 +488,19 @@
{
/* FIXME: should we cache colors used often? */
/* FIXME: won't work if destination isn't indexed */
-
- /* Extract the destination palette. */
- PalGDI = PALETTE_LockPalette(XlateGDI->DestPal);
-
+
/* Convert the source color to the palette RGB format. */
Color = ShiftAndMask(XlateGDI, Color);
- /* Return closest match for the given color. */
- Closest = ClosestColorMatch(XlateGDI, (LPPALETTEENTRY)&Color, PalGDI->IndexedColors, PalGDI->NumColors);
- PALETTE_UnlockPalette(XlateGDI->DestPal);
- return Closest;
+ /* Extract the destination palette. */
+ PalGDI = PALETTE_LockPalette(XlateGDI->DestPal);
+ if(PalGDI != NULL)
+ {
+ /* Return closest match for the given color. */
+ Closest = ClosestColorMatch(XlateGDI, (LPPALETTEENTRY)&Color, PalGDI->IndexedColors, PalGDI->NumColors);
+ PALETTE_UnlockPalette(PalGDI);
+ return Closest;
+ }
}
return 0;
@@ -498,8 +516,9 @@
HPALETTE hPalette;
XLATEGDI *XlateGDI;
PALGDI *PalGDI;
+ ULONG *InPal;
- XlateGDI = (XLATEGDI*)AccessInternalObjectFromUserObject(XlateObj);
+ XlateGDI = ObjToGDI(XlateObj, XLATE);
if (PalOutType == XO_SRCPALETTE)
hPalette = XlateGDI->SourcePal;
else if (PalOutType == XO_DESTPALETTE)
@@ -508,10 +527,23 @@
UNIMPLEMENTED;
PalGDI = PALETTE_LockPalette(hPalette);
- RtlCopyMemory(OutPal, PalGDI->IndexedColors, sizeof(ULONG) * cPal);
- PALETTE_UnlockPalette(hPalette);
+ if(PalGDI != NULL)
+ {
+ /* copy the indexed colors into the buffer */
- return cPal;
+ for(InPal = (ULONG*)PalGDI->IndexedColors;
+ cPal > 0;
+ cPal--, InPal++, OutPal++)
+ {
+ *OutPal = *InPal;
+ }
+
+ PALETTE_UnlockPalette(PalGDI);
+
+ return cPal;
+ }
+
+ return 0;
}
/* EOF */
reactos/subsys/win32k/eng
diff -N clip.h
--- clip.h 14 May 2004 22:56:18 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-/*
- * ReactOS kernel
- * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#ifndef __WIN32K_CLIP_H
-#define __WIN32K_CLIP_H
-
-typedef ULONG HCLIP;
-CLIPOBJ* STDCALL IntEngCreateClipRegion( ULONG count, PRECTL pRect, PRECTL rcBounds );
-VOID STDCALL IntEngDeleteClipRegion(CLIPOBJ *ClipObj);
-
-
-#define ENUM_RECT_LIMIT 50
-
-typedef struct _RECT_ENUM
-{
- ULONG c;
- RECTL arcl[ENUM_RECT_LIMIT];
-} RECT_ENUM;
-
-typedef struct tagSPAN
-{
- LONG Y;
- LONG X;
- ULONG Width;
-} SPAN, *PSPAN;
-
-BOOLEAN FASTCALL ClipobjToSpans(PSPAN *Spans, UINT *Count, CLIPOBJ *ClipRegion, PRECTL Boundary);
-
-#endif
reactos/subsys/win32k/eng
diff -N handle.c
--- handle.c 30 May 2004 14:01:12 -0000 1.16
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,134 +0,0 @@
-/*
- * ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id: handle.c,v 1.16 2004/05/30 14:01:12 weiden Exp $
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Manage GDI Handles
- * FILE: subsys/win32k/eng/handle.c
- * PROGRAMER: Jason Filby
- * REVISION HISTORY:
- * 29/8/1999: Created
- */
-#include <w32k.h>
-
-static int LastHandle = MAX_GDI_HANDLES;
-static GDI_HANDLE GDIHandles[MAX_GDI_HANDLES];
-
-ULONG FASTCALL CreateGDIHandle(ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject)
-{
- PENGOBJ pObj;
- int i;
-
- /* internal size includes header and user portions */
- pObj = EngAllocMem( FL_ZERO_MEMORY, InternalSize, 0 );
-
- if( !pObj )
- return 0;
-
- #if 0
- /* not used at the moment */
- pObj->InternalSize = InternalSize;
- pObj->UserSize = UserSize;
- #endif
-
- for( i = (MAX_GDI_HANDLES - 1 <= LastHandle ? 1 : LastHandle + 1); i != LastHandle;
- i = (MAX_GDI_HANDLES - 1 <= i ? 1 : i + 1) ){
- if( GDIHandles[ i ].pEngObj == NULL ){
- pObj->hObj = i;
- GDIHandles[ i ].pEngObj = pObj;
-
- *InternalObject = pObj;
- *UserObject = (PVOID)( (PCHAR)pObj + sizeof( ENGOBJ ) );
-
- DPRINT("CreateGDIHandle: obj: %x, handle: %d, usersize: %d\n", pObj, i, UserSize );
- LastHandle = i;
- return i;
- }
- }
- DPRINT1("CreateGDIHandle: Out of available handles!!!\n");
- EngFreeMem( pObj );
- return 0;
-}
-
-VOID FASTCALL FreeGDIHandle(ULONG Handle)
-{
- if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
- DPRINT1("FreeGDIHandle: invalid handle!!!!\n");
- return;
- }
- DPRINT("FreeGDIHandle: handle: %d\n", Handle);
- EngFreeMem( GDIHandles[Handle].pEngObj );
- GDIHandles[Handle].pEngObj = NULL;
-}
-
-PVOID FASTCALL AccessInternalObject(ULONG Handle)
-{
- PENGOBJ pEngObj;
-
- if (Handle == 0 || Handle >= MAX_GDI_HANDLES
- || !(pEngObj = GDIHandles[Handle].pEngObj))
- {
- DPRINT1("AccessInternalObject: invalid handle: %d!!!!\n", Handle);
- return NULL;
- }
-
- return (PVOID)pEngObj;
-}
-
-PVOID FASTCALL AccessUserObject(ULONG Handle)
-{
- PENGOBJ pEngObj;
-
- if (Handle == 0 || Handle >= MAX_GDI_HANDLES
- || !(pEngObj = GDIHandles[Handle].pEngObj))
- {
- DPRINT1("AccessUserObject: invalid handle: %d!!!!\n", Handle);
- return NULL;
- }
-
- return (PVOID)( (PCHAR)pEngObj + sizeof( ENGOBJ ) );
-}
-
-ULONG FASTCALL AccessHandleFromUserObject(PVOID UserObject)
-{
- PENGOBJ pEngObj;
- ULONG Handle;
-
- if( !UserObject )
- return INVALID_HANDLE;
-
- pEngObj = (PENGOBJ)((PCHAR) UserObject - sizeof( ENGOBJ ));
- Handle = pEngObj->hObj;
-
- if( Handle == 0 || Handle >= MAX_GDI_HANDLES ){
- DPRINT1("AccessHandleFromUserObject: inv handle: %d, obj: %x!!!!\n", Handle, pEngObj);
- return INVALID_HANDLE;
- }
- return Handle;
-}
-
-VOID FASTCALL InitEngHandleTable( void )
-{
- ULONG i;
- for( i=1; i < MAX_GDI_HANDLES; i++ ){
- GDIHandles[ i ].pEngObj = NULL;
- }
-}
-/* EOF */
reactos/subsys/win32k/eng
diff -N handle.h
--- handle.h 30 May 2004 14:01:12 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-/*
- * ReactOS kernel
- * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $Id: handle.h,v 1.6 2004/05/30 14:01:12 weiden Exp $
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS kernel
- * PURPOSE: Manage GDI Handle definitions
- * FILE: subsys/win32k/eng/handle.h
- * PROGRAMER: Jason Filby
- * REVISION HISTORY:
- * 29/8/1999: Created
- */
-#ifndef __ENG_HANDLE_H
-#define __ENG_HANDLE_H
-
-#include "objects.h"
-#include <include/object.h>
-
-typedef struct _GDI_HANDLE {
- PENGOBJ pEngObj;
-} GDI_HANDLE, *PGDI_HANDLE;
-
-#define INVALID_HANDLE 0
-#define MAX_GDI_HANDLES 4096
-
-#define ValidEngHandle( x ) (!( (x) == INVALID_HANDLE ))
-
-#endif
reactos/subsys/win32k/include
diff -N intddraw.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ intddraw.h 12 Sep 2004 19:21:06 -0000 1.1.2.1
@@ -0,0 +1,67 @@
+#ifndef _INT_W32k_DDRAW
+#define _INT_W32k_DDRAW
+
+#define GDI_OBJECT_TYPE_DIRECTDRAW 0x00600000
+#define GDI_OBJECT_TYPE_DD_SURFACE 0x00610000
+#define GDI_OBJECT_TYPE_DD_VIDEOPORT 0x00620000
+#define GDI_OBJECT_TYPE_DD_PALETTE 0x00630000
+#define GDI_OBJECT_TYPE_DD_CLIPPER 0x00640000
+#define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00650000
+
+typedef struct
+{
+ DD_SURFACE_LOCAL Local;
+ DD_SURFACE_MORE More;
+ DD_SURFACE_GLOBAL Global;
+ DD_ATTACHLIST AttachList;
+ DD_ATTACHLIST AttachListFrom;
+ BOOL bComplete;
+} DD_SURFACE, *PDD_SURFACE;
+
+typedef struct
+{
+ DD_DIRECTDRAW_LOCAL Local;
+ DD_DIRECTDRAW_GLOBAL Global;
+ // Drv callbacks
+ PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
+ PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
+ // DD callbacks
+ PDD_CREATESURFACE DdCreateSurface;
+ PDD_SETCOLORKEY DdDrvSetColorKey; // ?????
+ PDD_WAITFORVERTICALBLANK DdWaitForVerticalBlank;
+ PDD_CANCREATESURFACE DdCanCreateSurface;
+ PDD_CREATEPALETTE DdCreatePalette;
+ PDD_GETSCANLINE DdGetScanLine;
+ PDD_MAPMEMORY DdMapMemory;
+ // Surface callbacks
+ PDD_SURFCB_DESTROYSURFACE DdDestroySurface;
+ PDD_SURFCB_FLIP DdFlip;
+ PDD_SURFCB_SETCLIPLIST DdSetClipList;
+ PDD_SURFCB_LOCK DdLock;
+ PDD_SURFCB_UNLOCK DdUnlock;
+ PDD_SURFCB_BLT DdBlt;
+ PDD_SURFCB_SETCOLORKEY DdSetColorKey;
+ PDD_SURFCB_ADDATTACHEDSURFACE DdAddAttachedSurface;
+ PDD_SURFCB_GETBLTSTATUS DdGetBltStatus;
+ PDD_SURFCB_GETFLIPSTATUS DdGetFlipStatus;
+ PDD_SURFCB_UPDATEOVERLAY DdUpdateOverlay;
+ PDD_SURFCB_SETOVERLAYPOSITION DdSetOverlayPosition;
+ PDD_SURFCB_SETPALETTE DdSetPalette;
+ // Palette callbacks
+ PDD_PALCB_DESTROYPALETTE DdDestroyPalette;
+ PDD_PALCB_SETENTRIES DdSetEntries;
+ // D3D Device context callbacks
+ PD3DNTHAL_CONTEXTCREATECB D3dContextCreate;
+ PD3DNTHAL_CONTEXTDESTROYCB D3dContextDestroy;
+ // D3D Buffer callbacks
+ PDD_CANCREATESURFACE DdCanCreateD3DBuffer;
+ PDD_CREATESURFACE DdCreateD3DBuffer;
+ PDD_SURFCB_DESTROYSURFACE DdDestroyD3DBuffer;
+ PDD_SURFCB_LOCK DdLockD3DBuffer;
+ PDD_SURFCB_UNLOCK DdUnlockD3DBuffer;
+} DD_DIRECTDRAW, *PDD_DIRECTDRAW;
+
+BOOL FASTCALL DD_Cleanup(PDD_DIRECTDRAW pDD);
+BOOL FASTCALL DDSURF_Cleanup(PDD_SURFACE pDDSurf);
+
+#endif /* _INT_W32k_DDRAW */
reactos/subsys/win32k/include
diff -u -r1.15 -r1.15.2.1
--- inteng.h 14 Jul 2004 20:48:57 -0000 1.15
+++ inteng.h 12 Sep 2004 19:21:06 -0000 1.15.2.1
@@ -1,6 +1,23 @@
#ifndef _WIN32K_INTENG_H
#define _WIN32K_INTENG_H
+typedef ULONG HCLIP;
+
+#define ENUM_RECT_LIMIT 50
+
+typedef struct _RECT_ENUM
+{
+ ULONG c;
+ RECTL arcl[ENUM_RECT_LIMIT];
+} RECT_ENUM;
+
+typedef struct tagSPAN
+{
+ LONG Y;
+ LONG X;
+ ULONG Width;
+} SPAN, *PSPAN;
+
#define ROP_NOOP 0x00AA0029
/* Definitions of IntEngXxx functions */
@@ -54,19 +71,19 @@
POINTL *pptlDitherOrg,
ULONG ulMode);
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateXlate(USHORT DestPalType,
USHORT SourcePalType,
HPALETTE PaletteDest,
HPALETTE PaletteSource);
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateMonoXlate(USHORT SourcePalType,
HPALETTE PaletteDest,
HPALETTE PaletteSource,
ULONG BackgroundColor);
-XLATEOBJ * STDCALL
+XLATEOBJ* FASTCALL
IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
ULONG ForegroundColor,
ULONG BackgroundColor);
@@ -79,11 +96,20 @@
LONG dCount,
MIX mix);
-CLIPOBJ* STDCALL
+CLIPOBJ* FASTCALL
IntEngCreateClipRegion(ULONG count,
PRECTL pRect,
PRECTL rcBounds);
+VOID FASTCALL
+IntEngDeleteClipRegion(CLIPOBJ *ClipObj);
+
+BOOLEAN FASTCALL
+ClipobjToSpans(PSPAN *Spans,
+ UINT *Count,
+ CLIPOBJ *ClipRegion,
+ PRECTL Boundary);
+
BOOL FASTCALL
IntEngTransparentBlt(BITMAPOBJ *Dest,
BITMAPOBJ *Source,
reactos/subsys/win32k/include
diff -u -r1.1.4.7 -r1.1.4.8
--- internal.h 1 Sep 2004 22:14:50 -0000 1.1.4.7
+++ internal.h 12 Sep 2004 19:21:06 -0000 1.1.4.8
@@ -233,10 +233,10 @@
#define DCHF_VALIDATEVISRGN 0x0002
#define DCEOBJ_AllocDCE() \
- ((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)
+ ((HDCE) GDIOBJ_AllocObj (GDI_OBJECT_TYPE_DCE))
+#define DCEOBJ_FreeDCE(hDCE) GDIOBJ_FreeObj((HGDIOBJ)hDCE, GDI_OBJECT_TYPE_DCE)
#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)
+#define DCEOBJ_UnlockDCE(DCE) GDIOBJ_UnlockObj((PGDIOBJ)DCE)
typedef enum
{
@@ -260,10 +260,10 @@
PDCE FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
PDCE FASTCALL DCE_FreeDCE(PDCE dce);
VOID FASTCALL DCE_FreeWindowDCE(PWINDOW_OBJECT);
+BOOL FASTCALL DCE_Cleanup(PDCE pDce);
HRGN FASTCALL DceGetVisRgn(PWINDOW_OBJECT Window, ULONG Flags, PWINDOW_OBJECT Child, ULONG CFlags);
INT FASTCALL DCE_ExcludeRgn(HDC, PWINDOW_OBJECT, HRGN);
BOOL FASTCALL DCE_InvalidateDCE(PWINDOW_OBJECT, const PRECTL);
-BOOL FASTCALL DCE_InternalDelete(PDCE dce);
PWINDOW_OBJECT FASTCALL IntWindowFromDC(HDC hDc);
PDCE FASTCALL DceFreeDCE(PDCE dce);
void FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window);
@@ -293,6 +293,7 @@
NTSTATUS FASTCALL IntHideDesktop(PDESKTOP_OBJECT Desktop);
HDESK FASTCALL IntGetDesktopObjectHandle(PDESKTOP_OBJECT DesktopObject);
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP_OBJECT *Object);
+BOOL FASTCALL IntPaintDesktop(HDC hDC);
/* FOCUS **********************************************************************/
reactos/subsys/win32k/include
diff -u -r1.15 -r1.15.2.1
--- intgdi.h 14 Jul 2004 20:48:57 -0000 1.15
+++ intgdi.h 12 Sep 2004 19:21:06 -0000 1.15.2.1
@@ -145,5 +145,19 @@
LPXFORM xform1,
LPXFORM xform2);
+/* Stock objects */
+
+BOOL FASTCALL
+IntSetSysColors(UINT nColors, INT *Elements, COLORREF *Colors);
+
+BOOL FASTCALL
+IntGetSysColorBrushes(HBRUSH *Brushes, UINT nBrushes);
+
+BOOL FASTCALL
+IntGetSysColorPens(HPEN *Pens, UINT nPens);
+
+BOOL FASTCALL
+IntGetSysColors(COLORREF *Colors, UINT nColors);
+
#endif /* _WIN32K_INTGDI_H */
reactos/subsys/win32k/include
diff -u -r1.24.4.1 -r1.24.4.2
--- object.h 15 Jul 2004 20:07:16 -0000 1.24.4.1
+++ object.h 12 Sep 2004 19:21:06 -0000 1.24.4.2
@@ -97,21 +97,10 @@
* GDI
*/
-ULONG FASTCALL CreateGDIHandle (ULONG InternalSize, ULONG UserSize, PVOID *InternalObject, PVOID *UserObject);
-VOID FASTCALL FreeGDIHandle (ULONG Handle);
-
-PVOID FASTCALL AccessUserObject (ULONG Handle);
-PVOID FASTCALL AccessInternalObject (ULONG Handle);
-
-ULONG FASTCALL AccessHandleFromUserObject (PVOID UserObject);
-
-#define AccessInternalObjectFromUserObject(UserObj) \
- ((PVOID)( (PCHAR)(UserObj) - sizeof( ENGOBJ ) ) )
-
-VOID FASTCALL InitEngHandleTable (VOID);
VOID FASTCALL InitGdiObjectHandleTable (VOID);
VOID FASTCALL CreateStockObjects (VOID);
+VOID FASTCALL CreateSysColorObjects (VOID);
BOOL FASTCALL CleanupForProcess (struct _EPROCESS *Process, INT Pid);
reactos/subsys/win32k/include
diff -u -r1.9 -r1.9.4.1
--- palette.h 22 Jun 2004 20:08:16 -0000 1.9
+++ palette.h 12 Sep 2004 19:21:06 -0000 1.9.4.1
@@ -35,9 +35,10 @@
ULONG Blue);
HPALETTE FASTCALL PALETTE_AllocPaletteIndexedRGB(ULONG NumColors,
CONST RGBQUAD *Colors);
-#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE, GDIOBJFLAG_DEFAULT)
+#define PALETTE_FreePalette(hPalette) GDIOBJ_FreeObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
#define PALETTE_LockPalette(hPalette) ((PPALGDI)GDIOBJ_LockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE))
-#define PALETTE_UnlockPalette(hPalette) GDIOBJ_UnlockObj((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
+#define PALETTE_UnlockPalette(Palette) GDIOBJ_UnlockObj((PGDIOBJ)Palette)
+BOOL FASTCALL PALETTE_Cleanup(PPALGDI pPal);
HPALETTE FASTCALL PALETTE_Init (VOID);
VOID FASTCALL PALETTE_ValidateFlags (PALETTEENTRY* lpPalE, INT size);
reactos/subsys/win32k/include
diff -u -r1.5.12.1 -r1.5.12.2
--- tags.h 15 Jul 2004 20:07:16 -0000 1.5.12.1
+++ tags.h 12 Sep 2004 19:21:06 -0000 1.5.12.2
@@ -42,9 +42,15 @@
#define TAG_PRINT TAG('P', 'R', 'N', 'T') /* print */
#define TAG_REGION TAG('R', 'G', 'N', 'O') /* region */
#define TAG_GDITEXT TAG('T', 'X', 'T', 'O') /* text */
-#define TAG_FONT TAG('F', 'N', 'T', 'O') /* font entry */
+
+/* Eng objects */
+#define TAG_CLIPOBJ TAG('C', 'L', 'P', 'O') /* clip object */
+#define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate object */
+#define TAG_FONT TAG('F', 'N', 'T', 'E') /* font entry */
+#define TAG_FONTOBJ TAG('F', 'N', 'T', 'O') /* font object */
/* misc */
-#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */
+#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */
+#define TAG_FNTFILE TAG('F', 'N', 'T', 'F') /* font file */
#endif /* _WIN32K_TAGS_H */
reactos/subsys/win32k/main
diff -u -r1.76.12.2 -r1.76.12.3
--- dllmain.c 27 Aug 2004 15:56:05 -0000 1.76.12.2
+++ dllmain.c 12 Sep 2004 19:21:07 -0000 1.76.12.3
@@ -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: dllmain.c,v 1.76.12.2 2004/08/27 15:56:05 weiden Exp $
+/* $Id: dllmain.c,v 1.76.12.3 2004/09/12 19:21:07 weiden Exp $
*
* Entry Point for win32k.sys
*/
@@ -273,6 +273,7 @@
/* Create stock objects, ie. precreated objects commonly
used by win32 applications */
CreateStockObjects();
+ CreateSysColorObjects();
PREPARE_TESTS
reactos/subsys/win32k
diff -u -r1.101.4.1 -r1.101.4.2
--- makefile 15 Jul 2004 20:07:17 -0000 1.101.4.1
+++ makefile 12 Sep 2004 19:21:07 -0000 1.101.4.2
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.101.4.1 2004/07/15 20:07:17 weiden Exp $
+# $Id: makefile,v 1.101.4.2 2004/09/12 19:21:07 weiden Exp $
PATH_TO_TOP = ../..
@@ -32,6 +32,7 @@
-I$(PATH_TO_TOP)/ntoskrnl/include \
-I$(FREETYPE_DIR)/include \
-DUNICODE \
+ -DGDI_DEBUG \
-Wall -Werror \
-D__USE_W32API -D_WIN32_WINNT=0x0501 \
-DWINVER=0x600 -D_WIN32K_
@@ -42,7 +43,7 @@
--disable-stdcall-fixup
ENG_OBJECTS= eng/debug.o eng/error.o eng/mem.o eng/brush.o eng/bitblt.o \
- eng/clip.o eng/copybits.o eng/device.o eng/handle.o eng/lineto.o \
+ eng/clip.o eng/copybits.o eng/device.o eng/lineto.o \
eng/paint.o eng/palette.o eng/perfcnt.o eng/semaphor.o eng/surface.o \
eng/xlate.o eng/transblt.o eng/mouse.o eng/misc.o eng/sort.o \
eng/gradient.o eng/event.o eng/float.o
@@ -62,13 +63,13 @@
ntuser/vis.o ntuser/windc.o ntuser/window.o ntuser/winpos.o ntuser/winsta.o
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
- objects/color.o objects/coord.o objects/dc.o \
- objects/fillshap.o objects/gdiobj.o objects/icm.o \
- objects/line.o objects/metafile.o objects/paint.o \
+ objects/color.o objects/coord.o objects/cursoricon.o \
+ objects/dc.o objects/fillshap.o objects/gdiobj.o \
+ objects/icm.o objects/line.o objects/metafile.o objects/paint.o \
objects/path.o objects/pen.o objects/print.o \
objects/region.o objects/text.o objects/wingl.o \
objects/bezier.o objects/dib.o objects/palette.o \
- objects/rect.o objects/polyfill.o objects/cursoricon.o
+ objects/rect.o objects/polyfill.o objects/stockobj.o
DIB_OBJECTS = dib/dib.o dib/dib1bpp.o dib/dib4bpp.o dib/dib8bpp.o dib/dib16bpp.o \
dib/dib24bpp.o dib/dib32bpp.o
reactos/subsys/win32k
diff -u -r1.4.4.2 -r1.4.4.3
--- w32k.h 18 Jul 2004 23:44:00 -0000 1.4.4.2
+++ w32k.h 12 Sep 2004 19:21:07 -0000 1.4.4.3
@@ -31,8 +31,6 @@
#include <eng/objects.h>
#include <eng/misc.h>
-#include <eng/handle.h>
-#include <eng/clip.h>
#include <include/misc.h>
#include <include/color.h>
reactos/subsys/win32k/ntddraw
diff -u -r1.2 -r1.2.12.1
--- ddraw.c 10 May 2004 17:07:18 -0000 1.2
+++ ddraw.c 12 Sep 2004 19:21:07 -0000 1.2.12.1
@@ -8,71 +8,24 @@
* REVISION HISTORY:
* 25-10-2003 PB Created
*/
+
#include <ddk/ntddk.h>
#include <win32k/ntddraw.h>
#include <win32k/win32k.h>
+#include <include/intddraw.h>
#include <win32k/gdiobj.h>
#define NDEBUG
#include <debug.h>
-#define GDI_OBJECT_TYPE_DIRECTDRAW 0x00600000
-#define GDI_OBJECT_TYPE_DD_SURFACE 0x00610000
-#define GDI_OBJECT_TYPE_DD_VIDEOPORT 0x00620000
-#define GDI_OBJECT_TYPE_DD_PALETTE 0x00630000
-#define GDI_OBJECT_TYPE_DD_CLIPPER 0x00640000
-#define GDI_OBJECT_TYPE_DD_MOTIONCOMP 0x00650000
-
/************************************************************************/
/* DIRECT DRAW OBJECT */
/************************************************************************/
-typedef struct
-{
- DD_DIRECTDRAW_LOCAL Local;
- DD_DIRECTDRAW_GLOBAL Global;
- // Drv callbacks
- PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
- PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
- // DD callbacks
- PDD_CREATESURFACE DdCreateSurface;
- PDD_SETCOLORKEY DdDrvSetColorKey; // ?????
- PDD_WAITFORVERTICALBLANK DdWaitForVerticalBlank;
- PDD_CANCREATESURFACE DdCanCreateSurface;
- PDD_CREATEPALETTE DdCreatePalette;
- PDD_GETSCANLINE DdGetScanLine;
- PDD_MAPMEMORY DdMapMemory;
- // Surface callbacks
- PDD_SURFCB_DESTROYSURFACE DdDestroySurface;
- PDD_SURFCB_FLIP DdFlip;
- PDD_SURFCB_SETCLIPLIST DdSetClipList;
- PDD_SURFCB_LOCK DdLock;
- PDD_SURFCB_UNLOCK DdUnlock;
- PDD_SURFCB_BLT DdBlt;
- PDD_SURFCB_SETCOLORKEY DdSetColorKey;
- PDD_SURFCB_ADDATTACHEDSURFACE DdAddAttachedSurface;
- PDD_SURFCB_GETBLTSTATUS DdGetBltStatus;
- PDD_SURFCB_GETFLIPSTATUS DdGetFlipStatus;
- PDD_SURFCB_UPDATEOVERLAY DdUpdateOverlay;
- PDD_SURFCB_SETOVERLAYPOSITION DdSetOverlayPosition;
- PDD_SURFCB_SETPALETTE DdSetPalette;
- // Palette callbacks
- PDD_PALCB_DESTROYPALETTE DdDestroyPalette;
- PDD_PALCB_SETENTRIES DdSetEntries;
- // D3D Device context callbacks
- PD3DNTHAL_CONTEXTCREATECB D3dContextCreate;
- PD3DNTHAL_CONTEXTDESTROYCB D3dContextDestroy;
- // D3D Buffer callbacks
- PDD_CANCREATESURFACE DdCanCreateD3DBuffer;
- PDD_CREATESURFACE DdCreateD3DBuffer;
- PDD_SURFCB_DESTROYSURFACE DdDestroyD3DBuffer;
- PDD_SURFCB_LOCK DdLockD3DBuffer;
- PDD_SURFCB_UNLOCK DdUnlockD3DBuffer;
-} DD_DIRECTDRAW, *PDD_DIRECTDRAW;
-
-static BOOL FASTCALL DirectDrawCleanup(PDD_DIRECTDRAW pDirectDraw)
+BOOL FASTCALL
+DD_Cleanup(PDD_DIRECTDRAW pDD)
{
- pDirectDraw->DrvDisableDirectDraw(pDirectDraw->Global.dhpdev);
+ pDD->DrvDisableDirectDraw(pDD->Global.dhpdev);
return TRUE;
}
@@ -98,7 +51,7 @@
if (!pDC->DriverFunctions.EnableDirectDraw)
{
// Driver doesn't support DirectDraw
- DC_UnlockDc(hdc);
+ DC_UnlockDc(pDC);
return NULL;
}
@@ -108,11 +61,11 @@
if (!success)
{
// DirectDraw creation failed
- DC_UnlockDc(hdc);
+ DC_UnlockDc(pDC);
return NULL;
}
- HANDLE hDirectDraw = GDIOBJ_AllocObj(sizeof(DD_DIRECTDRAW), GDI_OBJECT_TYPE_DIRECTDRAW, (GDICLEANUPPROC)DirectDrawCleanup);
+ HANDLE hDirectDraw = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DIRECTDRAW);
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
pDirectDraw->Global.dhpdev = pDC->PDev;
@@ -168,8 +121,8 @@
if (palette_callbacks.dwFlags && DDHAL_PALCB32_SETENTRIES)
pDirectDraw->DdSetEntries = palette_callbacks.SetEntries;
- GDIOBJ_UnlockObj(hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
- DC_UnlockDc(hdc);
+ GDIOBJ_UnlockObj(pDirectDraw);
+ DC_UnlockDc(pDC);
return hDirectDraw;
}
@@ -178,7 +131,7 @@
HANDLE hDirectDrawLocal
)
{
- return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW, 0);
+ return GDIOBJ_FreeObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
}
BOOL STDCALL NtGdiDdQueryDirectDrawObject(
@@ -209,7 +162,7 @@
if (!success)
{
- GDIOBJ_UnlockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(pDirectDraw);
return FALSE;
}
@@ -235,7 +188,7 @@
pDirectDraw->DdUnlockD3DBuffer = puD3dBufferCallbacks->UnlockD3DBuffer;
}
- GDIOBJ_UnlockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(pDirectDraw);
return TRUE;
}
@@ -244,17 +197,8 @@
/* SURFACE OBJECT */
/************************************************************************/
-typedef struct
-{
- DD_SURFACE_LOCAL Local;
- DD_SURFACE_MORE More;
- DD_SURFACE_GLOBAL Global;
- DD_ATTACHLIST AttachList;
- DD_ATTACHLIST AttachListFrom;
- BOOL bComplete;
-} DD_SURFACE, *PDD_SURFACE;
-
-static BOOL FASTCALL DDSurfaceCleanup(PDD_SURFACE pSurface)
+BOOL FASTCALL
+DDSURF_Cleanup(PDD_SURFACE pDDSurf)
{
//FIXME: implement
return TRUE;
@@ -274,10 +218,11 @@
return NULL;
if (!hSurface)
- hSurface = GDIOBJ_AllocObj(sizeof(DD_SURFACE), GDI_OBJECT_TYPE_DD_SURFACE, (GDICLEANUPPROC)DDSurfaceCleanup);
+ hSurface = GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DD_SURFACE);
PDD_SURFACE pSurface = GDIOBJ_LockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
-
+ /* FIXME - Handle pSurface == NULL!!!! */
+
RtlMoveMemory(&pSurface->Local, puSurfaceLocal, sizeof(DD_SURFACE_LOCAL));
RtlMoveMemory(&pSurface->More, puSurfaceMore, sizeof(DD_SURFACE_MORE));
RtlMoveMemory(&pSurface->Global, puSurfaceGlobal, sizeof(DD_SURFACE_GLOBAL));
@@ -289,8 +234,8 @@
// FIXME: figure out how to use this
pSurface->bComplete = bComplete;
- GDIOBJ_UnlockObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
- GDIOBJ_UnlockObj(hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
+ GDIOBJ_UnlockObj(pSurface);
+ GDIOBJ_UnlockObj(pDirectDraw);
return hSurface;
}
@@ -299,7 +244,7 @@
HANDLE hSurface
)
{
- return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE, 0);
+ return GDIOBJ_FreeObj(hSurface, GDI_OBJECT_TYPE_DD_SURFACE);
}
/*
@@ -314,7 +259,7 @@
PDD_SURFACE pSurfaceTo = GDIOBJ_LockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
if (!pSurfaceTo)
{
- GDIOBJ_UnlockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
+ GDIOBJ_UnlockObj(pSurfaceFrom);
return FALSE;
}
@@ -323,8 +268,8 @@
pSurfaceFrom->Local.lpAttachListFrom = pSurfaceFrom->AttachListFrom;
}
- GDIOBJ_UnlockObj(hSurfaceFrom, GDI_OBJECT_TYPE_DD_SURFACE);
- GDIOBJ_UnlockObj(hSurfaceTo, GDI_OBJECT_TYPE_DD_SURFACE);
+ GDIOBJ_UnlockObj(pSurfaceFrom);
+ GDIOBJ_UnlockObj(pSurfaceTo);
return TRUE;
}
*/
reactos/subsys/win32k/ntuser
diff -u -r1.17.2.4 -r1.17.2.5
--- desktop.c 1 Sep 2004 22:14:50 -0000 1.17.2.4
+++ desktop.c 12 Sep 2004 19:21:07 -0000 1.17.2.5
@@ -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: desktop.c,v 1.17.2.4 2004/09/01 22:14:50 weiden Exp $
+ * $Id: desktop.c,v 1.17.2.5 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -112,14 +112,15 @@
PDC dc;
BITMAPOBJ *BitmapObj;
dc = DC_LockDc(ScreenDeviceContext);
+ /* FIXME - Handle dc == NULL!!!! */
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if(BitmapObj)
{
Ret->right = BitmapObj->SurfObj.sizlBitmap.cx;
Ret->bottom = BitmapObj->SurfObj.sizlBitmap.cy;
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
}
- DC_UnlockDc(ScreenDeviceContext);
+ DC_UnlockDc(dc);
}
if(Rect)
@@ -694,28 +695,31 @@
BOOL FASTCALL
IntPaintDesktop(HDC hDC)
{
- RECT Rect;
- HBRUSH DesktopBrush, PreviousBrush;
- PWINDOW_OBJECT WndDesktop;
+ PWINDOW_OBJECT DesktopWindow;
+ BOOL Ret = FALSE;
- IntGdiGetClipBox(hDC, &Rect);
-
- if(!(WndDesktop = IntGetDesktopWindow()))
+ DesktopWindow = IntGetDesktopWindow();
+ if(DesktopWindow != NULL)
{
- return FALSE;
- }
-
- DesktopBrush = (HBRUSH)IntGetClassLong(WndDesktop, GCL_HBRBACKGROUND, FALSE);
-
- /*
- * Paint desktop background
- */
+ HRGN hRgn;
+ hRgn = UnsafeIntCreateRectRgnIndirect(&DesktopWindow->ClientRect);
+ if(hRgn != NULL)
+ {
+ int type = IntGetUpdateRgn(DesktopWindow, hRgn, FALSE);
+ if(type == COMPLEXREGION || type == SIMPLEREGION)
+ {
+ HBRUSH hDesktopBrush = (HBRUSH)IntGetClassLong(DesktopWindow, GCL_HBRBACKGROUND, FALSE);
+ if(hDesktopBrush != NULL)
+ {
+ Ret = NtGdiFillRgn(hDC, hRgn, hDesktopBrush);
+ }
+ }
- PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);
- NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY);
- NtGdiSelectObject(hDC, PreviousBrush);
+ NtGdiDeleteObject(hRgn);
+ }
+ }
- return TRUE;
+ return Ret;
}
/*
reactos/subsys/win32k/ntuser
diff -u -r1.36.4.5 -r1.36.4.6
--- input.c 1 Sep 2004 22:14:50 -0000 1.36.4.5
+++ input.c 12 Sep 2004 19:21:07 -0000 1.36.4.6
@@ -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: input.c,v 1.36.4.5 2004/09/01 22:14:50 weiden Exp $
+/* $Id: input.c,v 1.36.4.6 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -532,7 +532,7 @@
DesktopWindow = WinSta->InputDesktop->DesktopWindow;
if (DesktopWindow != NULL)
{
- DbgPrint("DesktopWindow 0x%x: %d, %d\n", DesktopWindow, DesktopWindow->ClientRect.right, DesktopWindow->ClientRect.bottom);
+ DbgPrint("DesktopWindow 0x%x: %d, %d\n", DesktopWindow->Handle, DesktopWindow->ClientRect.right, DesktopWindow->ClientRect.bottom);
if(MousePos.x >= DesktopWindow->ClientRect.right)
MousePos.x = DesktopWindow->ClientRect.right - 1;
if(MousePos.y >= DesktopWindow->ClientRect.bottom)
@@ -574,7 +574,7 @@
if (dc)
{
hBitmap = dc->w.hBitmap;
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
BitmapObj = BITMAPOBJ_LockBitmap(hBitmap);
if (BitmapObj)
@@ -585,7 +585,7 @@
{
GDIDEV(SurfObj)->MovePointer(SurfObj, MousePos.x, MousePos.y, &PointerRect);
}
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
ExAcquireFastMutex(&CurInfo->CursorMutex);
SetPointerRect(CurInfo, &PointerRect);
reactos/subsys/win32k/ntuser
diff -u -r1.83.2.1 -r1.83.2.2
--- misc.c 15 Jul 2004 20:07:18 -0000 1.83.2.1
+++ misc.c 12 Sep 2004 19:21:07 -0000 1.83.2.2
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.83.2.1 2004/07/15 20:07:18 weiden Exp $
+/* $Id: misc.c,v 1.83.2.2 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -301,6 +301,9 @@
return TRUE;
}
+ case NOPARAM_ROUTINE_GDI_QUERY_TABLE:
+ return (DWORD)GDI_MapHandleTable(NtCurrentProcess());
+
default:
{
DPRINT1("SystemParametersInfo: Unsupported Action 0x%x (uiParam: 0x%x, pvParam: 0x%x, fWinIni: 0x%x)\n",
reactos/subsys/win32k/ntuser
diff -u -r1.1.4.8 -r1.1.4.9
--- ntuser.c 1 Sep 2004 22:14:50 -0000 1.1.4.8
+++ ntuser.c 12 Sep 2004 19:21:07 -0000 1.1.4.9
@@ -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: ntuser.c,v 1.1.4.8 2004/09/01 22:14:50 weiden Exp $
+/* $Id: ntuser.c,v 1.1.4.9 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -33,12 +33,10 @@
*/
#define BEGIN_NTUSER(ReturnType, ErrorReturn) \
- ReturnType Result, ErrorResult = ErrorReturn; \
- DbgPrint("%s:%i: %s\n", __FILE__, __LINE__, __FUNCTION__)
+ ReturnType Result, ErrorResult = ErrorReturn
#define BEGIN_NTUSER_NOERR(ReturnType) \
- ReturnType Result; \
- DbgPrint("%s:%i: %s\n", __FILE__, __LINE__, __FUNCTION__)
+ ReturnType Result
#define END_NTUSER() \
if(IN_CRITICAL()) \
@@ -69,7 +67,7 @@
goto error; \
}
-/* FIXME - Prope SizeMember first!!! */
+/* FIXME - Probe SizeMember first!!! */
#define NTUSER_FAIL_INVALID_STRUCT(StructType, StructAddr, SizeMember) \
if((StructAddr)->SizeMember != sizeof(StructType)) \
{ \
@@ -417,14 +415,14 @@
{
sz.cx = bmp->SurfObj.sizlBitmap.cx;
sz.cy = bmp->SurfObj.sizlBitmap.cy;
- BITMAPOBJ_UnlockBitmap(SafeInfo.hbmColor);
+ BITMAPOBJ_UnlockBitmap(bmp);
}
else if(SafeInfo.hbmMask &&
(bmp = BITMAPOBJ_LockBitmap(SafeInfo.hbmMask)))
{
sz.cx = bmp->SurfObj.sizlBitmap.cx;
sz.cy = bmp->SurfObj.sizlBitmap.cy / 2;
- BITMAPOBJ_UnlockBitmap(SafeInfo.hbmMask);
+ BITMAPOBJ_UnlockBitmap(bmp);
}
ENTER_CRITICAL();
@@ -1097,6 +1095,7 @@
NTSTATUS Status;
MsgCopyKMsgToMsg(&(Info.Msg), &(Msg.Msg));
+ DbgPrint("GotMessage for window 0x%x (h: 0x%x)\n", Msg.Msg.Window, (Msg.Msg.Window ? Msg.Msg.Window->Handle : NULL));
/* See if this message type is present in the table */
MsgMemoryEntry = FindMsgMemory(Info.Msg.message);
@@ -1409,6 +1408,18 @@
}
BOOL STDCALL
+NtUserPaintDesktop(HDC hDC)
+{
+ BEGIN_NTUSER_NOERR(BOOL);
+
+ ENTER_CRITICAL_SHARED();
+ Result = IntPaintDesktop(hDC);
+ LEAVE_CRITICAL();
+
+ END_NTUSER_NOERR();
+}
+
+BOOL STDCALL
NtUserPeekMessage(PNTUSERGETMESSAGEINFO UnsafeInfo,
HWND hWnd,
UINT MsgFilterMin,
@@ -2072,6 +2083,11 @@
VALIDATE_USER_OBJECT(WINDOW, hWndInsertAfter, InsertAfterWindow);
}
Result = WinPosSetWindowPos(Window, InsertAfterWindow, X, Y, cx, cy, uFlags);
+ if(hWnd == (HWND)1)
+ {
+ DbgPrint("SetWindowPos(w): %i,%i,%i,%i\n", Window->WindowRect.left, Window->WindowRect.top, Window->WindowRect.right, Window->WindowRect.bottom);
+ DbgPrint("SetWindowPos(c): %i,%i,%i,%i\n", Window->ClientRect.left, Window->ClientRect.top, Window->ClientRect.right, Window->ClientRect.bottom);
+ }
LEAVE_CRITICAL();
END_NTUSER();
@@ -2204,6 +2220,25 @@
}
BOOL STDCALL
+NtUserUpdateWindow(HWND hWnd)
+{
+ NTUSER_USER_OBJECT(WINDOW, Window);
+ BEGIN_NTUSER(BOOL, FALSE);
+
+ ENTER_CRITICAL();
+ if(hWnd != NULL)
+ {
+ VALIDATE_USER_OBJECT(WINDOW, hWnd, Window);
+ }
+
+ Result = IntUpdateWindow(Window);
+
+ LEAVE_CRITICAL();
+
+ END_NTUSER();
+}
+
+BOOL STDCALL
NtUserValidateRect(HWND hWnd, const RECT* Rect)
{
RECT SafeRect;
reactos/subsys/win32k/ntuser
diff -u -r1.84.2.2 -r1.84.2.3
--- painting.c 31 Aug 2004 11:38:56 -0000 1.84.2.2
+++ painting.c 12 Sep 2004 19:21:07 -0000 1.84.2.3
@@ -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: painting.c,v 1.84.2.2 2004/08/31 11:38:56 weiden Exp $
+ * $Id: painting.c,v 1.84.2.3 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -786,12 +786,12 @@
}
if (ERROR == UnsafeIntGetRgnBox(RgnData, Rect))
{
- RGNDATA_UnlockRgn(Rgn);
+ RGNDATA_UnlockRgn(RgnData);
NtGdiDeleteObject(Rgn);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return FALSE;
}
- RGNDATA_UnlockRgn(Rgn);
+ RGNDATA_UnlockRgn(RgnData);
NtGdiDeleteObject(Rgn);
return ((Rect->left < Rect->right) && (Rect->top < Rect->bottom));
@@ -845,7 +845,7 @@
NtGdiOffsetRect(&rSrc_lp, offset.left - offset.right, offset.top - offset.bottom);
IntDPtoLP(DC, (LPPOINT)&rDst_lp, 2);
IntDPtoLP(DC, (LPPOINT)&rSrc_lp, 2);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(DC);
if (!NtGdiBitBlt(hDC, rDst_lp.left, rDst_lp.top, rDst_lp.right - rDst_lp.left,
rDst_lp.bottom - rDst_lp.top, hDC, rSrc_lp.left, rSrc_lp.top,
@@ -854,7 +854,7 @@
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(DC);
}
/*
reactos/subsys/win32k/ntuser
diff -u -r1.45.12.5 -r1.45.12.6
--- stubs.c 1 Sep 2004 22:14:50 -0000 1.45.12.5
+++ stubs.c 12 Sep 2004 19:21:07 -0000 1.45.12.6
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.45.12.5 2004/09/01 22:14:50 weiden Exp $
+/* $Id: stubs.c,v 1.45.12.6 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -737,19 +737,6 @@
return 0;
}
-
-/*
- * Painting
- */
-
-
-BOOL STDCALL
-NtUserUpdateWindow(HWND hWnd)
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
/*
* Scroll
*/
@@ -1025,14 +1012,6 @@
}
-BOOL STDCALL
-NtUserPaintDesktop(HDC hDC)
-{
- UNIMPLEMENTED;
- return FALSE;
-}
-
-
DWORD STDCALL
NtUserGetInternalWindowPos(DWORD Unknown0,
DWORD Unknown1,
reactos/subsys/win32k/ntuser
diff -u -r1.29.12.1 -r1.29.12.2
--- vis.c 15 Jul 2004 20:07:18 -0000 1.29.12.1
+++ vis.c 12 Sep 2004 19:21:07 -0000 1.29.12.2
@@ -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: vis.c,v 1.29.12.1 2004/07/15 20:07:18 weiden Exp $
+ * $Id: vis.c,v 1.29.12.2 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -111,7 +111,7 @@
}
}
- CurrentWindow = IntGetParentObject(CurrentWindow);
+ Window = CurrentWindow;
}
if (ClipChildren)
reactos/subsys/win32k/ntuser
diff -u -r1.66.12.1 -r1.66.12.2
--- windc.c 15 Jul 2004 20:07:18 -0000 1.66.12.1
+++ windc.c 12 Sep 2004 19:21:07 -0000 1.66.12.2
@@ -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.66.12.1 2004/07/15 20:07:18 weiden Exp $
+/* $Id: windc.c,v 1.66.12.2 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -82,8 +82,9 @@
RtlInitUnicodeString(&DriverName, L"DISPLAY");
Dce = DCEOBJ_LockDCE(DceHandle);
- /* No real locking, just get the pointer */
- DCEOBJ_UnlockDCE(DceHandle);
+ /* FIXME - Dce can be NULL!!!!
+ No real locking, just get the pointer */
+ DCEOBJ_UnlockDCE(Dce);
Dce->Handle = DceHandle;
Dce->hDC = IntGdiCreateDC(&DriverName, NULL, NULL, NULL);
if (NULL == defaultDCstate)
@@ -146,7 +147,7 @@
dc->w.DCOrgY = WindowObject->ClientRect.top;
}
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
}
@@ -517,24 +518,24 @@
}
BOOL FASTCALL
-DCE_InternalDelete(PDCE Dce)
+DCE_Cleanup(PDCE pDce)
{
PDCE PrevInList;
/* FIXME - check global lock */
- if (Dce == FirstDce)
+ if (pDce == FirstDce)
{
- FirstDce = Dce->next;
- PrevInList = Dce;
+ FirstDce = pDce->next;
+ PrevInList = pDce;
}
else
{
for (PrevInList = FirstDce; NULL != PrevInList; PrevInList = PrevInList->next)
{
- if (Dce == PrevInList->next)
+ if (pDce == PrevInList->next)
{
- PrevInList->next = Dce->next;
+ PrevInList->next = pDce->next;
break;
}
}
@@ -718,7 +719,7 @@
NtGdiOffsetRgn(pDCE->hClipRgn, DeltaX, DeltaY);
}
}
- DC_UnlockDc(pDCE->hDC);
+ DC_UnlockDc(dc);
DceUpdateVisRgn(pDCE, CurrentWindow, pDCE->DCXFlags);
}
reactos/subsys/win32k/ntuser
diff -u -r1.244.2.5 -r1.244.2.6
--- window.c 1 Sep 2004 22:14:50 -0000 1.244.2.5
+++ window.c 12 Sep 2004 19:21:07 -0000 1.244.2.6
@@ -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: window.c,v 1.244.2.5 2004/09/01 22:14:50 weiden Exp $
+/* $Id: window.c,v 1.244.2.6 2004/09/12 19:21:07 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -229,10 +229,10 @@
InterlockedCompareExchangePointer(&ProcessData->WindowStation->ShellListView, NULL, Window);
}
- #if 0
+#if 0
/* Unregister hot keys */
UnregisterWindowHotKeys (Window);
- #endif
+#endif
/* FIXME: do we need to fake QS_MOUSEMOVE wakebit? */
@@ -1857,7 +1857,7 @@
if((pRgn = RGNDATA_LockRgn(hRgn)))
{
Ret = pRgn->rdh.iType;
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(pRgn);
}
else
Ret = ERROR;
@@ -1892,7 +1892,7 @@
{
Ret = pRgn->rdh.iType;
*Rect = pRgn->rdh.rcBound;
- RGNDATA_UnlockRgn(VisRgn);
+ RGNDATA_UnlockRgn(pRgn);
}
else
Ret = ERROR;
reactos/subsys/win32k/ntuser
diff -u -r1.120.2.2 -r1.120.2.3
--- winpos.c 1 Sep 2004 22:14:50 -0000 1.120.2.2
+++ winpos.c 12 Sep 2004 19:21:08 -0000 1.120.2.3
@@ -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.120.2.2 2004/09/01 22:14:50 weiden Exp $
+/* $Id: winpos.c,v 1.120.2.3 2004/09/12 19:21:08 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -788,7 +788,6 @@
if (Window == IntGetDesktopWindow() &&
Window->MessageQueue->Thread->ThreadsProcess != PsGetCurrentProcess())
{
- IntReleaseWindowObject(Window);
return FALSE;
}
@@ -839,13 +838,13 @@
if (VisBefore != NULL && (VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(VisBefore)) &&
UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION)
{
- RGNDATA_UnlockRgn(VisBefore);
+ RGNDATA_UnlockRgn(VisRgn);
NtGdiDeleteObject(VisBefore);
VisBefore = NULL;
}
else if(VisRgn)
{
- RGNDATA_UnlockRgn(VisBefore);
+ RGNDATA_UnlockRgn(VisRgn);
}
}
@@ -962,13 +961,13 @@
if (VisAfter != NULL && (VisRgn = (PROSRGNDATA)RGNDATA_LockRgn(VisAfter)) &&
UnsafeIntGetRgnBox(VisRgn, &TempRect) == NULLREGION)
{
- RGNDATA_UnlockRgn(VisAfter);
+ RGNDATA_UnlockRgn(VisRgn);
NtGdiDeleteObject(VisAfter);
VisAfter = NULL;
}
else if(VisRgn)
{
- RGNDATA_UnlockRgn(VisAfter);
+ RGNDATA_UnlockRgn(VisRgn);
}
/*
@@ -1023,7 +1022,7 @@
UnsafeIntGetRgnBox(VisRgn, &CopyRect) == NULLREGION)
{
/* Nothing to copy, clean up */
- RGNDATA_UnlockRgn(CopyRgn);
+ RGNDATA_UnlockRgn(VisRgn);
NtGdiDeleteObject(CopyRgn);
CopyRgn = NULL;
}
@@ -1032,7 +1031,7 @@
{
if(VisRgn)
{
- RGNDATA_UnlockRgn(CopyRgn);
+ RGNDATA_UnlockRgn(VisRgn);
}
/*
* Small trick here: there is no function to bitblt a region. So
@@ -1058,7 +1057,7 @@
}
else if(VisRgn)
{
- RGNDATA_UnlockRgn(CopyRgn);
+ RGNDATA_UnlockRgn(VisRgn);
}
}
else
@@ -1145,8 +1144,6 @@
WinPosToInternalWindowPosStructure(&WinPos, &wp);
}
- IntReleaseWindowObject(Window);
-
return TRUE;
}
@@ -1338,19 +1335,9 @@
for(Current = ScopeWin->FirstChild; Current != NULL; Current = Current->NextSibling)
{
- if (!(Current->Style & WS_VISIBLE))
- {
- IntReleaseWindowObject(Current);
- continue;
- }
-
- if ((Current->Style & (WS_POPUP | WS_CHILD | WS_DISABLED)) ==
- (WS_CHILD | WS_DISABLED))
- {
- continue;
- }
-
- if (!IntPtInWindow(Current, Point->x, Point->y))
+ if (!(Current->Style & WS_VISIBLE) ||
+ (Current->Style & (WS_POPUP | WS_CHILD | WS_DISABLED)) == (WS_CHILD | WS_DISABLED) ||
+ !IntPtInWindow(Current, Point->x, Point->y))
{
continue;
}
reactos/subsys/win32k/objects
diff -N stockobj.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ stockobj.c 12 Sep 2004 19:21:08 -0000 1.1.2.1
@@ -0,0 +1,319 @@
+/*
+ * ReactOS W32 Subsystem
+ * Copyright (C) 1998 - 2004 ReactOS Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+/*
+ * STOCKOBJ.C - GDI Stock Objects
+ *
+ * $Id: stockobj.c,v 1.1.2.1 2004/09/12 19:21:08 weiden Exp $
+ *
+ */
+#include <w32k.h>
+
+#define NDEBUG
+#include <debug.h>
+
+static COLORREF SysColors[] =
+{
+ RGB(212, 208, 200), /* COLOR_SCROLLBAR */
+ RGB(58, 110, 165), /* COLOR_BACKGROUND */
+ RGB(10, 36, 106), /* COLOR_ACTIVECAPTION */
+ RGB(128, 128, 128), /* COLOR_INACTIVECAPTION */
+ RGB(212, 208, 200), /* COLOR_MENU */
+ RGB(255, 255, 255), /* COLOR_WINDOW */
+ RGB(0, 0, 0), /* COLOR_WINDOWFRAME */
+ RGB(0, 0, 0), /* COLOR_MENUTEXT */
+ RGB(0, 0, 0), /* COLOR_WINDOWTEXT */
+ RGB(255, 255, 255), /* COLOR_CAPTIONTEXT */
+ RGB(212, 208, 200), /* COLOR_ACTIVEBORDER */
+ RGB(212, 208, 200), /* COLOR_INACTIVEBORDER */
+ RGB(128, 128, 128), /* COLOR_APPWORKSPACE */
+ RGB(10, 36, 106), /* COLOR_HIGHLIGHT */
+ RGB(255, 255, 255), /* COLOR_HIGHLIGHTTEXT */
+ RGB(212, 208, 200), /* COLOR_BTNFACE */
+ RGB(128, 128, 128), /* COLOR_BTNSHADOW */
+ RGB(128, 128, 128), /* COLOR_GRAYTEXT */
+ RGB(0, 0, 0), /* COLOR_BTNTEXT */
+ RGB(212, 208, 200), /* COLOR_INACTIVECAPTIONTEXT */
+ RGB(255, 255, 255), /* COLOR_BTNHIGHLIGHT */
+ RGB(64, 64, 64), /* COLOR_3DDKSHADOW */
+ RGB(212, 208, 200), /* COLOR_3DLIGHT */
+ RGB(0, 0, 0), /* COLOR_INFOTEXT */
+ RGB(255, 255, 225), /* COLOR_INFOBK */
+ RGB(181, 181, 181), /* COLOR_UNKNOWN */
+ RGB(0, 0, 128), /* COLOR_HOTLIGHT */
+ RGB(166, 202, 240), /* COLOR_GRADIENTACTIVECAPTION */
+ RGB(192, 192, 192), /* COLOR_GRADIENTINACTIVECAPTION */
+ RGB(49, 106, 197), /* COLOR_MENUHILIGHT */
+ RGB(236, 233, 216) /* COLOR_MENUBAR */
+};
+#define NUM_SYSCOLORS (sizeof(SysColors) / sizeof(SysColors[0]))
+
+static HPEN SysColorPens[NUM_SYSCOLORS];
+static HBRUSH SysColorBrushes[NUM_SYSCOLORS];
+
+/* GDI stock objects */
+
+static LOGBRUSH WhiteBrush =
+{ BS_SOLID, RGB(255,255,255), 0 };
+
+static LOGBRUSH LtGrayBrush =
+/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
+{ BS_SOLID, RGB(192,192,192), 0 };
+
+static LOGBRUSH GrayBrush =
+/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
+{ BS_SOLID, RGB(128,128,128), 0 };
+
+static LOGBRUSH DkGrayBrush =
+/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
+/* NB_HATCH_STYLES is an index into HatchBrushes */
+{ BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES };
+
+static LOGBRUSH BlackBrush =
+{ BS_SOLID, RGB(0,0,0), 0 };
+
+static LOGBRUSH NullBrush =
+{ BS_NULL, 0, 0 };
+
+static LOGPEN WhitePen =
+{ PS_SOLID, { 0, 0 }, RGB(255,255,255) };
+
+static LOGPEN BlackPen =
+{ PS_SOLID, { 0, 0 }, RGB(0,0,0) };
+
+static LOGPEN NullPen =
+{ PS_NULL, { 0, 0 }, 0 };
+
+static LOGFONTW OEMFixedFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+
+static LOGFONTW AnsiFixedFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+
+/*static LOGFONTW AnsiVarFont =
+ *{ 10, 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 =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
+
+static LOGFONTW DeviceDefaultFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
+
+static LOGFONTW SystemFixedFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
+
+/* FIXME: Is this correct? */
+static LOGFONTW DefaultGuiFont =
+{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
+ 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
+
+#define NB_STOCK_OBJECTS (DEFAULT_GUI_FONT + 1)
+
+static HGDIOBJ StockObjects[NB_STOCK_OBJECTS];
+
+/*!
+ * Creates a bunch of stock objects: brushes, pens, fonts.
+*/
+VOID FASTCALL
+CreateStockObjects(void)
+{
+ UINT Object;
+
+ DPRINT("Beginning creation of stock objects\n");
+
+ /* Create GDI Stock Objects from the logical structures we've defined */
+
+ StockObjects[WHITE_BRUSH] = IntGdiCreateBrushIndirect(&WhiteBrush);
+ StockObjects[LTGRAY_BRUSH] = IntGdiCreateBrushIndirect(&LtGrayBrush);
+ StockObjects[GRAY_BRUSH] = IntGdiCreateBrushIndirect(&GrayBrush);
+ StockObjects[DKGRAY_BRUSH] = IntGdiCreateBrushIndirect(&DkGrayBrush);
+ StockObjects[BLACK_BRUSH] = IntGdiCreateBrushIndirect(&BlackBrush);
+ StockObjects[NULL_BRUSH] = IntGdiCreateBrushIndirect(&NullBrush);
+
+ StockObjects[WHITE_PEN] = IntGdiCreatePenIndirect(&WhitePen);
+ StockObjects[BLACK_PEN] = IntGdiCreatePenIndirect(&BlackPen);
+ StockObjects[NULL_PEN] = IntGdiCreatePenIndirect(&NullPen);
+
+ (void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
+ (void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
+ (void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
+ (void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
+ (void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
+ (void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
+
+ StockObjects[DEFAULT_PALETTE] = (HGDIOBJ*)PALETTE_Init();
+
+ for (Object = 0; Object < NB_STOCK_OBJECTS; Object++)
+ {
+ if (NULL != StockObjects[Object])
+ {
+ GDIOBJ_ConvertToStockObj(&StockObjects[Object]);
+ }
+ }
+
+ DPRINT("Completed creation of stock objects\n");
+}
+
+/*!
+ * Return stock object.
+ * \param Object - stock object id.
+ * \return Handle to the object.
+*/
+HGDIOBJ STDCALL
+NtGdiGetStockObject(INT Object)
+{
+ DPRINT("NtGdiGetStockObject index %d\n", Object);
+
+ return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
+}
+
+BOOL FASTCALL
+IntSetSysColors(UINT nColors, INT *Elements, COLORREF *Colors)
+{
+ UINT i;
+
+ ASSERT(Elements);
+ ASSERT(Colors);
+
+ for(i = 0; i < nColors; i++)
+ {
+ if((*Elements) >= 0 && (*Elements) < NUM_SYSCOLORS)
+ {
+ SysColors[*Elements] = *Colors;
+ /* FIXME - update the syscolor pens and brushes */
+ }
+ Elements++;
+ Colors++;
+ }
+
+ return nColors > 0;
+}
+
+BOOL FASTCALL
+IntGetSysColorBrushes(HBRUSH *Brushes, UINT nBrushes)
+{
+ UINT i;
+
+ ASSERT(Brushes);
+
+ if(nBrushes > NUM_SYSCOLORS)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ for(i = 0; i < nBrushes; i++)
+ {
+ *(Brushes++) = SysColorBrushes[i];
+ }
+
+ return nBrushes > 0;
+}
+
+BOOL FASTCALL
+IntGetSysColorPens(HPEN *Pens, UINT nPens)
+{
+ UINT i;
+
+ ASSERT(Pens);
+
+ if(nPens > NUM_SYSCOLORS)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ for(i = 0; i < nPens; i++)
+ {
+ *(Pens++) = SysColorPens[i];
+ }
+
+ return nPens > 0;
+}
+
+BOOL FASTCALL
+IntGetSysColors(COLORREF *Colors, UINT nColors)
+{
+ UINT i;
+ COLORREF *col;
+
+ ASSERT(Colors);
+
+ if(nColors > NUM_SYSCOLORS)
+ {
+ SetLastWin32Error(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ col = &SysColors[0];
+ for(i = 0; i < nColors; i++)
+ {
+ *(Colors++) = *(col++);
+ }
+
+ return nColors > 0;
+}
+
+VOID FASTCALL
+CreateSysColorObjects(VOID)
+{
+ UINT i;
+ LOGBRUSH Brush;
+ LOGPEN Pen;
+
+ /* Create the syscolor brushes */
+ Brush.lbStyle = BS_SOLID;
+ Brush.lbHatch = 0;
+ for(i = 0; i < NUM_SYSCOLORS; i++)
+ {
+ if(SysColorBrushes[i] == NULL)
+ {
+ Brush.lbColor = SysColors[i];
+ SysColorBrushes[i] = IntGdiCreateBrushIndirect(&Brush);
+ if(SysColorBrushes[i] != NULL)
+ {
+ GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorBrushes[i]);
+ }
+ }
+ }
+
+ /* Create the syscolor pens */
+ Pen.lopnStyle = PS_SOLID;
+ Pen.lopnWidth.x = 0;
+ Pen.lopnWidth.y = 0;
+ for(i = 0; i < NUM_SYSCOLORS; i++)
+ {
+ if(SysColorPens[i] == NULL)
+ {
+ Pen.lopnColor = SysColors[i];
+ SysColorPens[i] = IntGdiCreatePenIndirect(&Pen);
+ if(SysColorPens[i] != NULL)
+ {
+ GDIOBJ_ConvertToStockObj((HGDIOBJ*)&SysColorPens[i]);
+ }
+ }
+ }
+}
+
+/* EOF */
reactos/subsys/win32k/objects
diff -u -r1.79 -r1.79.2.1
--- bitmaps.c 14 Jul 2004 20:48:57 -0000 1.79
+++ bitmaps.c 12 Sep 2004 19:21:08 -0000 1.79.2.1
@@ -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: bitmaps.c,v 1.79 2004/07/14 20:48:57 navaraf Exp $ */
+/* $Id: bitmaps.c,v 1.79.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
#define IN_RECT(r,x,y) \
@@ -67,7 +67,7 @@
DCSrc = DC_LockDc(hDCSrc);
if (NULL == DCSrc)
{
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiBitBlt\n", hDCSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
@@ -124,9 +124,17 @@
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ if(BitmapDest != NULL)
+ {
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ }
+ if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
+ {
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
+ }
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
@@ -170,9 +178,21 @@
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
+ }
+ DC_UnlockDc(DCDest);
+ if(BitmapDest != NULL)
+ {
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ }
+ if(BitmapSrc != NULL && BitmapSrc != BitmapDest)
+ {
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
+ }
+ if(BrushObj != NULL)
+ {
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
- DC_UnlockDc(hDCDest);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return FALSE;
}
@@ -185,20 +205,24 @@
if (UsesSource && XlateObj != NULL)
EngDeleteXlate(XlateObj);
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
- if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
+
+ if(BitmapDest != NULL)
+ {
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ }
+ if (UsesSource && BitmapSrc != BitmapDest)
{
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
}
- if (UsesPattern)
+ if (BrushObj != NULL)
{
- BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
return Status;
}
@@ -236,7 +260,7 @@
if((hdcDst != hdcSrc) && !(DCSrc = DC_LockDc(hdcSrc)))
{
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCDest);
DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiTransparentBlt\n", hdcSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
@@ -260,16 +284,16 @@
if(!(PalSourceGDI = PALETTE_LockPalette(SourcePalette)))
{
- DC_UnlockDc(hdcSrc);
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
if((DestPalette != SourcePalette) && !(PalDestGDI = PALETTE_LockPalette(DestPalette)))
{
- PALETTE_UnlockPalette(SourcePalette);
- DC_UnlockDc(hdcSrc);
- DC_UnlockDc(hdcDst);
+ PALETTE_UnlockPalette(PalSourceGDI);
+ DC_UnlockDc(DCSrc);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
@@ -277,13 +301,13 @@
{
PalDestMode = PalDestGDI->Mode;
PalSrcMode = PalSourceGDI->Mode;
- PALETTE_UnlockPalette(DestPalette);
+ PALETTE_UnlockPalette(PalDestGDI);
}
else
{
PalDestMode = PalSrcMode = PalSourceGDI->Mode;
}
- PALETTE_UnlockPalette(SourcePalette);
+ PALETTE_UnlockPalette(PalSourceGDI);
/* Translate Transparent (RGB) Color to the source palette */
if((XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalSrcMode, PAL_RGB, SourcePalette, NULL)))
@@ -296,8 +320,10 @@
XlateObj = (XLATEOBJ*)IntEngCreateXlate(PalDestMode, PalSrcMode, DestPalette, SourcePalette);
BitmapDest = BITMAPOBJ_LockBitmap(DCDest->w.hBitmap);
+ /* FIXME - BitmapDest can be NULL!!!! Don't assert here! */
ASSERT(BitmapDest);
BitmapSrc = BITMAPOBJ_LockBitmap(DCSrc->w.hBitmap);
+ /* FIXME - BitmapSrc can be NULL!!!! Don't assert here! */
ASSERT(BitmapSrc);
rcDest.left = xDst;
@@ -319,12 +345,12 @@
TransparentColor, 0);
done:
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
- DC_UnlockDc(hdcSrc);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
+ DC_UnlockDc(DCSrc);
if(hdcDst != hdcSrc)
{
- DC_UnlockDc(hdcDst);
+ DC_UnlockDc(DCDest);
}
if(XlateObj)
{
@@ -374,8 +400,9 @@
Size.cx, Size.cy, BitsPerPel, hBitmap);
bmp = BITMAPOBJ_LockBitmap( hBitmap );
+ /* FIXME - bmp can be NULL!!!!!! */
bmp->flFlags = BITMAPOBJ_IS_APIBITMAP;
- BITMAPOBJ_UnlockBitmap( hBitmap );
+ BITMAPOBJ_UnlockBitmap( bmp );
/*
* NOTE: It's ugly practice, but we are using the object even
@@ -392,10 +419,8 @@
}
BOOL FASTCALL
-Bitmap_InternalDelete( PBITMAPOBJ pBmp )
+BITMAP_Cleanup(PBITMAPOBJ pBmp)
{
- ASSERT( pBmp );
-
if (pBmp->SurfObj.pvBits != NULL &&
(pBmp->flFlags & BITMAPOBJ_IS_APIBITMAP))
{
@@ -464,7 +489,7 @@
Bmp = IntCreateCompatibleBitmap(Dc, Width, Height);
DPRINT ("\t\t%04x\n", Bmp);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(Dc);
return Bmp;
}
@@ -525,7 +550,7 @@
*Dimension = bmp->dimension;
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bmp);
return TRUE;
}
@@ -570,10 +595,10 @@
}
EngDeleteXlate(XlateObj);
}
+ BITMAPOBJ_UnlockBitmap(BitmapObject);
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
// if Result is still CLR_INVALID, then the "quick" method above didn't work
if ( bInRect && Result == CLR_INVALID )
@@ -602,7 +627,7 @@
if ( bmpobj )
{
Result = *(COLORREF*)bmpobj->SurfObj.pvScan0;
- BITMAPOBJ_UnlockBitmap ( hBmpTmp );
+ BITMAPOBJ_UnlockBitmap ( bmpobj );
}
}
NtGdiDeleteObject ( hBmpTmp );
@@ -901,7 +926,7 @@
ret = Bytes;
}
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bmp);
return ret;
}
@@ -928,7 +953,7 @@
bmp->dimension.cx = Width;
bmp->dimension.cy = Height;
- BITMAPOBJ_UnlockBitmap (hBitmap);
+ BITMAPOBJ_UnlockBitmap (bmp);
return TRUE;
}
@@ -1018,7 +1043,7 @@
DCSrc = DC_LockDc(hDCSrc);
if (NULL == DCSrc)
{
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
DPRINT1("Invalid source dc handle (0x%08x) passed to NtGdiStretchBlt\n", hDCSrc);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
@@ -1074,9 +1099,9 @@
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return FALSE;
}
@@ -1101,9 +1126,9 @@
{
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return FALSE;
}
@@ -1115,20 +1140,20 @@
if (UsesSource)
EngDeleteXlate(XlateObj);
- BITMAPOBJ_UnlockBitmap(DCDest->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapDest);
if (UsesSource && DCSrc->w.hBitmap != DCDest->w.hBitmap)
{
- BITMAPOBJ_UnlockBitmap(DCSrc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapSrc);
}
if (UsesPattern)
{
- BRUSHOBJ_UnlockBrush(DCDest->w.hBrush);
+ BRUSHOBJ_UnlockBrush(BrushObj);
}
if (UsesSource && hDCSrc != hDCDest)
{
- DC_UnlockDc(hDCSrc);
+ DC_UnlockDc(DCSrc);
}
- DC_UnlockDc(hDCDest);
+ DC_UnlockDc(DCDest);
return Status;
}
reactos/subsys/win32k/objects
diff -u -r1.40 -r1.40.2.1
--- brush.c 14 Jul 2004 20:48:57 -0000 1.40
+++ brush.c 12 Sep 2004 19:21:08 -0000 1.40.2.1
@@ -17,7 +17,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.40 2004/07/14 20:48:57 navaraf Exp $
+ * $Id: brush.c,v 1.40.2.1 2004/09/12 19:21:08 weiden Exp $
*/
#include <w32k.h>
@@ -32,10 +32,8 @@
};
BOOL FASTCALL
-Brush_InternalDelete( PGDIBRUSHOBJ pBrush )
+BRUSH_Cleanup(PGDIBRUSHOBJ pBrush)
{
- ASSERT(pBrush);
-
if(pBrush->flAttrs & (GDIBRUSH_IS_HATCH | GDIBRUSH_IS_BITMAP))
{
ASSERT(pBrush->hbmPattern);
@@ -73,7 +71,7 @@
Result = IntEngCreateSrcMonoXlate(Dc->w.hPalette, Dc->w.textColor, Dc->w.backgroundColor);
}
- BITMAPOBJ_UnlockBitmap(BrushObj->hbmPattern);
+ BITMAPOBJ_UnlockBitmap(Pattern);
*Failed = FALSE;
}
@@ -132,37 +130,43 @@
BrushObject = BRUSHOBJ_LockBrush(hBrush);
- switch (LogBrush->lbStyle)
+ if(BrushObject != NULL)
{
- case BS_NULL:
- BrushObject->flAttrs |= GDIBRUSH_IS_NULL;
- break;
-
- case BS_SOLID:
- BrushObject->flAttrs |= GDIBRUSH_IS_SOLID;
- BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
- /* FIXME: Fill in the rest of fields!!! */
- break;
-
- case BS_HATCHED:
- BrushObject->flAttrs |= GDIBRUSH_IS_HATCH;
- BrushObject->hbmPattern = hPattern;
- BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
- break;
-
- case BS_PATTERN:
- BrushObject->flAttrs |= GDIBRUSH_IS_BITMAP;
- BrushObject->hbmPattern = hPattern;
- /* FIXME: Fill in the rest of fields!!! */
- break;
+ switch (LogBrush->lbStyle)
+ {
+ case BS_NULL:
+ BrushObject->flAttrs |= GDIBRUSH_IS_NULL;
+ break;
+
+ case BS_SOLID:
+ BrushObject->flAttrs |= GDIBRUSH_IS_SOLID;
+ BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
+ /* FIXME: Fill in the rest of fields!!! */
+ break;
+
+ case BS_HATCHED:
+ BrushObject->flAttrs |= GDIBRUSH_IS_HATCH;
+ BrushObject->hbmPattern = hPattern;
+ BrushObject->BrushAttr.lbColor = LogBrush->lbColor & 0xFFFFFF;
+ break;
+
+ case BS_PATTERN:
+ BrushObject->flAttrs |= GDIBRUSH_IS_BITMAP;
+ BrushObject->hbmPattern = hPattern;
+ /* FIXME: Fill in the rest of fields!!! */
+ break;
+
+ default:
+ DPRINT1("Brush Style: %d\n", LogBrush->lbStyle);
+ UNIMPLEMENTED;
+ }
- default:
- DPRINT1("Brush Style: %d\n", LogBrush->lbStyle);
- UNIMPLEMENTED;
+ BRUSHOBJ_UnlockBrush(BrushObject);
+ return hBrush;
}
-
- BRUSHOBJ_UnlockBrush(hBrush);
- return hBrush;
+
+ NtGdiDeleteObject(hBrush);
+ return NULL;
}
BOOL FASTCALL
@@ -181,6 +185,8 @@
POINTL BrushOrigin;
BOOL ret = TRUE;
+ ASSERT(BrushObj);
+
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if (BitmapObj == NULL)
{
@@ -188,7 +194,6 @@
return FALSE;
}
- ASSERT(BrushObj);
if (!(BrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
if (Width > 0)
@@ -232,7 +237,7 @@
ROP);
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return ret;
}
@@ -260,19 +265,22 @@
for (r = pRects, i = 0; i < cRects; i++)
{
BrushObj = BRUSHOBJ_LockBrush(r->hBrush);
- IntPatBlt(
- dc,
- r->r.left,
- r->r.top,
- r->r.right,
- r->r.bottom,
- dwRop,
- BrushObj);
- BRUSHOBJ_UnlockBrush(r->hBrush);
+ if(BrushObj != NULL)
+ {
+ IntPatBlt(
+ dc,
+ r->r.left,
+ r->r.top,
+ r->r.right,
+ r->r.bottom,
+ dwRop,
+ BrushObj);
+ BRUSHOBJ_UnlockBrush(BrushObj);
+ }
r++;
}
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return TRUE;
}
@@ -385,7 +393,7 @@
Status = MmCopyToCaller(Point, &SafePoint, sizeof(POINT));
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
@@ -393,7 +401,7 @@
dc->w.brushOrgX = XOrg;
dc->w.brushOrgY = YOrg;
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -458,7 +466,7 @@
if (BrushObj == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
@@ -471,8 +479,8 @@
ROP,
BrushObj);
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
- DC_UnlockDc(hDC);
+ BRUSHOBJ_UnlockBrush(BrushObj);
+ DC_UnlockDc(dc);
return ret;
}
reactos/subsys/win32k/objects
diff -u -r1.42 -r1.42.2.1
--- cliprgn.c 14 Jul 2004 20:48:58 -0000 1.42
+++ cliprgn.c 12 Sep 2004 19:21:08 -0000 1.42.2.1
@@ -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.42 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: cliprgn.c,v 1.42.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
int FASTCALL
@@ -34,6 +34,7 @@
NtGdiOffsetRgn(Dc->w.hGCClipRgn, Dc->w.DCOrgX, Dc->w.DCOrgY);
CombinedRegion = RGNDATA_LockRgn(Dc->w.hGCClipRgn);
+ /* FIXME - CombinedRegion can be NULL!!!! Don't assert here ! */
ASSERT(CombinedRegion != NULL);
if (Dc->CombinedClip != NULL)
@@ -45,7 +46,7 @@
(PRECTL)&CombinedRegion->rdh.rcBound);
ASSERT(Dc->CombinedClip != NULL);
- RGNDATA_UnlockRgn(Dc->w.hGCClipRgn);
+ RGNDATA_UnlockRgn(CombinedRegion);
return NtGdiOffsetRgn(Dc->w.hGCClipRgn, -Dc->w.DCOrgX, -Dc->w.DCOrgY);
}
@@ -58,18 +59,19 @@
if (!dc) return 0;
obj = RGNDATA_LockRgn(dc->w.hVisRgn);
+ /* FIXME - Handle obj == NULL!!! */
if(!(copy = NtGdiCreateRectRgn(0, 0, 0, 0)))
{
- RGNDATA_UnlockRgn(dc->w.hVisRgn);
- DC_UnlockDc(hdc);
+ RGNDATA_UnlockRgn(obj);
+ DC_UnlockDc(dc);
return 0;
}
NtGdiCombineRgn(copy, dc->w.hVisRgn, 0, RGN_COPY);
copyObj = RGNDATA_LockRgn(copy);
/* copyObj->header.hNext = obj->header.hNext;
header.hNext = copy; */
-
+ DC_UnlockDc(dc);
return copy;
}
@@ -100,7 +102,7 @@
retval = NtGdiCombineRgn(dc->w.hVisRgn, hrgn, 0, RGN_COPY);
CLIPPING_UpdateGCRegion(dc);
- DC_UnlockDc( hdc );
+ DC_UnlockDc( dc );
return retval;
}
@@ -133,7 +135,7 @@
}
else
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return ERROR;
}
@@ -147,7 +149,7 @@
if((Rgn = RGNDATA_LockRgn(dc->w.hVisRgn)))
{
UnsafeIntGetRgnBox(Rgn, &rect);
- RGNDATA_UnlockRgn(dc->w.hVisRgn);
+ RGNDATA_UnlockRgn(Rgn);
dc->w.hClipRgn = UnsafeIntCreateRectRgnIndirect(&rect);
}
else
@@ -164,7 +166,7 @@
}
retval = CLIPPING_UpdateGCRegion(dc);
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return retval;
}
@@ -184,14 +186,14 @@
if (!(Rgn = RGNDATA_LockRgn(dc->w.hGCClipRgn)))
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
SetLastWin32Error(ERROR_INVALID_HANDLE);
return ERROR;
}
retval = UnsafeIntGetRgnBox(Rgn, rc);
- RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
+ RGNDATA_UnlockRgn(Rgn);
IntDPtoLP(dc, (LPPOINT)rc, 2);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return retval;
}
@@ -269,7 +271,7 @@
if (Result != ERROR)
CLIPPING_UpdateGCRegion(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Result;
}
@@ -319,7 +321,7 @@
if (Result != ERROR)
CLIPPING_UpdateGCRegion(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Result;
}
@@ -346,7 +348,7 @@
}
rgn = dc->w.hGCClipRgn;
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return (rgn ? NtGdiPtInRegion(rgn, X, Y) : FALSE);
}
@@ -369,7 +371,7 @@
Status = MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT));
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
@@ -379,10 +381,10 @@
{
IntLPtoDP(dc, (LPPOINT)&Rect, 2);
Result = UnsafeIntRectInRegion(Rgn, &Rect);
- RGNDATA_UnlockRgn(dc->w.hGCClipRgn);
+ RGNDATA_UnlockRgn(Rgn);
}
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Result;
}
reactos/subsys/win32k/objects
diff -u -r1.50 -r1.50.2.1
--- color.c 14 Jul 2004 20:48:58 -0000 1.50
+++ color.c 12 Sep 2004 19:21:08 -0000 1.50.2.1
@@ -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.50 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: color.c,v 1.50.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
// FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping
@@ -123,11 +123,12 @@
0, 0, 0);
PalGDI = (PPALGDI) PALETTE_LockPalette(NewPalette);
+ /* FIXME - Handle PalGDI == NULL!!!! */
PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors);
PalGDI->logicalToSystem = NULL;
- PALETTE_UnlockPalette(NewPalette);
+ PALETTE_UnlockPalette(PalGDI);
return NewPalette;
}
@@ -161,7 +162,7 @@
palGDI = (PPALGDI) PALETTE_LockPalette(hpal);
if (!palGDI)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return nearest;
}
@@ -185,8 +186,8 @@
(GetBValue(Color) >> BBits) << BBits);
break;
}
- PALETTE_UnlockPalette(hpal);
- DC_UnlockDc(hDC);
+ PALETTE_UnlockPalette(palGDI);
+ DC_UnlockDc(dc);
}
return nearest;
@@ -202,7 +203,7 @@
{
/* Return closest match for the given RGB color */
index = COLOR_PaletteLookupPixel(palGDI->IndexedColors, palGDI->NumColors, NULL, Color, FALSE);
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(palGDI);
}
return index;
@@ -231,7 +232,7 @@
{
if (numEntries <= StartIndex)
{
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(palGDI);
return 0;
}
memcpy(pe, palGDI->IndexedColors + StartIndex, Entries * sizeof(PALETTEENTRY));
@@ -244,7 +245,7 @@
}
}
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(palGDI);
return Entries;
}
@@ -333,6 +334,7 @@
systemPalette = NtGdiGetStockObject((INT)DEFAULT_PALETTE);
palGDI = PALETTE_LockPalette(dc->w.hPalette);
palPtr = (PALOBJ*) palGDI;
+ /* FIXME - Handle palGDI == NULL!!!! */
// Step 1: Create mapping of system palette\DC palette
#ifndef NO_MAPPING
@@ -345,6 +347,7 @@
sysGDI = PALETTE_LockPalette(systemPalette);
sysPtr = (PALOBJ*) sysGDI;
+ /* FIXME - Handle sysGDI == NULL!!!!! */
// Step 2:
// The RealizePalette function modifies the palette for the device associated with the specified device context. If the
@@ -366,8 +369,8 @@
// need to pass this to IntEngCreateXlate with palettes unlocked
sysMode = sysGDI->Mode;
palMode = palGDI->Mode;
- PALETTE_UnlockPalette(systemPalette);
- PALETTE_UnlockPalette(dc->w.hPalette);
+ PALETTE_UnlockPalette(sysGDI);
+ PALETTE_UnlockPalette(palGDI);
// Step 3: Create the XLATEOBJ for device managed DCs
if(dc->w.flags != DC_MEMORY)
@@ -376,7 +379,7 @@
palGDI->logicalToSystem = IntEngCreateXlate(sysMode, palMode, systemPalette, dc->w.hPalette);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return realized;
#endif
@@ -457,13 +460,13 @@
if ((dc->w.bitsPerPixel <= 8 && PAL_INDEXED == PalGDI->Mode)
|| (8 < dc->w.bitsPerPixel && PAL_INDEXED != PalGDI->Mode))
{
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(PalGDI);
oldPal = dc->w.hPalette;
dc->w.hPalette = hpal;
}
else
{
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(PalGDI);
oldPal = NULL;
}
}
@@ -471,7 +474,7 @@
{
oldPal = NULL;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
}
return oldPal;
@@ -498,7 +501,7 @@
numEntries = palGDI->NumColors;
if (Start >= numEntries)
{
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(palGDI);
return 0;
}
if (numEntries < Start + Entries)
@@ -509,7 +512,7 @@
PALETTE_ValidateFlags(palGDI->IndexedColors, palGDI->NumColors);
ExFreePool(palGDI->logicalToSystem);
palGDI->logicalToSystem = NULL;
- PALETTE_UnlockPalette(hpal);
+ PALETTE_UnlockPalette(palGDI);
return Entries;
}
reactos/subsys/win32k/objects
diff -u -r1.26 -r1.26.2.1
--- coord.c 14 Jul 2004 20:48:58 -0000 1.26
+++ coord.c 12 Sep 2004 19:21:08 -0000 1.26.2.1
@@ -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.26 2004/07/14 20:48:58 navaraf Exp $
+/* $Id: coord.c,v 1.26.2.1 2004/09/12 19:21:08 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -140,7 +140,7 @@
if (!UnsafePoints || Count <= 0)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -150,7 +150,7 @@
Points = (LPPOINT)ExAllocatePoolWithTag(PagedPool, Size, TAG_COORD);
if(!Points)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -158,7 +158,7 @@
Status = MmCopyFromCaller(Points, UnsafePoints, Size);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Points);
SetLastNtError(Status);
return FALSE;
@@ -169,13 +169,13 @@
Status = MmCopyToCaller(UnsafePoints, Points, Size);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Points);
SetLastNtError(Status);
return FALSE;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Points);
return TRUE;
}
@@ -204,7 +204,7 @@
GraphicsMode = dc->w.GraphicsMode;
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
return GraphicsMode;
}
@@ -224,14 +224,14 @@
}
if (!XForm)
{
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
Status = MmCopyToCaller(XForm, &dc->w.xformWorld2Wnd, sizeof(XFORM));
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
return NT_SUCCESS(Status);
}
@@ -289,7 +289,7 @@
if (!UnsafePoints || Count <= 0)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -299,7 +299,7 @@
Points = (LPPOINT)ExAllocatePoolWithTag(PagedPool, Size, TAG_COORD);
if(!Points)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -307,7 +307,7 @@
Status = MmCopyFromCaller(Points, UnsafePoints, Size);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Points);
SetLastNtError(Status);
return FALSE;
@@ -318,13 +318,13 @@
Status = MmCopyToCaller(UnsafePoints, Points, Size);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Points);
SetLastNtError(Status);
return FALSE;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Points);
return TRUE;
}
@@ -348,7 +348,7 @@
if (!UnsafeXForm)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -356,7 +356,7 @@
Status = MmCopyFromCaller(&SafeXForm, UnsafeXForm, sizeof(XFORM));
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
@@ -381,13 +381,13 @@
break;
default:
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
DC_UpdateXforms(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -417,7 +417,7 @@
if ( !NT_SUCCESS(Status) )
{
SetLastNtError(Status);
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
return FALSE;
}
}
@@ -426,7 +426,7 @@
dc->vportOrgY += YOffset;
DC_UpdateXforms(dc);
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
return TRUE;
}
@@ -458,7 +458,7 @@
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
}
@@ -467,7 +467,7 @@
dc->wndOrgY += YOffset;
DC_UpdateXforms(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -521,14 +521,14 @@
if ((Mode != GM_COMPATIBLE) && (Mode != GM_ADVANCED))
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
ret = dc->w.GraphicsMode;
dc->w.GraphicsMode = Mode;
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return ret;
}
@@ -550,7 +550,7 @@
PrevMapMode = dc->w.MapMode;
dc->w.MapMode = MapMode;
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
return PrevMapMode;
}
@@ -579,7 +579,7 @@
case MM_LOMETRIC:
case MM_TEXT:
case MM_TWIPS:
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
case MM_ISOTROPIC:
@@ -600,7 +600,7 @@
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
}
@@ -609,7 +609,7 @@
dc->vportExtY = YExtent;
DC_UpdateXforms(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -642,7 +642,7 @@
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
}
@@ -651,7 +651,7 @@
dc->vportOrgY = Y;
DC_UpdateXforms(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -680,7 +680,7 @@
case MM_LOMETRIC:
case MM_TEXT:
case MM_TWIPS:
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
@@ -696,7 +696,7 @@
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
}
@@ -705,7 +705,7 @@
dc->wndExtY = YExtent;
DC_UpdateXforms(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -738,7 +738,7 @@
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
}
@@ -747,7 +747,7 @@
dc->wndOrgY = Y;
DC_UpdateXforms(dc);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return TRUE;
}
@@ -769,7 +769,7 @@
if (!XForm)
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
/* Win doesn't set LastError */
return FALSE;
}
@@ -777,19 +777,19 @@
/* Check that graphics mode is GM_ADVANCED */
if ( dc->w.GraphicsMode != GM_ADVANCED )
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return FALSE;
}
Status = MmCopyFromCaller(&dc->w.xformWorld2Wnd, XForm, sizeof(XFORM));
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return FALSE;
}
DC_UpdateXforms (dc);
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return TRUE;
}
reactos/subsys/win32k/objects
diff -u -r1.63.2.1 -r1.63.2.2
--- cursoricon.c 15 Jul 2004 20:07:19 -0000 1.63.2.1
+++ cursoricon.c 12 Sep 2004 19:21:08 -0000 1.63.2.2
@@ -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: cursoricon.c,v 1.63.2.1 2004/07/15 20:07:19 weiden Exp $ */
+/* $Id: cursoricon.c,v 1.63.2.2 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
#define COLORCURSORS_ALLOWED FALSE
@@ -43,7 +43,7 @@
{
return OldCursor;
}
-
+ else
{
if(!(Screen = IntGetScreenDC()))
{
@@ -58,9 +58,10 @@
}
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!!! */
SurfObj = &BitmapObj->SurfObj;
DevInfo = dc->DevInfo;
- DC_UnlockDc(Screen);
+ DC_UnlockDc(dc);
}
if (!NewCursor && (CurInfo->CurrentCursorObject || ForceChange))
@@ -77,13 +78,13 @@
CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
CurInfo->ShowingCursor = 0;
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return OldCursor;
}
if (!NewCursor)
{
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return OldCursor;
}
@@ -94,9 +95,10 @@
if (MaskBmpObj)
{
const int maskBpp = BitsPerFormat(MaskBmpObj->SurfObj.iBitmapFormat);
- BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
+ BITMAPOBJ_UnlockBitmap(MaskBmpObj);
if (maskBpp != 1)
{
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n");
return OldCursor;
}
@@ -143,7 +145,7 @@
soMask = EngLockSurface((HSURF)hMask);
EngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
&DestRect, &SourcePoint);
- BITMAPOBJ_UnlockBitmap(NewCursor->IconInfo.hbmMask);
+ BITMAPOBJ_UnlockBitmap(MaskBmpObj);
}
}
}
@@ -192,7 +194,7 @@
SetPointerRect(CurInfo, &PointerRect);
- BITMAPOBJ_UnlockBitmap(SurfObj->hsurf);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
if(hMask)
{
EngUnlockSurface(soMask);
@@ -388,7 +390,7 @@
Size->cx = bmp->SurfObj.sizlBitmap.cx;
Size->cy = (hbmp != Cursor->IconInfo.hbmMask ? bmp->SurfObj.sizlBitmap.cy : bmp->SurfObj.sizlBitmap.cy / 2);
- BITMAPOBJ_UnlockBitmap(hbmp);
+ BITMAPOBJ_UnlockBitmap(bmp);
return TRUE;
}
reactos/subsys/win32k/objects
diff -u -r1.144.2.1 -r1.144.2.2
--- dc.c 18 Jul 2004 23:44:01 -0000 1.144.2.1
+++ dc.c 12 Sep 2004 19:21:08 -0000 1.144.2.2
@@ -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.144.2.1 2004/07/18 23:44:01 weiden Exp $
+/* $Id: dc.c,v 1.144.2.2 2004/09/12 19:21:08 weiden Exp $
*
* DC.C - Device context functions
*
@@ -47,7 +47,7 @@
return 0; \
} \
ft = dc->dc_field; \
- DC_UnlockDc( hdc ); \
+ DC_UnlockDc( dc ); \
return ft; \
}
@@ -79,7 +79,7 @@
return FALSE; \
} \
Int##FuncName( dc, &Safept); \
- DC_UnlockDc(hdc); \
+ DC_UnlockDc(dc); \
Status = MmCopyToCaller(pt, &Safept, sizeof( type )); \
if(!NT_SUCCESS(Status)) \
{ \
@@ -107,7 +107,7 @@
} \
prevMode = dc->dc_field; \
dc->dc_field = mode; \
- DC_UnlockDc ( hdc ); \
+ DC_UnlockDc ( dc ); \
return prevMode; \
}
@@ -158,7 +158,7 @@
if (NULL == hNewDC)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(OrigDC);
if (NULL != DisplayDC)
{
NtGdiDeleteDC(DisplayDC);
@@ -193,8 +193,8 @@
/* Create default bitmap */
if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, NewDC->w.bitsPerPixel, NULL )))
{
- DC_UnlockDc( hDC );
- DC_UnlockDc( hNewDC );
+ DC_UnlockDc( OrigDC );
+ DC_UnlockDc( NewDC );
DC_FreeDC( hNewDC );
if (NULL != DisplayDC)
{
@@ -212,12 +212,12 @@
NewDC->w.textAlign = OrigDC->w.textAlign;
NewDC->w.backgroundColor = OrigDC->w.backgroundColor;
NewDC->w.backgroundMode = OrigDC->w.backgroundMode;
- DC_UnlockDc( hDC );
+ DC_UnlockDc( OrigDC );
if (NULL != DisplayDC)
{
NtGdiDeleteDC(DisplayDC);
}
- DC_UnlockDc(hNewDC);
+ DC_UnlockDc(NewDC);
hVisRgn = NtGdiCreateRectRgn(0, 0, 1, 1);
NtGdiSelectVisRgn(hNewDC, hVisRgn);
@@ -720,6 +720,7 @@
}
NewDC = DC_LockDc( hNewDC );
+ /* FIXME - NewDC can be NULL!!! Don't assert here! */
ASSERT( NewDC );
NewDC->DMW = PrimarySurface.DMW;
@@ -751,7 +752,7 @@
DPRINT("Bits per pel: %u\n", NewDC->w.bitsPerPixel);
- DC_UnlockDc( hNewDC );
+ DC_UnlockDc( NewDC );
hVisRgn = NtGdiCreateRectRgn(0, 0, SurfObj->sizlBitmap.cx,
SurfObj->sizlBitmap.cy);
@@ -854,7 +855,7 @@
}
DC_SetNextDC (DCToDelete, DC_GetNextDC (savedDC));
DCToDelete->saveLevel--;
- DC_UnlockDc( savedHDC );
+ DC_UnlockDc( savedDC );
NtGdiDeleteDC (savedHDC);
}
@@ -894,7 +895,7 @@
#if 0 /* FIXME */
PATH_DestroyGdiPath (&DCToDelete->w.path);
#endif
- DC_UnlockDc( DCHandle );
+ DC_UnlockDc( DCToDelete );
DC_FreeDC ( DCHandle );
return TRUE;
@@ -965,7 +966,7 @@
break;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return SelObject;
}
@@ -1007,11 +1008,11 @@
if(!NT_SUCCESS(Status))
{
SetLastNtError(Status);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -1031,7 +1032,7 @@
oldColor = dc->w.backgroundColor;
dc->w.backgroundColor = color;
hBrush = dc->w.hBrush;
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
NtGdiSelectObject(hDC, hBrush);
return oldColor;
}
@@ -1052,10 +1053,11 @@
hnewdc = DC_AllocDC(NULL);
if (hnewdc == NULL)
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return 0;
}
newdc = DC_LockDc( hnewdc );
+ /* FIXME - newdc can be NULL!!!! Don't assert here!!! */
ASSERT( newdc );
newdc->w.flags = dc->w.flags | DC_SAVED;
@@ -1123,8 +1125,8 @@
newdc->w.hClipRgn = NtGdiCreateRectRgn( 0, 0, 0, 0 );
NtGdiCombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
}
- DC_UnlockDc( hnewdc );
- DC_UnlockDc( hDC );
+ DC_UnlockDc( newdc );
+ DC_UnlockDc( dc );
return hnewdc;
}
@@ -1216,9 +1218,9 @@
dc->w.hClipRgn = 0;
}
CLIPPING_UpdateGCRegion( dc );
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
#else
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
NtGdiSelectClipRgn(hDC, dcs->w.hClipRgn);
#endif
@@ -1235,11 +1237,11 @@
GDISelectPalette16( hDC, dcs->w.hPalette, FALSE );
#endif
} else {
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
}
- DC_UnlockDc ( hDCSave );
+ DC_UnlockDc ( dcs );
} else {
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
SetLastWin32Error(ERROR_INVALID_HANDLE);
}
}
@@ -1450,7 +1452,7 @@
DPRINT("(%04x,%d): returning %d\n", hDC, Index, ret);
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return ret;
}
@@ -1505,7 +1507,7 @@
break;
}
- GDIOBJ_UnlockObj(Handle, GDI_OBJECT_TYPE_DONTCARE);
+ GDIOBJ_UnlockObj(GdiObject);
return Result;
}
@@ -1546,7 +1548,7 @@
NtGdiGetObjectType(HANDLE handle)
{
GDIOBJHDR * ptr;
- INT result = 0;
+ INT result;
DWORD objectType;
ptr = GDIOBJ_LockObj(handle, GDI_OBJECT_TYPE_DONTCARE);
@@ -1598,11 +1600,13 @@
case GDI_OBJECT_TYPE_MEMDC:
result = OBJ_MEMDC;
break;
+
default:
DPRINT1("Magic 0x%08x not implemented\n", objectType);
+ result = 0;
break;
}
- GDIOBJ_UnlockObj(handle, GDI_OBJECT_TYPE_DONTCARE);
+ GDIOBJ_UnlockObj(ptr);
return result;
}
@@ -1643,7 +1647,7 @@
if ((SaveLevel < 1) || (SaveLevel > dc->saveLevel))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
@@ -1655,14 +1659,14 @@
dcs = DC_LockDc (hdcs);
if (dcs == NULL)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
DC_SetNextDC (dcs, DC_GetNextDC (dcs));
if (--dc->saveLevel < SaveLevel)
{
- DC_UnlockDc( hDC );
- DC_UnlockDc( hdcs );
+ DC_UnlockDc( dc );
+ DC_UnlockDc( dcs );
NtGdiSetDCState(hDC, hdcs);
#if 0
if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path ))
@@ -1680,11 +1684,11 @@
}
else
{
- DC_UnlockDc( hdcs );
+ DC_UnlockDc( dcs );
}
NtGdiDeleteDC (hdcs);
}
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return success;
}
@@ -1711,7 +1715,7 @@
dc = DC_LockDc (hDC);
if (dc == NULL)
{
- DC_UnlockDc(dc);
+ DC_UnlockDc(dcs);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
@@ -1733,8 +1737,8 @@
DC_SetNextDC (dcs, DC_GetNextDC (dc));
DC_SetNextDC (dc, hdcs);
ret = ++dc->saveLevel;
- DC_UnlockDc( hdcs );
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dcs );
+ DC_UnlockDc( dc );
return ret;
}
@@ -1776,7 +1780,7 @@
}
XlateObj = IntGdiCreateBrushXlate(dc, pen, &Failed);
- PENOBJ_UnlockPen((HPEN) hGDIObj);
+ PENOBJ_UnlockPen(pen);
if (Failed)
{
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
@@ -1799,7 +1803,7 @@
}
XlateObj = IntGdiCreateBrushXlate(dc, brush, &Failed);
- BRUSHOBJ_UnlockBrush((HPEN) hGDIObj);
+ BRUSHOBJ_UnlockBrush(brush);
if (Failed)
{
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
@@ -1814,23 +1818,25 @@
break;
case GDI_OBJECT_TYPE_FONT:
- objOrg = (HGDIOBJ)dc->w.hFont;
- dc->w.hFont = (HFONT) hGDIObj;
- TextIntRealizeFont(dc->w.hFont);
+ if(NT_SUCCESS(TextIntRealizeFont((HFONT)hGDIObj)))
+ {
+ objOrg = (HGDIOBJ)dc->w.hFont;
+ dc->w.hFont = (HFONT) hGDIObj;
+ }
break;
case GDI_OBJECT_TYPE_BITMAP:
// must be memory dc to select bitmap
if (!(dc->w.flags & DC_MEMORY))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return NULL;
}
pb = BITMAPOBJ_LockBitmap(hGDIObj);
if (NULL == pb)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return NULL;
}
objOrg = (HGDIOBJ)dc->w.hBitmap;
@@ -1868,16 +1874,16 @@
NtGdiSelectObject ( hDC, dc->w.hBrush );
NtGdiSelectObject ( hDC, dc->w.hPen );
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
hVisRgn = NtGdiCreateRectRgn ( 0, 0, pb->SurfObj.sizlBitmap.cx, pb->SurfObj.sizlBitmap.cy );
+ BITMAPOBJ_UnlockBitmap( pb );
NtGdiSelectVisRgn ( hDC, hVisRgn );
NtGdiDeleteObject ( hVisRgn );
- BITMAPOBJ_UnlockBitmap(hGDIObj);
return objOrg;
case GDI_OBJECT_TYPE_REGION:
- DC_UnlockDc (hDC);
+ DC_UnlockDc (dc);
/*
* The return value is one of the following values:
* SIMPLEREGION
@@ -1889,7 +1895,7 @@
default:
break;
}
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return objOrg;
}
@@ -1921,7 +1927,7 @@
dc->w.flags &= ~DC_DIRTY;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return wRet;
}
@@ -1951,7 +1957,7 @@
RtlCopyMemory(Buf, Driver->Buffer, Driver->MaximumLength);
}
- hDC = (HDC) GDIOBJ_AllocObj(sizeof(DC), GDI_OBJECT_TYPE_DC, (GDICLEANUPPROC) DC_InternalDeleteDC);
+ hDC = (HDC) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_DC);
if (hDC == NULL)
{
if(Buf)
@@ -1962,6 +1968,7 @@
}
NewDC = DC_LockDc(hDC);
+ /* FIXME - Handle NewDC == NULL! */
if (Driver != NULL)
{
@@ -1991,7 +1998,7 @@
NewDC->w.hPalette = NtGdiGetStockObject(DEFAULT_PALETTE);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(NewDC);
return hDC;
}
@@ -2021,17 +2028,16 @@
VOID FASTCALL
DC_FreeDC(HDC DCToFree)
{
- if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC, GDIOBJFLAG_DEFAULT))
+ if (!GDIOBJ_FreeObj(DCToFree, GDI_OBJECT_TYPE_DC))
{
DPRINT("DC_FreeDC failed\n");
}
}
BOOL FASTCALL
-DC_InternalDeleteDC( PDC DCToDelete )
+DC_Cleanup( PDC pDC )
{
-
- RtlFreeUnicodeString(&DCToDelete->DriverName);
+ RtlFreeUnicodeString(&pDC->DriverName);
return TRUE;
}
@@ -2113,7 +2119,7 @@
{
GDIOBJ_CopyOwnership(hDC, DC->w.hGCClipRgn);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(DC);
}
}
reactos/subsys/win32k/objects
diff -u -r1.56 -r1.56.4.1
--- dib.c 3 Jul 2004 13:55:36 -0000 1.56
+++ dib.c 12 Sep 2004 19:21:08 -0000 1.56.4.1
@@ -1,5 +1,5 @@
/*
- * $Id: dib.c,v 1.56 2004/07/03 13:55:36 navaraf Exp $
+ * $Id: dib.c,v 1.56.4.1 2004/09/12 19:21:08 weiden Exp $
*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
@@ -31,15 +31,15 @@
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if (BitmapObj == NULL)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
if (BitmapObj->dib == NULL)
{
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- DC_UnlockDc(hDC);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -60,8 +60,8 @@
else
Entries = 0;
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- DC_UnlockDc(hDC);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ DC_UnlockDc(dc);
return Entries;
}
@@ -77,15 +77,15 @@
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
if (BitmapObj == NULL)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
if (BitmapObj->dib == NULL)
{
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- DC_UnlockDc(hDC);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return 0;
}
@@ -101,8 +101,8 @@
else
Entries = 0;
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- DC_UnlockDc(hDC);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ DC_UnlockDc(dc);
return Entries;
}
@@ -167,13 +167,13 @@
{
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bitmap);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return 0;
}
DDB_Palette_Type = hDCPalette->Mode;
DDB_Palette = DC->DevInfo->hpalDefault;
- PALETTE_UnlockPalette(DC->DevInfo->hpalDefault);
+ PALETTE_UnlockPalette(hDCPalette);
// Source palette obtained from the BITMAPINFO
DIB_Palette = BuildDIBPalette ( (PBITMAPINFO)bmi, (PINT)&DIB_Palette_Type );
@@ -181,7 +181,7 @@
{
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bitmap);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
@@ -193,7 +193,7 @@
PALETTE_FreePalette(DIB_Palette);
EngUnlockSurface(SourceSurf);
EngDeleteSurface((HSURF)SourceBitmap);
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bitmap);
SetLastWin32Error(ERROR_NO_SYSTEM_RESOURCES);
return 0;
}
@@ -225,7 +225,7 @@
// if (ColorUse == DIB_PAL_COLORS)
// WinFree((LPSTR)lpRGB);
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(bitmap);
return result;
}
@@ -253,7 +253,7 @@
Ret = IntSetDIBits(Dc, hBitmap, StartScan, ScanLines, Bits, bmi, ColorUse);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(Dc);
return Ret;
}
@@ -314,7 +314,7 @@
hSourcePalette = Dc->w.hPalette;
/* FIXME: This is incorrect. hDestPalette should be something other. */
hDestPalette = Dc->DevInfo->hpalDefault;
- DC_UnlockDc(hDC);
+ DC_UnlockDc(Dc);
/* Get pointer to the source bitmap object. */
BitmapObj = BITMAPOBJ_LockBitmap(hBitmap);
@@ -385,11 +385,13 @@
DestSurfObj = EngLockSurface((HSURF)DestBitmap);
SourcePalette = PALETTE_LockPalette(hSourcePalette);
+ /* FIXME - SourcePalette can be NULL!!! Don't assert here! */
ASSERT(SourcePalette);
SourcePaletteType = SourcePalette->Mode;
- PALETTE_UnlockPalette(hSourcePalette);
+ PALETTE_UnlockPalette(SourcePalette);
DestPalette = PALETTE_LockPalette(hDestPalette);
+ /* FIXME - DestPalette can be NULL!!!! Don't assert here!!! */
ASSERT(DestPalette);
DestPaletteType = DestPalette->Mode;
@@ -418,7 +420,7 @@
}
}
- PALETTE_UnlockPalette(hDestPalette);
+ PALETTE_UnlockPalette(DestPalette);
XlateObj = IntEngCreateXlate(
DestPaletteType, SourcePaletteType, hDestPalette, hSourcePalette);
@@ -443,7 +445,7 @@
}
}
- BITMAPOBJ_UnlockBitmap(hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return Result;
}
@@ -527,7 +529,7 @@
if (Bits == NULL)
{
ret = bmp->SurfObj.cjBits;
- BITMAPOBJ_UnlockBitmap (hBitmap);
+ BITMAPOBJ_UnlockBitmap (bmp);
return ret;
}
@@ -547,7 +549,7 @@
if (Count == 0)
{
DPRINT("Less then one entire line requested\n");
- BITMAPOBJ_UnlockBitmap (hBitmap);
+ BITMAPOBJ_UnlockBitmap (bmp);
return 0;
}
@@ -578,7 +580,7 @@
ret = Count;
}
- BITMAPOBJ_UnlockBitmap (hBitmap);
+ BITMAPOBJ_UnlockBitmap (bmp);
return ret;
}
@@ -680,7 +682,7 @@
Bmp = IntCreateDIBitmap(Dc, Header, Init, Bits, Data, ColorUse);
- DC_UnlockDc(hDc);
+ DC_UnlockDc(Dc);
return Bmp;
}
@@ -707,7 +709,7 @@
{
hbitmap = DIB_CreateDIBSection ( dc, (BITMAPINFO*)bmi, Usage, Bits,
hSection, dwOffset, 0);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
}
if (bDesktopDC)
@@ -774,6 +776,11 @@
if (bm.bmBits)
{
dib = ExAllocatePoolWithTag(PagedPool, sizeof(DIBSECTION), TAG_DIB);
+ if(dib == NULL)
+ {
+ DPRINT("DIB_CreateDIBSection: Failed to allocate memory for the DIBSECTION\n");
+ return 0;
+ }
RtlZeroMemory(dib, sizeof(DIBSECTION));
}
@@ -809,11 +816,8 @@
}
dib->dshSection = section;
dib->dsOffset = offset;
- }
-
- // Create Device Dependent Bitmap and add DIB pointer
- if (dib)
- {
+
+ // Create Device Dependent Bitmap and add DIB pointer
Size.cx = bm.bmWidth;
Size.cy = bm.bmHeight;
res = IntCreateBitmap(Size, bm.bmWidthBytes,
@@ -840,8 +844,15 @@
if(bi->biBitCount == 4) { Entries = 16; } else
if(bi->biBitCount == 8) { Entries = 256; }
- bmp->ColorMap = ExAllocatePoolWithTag(PagedPool, sizeof(RGBQUAD)*Entries, TAG_COLORMAP);
- RtlCopyMemory(bmp->ColorMap, bmi->bmiColors, sizeof(RGBQUAD)*Entries);
+ if(Entries > 0)
+ {
+ if((bmp->ColorMap = ExAllocatePoolWithTag(PagedPool, sizeof(RGBQUAD)*Entries, TAG_COLORMAP)))
+ {
+ RtlCopyMemory(bmp->ColorMap, bmi->bmiColors, sizeof(RGBQUAD)*Entries);
+ }
+ }
+ else
+ bmp->ColorMap = NULL;
}
// Clean up in case of errors
@@ -863,7 +874,7 @@
if (bmp)
{
- BITMAPOBJ_UnlockBitmap(res);
+ BITMAPOBJ_UnlockBitmap(bmp);
}
// Return BITMAP handle and storage location
@@ -1029,7 +1040,7 @@
lpIndex++;
}
// RELEASEDCINFO(hDC);
- PALETTE_UnlockPalette(dc->w.hPalette);
+ PALETTE_UnlockPalette(palGDI);
return lpRGB;
}
reactos/subsys/win32k/objects
diff -u -r1.52 -r1.52.2.1
--- fillshap.c 14 Jul 2004 20:48:58 -0000 1.52
+++ fillshap.c 12 Sep 2004 19:21:08 -0000 1.52.2.1
@@ -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: fillshap.c,v 1.52 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: fillshap.c,v 1.52.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
/*
@@ -59,6 +59,7 @@
}
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
/* Convert to screen coordinates */
@@ -87,16 +88,18 @@
/* Now fill the polygon with the current brush. */
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+ /* FIXME - FillBrushObj can be NULL!!!!!!!! Don't Assert! */
ASSERT(FillBrushObj);
if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
IntGdiInitBrushInstance(&FillBrushInst, FillBrushObj, dc->XlateBrush);
ret = FillPolygon ( dc, BitmapObj, &FillBrushInst.BrushObject, dc->w.ROPmode, UnsafePoints, Count, DestRect );
}
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
/* get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+ /* FIXME - handle PenBrushObj == NULL !!!!! */
IntGdiInitBrushInstance(&PenBrushInst, PenBrushObj, dc->XlatePen);
// Draw the Polygon Edges with the current pen ( if not a NULL pen )
@@ -128,10 +131,10 @@
dc->w.ROPmode); /* MIX */
}
}
+ PENOBJ_UnlockPen( PenBrushObj );
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- PENOBJ_UnlockPen( dc->w.hPen );
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return ret;
}
@@ -242,7 +245,7 @@
FillBrush = BRUSHOBJ_LockBrush(dc->w.hBrush);
if (NULL == FillBrush)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INTERNAL_ERROR);
return FALSE;
}
@@ -250,13 +253,14 @@
PenBrush = PENOBJ_LockPen(dc->w.hPen);
if (NULL == PenBrush)
{
- PENOBJ_UnlockPen(dc->w.hPen);
- DC_UnlockDc(hDC);
+ BRUSHOBJ_UnlockBrush(FillBrush);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INTERNAL_ERROR);
return FALSE;
}
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
IntGdiInitBrushInstance(&FillBrushInst, FillBrush, dc->XlateBrush);
@@ -379,10 +383,10 @@
}
} while (B > A);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
- PENOBJ_UnlockPen(dc->w.hPen);
- DC_UnlockDc(hDC);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ BRUSHOBJ_UnlockBrush(FillBrush);
+ PENOBJ_UnlockPen(PenBrush);
+ DC_UnlockDc(dc);
return ret;
}
@@ -662,7 +666,7 @@
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
if (NULL == FillBrushObj)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INTERNAL_ERROR);
return FALSE;
}
@@ -690,8 +694,8 @@
ShapePoints = ExAllocatePoolWithTag(PagedPool, 8 * (Right - Left + 1) / 2 * sizeof(SHAPEPOINT), TAG_SHAPE);
if (NULL == ShapePoints)
{
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
- DC_UnlockDc(hDC);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
@@ -700,8 +704,8 @@
if (Left == Right)
{
PUTPIXEL(Left, Top, &PenBrushObj);
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
- DC_UnlockDc(hDC);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
+ DC_UnlockDc(dc);
return ret;
}
@@ -786,8 +790,8 @@
}
ExFreePool(ShapePoints);
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
- DC_UnlockDc(hDC);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
+ DC_UnlockDc(dc);
return ret;
#else
@@ -851,7 +855,7 @@
ExFreePool(Safept);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
}
return Ret;
@@ -883,7 +887,7 @@
Safept = ExAllocatePoolWithTag(PagedPool, (sizeof(POINT) + sizeof(INT)) * Count, TAG_SHAPE);
if(!Safept)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -893,7 +897,7 @@
Status = MmCopyFromCaller(Safept, Points, sizeof(POINT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Safept);
SetLastNtError(Status);
return FALSE;
@@ -901,7 +905,7 @@
Status = MmCopyFromCaller(SafePolyPoints, PolyCounts, sizeof(INT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Safept);
SetLastNtError(Status);
return FALSE;
@@ -909,7 +913,7 @@
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -917,7 +921,7 @@
Ret = IntGdiPolyPolygon(dc, Safept, SafePolyPoints, Count);
ExFreePool(Safept);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -937,6 +941,7 @@
RECTL DestRect;
ASSERT ( dc ); // caller's responsibility to set this up
+ /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
ASSERT ( BitmapObj );
if ( PATH_IsPathOpen(dc->w.path) )
@@ -956,6 +961,7 @@
DestRect.bottom = BottomRect;
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+ /* FIXME - Handle FillBrushObj == NULL !!!! */
IntGdiInitBrushInstance(&FillBrushInst, FillBrushObj, dc->XlateBrush);
if ( FillBrushObj )
@@ -976,14 +982,14 @@
}
}
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
/* get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
if (PenBrushObj == NULL)
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return FALSE;
}
@@ -1024,10 +1030,10 @@
dc->w.ROPmode); // MIX */
}
- PENOBJ_UnlockPen(dc->w.hPen);
+ PENOBJ_UnlockPen(PenBrushObj);
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
/* Move current position in DC?
MSDN: The current position is neither used nor updated by Rectangle. */
@@ -1054,7 +1060,7 @@
}
ret = IntRectangle ( dc, LeftRect, TopRect, RightRect, BottomRect );
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
return ret;
}
@@ -1105,21 +1111,24 @@
RectBounds.bottom = bottom;
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Handle this case gracefully instead of ASSERT! */
ASSERT(BitmapObj);
FillBrushObj = BRUSHOBJ_LockBrush(dc->w.hBrush);
+ /* FIXME - Don't assert if FillBrushObj == NULL, handle this case !!!! */
ASSERT(FillBrushObj);
if (FillBrushObj->flAttrs & GDIBRUSH_IS_NULL)
{
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
FillBrushObj = NULL; // make null brush check simpler...
}
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+ /* FIXME - PenBrushObject can be NULL!!! Don't assert!!!! */
ASSERT(PenBrushObj);
if (PenBrushObj->flAttrs & GDIBRUSH_IS_NULL)
{
- PENOBJ_UnlockPen(dc->w.hPen);
+ PENOBJ_UnlockPen(PenBrushObj);
PenBrushObj = NULL;
}
@@ -1303,9 +1312,10 @@
PUTLINE ( left, y2, left, y1, PenBrushInst );
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- PENOBJ_UnlockPen(dc->w.hPen);
- BRUSHOBJ_UnlockBrush(dc->w.hBrush);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ if(PenBrushObj != NULL)
+ PENOBJ_UnlockPen(PenBrushObj);
+ BRUSHOBJ_UnlockBrush(FillBrushObj);
return ret;
}
@@ -1333,7 +1343,7 @@
else
{
ret = IntRoundRect ( dc, LeftRect, TopRect, RightRect, BottomRect, Width, Height );
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
}
return ret;
@@ -1410,12 +1420,14 @@
Extent.bottom += DitherOrg.y;
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!! Don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
PalDestGDI = PALETTE_LockPalette(dc->w.hPalette);
+ /* FIXME - PalDestGDI can be NULL!!! Don't assert but handle this case gracefully! */
ASSERT(PalDestGDI);
Mode = PalDestGDI->Mode;
- PALETTE_UnlockPalette(dc->w.hPalette);
+ PALETTE_UnlockPalette(PalDestGDI);
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
ASSERT(XlateObj);
@@ -1431,7 +1443,7 @@
&DitherOrg,
ulMode);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
EngDeleteXlate(XlateObj);
return Ret;
@@ -1462,7 +1474,7 @@
}
if(!pVertex || !uVertex || !pMesh || !uMesh)
{
- DC_UnlockDc(hdc);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -1477,21 +1489,21 @@
SizeMesh = uMesh * sizeof(TRIVERTEX);
break;
default:
- DC_UnlockDc(hdc);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
if(!(SafeVertex = ExAllocatePoolWithTag(PagedPool, (uVertex * sizeof(TRIVERTEX)) + SizeMesh, TAG_SHAPE)))
{
- DC_UnlockDc(hdc);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
Status = MmCopyFromCaller(SafeVertex, pVertex, uVertex * sizeof(TRIVERTEX));
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hdc);
+ DC_UnlockDc(dc);
ExFreePool(SafeVertex);
SetLastNtError(Status);
return FALSE;
@@ -1500,7 +1512,7 @@
Status = MmCopyFromCaller(SafeMesh, pMesh, SizeMesh);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hdc);
+ DC_UnlockDc(dc);
ExFreePool(SafeVertex);
SetLastNtError(Status);
return FALSE;
@@ -1508,7 +1520,7 @@
Ret = IntGdiGradientFill(dc, SafeVertex, uVertex, SafeMesh, uMesh, ulMode);
- DC_UnlockDc(hdc);
+ DC_UnlockDc(dc);
ExFreePool(SafeVertex);
return Ret;
}
reactos/subsys/win32k/objects
diff -u -r1.71 -r1.71.4.1
--- gdiobj.c 4 Jul 2004 12:00:40 -0000 1.71
+++ gdiobj.c 12 Sep 2004 19:21:08 -0000 1.71.4.1
@@ -1,6 +1,6 @@
/*
* ReactOS W32 Subsystem
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
+ * Copyright (C) 1998 - 2004 ReactOS Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,352 +19,282 @@
/*
* GDIOBJ.C - GDI object manipulation routines
*
- * $Id: gdiobj.c,v 1.71 2004/07/04 12:00:40 navaraf Exp $
- *
+ * $Id: gdiobj.c,v 1.71.4.1 2004/09/12 19:21:08 weiden Exp $
*/
#include <w32k.h>
-/* count all gdi objects */
-#define GDI_COUNT_OBJECTS 1
-
-/*! Size of the GDI handle table
- * http://www.windevnet.com/documents/s=7290/wdj9902b/9902b.htm
- * gdi handle table can hold 0x4000 handles
-*/
-#define GDI_HANDLE_COUNT 0x4000
+#define NDEBUG
+#include <debug.h>
-#define GDI_GLOBAL_PROCESS ((HANDLE) 0xffffffff)
+/* FIXME - This is a HACK!!!!!! If you don't get the warnings anymore, this hack
+ should be removed immediately!! */
+#define IGNORE_PID_WHILE_LOCKING
+
+#ifdef __USE_W32API
+/* F*(&#$ header mess!!!! */
+HANDLE
+STDCALL PsGetProcessId(
+ PEPROCESS Process
+ );
+#endif /* __USE_W32API */
+
+
+#define GDI_ENTRY_TO_INDEX(ht, e) \
+ (((PCHAR)(e) - (PCHAR)&((ht)->Entries[0])) / sizeof(GDI_TABLE_ENTRY))
+#define GDI_HANDLE_GET_ENTRY(HandleTable, h) \
+ (&(HandleTable)->Entries[GDI_HANDLE_GET_INDEX((h))])
+#define GDI_VALID_OBJECT(h, obj, t, f) \
+ (((h) == (obj)->hGdiHandle) && \
+ ((GDI_HANDLE_GET_TYPE((obj)->hGdiHandle) == (t)) || ((t) == GDI_OBJECT_TYPE_DONTCARE)))
-#define GDI_HANDLE_INDEX_MASK (GDI_HANDLE_COUNT - 1)
-#define GDI_HANDLE_TYPE_MASK 0x007f0000
-#define GDI_HANDLE_STOCK_MASK 0x00800000
-
-#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))
+#define GDIBdyToHdr(body) \
+ (PGDIOBJHDR)((PCHAR)(body) - sizeof(GDI_TABLE_ENTRY))
+#define GDIHdrToBdy(hdr) \
+ (PGDIOBJ)((PCHAR)(hdr) + sizeof(GDI_TABLE_ENTRY))
-#define GDI_TYPE_TO_MAGIC(t) ((WORD) ((t) >> 16))
-#define GDI_MAGIC_TO_TYPE(m) ((DWORD)(m) << 16)
-
-/* FIXME Ownership of GDI objects by processes not properly implemented yet */
-#if 0
-#define GDI_VALID_OBJECT(h, obj, t, f) \
- (NULL != (obj) \
- && (GDI_MAGIC_TO_TYPE((obj)->Magic) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
- && (GDI_HANDLE_GET_TYPE((h)) == GDI_MAGIC_TO_TYPE((obj)->Magic)) \
- && (((obj)->hProcessId == PsGetCurrentProcessId()) \
- || (GDI_GLOBAL_PROCESS == (obj)->hProcessId) \
- || ((f) & GDIOBJFLAG_IGNOREPID)))
-#else
-#define GDI_VALID_OBJECT(h, obj, t, f) \
- (NULL != (obj) \
- && (GDI_MAGIC_TO_TYPE((obj)->Magic) == (t) || GDI_OBJECT_TYPE_DONTCARE == (t)) \
- && (GDI_HANDLE_GET_TYPE((h)) == GDI_MAGIC_TO_TYPE((obj)->Magic)))
-#endif
+/* apparently the first 10 entries are never used in windows as they are empty */
+#define RESERVE_ENTRIES_COUNT 10
typedef struct _GDI_HANDLE_TABLE
{
- WORD wTableSize;
- WORD AllocationHint;
- #if GDI_COUNT_OBJECTS
- ULONG HandlesCount;
- #endif
+ LONG HandlesCount;
+ LONG nEntries;
PPAGED_LOOKASIDE_LIST LookasideLists;
- PGDIOBJHDR Handles[1];
+
+ PGDI_TABLE_ENTRY EntriesEnd;
+
+ GDI_TABLE_ENTRY Entries[1];
} GDI_HANDLE_TABLE, *PGDI_HANDLE_TABLE;
typedef struct
{
ULONG Type;
ULONG Size;
-} GDI_OBJ_SIZE;
+ PVOID CleanupProc; /* GDICLEANUPPROC */
+} GDI_OBJ_INFO, *PGDI_OBJ_INFO;
+/*
+ * Dummy GDI Cleanup Callback
+ */
+BOOL FASTCALL
+GDI_CleanupDummy(PGDIOBJ pObj)
+{
+ return TRUE;
+}
+
+/* Testing shows that regions are the most used GDIObj type,
+ so put that one first for performance */
const
-GDI_OBJ_SIZE ObjSizes[] =
+GDI_OBJ_INFO ObjInfo[] =
{
- /* Testing shows that regions are the most used GDIObj type,
- so put that one first for performance */
- {GDI_OBJECT_TYPE_REGION, sizeof(ROSRGNDATA)},
- {GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAPOBJ)},
- {GDI_OBJECT_TYPE_DC, sizeof(DC)},
- {GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI)},
- {GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ)},
- {GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ)},
- {GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ)},
- {GDI_OBJECT_TYPE_DCE, sizeof(DCE)},
-/*
- {GDI_OBJECT_TYPE_DIRECTDRAW, sizeof(DD_DIRECTDRAW)},
- {GDI_OBJECT_TYPE_DD_SURFACE, sizeof(DD_SURFACE)},
-*/
- {GDI_OBJECT_TYPE_EXTPEN, 0},
- {GDI_OBJECT_TYPE_METADC, 0},
- {GDI_OBJECT_TYPE_METAFILE, 0},
- {GDI_OBJECT_TYPE_ENHMETAFILE, 0},
- {GDI_OBJECT_TYPE_ENHMETADC, 0},
- {GDI_OBJECT_TYPE_MEMDC, 0},
- {GDI_OBJECT_TYPE_EMF, 0}
+ /* Type */ /* Size */ /* CleanupProc */
+ {GDI_OBJECT_TYPE_REGION, sizeof(ROSRGNDATA), RGNDATA_Cleanup},
+ {GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAPOBJ), BITMAP_Cleanup},
+ {GDI_OBJECT_TYPE_DC, sizeof(DC), DC_Cleanup},
+ {GDI_OBJECT_TYPE_PALETTE, sizeof(PALGDI), PALETTE_Cleanup},
+ {GDI_OBJECT_TYPE_BRUSH, sizeof(GDIBRUSHOBJ), BRUSH_Cleanup},
+ {GDI_OBJECT_TYPE_PEN, sizeof(GDIBRUSHOBJ), GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_FONT, sizeof(TEXTOBJ), GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_DCE, sizeof(DCE), DCE_Cleanup},
+/*{GDI_OBJECT_TYPE_DIRECTDRAW, sizeof(DD_DIRECTDRAW), DD_Cleanup},
+ {GDI_OBJECT_TYPE_DD_SURFACE, sizeof(DD_SURFACE), DDSURF_Cleanup},*/
+ {GDI_OBJECT_TYPE_EXTPEN, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_METADC, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_METAFILE, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_ENHMETAFILE, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_ENHMETADC, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_MEMDC, 0, GDI_CleanupDummy},
+ {GDI_OBJECT_TYPE_EMF, 0, GDI_CleanupDummy}
};
-#define OBJTYPE_COUNT (sizeof(ObjSizes) / sizeof(ObjSizes[0]))
-
-/* GDI stock objects */
-
-static LOGBRUSH WhiteBrush =
-{ BS_SOLID, RGB(255,255,255), 0 };
-
-static LOGBRUSH LtGrayBrush =
-/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
-{ BS_SOLID, RGB(192,192,192), 0 };
-
-static LOGBRUSH GrayBrush =
-/* FIXME : this should perhaps be BS_HATCHED, at least for 1 bitperpixel */
-{ BS_SOLID, RGB(128,128,128), 0 };
-
-static LOGBRUSH DkGrayBrush =
-/* This is BS_HATCHED, for 1 bitperpixel. This makes the spray work in pbrush */
-/* NB_HATCH_STYLES is an index into HatchBrushes */
-{ BS_HATCHED, RGB(0,0,0), NB_HATCH_STYLES };
-
-static LOGBRUSH BlackBrush =
-{ BS_SOLID, RGB(0,0,0), 0 };
+#define OBJTYPE_COUNT (sizeof(ObjInfo) / sizeof(ObjInfo[0]))
-static LOGBRUSH NullBrush =
-{ BS_NULL, 0, 0 };
+static PGDI_HANDLE_TABLE HandleTable = NULL;
+static LARGE_INTEGER ShortDelay;
-static LOGPEN WhitePen =
-{ PS_SOLID, { 0, 0 }, RGB(255,255,255) };
-
-static LOGPEN BlackPen =
-{ PS_SOLID, { 0, 0 }, RGB(0,0,0) };
-
-static LOGPEN NullPen =
-{ PS_NULL, { 0, 0 }, 0 };
-
-static LOGFONTW OEMFixedFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, OEM_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
-
-static LOGFONTW AnsiFixedFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
-
-/*static LOGFONTW AnsiVarFont =
- *{ 10, 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 =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
-
-static LOGFONTW DeviceDefaultFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
-
-static LOGFONTW SystemFixedFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, L"Bitstream Vera Sans Mono" };
-
-/* FIXME: Is this correct? */
-static LOGFONTW DefaultGuiFont =
-{ 11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
- 0, 0, DEFAULT_QUALITY, VARIABLE_PITCH | FF_SWISS, L"Bitstream Vera Sans" };
-
-#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;
-static LARGE_INTEGER ShortDelay;
+#define DelayExecution() DbgPrint("%s:%i: Delay\n", __FILE__, __LINE__); KeDelayExecutionThread(KernelMode, FALSE, &ShortDelay)
/*!
* Allocate GDI object table.
* \param Size - number of entries in the object table.
- * Notes:: Must be called at IRQL < DISPATCH_LEVEL.
*/
static PGDI_HANDLE_TABLE FASTCALL
-GDIOBJ_iAllocHandleTable (WORD Size)
+GDIOBJ_iAllocHandleTable(ULONG Entries)
{
- PGDI_HANDLE_TABLE handleTable;
- ULONG MemSize;
+ PGDI_HANDLE_TABLE handleTable;
UINT ObjType;
-
- MemSize = sizeof(GDI_HANDLE_TABLE) + sizeof(PGDIOBJ) * Size;
+ ULONG MemSize = sizeof(GDI_HANDLE_TABLE) + (sizeof(GDI_TABLE_ENTRY) * (Entries - 1));
- /* prevent APC delivery for the *FastMutexUnsafe calls */
- const KIRQL PrevIrql = KfRaiseIrql(APC_LEVEL);
- ExAcquireFastMutexUnsafe (&HandleTableMutex);
handleTable = ExAllocatePoolWithTag(PagedPool, MemSize, TAG_GDIHNDTBLE);
ASSERT( handleTable );
- memset (handleTable, 0, MemSize);
-#if GDI_COUNT_OBJECTS
+ RtlZeroMemory(handleTable, MemSize);
+
handleTable->HandlesCount = 0;
-#endif
- handleTable->wTableSize = Size;
- handleTable->AllocationHint = 1;
+ handleTable->nEntries = Entries;
+
+ handleTable->EntriesEnd = &handleTable->Entries[Entries];
+
handleTable->LookasideLists = ExAllocatePoolWithTag(PagedPool,
OBJTYPE_COUNT * sizeof(PAGED_LOOKASIDE_LIST),
TAG_GDIHNDTBLE);
- if (NULL == handleTable->LookasideLists)
- {
- ExFreePool(handleTable);
- ExReleaseFastMutexUnsafe (&HandleTableMutex);
- KfLowerIrql(PrevIrql);
- return NULL;
- }
- for (ObjType = 0; ObjType < OBJTYPE_COUNT; ObjType++)
- {
- ExInitializePagedLookasideList(handleTable->LookasideLists + ObjType, NULL, NULL, 0,
- ObjSizes[ObjType].Size + sizeof(GDIOBJHDR), TAG_GDIOBJ, 0);
- }
- ExReleaseFastMutexUnsafe (&HandleTableMutex);
- KfLowerIrql(PrevIrql);
+ if(handleTable->LookasideLists == NULL)
+ {
+ ExFreePool(handleTable);
+ return NULL;
+ }
+
+ for(ObjType = 0; ObjType < OBJTYPE_COUNT; ObjType++)
+ {
+ ExInitializePagedLookasideList(handleTable->LookasideLists + ObjType, NULL, NULL, 0,
+ ObjInfo[ObjType].Size + sizeof(GDIOBJHDR), TAG_GDIOBJ, 0);
+ }
+
+ ShortDelay.QuadPart = -100;
return handleTable;
}
-/*!
- * Returns the entry into the handle table by index.
-*/
-static PGDIOBJHDR FASTCALL
-GDIOBJ_iGetObjectForIndex(WORD TableIndex)
+static inline PPAGED_LOOKASIDE_LIST
+FindLookasideList(DWORD ObjectType)
{
- if (0 == TableIndex || HandleTable->wTableSize < TableIndex)
+ int Index;
+
+ for (Index = 0; Index < OBJTYPE_COUNT; Index++)
+ {
+ if (ObjInfo[Index].Type == ObjectType)
{
- DPRINT1("Invalid TableIndex %u\n", (unsigned) TableIndex);
- return NULL;
+ return HandleTable->LookasideLists + Index;
}
+ }
+
+ DPRINT1("Can't find lookaside list for object type 0x%08x\n", ObjectType);
- return HandleTable->Handles[TableIndex];
+ return NULL;
}
-/*!
- * Finds next free entry in the GDI handle table.
- * \return index into the table is successful, zero otherwise.
-*/
-static WORD FASTCALL
-GDIOBJ_iGetNextOpenHandleIndex (void)
+static inline BOOL
+RunCleanupCallback(PGDIOBJ pObj, DWORD ObjectType)
{
- WORD tableIndex;
-
- for (tableIndex = HandleTable->AllocationHint;
- tableIndex < HandleTable->wTableSize;
- tableIndex++)
- {
- if (HandleTable->Handles[tableIndex] == NULL)
- {
- HandleTable->AllocationHint = tableIndex + 1;
- return tableIndex;
- }
- }
+ int Index;
- for (tableIndex = 1;
- tableIndex < HandleTable->AllocationHint;
- tableIndex++)
- {
- if (HandleTable->Handles[tableIndex] == NULL)
- {
- HandleTable->AllocationHint = tableIndex + 1;
- return tableIndex;
- }
- }
+ for (Index = 0; Index < OBJTYPE_COUNT; Index++)
+ {
+ if (ObjInfo[Index].Type == ObjectType)
+ {
+ return ((GDICLEANUPPROC)ObjInfo[Index].CleanupProc)(pObj);
+ }
+ }
- return 0;
+ DPRINT1("Can't find cleanup callback for object type 0x%08x\n", ObjectType);
+ return TRUE;
}
-static PPAGED_LOOKASIDE_LIST FASTCALL
-FindLookasideList(DWORD ObjectType)
+static inline ULONG
+GetObjectSize(DWORD ObjectType)
{
int Index;
for (Index = 0; Index < OBJTYPE_COUNT; Index++)
+ {
+ if (ObjInfo[Index].Type == ObjectType)
{
- if (ObjSizes[Index].Type == ObjectType)
- {
- return HandleTable->LookasideLists + Index;
- }
+ return ObjInfo[Index].Size;
}
+ }
- DPRINT1("Can't find lookaside list for object type 0x%08x\n", ObjectType);
-
- return NULL;
+ DPRINT1("Can't find size for object type 0x%08x\n", ObjectType);
+ return 0;
}
/*!
* Allocate memory for GDI object and return handle to it.
*
- * \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 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.
+ * \todo return the object pointer and lock it by default.
*/
HGDIOBJ FASTCALL
-GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc)
+GDIOBJ_AllocObj(ULONG ObjectType)
{
PW32PROCESS W32Process;
PGDIOBJHDR newObject;
- WORD Index;
PPAGED_LOOKASIDE_LIST LookasideList;
-
- ExAcquireFastMutex(&HandleTableMutex);
- Index = GDIOBJ_iGetNextOpenHandleIndex ();
- if (0 == Index)
- {
- ExReleaseFastMutex(&HandleTableMutex);
- DPRINT1("Out of GDI handles\n");
- return NULL;
- }
+ LONG CurrentProcessId;
+
+ ASSERT(ObjectType != GDI_OBJECT_TYPE_DONTCARE);
LookasideList = FindLookasideList(ObjectType);
- if (NULL == LookasideList)
+ if(LookasideList != NULL)
+ {
+ newObject = ExAllocateFromPagedLookasideList(LookasideList);
+ if(newObject != NULL)
{
- ExReleaseFastMutex(&HandleTableMutex);
- return NULL;
+ PGDI_TABLE_ENTRY Entry;
+ PGDIOBJ ObjectBody;
+ LONG TypeInfo;
+
+ /* shift the process id to the left so we can use the first bit to lock
+ the object.
+ FIXME - don't shift once ROS' PIDs match with nt! */
+ CurrentProcessId = (LONG)PsGetCurrentProcessId() << 1;
+ W32Process = PsGetWin32Process();
+
+ newObject->RefCount = 1;
+ newObject->LockingThread = NULL;
+ newObject->Type = ObjectType;
+ newObject->LookasideList = LookasideList;
+
+#ifdef GDI_DEBUG
+ newObject->lockfile = NULL;
+ newObject->lockline = 0;
+#endif
+
+ ObjectBody = GDIHdrToBdy(newObject);
+
+ RtlZeroMemory(ObjectBody, GetObjectSize(ObjectType));
+
+ TypeInfo = (ObjectType & 0xFFFF0000) | (ObjectType >> 16);
+
+ /* Search for a free handle entry */
+ for(Entry = &HandleTable->Entries[RESERVE_ENTRIES_COUNT];
+ Entry < HandleTable->EntriesEnd;
+ Entry++)
+ {
+ if(InterlockedCompareExchangePointer(&Entry->KernelData, ObjectBody, NULL) == NULL)
+ {
+ UINT Index;
+
+ /* we found a free entry */
+ InterlockedExchange(&Entry->ProcessId, CurrentProcessId);
+ InterlockedExchange(&Entry->Type, TypeInfo);
+
+ if(W32Process != NULL)
+ {
+ InterlockedIncrement(&W32Process->GDIObjects);
+ }
+
+ Index = GDI_ENTRY_TO_INDEX(HandleTable, Entry);
+ DPRINT("GDIOBJ_AllocObj: 0x%x kd:0x%x ob: 0x%x\n", ((Index & 0xFFFF) | (ObjectType & 0xFFFF0000)), Entry->KernelData, ObjectBody);
+ return (HGDIOBJ)((Index & 0xFFFF) | (ObjectType & 0xFFFF0000));
+ }
+ }
+
+ ExFreeToPagedLookasideList(LookasideList, newObject);
+ DPRINT1("Failed to insert gdi object into the handle table, no handles left!\n");
}
- newObject = ExAllocateFromPagedLookasideList(LookasideList);
- if (NULL == newObject)
+ else
{
- ExReleaseFastMutex(&HandleTableMutex);
- DPRINT1("Unable to allocate GDI object from lookaside list\n");
- return NULL;
- }
- RtlZeroMemory (newObject, Size + sizeof(GDIOBJHDR));
-
- newObject->wTableIndex = Index;
-
- newObject->dwCount = 0;
- newObject->hProcessId = PsGetCurrentProcessId ();
- newObject->CleanupProc = CleanupProc;
- newObject->Magic = GDI_TYPE_TO_MAGIC(ObjectType);
- newObject->lockfile = NULL;
- newObject->lockline = 0;
-#ifdef GDIOBJ_USE_FASTMUTEX
- ExInitializeFastMutex(&newObject->Lock);
- newObject->RecursiveLockCount = 0;
-#else
- newObject->LockTid = 0;
- newObject->LockCount = 0;
-#endif
- HandleTable->Handles[Index] = newObject;
-#if GDI_COUNT_OBJECTS
- HandleTable->HandlesCount++;
-#endif
- ExReleaseFastMutex(&HandleTableMutex);
-
- W32Process = PsGetCurrentProcess()->Win32Process;
- if(W32Process)
+ DPRINT1("Not enough memory to allocate gdi object!\n");
+ }
+ }
+ else
{
- W32Process->GDIObjects++;
+ DPRINT1("Failed to find lookaside list for object type 0x%x\n", ObjectType);
}
-
- return GDI_HANDLE_CREATE(Index, ObjectType);
+ return NULL;
}
/*!
@@ -372,77 +302,133 @@
* appropriate cleanup routine.
*
* \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.
- *
- * \note You should only use GDIOBJFLAG_IGNOREPID if you are cleaning up after the process that terminated.
- * \note This function deferres object deletion if it is still in use.
+ * \return Returns FALSE if the cleanup routine returned FALSE or the object doesn't belong
+ * to the calling process.
*/
-BOOL STDCALL
-GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType, DWORD Flag)
+BOOL FASTCALL
+GDIOBJ_FreeObj(HGDIOBJ hObj, DWORD ObjectType)
{
- PW32PROCESS W32Process;
- PGDIOBJHDR objectHeader;
- PGDIOBJ Obj;
+ /* FIXME - get rid of the ObjectType and Flag parameters, they're obsolete! */
+ PGDI_TABLE_ENTRY Entry;
PPAGED_LOOKASIDE_LIST LookasideList;
- BOOL bRet = TRUE;
-
- objectHeader = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(hObj));
- DPRINT("GDIOBJ_FreeObj: hObj: 0x%08x, object: %x\n", hObj, objectHeader);
+ LONG ProcessId, LockedProcessId, PrevProcId, ExpectedType;
- if (! GDI_VALID_OBJECT(hObj, objectHeader, ObjectType, Flag)
- || GDI_GLOBAL_PROCESS == objectHeader->hProcessId)
+ DPRINT("GDIOBJ_FreeObj: hObj: 0x%08x\n", hObj);
- {
- DPRINT1("Can't delete hObj:0x%08x, type:0x%08x, flag:%d\n", hObj, ObjectType, Flag);
- return FALSE;
- }
+ /* shift the process id to the left so we can use the first bit to lock the object.
+ FIXME - don't shift once ROS' PIDs match with nt! */
+ ProcessId = (LONG)PsGetCurrentProcessId() << 1;
+ LockedProcessId = ProcessId | 0x1;
+
+ ExpectedType = ((ObjectType != GDI_OBJECT_TYPE_DONTCARE) ? 0 : (ObjectType & 0xFFFF0000) | (ObjectType >> 16));
+
+ Entry = GDI_HANDLE_GET_ENTRY(HandleTable, hObj);
+
+LockHandle:
+ /* lock the object, we must not delete stock objects, so don't check!!! */
+ PrevProcId = InterlockedCompareExchange(&Entry->ProcessId, LockedProcessId, ProcessId);
+ if(PrevProcId == ProcessId)
+ {
+ LONG PrevType;
+
+ExchangeType:
+ /* clear the type field as we're about to delete the object */
+ PrevType = InterlockedCompareExchange(&Entry->Type, 0, ExpectedType);
+ if(PrevType != 0 && PrevType == ExpectedType)
+ {
+ PGDIOBJHDR GdiHdr = GDIBdyToHdr(Entry->KernelData);
+
+ /* we're save now, any attempt to lock or delete the object will fail as
+ the type field now is 0, which indicates the object is being deleted.
+ We're safe to access the object now and decrement the reference counter */
+ if(InterlockedDecrement(&GdiHdr->RefCount) == 0)
+ {
+ BOOL Ret;
+
+ /* We removed the keep-alive reference, it's time to clear the PID and object
+ pointer in the table. */
+ InterlockedExchange(&Entry->ProcessId, 0);
+ InterlockedExchangePointer(&Entry->KernelData, NULL);
+
+ /* As we removed the keep-alive reference no thread is allowed to hold the lock */
+ ASSERT(GdiHdr->LockingThread == NULL);
+
+ /* call the cleanup routine. */
+ Ret = RunCleanupCallback(GDIHdrToBdy(GdiHdr), GdiHdr->Type);
+
+ /* Now it's time to free the memory */
+ LookasideList = FindLookasideList(PrevType << 16);
+ if(LookasideList != NULL)
+ {
+ ExFreeToPagedLookasideList(LookasideList, GdiHdr);
+ }
+
+ return Ret;
+ }
+ else
+ {
+ /* the LockingThread field should not be NULL here, the object must be locked right now! */
+ ASSERT(GdiHdr->LockingThread != NULL);
- 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);
+ /* there's still some references to the object, some kids locked the object
+ more than once!!! We however remove the object from the table so they're
+ not accessible anymore. The object gets deleted as soon as the reference
+ counter is 0 in the unlocking routine. */
+ InterlockedExchange(&Entry->ProcessId, 0);
+ InterlockedExchangePointer(&Entry->KernelData, NULL);
+
+ /* report a successful deletion as the object is actually removed from the table */
+ return TRUE;
+ }
}
-
- /* allow object to delete internal data */
- if (NULL != objectHeader->CleanupProc)
+ else if(PrevType != 0)
{
- Obj = (PGDIOBJ)((PCHAR)objectHeader + sizeof(GDIOBJHDR));
- bRet = (*(objectHeader->CleanupProc))(Obj);
+ /* try again, the caller passed GDI_OBJECT_TYPE_DONTCARE as type */
+ ExpectedType = PrevType;
+ goto ExchangeType;
}
- LookasideList = FindLookasideList(GDI_MAGIC_TO_TYPE(objectHeader->Magic));
- if (NULL != LookasideList)
+ else
{
- ExFreeToPagedLookasideList(LookasideList, objectHeader);
+ if(ObjectType == 0)
+ {
+ DPRINT1("Another thread already deleted the object 0x%x!\n", hObj);
+ }
+ else
+ {
+ DPRINT1("Attempted to delete object 0x%x, type mismatch (0x%x : 0x%x)\n", hObj, ObjectType, ExpectedType);
+ }
}
- ExAcquireFastMutexUnsafe (&HandleTableMutex);
- HandleTable->Handles[GDI_HANDLE_GET_INDEX(hObj)] = NULL;
-#if GDI_COUNT_OBJECTS
- HandleTable->HandlesCount--;
+ }
+ else if(PrevProcId == LockedProcessId)
+ {
+ /* the object is currently locked, wait some time and try again.
+ FIXME - we shouldn't loop forever! Give up after some time! */
+ DelayExecution();
+ /* try again */
+ goto LockHandle;
+ }
+#ifdef IGNORE_PID_WHILE_LOCKING
+ /* FIXME - HACK HACK HACK HACK!!!!!!
+ Remove when no longer needed! */
+ else if((PrevProcId >> 1) != (LONG)PsGetCurrentProcessId())
+ {
+ DPRINT("HACK!!!! Deleting Object 0x%x (pid: 0x%x) from pid 0x%x!!!\n", hObj, PrevProcId >> 1, PsGetCurrentProcessId());
+#ifdef GDI_DEBUG
+ DPRINT("\tcalled from %s:%i\n", file, line);
#endif
- ExReleaseFastMutexUnsafe (&HandleTableMutex);
-
- W32Process = PsGetCurrentProcess()->Win32Process;
- if(W32Process)
+ ProcessId = PrevProcId & 0xFFFFFFFE;
+ LockedProcessId = ProcessId | 0x1;
+ goto LockHandle;
+ }
+#endif /* IGNORE_PID_WHILE_LOCKING */
+ else
{
- W32Process->GDIObjects--;
+ DPRINT1("Attempted to free invalid handle: 0x%x\n", hObj);
}
-
- return bRet;
+
+ return FALSE;
}
/*!
@@ -516,7 +502,7 @@
pList[j].pObj = NULL;
}
}
- GDIOBJ_UnlockObj(pList[i].hObj, pList[i].ObjectType);
+ GDIOBJ_UnlockObj(pList[i].pObj);
pList[i].pObj = NULL;
}
}
@@ -525,101 +511,15 @@
}
/*!
- * Get the type of the object.
- * \param ObjectHandle - handle of the object.
- * \return One of the \ref GDI object types
-*/
-DWORD FASTCALL
-GDIOBJ_GetObjectType(HGDIOBJ ObjectHandle)
-{
- PGDIOBJHDR ObjHdr;
-
- ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(ObjectHandle));
- if (NULL == ObjHdr
- || ! GDI_VALID_OBJECT(ObjectHandle, ObjHdr, GDI_MAGIC_TO_TYPE(ObjHdr->Magic), 0))
- {
- DPRINT1("Invalid ObjectHandle 0x%08x\n", ObjectHandle);
- return 0;
- }
- DPRINT("GDIOBJ_GetObjectType for handle 0x%08x returns 0x%08x\n", ObjectHandle,
- GDI_MAGIC_TO_TYPE(ObjHdr->Magic));
-
- return GDI_MAGIC_TO_TYPE(ObjHdr->Magic);
-}
-
-/*!
* Initialization of the GDI object engine.
*/
VOID FASTCALL
InitGdiObjectHandleTable (VOID)
{
DPRINT("InitGdiObjectHandleTable\n");
- ExInitializeFastMutex (&HandleTableMutex);
- ExInitializeFastMutex (&RefCountHandling);
-
- ShortDelay.QuadPart = -100;
HandleTable = GDIOBJ_iAllocHandleTable (GDI_HANDLE_COUNT);
- DPRINT("HandleTable: %x\n", HandleTable );
-
- InitEngHandleTable();
-}
-
-/*!
- * Creates a bunch of stock objects: brushes, pens, fonts.
-*/
-VOID FASTCALL
-CreateStockObjects(void)
-{
- unsigned Object;
-
- DPRINT("Beginning creation of stock objects\n");
-
- /* Create GDI Stock Objects from the logical structures we've defined */
-
- StockObjects[WHITE_BRUSH] = IntGdiCreateBrushIndirect(&WhiteBrush);
- StockObjects[LTGRAY_BRUSH] = IntGdiCreateBrushIndirect(&LtGrayBrush);
- StockObjects[GRAY_BRUSH] = IntGdiCreateBrushIndirect(&GrayBrush);
- StockObjects[DKGRAY_BRUSH] = IntGdiCreateBrushIndirect(&DkGrayBrush);
- StockObjects[BLACK_BRUSH] = IntGdiCreateBrushIndirect(&BlackBrush);
- StockObjects[NULL_BRUSH] = IntGdiCreateBrushIndirect(&NullBrush);
-
- StockObjects[WHITE_PEN] = IntGdiCreatePenIndirect(&WhitePen);
- StockObjects[BLACK_PEN] = IntGdiCreatePenIndirect(&BlackPen);
- StockObjects[NULL_PEN] = IntGdiCreatePenIndirect(&NullPen);
-
- (void) TextIntCreateFontIndirect(&OEMFixedFont, (HFONT*)&StockObjects[OEM_FIXED_FONT]);
- (void) TextIntCreateFontIndirect(&AnsiFixedFont, (HFONT*)&StockObjects[ANSI_FIXED_FONT]);
- (void) TextIntCreateFontIndirect(&SystemFont, (HFONT*)&StockObjects[SYSTEM_FONT]);
- (void) TextIntCreateFontIndirect(&DeviceDefaultFont, (HFONT*)&StockObjects[DEVICE_DEFAULT_FONT]);
- (void) TextIntCreateFontIndirect(&SystemFixedFont, (HFONT*)&StockObjects[SYSTEM_FIXED_FONT]);
- (void) TextIntCreateFontIndirect(&DefaultGuiFont, (HFONT*)&StockObjects[DEFAULT_GUI_FONT]);
-
- StockObjects[DEFAULT_PALETTE] = (HGDIOBJ*)PALETTE_Init();
-
- for (Object = 0; Object < NB_STOCK_OBJECTS; Object++)
- {
- if (NULL != StockObjects[Object])
- {
- GDIOBJ_SetOwnership(StockObjects[Object], NULL);
-/* GDI_HANDLE_SET_STOCKOBJ(StockObjects[Object]);*/
- }
- }
-
- DPRINT("Completed creation of stock objects\n");
-}
-
-/*!
- * Return stock object.
- * \param Object - stock object id.
- * \return Handle to the object.
-*/
-HGDIOBJ STDCALL
-NtGdiGetStockObject(INT Object)
-{
- DPRINT("NtGdiGetStockObject index %d\n", Object);
-
- return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object];
+ DPRINT("HandleTable: %x\n", HandleTable);
}
/*!
@@ -633,7 +533,7 @@
DPRINT("NtGdiDeleteObject handle 0x%08x\n", hObject);
return NULL != hObject
- ? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE, GDIOBJFLAG_DEFAULT) : FALSE;
+ ? GDIOBJ_FreeObj(hObject, GDI_OBJECT_TYPE_DONTCARE) : FALSE;
}
/*!
@@ -643,9 +543,11 @@
BOOL FASTCALL
CleanupForProcess (struct _EPROCESS *Process, INT Pid)
{
- DWORD i;
- PGDIOBJHDR objectHeader;
+ PGDI_TABLE_ENTRY Entry;
PEPROCESS CurrentProcess;
+ PW32PROCESS W32Process;
+ LONG ProcId;
+ ULONG Index = RESERVE_ENTRIES_COUNT;
DPRINT("Starting CleanupForProcess prochandle %x Pid %d\n", Process, Pid);
CurrentProcess = PsGetCurrentProcess();
@@ -653,19 +555,39 @@
{
KeAttachProcess(Process);
}
+ W32Process = Process->Win32Process;
+ ASSERT(W32Process);
- for(i = 1; i < HandleTable->wTableSize; i++)
+ if(W32Process->GDIObjects > 0)
+ {
+ /* FIXME - Instead of building the handle here and delete it using GDIOBJ_FreeObj
+ we should delete it directly here! */
+ ProcId = ((LONG)PsGetCurrentProcessId() << 1);
+
+ for(Entry = &HandleTable->Entries[RESERVE_ENTRIES_COUNT];
+ Entry < HandleTable->EntriesEnd;
+ Entry++, Index++)
{
- objectHeader = GDIOBJ_iGetObjectForIndex(i);
- if (NULL != objectHeader &&
- (INT) objectHeader->hProcessId == Pid)
- {
- DPRINT("CleanupForProcess: %d, process: %d, locks: %d, magic: 0x%x", i, objectHeader->hProcessId, objectHeader->dwCount, objectHeader->Magic);
- GDIOBJ_FreeObj(GDI_HANDLE_CREATE(i, GDI_MAGIC_TO_TYPE(objectHeader->Magic)),
- GDI_MAGIC_TO_TYPE(objectHeader->Magic),
- GDIOBJFLAG_IGNOREPID | GDIOBJFLAG_IGNORELOCK);
- }
+ /* ignore the lock bit */
+ if((Entry->ProcessId & 0xFFFFFFFE) == ProcId && Entry->Type != 0)
+ {
+ HANDLE ObjectHandle;
+
+ /* Create the object handle for the entry, the upper 16 bit of the
+ Type field includes the type of the object including the stock
+ object flag - but since stock objects don't have a process id we can
+ simply ignore this fact here. */
+ ObjectHandle = (HANDLE)(Index | (Entry->Type & 0xFFFF0000));
+
+ if(GDIOBJ_FreeObj(ObjectHandle, GDI_OBJECT_TYPE_DONTCARE) &&
+ W32Process->GDIObjects == 0)
+ {
+ /* there are no more gdi handles for this process, bail */
+ break;
+ }
+ }
}
+ }
if (CurrentProcess != Process)
{
@@ -679,340 +601,567 @@
#define GDIOBJ_TRACKLOCKS
-#ifdef GDIOBJ_LockObj
-#undef GDIOBJ_LockObj
-PGDIOBJ FASTCALL
-GDIOBJ_LockObjDbg (const char* file, int line, HGDIOBJ hObj, DWORD ObjectType)
-{
- PGDIOBJHDR ObjHdr = GDIOBJ_iGetObjectForIndex(GDI_HANDLE_GET_INDEX(hObj));
-#ifndef GDIOBJ_USE_FASTMUTEX
- DWORD CurrentTid = (DWORD)PsGetCurrentThreadId();
-#endif
-
- DPRINT("(%s:%i) GDIOBJ_LockObjDbg(0x%08x,0x%08x)\n", file, line, hObj, ObjectType);
- if (! GDI_VALID_OBJECT(hObj, ObjHdr, ObjectType, GDIOBJFLAG_DEFAULT))
- {
- int reason = 0;
- if (NULL == ObjHdr)
- {
- reason = 1;
- }
- else if (GDI_MAGIC_TO_TYPE(ObjHdr->Magic) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE)
- {
- reason = 2;
- }
- else if (ObjHdr->hProcessId != GDI_GLOBAL_PROCESS
- && ObjHdr->hProcessId != PsGetCurrentProcessId())
- {
- reason = 3;
- }
- else if (GDI_HANDLE_GET_TYPE(hObj) != ObjectType && ObjectType != GDI_OBJECT_TYPE_DONTCARE)
- {
- reason = 4;
- }
- 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;
- }
-
-#ifdef GDIOBJ_USE_FASTMUTEX
- if (ObjHdr->Lock.Owner == KeGetCurrentThread())
- {
- ObjHdr->RecursiveLockCount++;
- }
- else
- {
-#ifdef NDEBUG
- ExAcquireFastMutex(&ObjHdr->Lock);
-#else /* NDEBUG */
- if (! ExTryToAcquireFastMutex(&ObjHdr->Lock))
- {
- DPRINT1("Caution! GDIOBJ_LockObj trying to lock object 0x%x second time\n", hObj);
- DPRINT1(" called from: %s:%i (thread %x)\n", file, line, KeGetCurrentThread());
- if (NULL != ObjHdr->lockfile)
- {
- DPRINT1(" previously locked from: %s:%i (thread %x)\n", ObjHdr->lockfile, ObjHdr->lockline, ObjHdr->Lock.Owner);
- }
- ExAcquireFastMutex(&ObjHdr->Lock);
- DPRINT1(" Disregard previous message about object 0x%x, it's ok\n", hObj);
- }
-#endif /* NDEBUG */
- ObjHdr->RecursiveLockCount++;
- }
-#else
- if (ObjHdr->LockTid == CurrentTid)
- {
- InterlockedIncrement(&ObjHdr->LockCount);
[truncated at 1000 lines; 757 more skipped]
reactos/subsys/win32k/objects
diff -u -r1.37 -r1.37.2.1
--- line.c 14 Jul 2004 20:48:58 -0000 1.37
+++ line.c 12 Sep 2004 19:21:08 -0000 1.37.2.1
@@ -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.37 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: line.c,v 1.37.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
// Some code from the WINE project source (www.winehq.com)
@@ -98,6 +98,7 @@
/* get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen( dc->w.hPen );
+ /* FIXME - PenBrushObj can be NULL!!!! Don't assert here! */
ASSERT(PenBrushObj);
if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
@@ -112,8 +113,8 @@
dc->w.ROPmode);
}
- BITMAPOBJ_UnlockBitmap ( dc->w.hBitmap );
- PENOBJ_UnlockPen( dc->w.hPen );
+ BITMAPOBJ_UnlockBitmap ( BitmapObj );
+ PENOBJ_UnlockPen( PenBrushObj );
}
if (Ret)
@@ -202,6 +203,7 @@
/* Get BRUSHOBJ from current pen. */
PenBrushObj = PENOBJ_LockPen(dc->w.hPen);
+ /* FIXME - PenBrushObj can be NULL! Don't assert here! */
ASSERT(PenBrushObj);
if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
@@ -210,6 +212,7 @@
if (Points != NULL)
{
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - BitmapObj can be NULL!!!! Don't assert but handle this case gracefully! */
ASSERT(BitmapObj);
RtlCopyMemory(Points, pt, Count * sizeof(POINT));
@@ -227,7 +230,7 @@
&PenBrushInst.BrushObject, Points, Count,
dc->w.ROPmode);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
EngFreeMem(Points);
}
else
@@ -236,7 +239,7 @@
}
}
- PENOBJ_UnlockPen(dc->w.hPen);
+ PENOBJ_UnlockPen(PenBrushObj);
return Ret;
}
@@ -376,7 +379,7 @@
XEndArc,
YEndArc);
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return Ret;
}
@@ -405,7 +408,7 @@
// Line from current position to starting point of arc
if ( !IntGdiLineTo(dc, XRadial1, YRadial1) )
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return FALSE;
}
@@ -417,13 +420,13 @@
result = IntGdiArc(dc, LeftRect, TopRect, RightRect, BottomRect,
XRadial1, YRadial1, XRadial2, YRadial2);
- //DC_UnlockDc( hDC );
+ //DC_UnlockDc( dc );
// If no error occured, the current position is moved to the ending point of the arc.
if(result)
IntGdiMoveToEx(dc, XRadial2, YRadial2, NULL);
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return result;
}
@@ -438,7 +441,7 @@
if ( dc )
{
ret = IntGdiGetArcDirection ( dc );
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
}
else
{
@@ -466,7 +469,7 @@
Ret = IntGdiLineTo(dc, XEnd, YEnd);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -494,7 +497,7 @@
Status = MmCopyFromCaller(&SafePoint, Point, sizeof(POINT));
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
@@ -502,7 +505,7 @@
Ret = IntGdiMoveToEx(dc, X, Y, (Point ? &SafePoint : NULL));
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -529,7 +532,7 @@
Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_BEZIER);
if(!Safept)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -537,14 +540,14 @@
Status = MmCopyFromCaller(Safept, pt, sizeof(POINT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -552,7 +555,7 @@
Ret = IntGdiPolyBezier(dc, Safept, Count);
ExFreePool(Safept);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -580,7 +583,7 @@
Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_BEZIER);
if(!Safept)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -588,14 +591,14 @@
Status = MmCopyFromCaller(Safept, pt, sizeof(POINT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -603,7 +606,7 @@
Ret = IntGdiPolyBezierTo(dc, Safept, Count);
ExFreePool(Safept);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -642,7 +645,7 @@
Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
if(!Safept)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -650,14 +653,14 @@
Status = MmCopyFromCaller(Safept, pt, sizeof(POINT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -665,7 +668,7 @@
Ret = IntGdiPolyline(dc, Safept, Count);
ExFreePool(Safept);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -693,7 +696,7 @@
Safept = ExAllocatePoolWithTag(PagedPool, sizeof(POINT) * Count, TAG_SHAPE);
if(!Safept)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -701,14 +704,14 @@
Status = MmCopyFromCaller(Safept, pt, sizeof(POINT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastNtError(Status);
return FALSE;
}
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -716,7 +719,7 @@
Ret = IntGdiPolylineTo(dc, Safept, Count);
ExFreePool(Safept);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -746,7 +749,7 @@
Safept = ExAllocatePoolWithTag(PagedPool, (sizeof(POINT) + sizeof(DWORD)) * Count, TAG_SHAPE);
if(!Safept)
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
@@ -756,7 +759,7 @@
Status = MmCopyFromCaller(Safept, pt, sizeof(POINT) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Safept);
SetLastNtError(Status);
return FALSE;
@@ -764,7 +767,7 @@
Status = MmCopyFromCaller(SafePolyPoints, PolyPoints, sizeof(DWORD) * Count);
if(!NT_SUCCESS(Status))
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
ExFreePool(Safept);
SetLastNtError(Status);
return FALSE;
@@ -772,7 +775,7 @@
}
else
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return FALSE;
}
@@ -780,7 +783,7 @@
Ret = IntGdiPolyPolyline(dc, Safept, SafePolyPoints, Count);
ExFreePool(Safept);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return Ret;
}
@@ -802,7 +805,7 @@
dc->w.ArcDirection = ArcDirection;
}
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return nOldDirection;
}
/* EOF */
reactos/subsys/win32k/objects
diff -u -r1.20 -r1.20.4.1
--- palette.c 22 Jun 2004 20:08:17 -0000 1.20
+++ palette.c 12 Sep 2004 19:21:08 -0000 1.20.4.1
@@ -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: palette.c,v 1.20 2004/06/22 20:08:17 gvg Exp $ */
+/* $Id: palette.c,v 1.20.4.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
#ifndef NO_MAPPING
@@ -36,12 +36,12 @@
return COLOR_sysPal;
}
-static BOOL FASTCALL
-PALETTE_InternalDelete(PPALGDI Palette)
+BOOL FASTCALL
+PALETTE_Cleanup(PPALGDI pPal)
{
- if (NULL != Palette->IndexedColors)
+ if (NULL != pPal->IndexedColors)
{
- ExFreePool(Palette->IndexedColors);
+ ExFreePool(pPal->IndexedColors);
}
return TRUE;
@@ -58,13 +58,14 @@
HPALETTE NewPalette;
PPALGDI PalGDI;
- NewPalette = (HPALETTE) GDIOBJ_AllocObj(sizeof(PALGDI), GDI_OBJECT_TYPE_PALETTE, (GDICLEANUPPROC) PALETTE_InternalDelete);
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
if (NULL == NewPalette)
{
return NULL;
}
PalGDI = PALETTE_LockPalette(NewPalette);
+ /* FIXME - PalGDI can be NULL!!! Don't assert here! */
ASSERT( PalGDI );
PalGDI->Self = NewPalette;
@@ -75,7 +76,7 @@
PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * NumColors, TAG_PALETTE);
if (NULL == PalGDI->IndexedColors)
{
- PALETTE_UnlockPalette(NewPalette);
+ PALETTE_UnlockPalette(PalGDI);
PALETTE_FreePalette(NewPalette);
return NULL;
}
@@ -93,7 +94,7 @@
PalGDI->BlueMask = Blue;
}
- PALETTE_UnlockPalette(NewPalette);
+ PALETTE_UnlockPalette(PalGDI);
return NewPalette;
}
@@ -106,13 +107,14 @@
PPALGDI PalGDI;
unsigned i;
- NewPalette = (HPALETTE) GDIOBJ_AllocObj(sizeof(PALGDI), GDI_OBJECT_TYPE_PALETTE, (GDICLEANUPPROC) PALETTE_InternalDelete);
+ NewPalette = (HPALETTE) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_PALETTE);
if (NULL == NewPalette)
{
return NULL;
}
PalGDI = PALETTE_LockPalette(NewPalette);
+ /* FIXME - PalGDI can be NULL!!! Don't assert here! */
ASSERT( PalGDI );
PalGDI->Self = NewPalette;
@@ -121,7 +123,7 @@
PalGDI->IndexedColors = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * NumColors, TAG_PALETTE);
if (NULL == PalGDI->IndexedColors)
{
- PALETTE_UnlockPalette(NewPalette);
+ PALETTE_UnlockPalette(PalGDI);
PALETTE_FreePalette(NewPalette);
return NULL;
}
@@ -135,7 +137,7 @@
PalGDI->NumColors = NumColors;
- PALETTE_UnlockPalette(NewPalette);
+ PALETTE_UnlockPalette(PalGDI);
return NewPalette;
}
@@ -177,7 +179,7 @@
DbgPrint("Win32k: Can not create palette mapping -- out of memory!");
return FALSE;
}
- PALETTE_UnlockPalette(hpalette);
+ PALETTE_UnlockPalette(palObj);
}
#endif
@@ -227,9 +229,10 @@
HPALETTE hSysPal = NtGdiGetStockObject(DEFAULT_PALETTE);
PPALGDI pSysPal = PALETTE_LockPalette(hSysPal);
PPALGDI palGDI = (PPALGDI) palPtr;
+ /* FIXME - handle pSysPal == NULL!!!!!!! */
COLOR_sysPal = pSysPal->IndexedColors;
- PALETTE_UnlockPalette(hSysPal); // FIXME: Is this a right way to obtain pointer to the system palette?
+ PALETTE_UnlockPalette(pSysPal); // FIXME: Is this a right way to obtain pointer to the system palette?
// reset dynamic system palette entries
reactos/subsys/win32k/objects
diff -u -r1.24 -r1.24.2.1
--- path.c 14 Jul 2004 20:48:58 -0000 1.24
+++ path.c 12 Sep 2004 19:21:08 -0000 1.24.2.1
@@ -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.24 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: path.c,v 1.24.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
#include <win32k/float.h>
@@ -72,7 +72,7 @@
if ( dc )
{
ret = IntCloseFigure ( dc );
- DC_UnlockDc ( hDC );
+ DC_UnlockDc ( dc );
}
return ret;
reactos/subsys/win32k/objects
diff -u -r1.16 -r1.16.2.1
--- pen.c 14 Jul 2004 20:48:58 -0000 1.16
+++ pen.c 12 Sep 2004 19:21:08 -0000 1.16.2.1
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: pen.c,v 1.16 2004/07/14 20:48:58 navaraf Exp $
+ * $Id: pen.c,v 1.16.2.1 2004/09/12 19:21:08 weiden Exp $
*/
#include <w32k.h>
@@ -42,6 +42,7 @@
}
PenObject = PENOBJ_LockPen(hPen);
+ /* FIXME - Handle PenObject == NULL!!! */
PenObject->ptPenWidth = LogPen->lopnWidth;
PenObject->ulPenStyle = LogPen->lopnStyle;
PenObject->BrushAttr.lbColor = LogPen->lopnColor;
@@ -65,7 +66,7 @@
UNIMPLEMENTED;
}
- PENOBJ_UnlockPen(hPen);
+ PENOBJ_UnlockPen(PenObject);
return hPen;
}
reactos/subsys/win32k/objects
diff -u -r1.20.2.1 -r1.20.2.2
--- print.c 18 Jul 2004 23:44:01 -0000 1.20.2.1
+++ print.c 12 Sep 2004 19:21:08 -0000 1.20.2.2
@@ -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: print.c,v 1.20.2.1 2004/07/18 23:44:01 weiden Exp $ */
+/* $Id: print.c,v 1.20.2.2 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
INT
@@ -85,6 +85,8 @@
BITMAPOBJ *BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
INT Result;
+ /* FIXME - Handle BitmapObj == NULL !!!!!! */
+
if ( NULL == dc->DriverFunctions.Escape )
{
Result = IntEngExtEscape(
@@ -105,7 +107,7 @@
OutSize,
(PVOID)OutData );
}
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
return Result;
}
@@ -137,7 +139,7 @@
SafeInData = ExAllocatePoolWithTag ( PagedPool, InSize, TAG_PRINT );
if ( !SafeInData )
{
- DC_UnlockDc(hDC);
+ DC_UnlockDc(pDC);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return -1;
}
@@ -145,7 +147,7 @@
if ( !NT_SUCCESS(Status) )
{
ExFreePool ( SafeInData );
- DC_UnlockDc(hDC);
+ DC_UnlockDc(pDC);
SetLastNtError(Status);
return -1;
}
@@ -158,7 +160,7 @@
{
if ( SafeInData )
ExFreePool ( SafeInData );
- DC_UnlockDc(hDC);
+ DC_UnlockDc(pDC);
SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
return -1;
}
@@ -166,7 +168,7 @@
Result = IntGdiExtEscape ( pDC, Escape, InSize, SafeInData, OutSize, SafeOutData );
- DC_UnlockDc(hDC);
+ DC_UnlockDc(pDC);
if ( SafeInData )
ExFreePool ( SafeInData );
reactos/subsys/win32k/objects
diff -u -r1.62 -r1.62.2.1
--- region.c 14 Jul 2004 20:48:58 -0000 1.62
+++ region.c 12 Sep 2004 19:21:08 -0000 1.62.2.1
@@ -113,12 +113,26 @@
* the y-x-banding that's so nice to have...
*/
-/* $Id: region.c,v 1.62 2004/07/14 20:48:58 navaraf Exp $ */
+/* $Id: region.c,v 1.62.2.1 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
#include <win32k/float.h>
// Internal Functions
+#if 1
+#define COPY_RECTS(dest, src, nRects) \
+ do { \
+ PRECT xDest = (dest); \
+ PRECT xSrc = (src); \
+ UINT xRects = (nRects); \
+ while(xRects-- > 0) { \
+ *(xDest++) = *(xSrc++); \
+ } \
+ } while(0)
+#else
+#define COPY_RECTS(dest, src, nRects) RtlCopyMemory(dest, src, (nRects) * sizeof(RECT))
+#endif
+
#define EMPTY_REGION(pReg) { \
(pReg)->rdh.nCount = 0; \
(pReg)->rdh.rcBound.left = (pReg)->rdh.rcBound.top = 0; \
@@ -382,8 +396,6 @@
#define LARGE_COORDINATE 0x7fffffff /* FIXME */
#define SMALL_COORDINATE 0x80000000
-
-
/*
* Check to see if there is enough memory in the present region.
*/
@@ -394,7 +406,10 @@
if (temp == 0)
return 0;
- RtlCopyMemory( temp, *firstrect, reg->rdh.nRgnSize );
+
+ /* copy the rectangles */
+ COPY_RECTS(temp, *firstrect, reg->rdh.nCount);
+
reg->rdh.nRgnSize *= 2;
if (*firstrect != ®->rdh.rcBound)
ExFreePool( *firstrect );
@@ -446,7 +461,7 @@
Data->rdh.rcBound.bottom,
Data->rdh.iType);
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(Data);
}
#endif /* NDEBUG */
@@ -473,7 +488,7 @@
dst->rdh.rcBound.right = src->rdh.rcBound.right;
dst->rdh.rcBound.bottom = src->rdh.rcBound.bottom;
dst->rdh.iType = src->rdh.iType;
- RtlCopyMemory(dst->Buffer, src->Buffer, (int)(src->rdh.nCount * sizeof(RECT)));
+ COPY_RECTS(dst->Buffer, src->Buffer, src->rdh.nCount);
}
return TRUE;
}
@@ -546,7 +561,9 @@
ULONG i;
if(rgnDst != rgnSrc)
- RtlCopyMemory(rgnDst, rgnSrc, sizeof(ROSRGNDATA));
+ {
+ *rgnDst = *rgnSrc;
+ }
if(off->x || off->y)
{
@@ -563,7 +580,9 @@
rgnDst->rdh.rcBound.bottom += off->y;
}
else
- RtlCopyMemory(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount * sizeof(RECT));
+ {
+ COPY_RECTS(xrect, rgnSrc->Buffer, rgnDst->rdh.nCount);
+ }
rgnDst->Buffer = xrect;
} else
@@ -1137,7 +1156,7 @@
newReg->Buffer = prev_rects;
else{
newReg->rdh.nRgnSize = newReg->rdh.nCount*sizeof(RECT);
- RtlCopyMemory( newReg->Buffer, prev_rects, newReg->rdh.nRgnSize );
+ COPY_RECTS(newReg->Buffer, prev_rects, newReg->rdh.nCount);
if (prev_rects != &newReg->rdh.rcBound)
ExFreePool( prev_rects );
}
@@ -1700,7 +1719,7 @@
trb = RGNDATA_LockRgn( htrb );
if( !trb ){
- RGNDATA_UnlockRgn( htra );
+ RGNDATA_UnlockRgn( tra );
NtGdiDeleteObject( htra );
NtGdiDeleteObject( htrb );
return;
@@ -1709,8 +1728,8 @@
REGION_SubtractRegion(tra,sra,srb);
REGION_SubtractRegion(trb,srb,sra);
REGION_UnionRegion(dr,tra,trb);
- RGNDATA_UnlockRgn( htra );
- RGNDATA_UnlockRgn( htrb );
+ RGNDATA_UnlockRgn( tra );
+ RGNDATA_UnlockRgn( trb );
NtGdiDeleteObject( htra );
NtGdiDeleteObject( htrb );
@@ -1744,20 +1763,20 @@
}
if (!REGION_NOT_EMPTY(srcObj))
{
- RGNDATA_UnlockRgn(hSrc);
+ RGNDATA_UnlockRgn(srcObj);
return FALSE;
}
if (!(destObj = (PROSRGNDATA)RGNDATA_LockRgn(hDest)))
{
- RGNDATA_UnlockRgn(hSrc);
+ RGNDATA_UnlockRgn(srcObj);
return FALSE;
}
EMPTY_REGION(destObj);
if (!REGION_CopyRegion(destObj, srcObj))
{
- RGNDATA_UnlockRgn(hDest);
- RGNDATA_UnlockRgn(hSrc);
+ RGNDATA_UnlockRgn(destObj);
+ RGNDATA_UnlockRgn(srcObj);
return FALSE;
}
@@ -1813,8 +1832,8 @@
}
REGION_SubtractRegion(destObj, srcObj, destObj);
- RGNDATA_UnlockRgn(hDest);
- RGNDATA_UnlockRgn(hSrc);
+ RGNDATA_UnlockRgn(destObj);
+ RGNDATA_UnlockRgn(srcObj);
return TRUE;
}
@@ -1846,7 +1865,7 @@
goto done;
if(!( destObj = (PROSRGNDATA) RGNDATA_LockRgn( hDest ) ))
{
- RGNDATA_UnlockRgn( hSrc );
+ RGNDATA_UnlockRgn( srcObj );
goto done;
}
EMPTY_REGION(destObj);
@@ -1869,11 +1888,11 @@
}
ret = TRUE;
- RGNDATA_UnlockRgn( hSrc );
- RGNDATA_UnlockRgn( hDest );
+ RGNDATA_UnlockRgn( srcObj );
+ RGNDATA_UnlockRgn( destObj );
done:
- DC_UnlockDc( hdc );
+ DC_UnlockDc( dc );
return ret;
}
@@ -1883,8 +1902,7 @@
PROSRGNDATA pReg;
BOOL bRet;
- if ((hReg = (HRGN) GDIOBJ_AllocObj(sizeof(ROSRGNDATA), GDI_OBJECT_TYPE_REGION,
- (GDICLEANUPPROC) RGNDATA_InternalDelete)))
+ if ((hReg = (HRGN) GDIOBJ_AllocObj(GDI_OBJECT_TYPE_REGION)))
{
if (NULL != (pReg = RGNDATA_LockRgn(hReg)))
{
@@ -1906,7 +1924,7 @@
pReg->rdh.nCount = n;
pReg->rdh.nRgnSize = n*sizeof(RECT);
- bRet = RGNDATA_UnlockRgn(hReg);
+ bRet = RGNDATA_UnlockRgn(pReg);
ASSERT(bRet);
return hReg;
@@ -1921,9 +1939,9 @@
return NULL;
}
-BOOL FASTCALL RGNDATA_InternalDelete( PROSRGNDATA pRgn )
+BOOL FASTCALL
+RGNDATA_Cleanup(PROSRGNDATA pRgn)
{
- ASSERT(pRgn);
if(pRgn->Buffer && pRgn->Buffer != &pRgn->rdh.rcBound)
ExFreePool(pRgn->Buffer);
return TRUE;
@@ -2151,7 +2169,7 @@
rect.bottom = bottom;
UnsafeIntUnionRectWithRgn( obj, &rect );
}
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( obj );
return hrgn;
}
@@ -2169,7 +2187,7 @@
return ERROR;
if( !(rgn2 = RGNDATA_LockRgn(hSrcRgn2))){
- RGNDATA_UnlockRgn( hSrcRgn1 );
+ RGNDATA_UnlockRgn( rgn1 );
return ERROR;
}
@@ -2198,8 +2216,8 @@
bRet = TRUE;
exit:
- RGNDATA_UnlockRgn( hSrcRgn1 );
- RGNDATA_UnlockRgn( hSrcRgn2 );
+ RGNDATA_UnlockRgn( rgn1 );
+ RGNDATA_UnlockRgn( rgn2 );
return bRet;
}
@@ -2228,7 +2246,7 @@
if (NULL == (oldhBrush = NtGdiSelectObject(hDC, hBrush)))
{
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(rgn);
return FALSE;
}
@@ -2237,8 +2255,8 @@
NtGdiPatBlt(hDC, r->left, r->top, r->right - r->left, r->bottom - r->top, PATCOPY);
}
+ RGNDATA_UnlockRgn( rgn );
NtGdiSelectObject(hDC, oldhBrush);
- RGNDATA_UnlockRgn( hRgn );
return TRUE;
}
@@ -2297,7 +2315,7 @@
}
ret = UnsafeIntGetRgnBox(Rgn, &SafeRect);
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(Rgn);
if (ERROR == ret)
{
return ret;
@@ -2332,13 +2350,13 @@
if(!NtGdiPatBlt(hDC, rc->left, rc->top, rc->right - rc->left, rc->bottom - rc->top, DSTINVERT))
{
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(RgnData);
return FALSE;
}
rc++;
}
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(RgnData);
return TRUE;
}
@@ -2380,7 +2398,7 @@
}
}
ret = rgn->rdh.iType;
- RGNDATA_UnlockRgn( hRgn );
+ RGNDATA_UnlockRgn( rgn );
return ret;
}
@@ -2404,7 +2422,7 @@
return FALSE;
if(!(tmpVisRgn = NtGdiCreateRectRgn(0, 0, 0, 0))){
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return FALSE;
}
@@ -2412,7 +2430,7 @@
// Transform region into device co-ords
if(!REGION_LPTODP(hDC, tmpVisRgn, hRgn) || NtGdiOffsetRgn(tmpVisRgn, dc->w.DCOrgX, dc->w.DCOrgY) == ERROR) {
NtGdiDeleteObject( tmpVisRgn );
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return FALSE;
}
*/
@@ -2424,7 +2442,7 @@
visrgn = RGNDATA_LockRgn(hRgn);
if (visrgn == NULL)
{
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return FALSE;
}
@@ -2438,6 +2456,7 @@
BrushOrigin.x = dc->w.brushOrgX;
BrushOrigin.y = dc->w.brushOrgY;
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
+ /* FIXME - Handle BitmapObj == NULL !!!! */
bRet = IntEngPaint(BitmapObj,
ClipRegion,
@@ -2445,11 +2464,11 @@
&BrushOrigin,
0xFFFF);//FIXME:don't know what to put here
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- RGNDATA_UnlockRgn( tmpVisRgn );
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ RGNDATA_UnlockRgn( visrgn );
// Fill the region
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return TRUE;
}
@@ -2470,13 +2489,13 @@
r = (PRECT) rgn->Buffer;
for(i = 0; i < rgn->rdh.nCount; i++) {
if(INRECT(*r, X, Y)){
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(rgn);
return TRUE;
}
r++;
}
}
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(rgn);
return FALSE;
}
@@ -2519,13 +2538,13 @@
if (!NT_SUCCESS(MmCopyFromCaller(&rc, unsaferc, sizeof(RECT))))
{
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(Rgn);
DPRINT1("NtGdiRectInRegion: bogus rc\n");
return ERROR;
}
Ret = UnsafeIntRectInRegion(Rgn, &rc);
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(Rgn);
return Ret;
}
@@ -2561,7 +2580,7 @@
} else
EMPTY_REGION(rgn);
- RGNDATA_UnlockRgn( hRgn );
+ RGNDATA_UnlockRgn( rgn );
return TRUE;
}
@@ -2571,7 +2590,7 @@
RECT SafeRect;
PROSRGNDATA Rgn;
- if(!(Rgn = (PROSRGNDATA)RGNDATA_UnlockRgn(hDest)))
+ if(!(Rgn = (PROSRGNDATA)RGNDATA_LockRgn(hDest)))
{
SetLastWin32Error(ERROR_INVALID_HANDLE);
return NULL;
@@ -2579,13 +2598,13 @@
if (! NT_SUCCESS(MmCopyFromCaller(&SafeRect, UnsafeRect, sizeof(RECT))))
{
- RGNDATA_UnlockRgn(hDest);
+ RGNDATA_UnlockRgn(Rgn);
SetLastWin32Error(ERROR_INVALID_PARAMETER);
return NULL;
}
UnsafeIntUnionRectWithRgn(Rgn, &SafeRect);
- RGNDATA_UnlockRgn(hDest);
+ RGNDATA_UnlockRgn(Rgn);
return hDest;
}
@@ -2610,7 +2629,7 @@
size = obj->rdh.nCount * sizeof(RECT);
if(count < (size + sizeof(RGNDATAHEADER)) || rgndata == NULL)
{
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( obj );
if (rgndata) /* buffer is too small, signal it by return 0 */
return 0;
else /* user requested buffer size with rgndata NULL */
@@ -2619,15 +2638,15 @@
//first we copy the header then we copy buffer
if( !NT_SUCCESS( MmCopyToCaller( rgndata, obj, sizeof( RGNDATAHEADER )))){
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( obj );
return 0;
}
if( !NT_SUCCESS( MmCopyToCaller( (char*)rgndata+sizeof( RGNDATAHEADER ), obj->Buffer, size ))){
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( obj );
return 0;
}
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( obj );
return size + sizeof(RGNDATAHEADER);
}
@@ -2870,7 +2889,7 @@
}
if(reg->Buffer != NULL)
{
- RtlCopyMemory(temp, reg->Buffer, reg->rdh.nCount * sizeof(RECT));
+ COPY_RECTS(temp, reg->Buffer, reg->rdh.nCount);
if(reg->Buffer != ®->rdh.rcBound)
ExFreePool(reg->Buffer);
}
@@ -3082,7 +3101,7 @@
(Pts[2].x == Pts[3].x) &&
(Pts[3].y == Pts[0].y))))
{
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( region );
NtGdiSetRectRgn( hrgn, min(Pts[0].x, Pts[2].x), min(Pts[0].y, Pts[2].y),
max(Pts[0].x, Pts[2].x), max(Pts[0].y, Pts[2].y) );
return hrgn;
@@ -3215,7 +3234,7 @@
curPtBlock = tmpPtBlock;
}
ExFreePool( pETEs );
- RGNDATA_UnlockRgn( hrgn );
+ RGNDATA_UnlockRgn( region );
return hrgn;
}
@@ -3261,7 +3280,7 @@
EMPTY_REGION(rgn);
- RGNDATA_UnlockRgn(hRgn);
+ RGNDATA_UnlockRgn(rgn);
return hRgn;
}
reactos/subsys/win32k/objects
diff -u -r1.105.2.1 -r1.105.2.2
--- text.c 27 Aug 2004 15:56:05 -0000 1.105.2.1
+++ text.c 12 Sep 2004 19:21:08 -0000 1.105.2.2
@@ -22,7 +22,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.105.2.1 2004/08/27 15:56:05 weiden Exp $ */
+/* $Id: text.c,v 1.105.2.2 2004/09/12 19:21:08 weiden Exp $ */
#include <w32k.h>
#include <ft2build.h>
@@ -33,7 +33,7 @@
typedef struct _FONT_ENTRY {
LIST_ENTRY ListEntry;
- HFONT hFont;
+ FONTGDI *Font;
UNICODE_STRING FaceName;
BYTE NotEnum;
} FONT_ENTRY, *PFONT_ENTRY;
@@ -245,9 +245,7 @@
INT FASTCALL
IntGdiAddFontResource(PUNICODE_STRING FileName, DWORD Characteristics)
{
- HFONT NewFont;
- FONTOBJ *FontObj;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
NTSTATUS Status;
HANDLE FileHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
@@ -259,20 +257,6 @@
ANSI_STRING AnsiFaceName;
PFONT_ENTRY Entry;
- /* Create handle for the font */
-
- NewFont = (HFONT)CreateGDIHandle(
- sizeof(FONTGDI),
- sizeof(FONTOBJ),
- (PVOID*)&FontGDI,
- (PVOID*)&FontObj);
-
- if (NewFont == 0)
- {
- DPRINT("Could not allocate a new GDI font object\n");
- return 0;
- }
-
/* Open the font file */
InitializeObjectAttributes(&ObjectAttributes, FileName, 0, NULL, NULL);
@@ -287,7 +271,6 @@
if (!NT_SUCCESS(Status))
{
DPRINT("Could not font file: %wZ\n", FileName);
- NtGdiDeleteObject(NewFont);
return 0;
}
@@ -303,7 +286,6 @@
if (!NT_SUCCESS(Status))
{
DPRINT("Could not get file size\n");
- NtGdiDeleteObject(NewFont);
ZwClose(FileHandle);
return 0;
}
@@ -313,12 +295,11 @@
Buffer = ExAllocatePoolWithTag(
PagedPool,
FileStdInfo.EndOfFile.u.LowPart,
- TAG_GDITEXT);
+ TAG_FNTFILE);
if (Buffer == NULL)
{
DPRINT("Could not allocate memory for font");
- NtGdiDeleteObject(NewFont);
ZwClose(FileHandle);
return 0;
}
@@ -340,7 +321,6 @@
{
DPRINT("Could not read the font file into memory");
ExFreePool(Buffer);
- NtGdiDeleteObject(NewFont);
ZwClose(FileHandle);
return 0;
}
@@ -363,7 +343,6 @@
else
DPRINT("Error reading font file (error code: %u)\n", Error);
ExFreePool(Buffer);
- NtGdiDeleteObject(NewFont);
return 0;
}
@@ -376,6 +355,16 @@
return 0;
}
+ FontGDI = EngAllocMem(0, sizeof(FONTGDI), TAG_FONTOBJ);
+ if(FontGDI == NULL)
+ {
+ FT_Done_Face(Face);
+ ExFreePool(Buffer);
+ ExFreePool(Entry);
+ SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+
/* FontGDI->Filename = FileName; perform strcpy */
FontGDI->face = Face;
@@ -390,7 +379,7 @@
/* Add this font resource to the font table */
- Entry->hFont = NewFont;
+ Entry->Font = FontGDI;
Entry->NotEnum = (Characteristics & FR_NOT_ENUM);
RtlInitAnsiString(&AnsiFaceName, (LPSTR)Face->family_name);
RtlAnsiStringToUnicodeString(&Entry->FaceName, &AnsiFaceName, TRUE);
@@ -449,39 +438,6 @@
}
return FT_RENDER_MODE_MONO;
}
-static NTSTATUS STDCALL
-GetFontObjectsFromTextObj(PTEXTOBJ TextObj, HFONT *FontHandle, FONTOBJ **FontObj, PFONTGDI *FontGDI)
-{
- FONTOBJ *FntObj;
- NTSTATUS Status = STATUS_SUCCESS;
-
- ASSERT(NULL != TextObj && NULL != TextObj->GDIFontHandle);
- if (NULL != TextObj && NULL != TextObj->GDIFontHandle)
- {
- if (NULL != FontHandle)
- {
- *FontHandle = TextObj->GDIFontHandle;
- }
- FntObj = (FONTOBJ*)AccessUserObject((ULONG) TextObj->GDIFontHandle);
- if (NULL != FontObj)
- {
- *FontObj = FntObj;
- if (NULL == *FontObj)
- {
- ASSERT(FALSE);
- Status = STATUS_INVALID_HANDLE;
- }
- }
- if (NT_SUCCESS(Status) && NULL != FontGDI)
- {
- *FontGDI = AccessInternalObjectFromUserObject(FntObj);
- }
-
- return Status;
- }
-
- return STATUS_INVALID_HANDLE;
-}
int
STDCALL
@@ -547,7 +503,7 @@
/* this should really depend on whether GM_ADVANCED is set */
TextObj->logfont.lfOrientation = TextObj->logfont.lfEscapement;
}
- TEXTOBJ_UnlockText(*NewFont);
+ TEXTOBJ_UnlockText(TextObj);
}
else
{
@@ -1005,18 +961,16 @@
PFONT_ENTRY CurrentEntry;
ANSI_STRING EntryFaceNameA;
UNICODE_STRING EntryFaceNameW;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
Entry = Head->Flink;
while (Entry != Head)
{
CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
- if (NULL == (FontGDI = AccessInternalObject((ULONG) CurrentEntry->hFont)))
- {
- Entry = Entry->Flink;
- continue;
- }
+ FontGDI = CurrentEntry->Font;
+ ASSERT(FontGDI);
+
RtlInitAnsiString(&EntryFaceNameA, FontGDI->face->family_name);
RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length)
@@ -1273,18 +1227,16 @@
PFONT_ENTRY CurrentEntry;
ANSI_STRING EntryFaceNameA;
UNICODE_STRING EntryFaceNameW;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
Entry = Head->Flink;
while (Entry != Head)
{
CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
- if (NULL == (FontGDI = AccessInternalObject((ULONG) CurrentEntry->hFont)))
- {
- Entry = Entry->Flink;
- continue;
- }
+ FontGDI = CurrentEntry->Font;
+ ASSERT(FontGDI);
+
RtlInitAnsiString(&EntryFaceNameA, FontGDI->face->family_name);
RtlAnsiStringToUnicodeString(&EntryFaceNameW, &EntryFaceNameA, TRUE);
if ((LF_FACESIZE - 1) * sizeof(WCHAR) < EntryFaceNameW.Length)
@@ -1591,7 +1543,7 @@
else
{
Mode = PalDestGDI->Mode;
- PALETTE_UnlockPalette(dc->w.hPalette);
+ PALETTE_UnlockPalette(PalDestGDI);
}
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
hBrushFg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.textColor));
@@ -1603,6 +1555,7 @@
if (hBrushBg)
{
BrushBg = BRUSHOBJ_LockBrush(hBrushBg);
+ /* FIXME - Handle BrushBg == NULL !!!!! */
IntGdiInitBrushInstance(&BrushBgInst, BrushBg, NULL);
}
else
@@ -1650,12 +1603,14 @@
}
TextObj = TEXTOBJ_LockText(dc->w.hFont);
-
- if (!NT_SUCCESS(GetFontObjectsFromTextObj(TextObj, NULL, &FontObj, &FontGDI)))
+ if(TextObj == NULL)
{
- goto fail;
+ goto fail;
}
+ FontObj = TextObj->Font;
+ FontGDI = ObjToGDI(FontObj, FONT);
+
face = FontGDI->face;
if (face->charmap == NULL)
{
@@ -1910,41 +1865,43 @@
EngDeleteXlate(XlateObj);
EngDeleteXlate(XlateObj2);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
- TEXTOBJ_UnlockText(dc->w.hFont);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
+ if(TextObj != NULL)
+ TEXTOBJ_UnlockText(TextObj);
if (hBrushBg != NULL)
{
- BRUSHOBJ_UnlockBrush(hBrushBg);
+ BRUSHOBJ_UnlockBrush(BrushBg);
NtGdiDeleteObject(hBrushBg);
}
- BRUSHOBJ_UnlockBrush(hBrushFg);
+ BRUSHOBJ_UnlockBrush(BrushFg);
NtGdiDeleteObject(hBrushFg);
if (NULL != Dx)
{
ExFreePool(Dx);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc( dc );
return TRUE;
fail:
- TEXTOBJ_UnlockText(dc->w.hFont);
- BITMAPOBJ_UnlockBitmap(dc->w.hBitmap);
+ if(TextObj != NULL)
+ TEXTOBJ_UnlockText(TextObj);
+ BITMAPOBJ_UnlockBitmap(BitmapObj);
if (hBrushBg != NULL)
{
- BRUSHOBJ_UnlockBrush(hBrushBg);
+ BRUSHOBJ_UnlockBrush(BrushBg);
NtGdiDeleteObject(hBrushBg);
}
if (hBrushFg != NULL)
{
- BRUSHOBJ_UnlockBrush(hBrushFg);
+ BRUSHOBJ_UnlockBrush(BrushFg);
NtGdiDeleteObject(hBrushFg);
}
if (NULL != Dx)
{
ExFreePool(Dx);
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
return FALSE;
}
@@ -2032,7 +1989,7 @@
}
hFont = dc->w.hFont;
TextObj = TEXTOBJ_LockText(hFont);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
if (TextObj == NULL)
{
@@ -2041,13 +1998,7 @@
return FALSE;
}
- if (!NT_SUCCESS(GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGDI)))
- {
- ExFreePool(SafeBuffer);
- SetLastWin32Error(ERROR_INVALID_HANDLE);
- TEXTOBJ_UnlockText(hFont);
- return FALSE;
- }
+ FontGDI = ObjToGDI(TextObj->Font, FONT);
face = FontGDI->face;
if (face->charmap == NULL)
@@ -2090,7 +2041,7 @@
SafeBuffer[i - FirstChar] = (face->glyph->advance.x + 32) >> 6;
}
IntUnLockFreeType;
- TEXTOBJ_UnlockText(hFont);
+ TEXTOBJ_UnlockText(TextObj);
MmCopyToCaller(Buffer, SafeBuffer, BufferSize);
ExFreePool(SafeBuffer);
return TRUE;
@@ -2195,10 +2146,7 @@
FT_CharMap charmap, found = NULL;
BOOL use_kerning;
- if (!NT_SUCCESS(GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGDI)))
- {
- return FALSE;
- }
+ FontGDI = ObjToGDI(TextObj->Font, FONT);
face = FontGDI->face;
if (NULL != Fit)
@@ -2379,10 +2327,11 @@
return FALSE;
}
TextObj = TEXTOBJ_LockText(dc->w.hFont);
- DC_UnlockDc(hDC);
+ /* FIXME - TextObj can be NULL!!!! Handle this case!!! */
+ DC_UnlockDc(dc);
Result = TextIntGetTextExtentPoint(hDC, TextObj, String, Count, MaxExtent,
NULL == UnsafeFit ? NULL : &Fit, Dx, &Size);
- TEXTOBJ_UnlockText(dc->w.hFont);
+ TEXTOBJ_UnlockText(TextObj);
ExFreePool(String);
if (! Result)
@@ -2501,13 +2450,14 @@
return FALSE;
}
TextObj = TEXTOBJ_LockText(dc->w.hFont);
- DC_UnlockDc(hDC);
+ /* FIXME - TextObj can be NULL!!! Handle this case!!! */
+ DC_UnlockDc(dc);
Result = TextIntGetTextExtentPoint (
hDC, TextObj, String, Count, 0, NULL, NULL, &Size);
dc = DC_LockDc(hDC);
ASSERT(dc); // it succeeded earlier, it should now, too
- TEXTOBJ_UnlockText(dc->w.hFont);
- DC_UnlockDc(hDC);
+ TEXTOBJ_UnlockText(TextObj);
+ DC_UnlockDc(dc);
ExFreePool(String);
if (! Result)
@@ -2539,7 +2489,7 @@
return FALSE;
}
TextObj = TEXTOBJ_LockText(Dc->w.hFont);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(Dc);
Count = min(Count, wcslen(TextObj->logfont.lfFaceName));
Status = MmCopyToCaller(FaceName, TextObj->logfont.lfFaceName, Count * sizeof(WCHAR));
@@ -2581,9 +2531,8 @@
TextObj = TEXTOBJ_LockText(dc->w.hFont);
if (NULL != TextObj)
{
- Status = GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGDI);
- if (NT_SUCCESS(Status))
- {
+ FontGDI = ObjToGDI(TextObj->Font, FONT);
+
Face = FontGDI->face;
IntLockFreeType;
Error = FT_Set_Pixel_Sizes(Face,
@@ -2623,15 +2572,14 @@
}
Status = MmCopyToCaller(tm, &SafeTm, sizeof(TEXTMETRICW));
}
- }
- TEXTOBJ_UnlockText(dc->w.hFont);
+ TEXTOBJ_UnlockText(TextObj);
}
else
{
ASSERT(FALSE);
Status = STATUS_INVALID_HANDLE;
}
- DC_UnlockDc(hDC);
+ DC_UnlockDc(dc);
if(!NT_SUCCESS(Status))
{
@@ -2685,7 +2633,7 @@
}
prevAlign = dc->w.textAlign;
dc->w.textAlign = Mode;
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
return prevAlign;
}
@@ -2707,7 +2655,7 @@
oldColor = dc->w.textColor;
dc->w.textColor = color;
hBrush = dc->w.hBrush;
- DC_UnlockDc( hDC );
+ DC_UnlockDc( dc );
NtGdiSelectObject(hDC, hBrush);
return oldColor;
}
@@ -2746,7 +2694,6 @@
PTEXTOBJ TextObj;
PFONTGDI FontGdi;
DWORD Result = GDI_ERROR;
- NTSTATUS Status;
Dc = DC_LockDc(hDC);
if (Dc == NULL)
@@ -2756,7 +2703,7 @@
}
hFont = Dc->w.hFont;
TextObj = TEXTOBJ_LockText(hFont);
- DC_UnlockDc(hDC);
+ DC_UnlockDc(Dc);
if (TextObj == NULL)
{
@@ -2764,28 +2711,26 @@
return GDI_ERROR;
}
- Status = GetFontObjectsFromTextObj(TextObj, NULL, NULL, &FontGdi);
- if (NT_SUCCESS(Status))
- {
- IntLockFreeType;
-
- if (FT_IS_SFNT(FontGdi->face))
- {
- if (Table)
- Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
- (Table << 8 & 0xFF0000);
+ FontGdi = ObjToGDI(TextObj->Font, FONT);
+
+ IntLockFreeType;
- if (Buffer == NULL)
- Size = 0;
+ if (FT_IS_SFNT(FontGdi->face))
+ {
+ if (Table)
+ Table = Table >> 24 | Table << 24 | (Table >> 8 & 0xFF00) |
+ (Table << 8 & 0xFF0000);
- if (!FT_Load_Sfnt_Table(FontGdi->face, Table, Offset, Buffer, &Size))
- Result = Size;
- }
+ if (Buffer == NULL)
+ Size = 0;
- IntUnLockFreeType;
+ if (!FT_Load_Sfnt_Table(FontGdi->face, Table, Offset, Buffer, &Size))
+ Result = Size;
}
- TEXTOBJ_UnlockText(hFont);
+ IntUnLockFreeType;
+
+ TEXTOBJ_UnlockText(TextObj);
return Result;
}
@@ -2845,35 +2790,34 @@
return Score;
}
-static VOID FASTCALL
-FindBestFontFromList(HFONT *Font, UINT *MatchScore, LOGFONTW *LogFont,
+static inline VOID
+FindBestFontFromList(FONTOBJ **FontObj, UINT *MatchScore, LOGFONTW *LogFont,
PUNICODE_STRING FaceName, PLIST_ENTRY Head)
{
PLIST_ENTRY Entry;
PFONT_ENTRY CurrentEntry;
- PFONTGDI FontGDI;
+ FONTGDI *FontGDI;
UINT Score;
Entry = Head->Flink;
while (Entry != Head)
{
CurrentEntry = (PFONT_ENTRY) CONTAINING_RECORD(Entry, FONT_ENTRY, ListEntry);
- if (NULL == (FontGDI = AccessInternalObject((ULONG) CurrentEntry->hFont)))
- {
- Entry = Entry->Flink;
- continue;
- }
+
+ FontGDI = CurrentEntry->Font;
+ ASSERT(FontGDI);
+
Score = GetFontScore(LogFont, FaceName, FontGDI);
if (*MatchScore == 0 || *MatchScore < Score)
{
- *Font = CurrentEntry->hFont;
+ *FontObj = GDIToObj(FontGDI, FONT);
*MatchScore = Score;
}
Entry = Entry->Flink;
}
}
-static BOOLEAN FASTCALL
+static inline BOOLEAN
SubstituteFontFamilyKey(PUNICODE_STRING FaceName,
LPCWSTR Key)
{
@@ -2909,7 +2853,7 @@
return NT_SUCCESS(Status);
}
-static void FASTCALL
+static inline void
SubstituteFontFamily(PUNICODE_STRING FaceName, UINT Level)
{
if (10 < Level) /* Enough is enough */
@@ -2941,39 +2885,43 @@
if (! RtlCreateUnicodeString(&FaceName, TextObj->logfont.lfFaceName))
{
- TEXTOBJ_UnlockText(FontHandle);
+ TEXTOBJ_UnlockText(TextObj);
return STATUS_NO_MEMORY;
}
SubstituteFontFamily(&FaceName, 0);
MatchScore = 0;
- TextObj->GDIFontHandle = NULL;
+ TextObj->Font = NULL;
/* First search private fonts */
Win32Process = PsGetWin32Process();
IntLockProcessPrivateFonts(Win32Process);
- FindBestFontFromList(&TextObj->GDIFontHandle, &MatchScore,
+ FindBestFontFromList(&TextObj->Font, &MatchScore,
&TextObj->logfont, &FaceName,
&Win32Process->PrivateFontListHead);
IntUnLockProcessPrivateFonts(Win32Process);
/* Search system fonts */
IntLockGlobalFonts;
- FindBestFontFromList(&TextObj->GDIFontHandle, &MatchScore,
+ FindBestFontFromList(&TextObj->Font, &MatchScore,
&TextObj->logfont, &FaceName,
&FontListHead);
IntUnLockGlobalFonts;
- if (NULL == TextObj->GDIFontHandle)
+ if (NULL == TextObj->Font)
{
DPRINT1("Requested font %S not found, no fonts loaded at all\n",
TextObj->logfont.lfFaceName);
Status = STATUS_NOT_FOUND;
}
+ else
+ {
+ Status = STATUS_SUCCESS;
+ }
RtlFreeUnicodeString(&FaceName);
- TEXTOBJ_UnlockText(FontHandle);
+ TEXTOBJ_UnlockText(TextObj);
- ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->GDIFontHandle)) != 0);
+ ASSERT((NT_SUCCESS(Status) ^ (NULL == TextObj->Font)) != 0);
return Status;
}
CVSspam 0.2.8