eng/driverobj.c: DRIVEROBJ implementation.

eng/semaphor.c: Implement safe semaphore functions.
eng/window.c: Basic WNDOBJ implementation.
include/inteng.h: IntEngXxx functions for DRIVEROBJs.
main/dllmain.c: Cleanup DRIVEROBJs.
makefile: Add eng/driverobj.o and eng/window.o.
stubs/stubs.c, win32k.def: Add EngAllocPrivateUserMem and EngFreePrivateUserMem stubs.

svn path=/trunk/; revision=12857
This commit is contained in:
Gregor Anich 2005-01-06 23:12:59 +00:00
parent 019137fd50
commit a2189e5e4b
11 changed files with 477 additions and 140 deletions

View file

@ -0,0 +1,171 @@
/*
* ReactOS W32 Subsystem
* Copyright (C) 2005 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.
*/
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: GDI DRIVEROBJ Functions
* FILE: subsys/win32k/eng/driverobj.c
* PROGRAMER: Gregor Anich
* REVISION HISTORY:
* 04/01/2005: Created
*/
#include <w32k.h>
/*!\brief Called when the process is terminated.
*
* Calls the free-proc for each existing DRIVEROBJ.
*
* \param Process Pointer to the EPROCESS struct for the process beeing terminated.
* \param Win32Process Pointer to the W32PROCESS
*/
VOID FASTCALL
IntEngCleanupDriverObjs(struct _EPROCESS *Process,
PW32PROCESS Win32Process)
{
PDRIVERGDI DrvObjInt;
IntEngLockProcessDriverObjs(PsGetWin32Process());
while (!IsListEmpty(&Win32Process->DriverObjListHead))
{
DrvObjInt = CONTAINING_RECORD(Win32Process->DriverObjListHead.Flink,
DRIVERGDI, ListEntry);
IntEngUnLockProcessDriverObjs(PsGetWin32Process());
EngDeleteDriverObj((HDRVOBJ)(&DrvObjInt->DriverObj), TRUE, FALSE);
IntEngLockProcessDriverObjs(PsGetWin32Process());
}
IntEngUnLockProcessDriverObjs(PsGetWin32Process());
}
/*
* @implemented
*/
HDRVOBJ
STDCALL
EngCreateDriverObj(
IN PVOID pvObj,
IN FREEOBJPROC pFreeObjProc,
IN HDEV hdev
)
{
PDRIVERGDI DrvObjInt;
PDRIVEROBJ DrvObjUser;
/* Create DRIVEROBJ */
DrvObjInt = EngAllocMem(0, sizeof (DRIVERGDI), TAG_DRIVEROBJ);
if (DrvObjInt == NULL)
{
DPRINT1("Failed to allocate memory for a DRIVERGDI structure!\n");
return NULL;
}
/* fill user object */
DrvObjUser = GDIToObj(DrvObjInt, DRIVER);
DrvObjUser->pvObj = pvObj;
DrvObjUser->pFreeProc = pFreeObjProc;
DrvObjUser->hdev = hdev;
DrvObjUser->dhpdev = ((GDIDEVICE*)hdev)->PDev;
/* fill internal object */
ExInitializeFastMutex(&DrvObjInt->Lock);
IntEngLockProcessDriverObjs(PsGetWin32Process());
InsertTailList(&PsGetWin32Process()->DriverObjListHead, &DrvObjInt->ListEntry);
IntEngUnLockProcessDriverObjs(PsGetWin32Process());
return (HDRVOBJ)DrvObjUser;
}
/*
* @implemented
*/
BOOL
STDCALL
EngDeleteDriverObj(
IN HDRVOBJ hdo,
IN BOOL bCallBack,
IN BOOL bLocked
)
{
PDRIVEROBJ DrvObjUser = (PDRIVEROBJ)hdo;
PDRIVERGDI DrvObjInt = ObjToGDI(DrvObjUser, DRIVER);
/* Make sure the obj is locked */
if (!bLocked)
{
if (!ExTryToAcquireFastMutex(&DrvObjInt->Lock))
{
return FALSE;
}
}
/* Call the free-proc */
if (bCallBack)
{
if (!DrvObjUser->pFreeProc(DrvObjUser))
{
return FALSE;
}
}
/* Free the DRIVEROBJ */
IntEngLockProcessDriverObjs(PsGetWin32Process());
RemoveEntryList(&DrvObjInt->ListEntry);
IntEngUnLockProcessDriverObjs(PsGetWin32Process());
EngFreeMem(DrvObjInt);
return TRUE;
}
/*
* @implemented
*/
PDRIVEROBJ
STDCALL
EngLockDriverObj( IN HDRVOBJ hdo )
{
PDRIVEROBJ DrvObjUser = (PDRIVEROBJ)hdo;
PDRIVERGDI DrvObjInt = ObjToGDI(DrvObjUser, DRIVER);
if (!ExTryToAcquireFastMutex(&DrvObjInt->Lock))
{
return NULL;
}
return DrvObjUser;
}
/*
* @implemented
*/
BOOL
STDCALL
EngUnlockDriverObj ( IN HDRVOBJ hdo )
{
PDRIVERGDI DrvObjInt = ObjToGDI((PDRIVEROBJ)hdo, DRIVER);
ExReleaseFastMutex(&DrvObjInt->Lock);
return TRUE;
}
/* EOF */

View file

@ -51,6 +51,12 @@ typedef struct _CLIPGDI {
ENUMRECTS EnumRects;
} CLIPGDI, *PCLIPGDI;
typedef struct _DRIVERGDI {
DRIVEROBJ DriverObj;
LIST_ENTRY ListEntry;
FAST_MUTEX Lock;
} DRIVERGDI, *PDRIVERGDI;
/*ei What is this for? */
typedef struct _DRVFUNCTIONSGDI {
HDEV hdev;
@ -122,6 +128,14 @@ typedef BOOL STDCALL (*PFN_SetPalette)(DHPDEV, PALOBJ*, ULONG, ULONG, ULONG);
typedef BOOL STDCALL (*PFN_GradientFill)(SURFOBJ*, CLIPOBJ*, XLATEOBJ*, TRIVERTEX*, ULONG, PVOID, ULONG, RECTL*, POINTL*, ULONG);
typedef struct _WNDGDI {
WNDOBJ WndObj;
CLIPOBJ *ClientClipObj;
WNDOBJCHANGEPROC ChangeProc;
FLONG Flags;
int PixelFormat;
} WNDGDI, *PWNDGDI;
typedef struct _XFORMGDI {
ULONG Dummy;
/* XFORMOBJ has no public members */

View file

@ -80,3 +80,50 @@ EngIsSemaphoreOwnedByCurrentThread ( IN HSEMAPHORE hsem )
ASSERT(hsem);
return ExIsResourceAcquiredExclusiveLite ( (PERESOURCE)hsem );
}
/*
* @implemented
*/
BOOL STDCALL
EngInitializeSafeSemaphore(
OUT ENGSAFESEMAPHORE *Semaphore)
{
HSEMAPHORE hSem;
if (InterlockedIncrement(&Semaphore->lCount) == 1)
{
/* Create the semaphore */
hSem = EngCreateSemaphore();
if (hSem == 0)
{
InterlockedDecrement(&Semaphore->lCount);
return FALSE;
}
InterlockedExchangePointer((volatile PVOID *)&Semaphore->hsem, hSem);
}
else
{
/* Wait for the other thread to create the semaphore */
ASSERT(Semaphore->lCount > 1);
ASSERT_IRQL(PASSIVE_LEVEL);
while (Semaphore->hsem == NULL);
}
return TRUE;
}
/*
* @implemented
*/
VOID STDCALL
EngDeleteSafeSemaphore(
IN OUT ENGSAFESEMAPHORE *Semaphore)
{
if (InterlockedDecrement(&Semaphore->lCount) == 0)
{
EngDeleteSemaphore(Semaphore->hsem);
InterlockedExchangePointer((volatile PVOID *)&Semaphore->hsem, NULL);
}
}

View file

@ -0,0 +1,200 @@
/*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 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.
*/
/* $Id: window.c,v 1.11 2004/05/10 17:07:17 blight Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: GDI WNDOBJ Functions
* FILE: subsys/win32k/eng/window.c
* PROGRAMER: Gregor Anich
* REVISION HISTORY:
* 16/11/2004: Created
*/
#include <w32k.h>
/*
* Calls the WNDOBJCHANGEPROC of the given WNDOBJ
*/
VOID
FASTCALL
IntEngWndChanged(
IN WNDOBJ *pwo,
IN FLONG flChanged)
{
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
if (WndObjInt->ChangeProc == NULL)
{
return;
}
/* check flags of the WNDOBJ */
flChanged &= WndObjInt->Flags;
if (flChanged == 0)
{
return;
}
/* Call the WNDOBJCHANGEPROC */
if (flChanged == WOC_CHANGED)
{
pwo = NULL;
}
DPRINT1("Calling WNDOBJCHANGEPROC (0x%x), Changed = 0x%x\n",
WndObjInt->ChangeProc, flChanged);
WndObjInt->ChangeProc(pwo, flChanged);
}
/*
* @implemented
*/
WNDOBJ*
STDCALL
EngCreateWnd(
SURFOBJ *pso,
HWND hwnd,
WNDOBJCHANGEPROC pfn,
FLONG fl,
int iPixelFormat
)
{
WNDGDI *WndObjInt = NULL;
WNDOBJ *WndObjUser = NULL;
PWINDOW_OBJECT Window;
CLIPOBJ *ClientClipObj;
DPRINT("EngCreateWnd: WNDOBJCHANGEPROC = 0x%x, Flags = 0x%x\n", pfn, fl);
/* Get window object */
Window = IntGetWindowObject(hwnd);
if (Window == NULL)
{
return NULL;
}
/* Create WNDOBJ */
WndObjInt = EngAllocMem(0, sizeof (WNDGDI), TAG_WNDOBJ);
if (WndObjInt == NULL)
{
IntReleaseWindowObject(Window);
DPRINT1("Failed to allocate memory for a WND structure!\n");
return NULL;
}
ClientClipObj = IntEngCreateClipRegion(1, (PRECTL)&Window->ClientRect,
(PRECTL)&Window->ClientRect);
if (ClientClipObj == NULL)
{
IntReleaseWindowObject(Window);
EngFreeMem(WndObjInt);
return NULL;
}
/* fill user object */
WndObjUser = GDIToObj(WndObjInt, WND);
WndObjUser->psoOwner = pso;
WndObjUser->pvConsumer = NULL;
RtlCopyMemory(&WndObjUser->rclClient, &Window->ClientRect, sizeof (RECT));
RtlCopyMemory(&WndObjUser->coClient, ClientClipObj, sizeof (CLIPOBJ));
/* fill internal object */
WndObjInt->ChangeProc = pfn;
WndObjInt->Flags = fl;
WndObjInt->PixelFormat = iPixelFormat;
WndObjInt->ClientClipObj = ClientClipObj;
/* release resources */
IntReleaseWindowObject(Window);
/* HACKHACKHACK */
IntEngWndChanged(WndObjUser, WOC_RGN_CLIENT);
DPRINT("EngCreateWnd: SUCCESS!\n");
return WndObjUser;
}
/*
* @implemented
*/
VOID
STDCALL
EngDeleteWnd ( IN WNDOBJ *pwo )
{
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
DPRINT("EngDeleteWnd\n");
IntEngDeleteClipRegion(WndObjInt->ClientClipObj);
EngFreeMem(WndObjInt);
}
/*
* @implemented
*/
BOOL
STDCALL
WNDOBJ_bEnum(
IN WNDOBJ *pwo,
IN ULONG cj,
OUT ULONG *pul
)
{
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
DPRINT("WNDOBJ_bEnum\n");
return CLIPOBJ_bEnum(WndObjInt->ClientClipObj, cj, pul);
}
/*
* @implemented
*/
ULONG
STDCALL
WNDOBJ_cEnumStart(
IN WNDOBJ *pwo,
IN ULONG iType,
IN ULONG iDirection,
IN ULONG cLimit
)
{
WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
DPRINT("WNDOBJ_cEnumStart\n");
/* FIXME: Should we enumerate all rectangles or not? */
return CLIPOBJ_cEnumStart(WndObjInt->ClientClipObj, FALSE, iType, iDirection, cLimit);
}
/*
* @implemented
*/
VOID
STDCALL
WNDOBJ_vSetConsumer(
IN WNDOBJ *pwo,
IN PVOID pvConsumer
)
{
pwo->pvConsumer = pvConsumer;
}
/* EOF */

View file

@ -22,6 +22,17 @@ typedef struct tagSPAN
/* Definitions of IntEngXxx functions */
#define IntEngLockProcessDriverObjs(W32Process) \
ExAcquireFastMutex(&(W32Process)->DriverObjListLock)
#define IntEngUnLockProcessDriverObjs(W32Process) \
ExReleaseFastMutex(&(W32Process)->DriverObjListLock)
VOID FASTCALL
IntEngCleanupDriverObjs(struct _EPROCESS *Process,
PW32PROCESS Win32Process);
BOOL STDCALL
IntEngLineTo(BITMAPOBJ *Surface,
CLIPOBJ *Clip,

View file

@ -45,16 +45,16 @@ PMENU_OBJECT FASTCALL
IntGetMenuObject(HMENU hMenu);
#define IntLockMenuItems(MenuObj) \
ExAcquireFastMutex(&MenuObj->MenuItemsLock)
ExAcquireFastMutex(&(MenuObj)->MenuItemsLock)
#define IntUnLockMenuItems(MenuObj) \
ExReleaseFastMutex(&MenuObj->MenuItemsLock)
ExReleaseFastMutex(&(MenuObj)->MenuItemsLock)
#define IntLockProcessMenus(W32Process) \
ExAcquireFastMutex(&W32Process->MenuListLock)
ExAcquireFastMutex(&(W32Process)->MenuListLock)
#define IntUnLockProcessMenus(W32Process) \
ExReleaseFastMutex(&W32Process->MenuListLock)
ExReleaseFastMutex(&(W32Process)->MenuListLock)
#define IntReleaseMenuObject(MenuObj) \
ObmDereferenceObject(MenuObj)

View file

@ -45,9 +45,11 @@
/* Eng objects */
#define TAG_CLIPOBJ TAG('C', 'L', 'P', 'O') /* clip object */
#define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate object */
#define TAG_DRIVEROBJ TAG('D', 'R', 'V', 'O') /* driver object */
#define TAG_FONT TAG('F', 'N', 'T', 'E') /* font entry */
#define TAG_FONTOBJ TAG('F', 'N', 'T', 'O') /* font object */
#define TAG_WNDOBJ TAG('W', 'N', 'D', 'O') /* window object */
#define TAG_XLATEOBJ TAG('X', 'L', 'A', 'O') /* xlate object */
/* misc */
#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */

View file

@ -1,6 +1,6 @@
/*
* ReactOS W32 Subsystem
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 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
@ -71,6 +71,9 @@ Win32kProcessCallback (struct _EPROCESS *Process,
InitializeListHead(&Win32Process->PrivateFontListHead);
ExInitializeFastMutex(&Win32Process->PrivateFontListLock);
InitializeListHead(&Win32Process->DriverObjListHead);
ExInitializeFastMutex(&Win32Process->DriverObjListLock);
Win32Process->KeyboardLayout = W32kGetDefaultKeyLayout();
/* setup process flags */
@ -82,8 +85,10 @@ Win32kProcessCallback (struct _EPROCESS *Process,
IntRemoveProcessWndProcHandles((HANDLE)Process->UniqueProcessId);
IntCleanupMenus(Process, Win32Process);
IntCleanupCurIcons(Process, Win32Process);
IntEngCleanupDriverObjs(Process, Win32Process);
CleanupMonitorImpl();
GDI_CleanupForProcess(Process);
IntGraphicsCheck(FALSE);

View file

@ -55,7 +55,7 @@ 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/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
eng/gradient.o eng/event.o eng/float.o eng/driverobj.o eng/window.o
MAIN_OBJECTS = main/dllmain.o main/svctabm.o

View file

@ -126,22 +126,6 @@ EngComputeGlyphSet(
return NULL;
}
/*
* @unimplemented
*/
HDRVOBJ
STDCALL
EngCreateDriverObj(
PVOID pvObj,
FREEOBJPROC pFreeObjProc,
HDEV hdev
)
{
// www.osr.com/ddk/graphics/gdifncs_8svb.htm
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented
*/
@ -154,40 +138,6 @@ EngCreatePath ( VOID )
return NULL;
}
/*
* @unimplemented
*/
WNDOBJ*
STDCALL
EngCreateWnd(
SURFOBJ *pso,
HWND hwnd,
WNDOBJCHANGEPROC pfn,
FLONG fl,
int iPixelFormat
)
{
// www.osr.com/ddk/graphics/gdifncs_2ip3.htm
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented
*/
BOOL
STDCALL
EngDeleteDriverObj(
IN HDRVOBJ hdo,
IN BOOL bCallBack,
IN BOOL bLocked
)
{
// www.osr.com/ddk/graphics/gdifncs_0qlj.htm
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/
@ -199,17 +149,6 @@ EngDeletePath ( IN PATHOBJ *ppo )
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
VOID
STDCALL
EngDeleteWnd ( IN WNDOBJ *pwo )
{
// www.osr.com/ddk/graphics/gdifncs_2z3b.htm
UNIMPLEMENTED;
}
/*
* @unimplemented
*/
@ -422,18 +361,6 @@ EngLoadModuleForWrite(
return NULL;
}
/*
* @unimplemented
*/
DRIVEROBJ*
STDCALL
EngLockDriverObj ( IN HDRVOBJ hdo )
{
// www.osr.com/ddk/graphics/gdifncs_41if.htm
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented
*/
@ -575,15 +502,6 @@ EngUnloadImage ( IN HANDLE hModule )
UNIMPLEMENTED;
}
BOOL
STDCALL
EngUnlockDriverObj ( IN HDRVOBJ hdo )
{
// www.osr.com/ddk/graphics/gdifncs_0l5z.htm
UNIMPLEMENTED;
return FALSE;
}
INT
STDCALL
EngWideCharToMultiByte(
@ -1108,44 +1026,6 @@ STROBJ_vEnumStart ( IN STROBJ *pstro )
UNIMPLEMENTED;
}
BOOL
STDCALL
WNDOBJ_bEnum(
IN WNDOBJ *pwo,
IN ULONG cj,
OUT ULONG *pul
)
{
// www.osr.com/ddk/graphics/gdifncs_3jqf.htm
UNIMPLEMENTED;
return FALSE;
}
ULONG
STDCALL
WNDOBJ_cEnumStart(
IN WNDOBJ *pwo,
IN ULONG iType,
IN ULONG iDirection,
IN ULONG cLimit
)
{
// www.osr.com/ddk/graphics/gdifncs_18o7.htm
UNIMPLEMENTED;
return 0;
}
VOID
STDCALL
WNDOBJ_vSetConsumer(
IN WNDOBJ *pwo,
IN PVOID pvConsumer
)
{
// www.osr.com/ddk/graphics/gdifncs_484n.htm
UNIMPLEMENTED;
}
BOOL
STDCALL
XFORMOBJ_bApplyXform(
@ -1267,6 +1147,19 @@ BRUSHOBJ_hGetColorTransform(
return NULL;
}
/*
* @unimplemented
*/
PVOID STDCALL
EngAllocPrivateUserMem(
IN PDD_SURFACE_LOCAL psl,
IN SIZE_T cj,
IN ULONG tag)
{
UNIMPLEMENTED;
return NULL;
}
/*
* @unimplemented
*/
@ -1292,8 +1185,9 @@ EngDeleteFile(
* @unimplemented
*/
VOID STDCALL
EngDeleteSafeSemaphore(
IN OUT ENGSAFESEMAPHORE *Semaphore)
EngFreePrivateUserMem(
IN PDD_SURFACE_LOCAL psl,
IN PVOID pv)
{
UNIMPLEMENTED;
}
@ -1326,17 +1220,6 @@ EngHangNotification(
return EHN_ERROR;
}
/*
* @unimplemented
*/
BOOL STDCALL
EngInitializeSafeSemaphore(
OUT ENGSAFESEMAPHORE *Semaphore)
{
UNIMPLEMENTED;
return FALSE;
}
/*
* @unimplemented
*/

View file

@ -15,6 +15,7 @@ CLIPOBJ_ppoGetPath@4
EngAlphaBlend@28
EngAcquireSemaphore@4
EngAllocMem@12
EngAllocPrivateUserMem@12
EngAllocUserMem@8
EngAssociateSurface@12
EngBitBlt@44
@ -39,6 +40,7 @@ EngDeleteDriverObj@12
EngDeleteEvent@4
EngDeletePalette@4
EngDeletePath@4
EngDeleteSafeSemaphore@4
EngDeleteSemaphore@4
EngDeleteSurface@4
EngDeleteWnd@4
@ -51,6 +53,7 @@ EngFindImageProcAddress@8
EngFindResource@16
EngFreeMem@4
EngFreeModule@4
EngFreePrivateUserMem@8
EngFreeUserMem@4
EngGetCurrentCodePage@8=ntoskrnl.RtlGetCurrentCodePage
EngGetCurrentProcessId@0
@ -66,6 +69,7 @@ EngGetPrinterDataFileName@4
EngGetProcessHandle@0
EngGetType1FontList@24
EngGradientFill@40
EngInitializeSafeSemaphore@4
EngLineTo@36
EngLoadImage@4
EngLoadModule@4