- Formatting, no code change.

svn path=/trunk/; revision=61884
This commit is contained in:
Jérôme Gardou 2014-01-29 19:09:15 +00:00
parent e2be2729b0
commit ac3145e072
2 changed files with 222 additions and 225 deletions

View file

@ -18,8 +18,8 @@ IntEngMaskBlt(SURFOBJ *psoDest,
VOID FASTCALL VOID FASTCALL
IntEngWindowChanged( IntEngWindowChanged(
PWND Window, _In_ PWND Window,
FLONG flChanged); _In_ FLONG flChanged);
VOID FASTCALL IntGdiAcquireSemaphore ( HSEMAPHORE hsem ); VOID FASTCALL IntGdiAcquireSemaphore ( HSEMAPHORE hsem );
VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem ); VOID FASTCALL IntGdiReleaseSemaphore ( HSEMAPHORE hsem );

View file

@ -6,9 +6,6 @@
* PROGRAMER: Gregor Anich * PROGRAMER: Gregor Anich
*/ */
/* TODO: Check how the WNDOBJ implementation should behave with a driver on windows.
*/
#include <win32k.h> #include <win32k.h>
#define NDEBUG #define NDEBUG
@ -22,32 +19,32 @@ INT gcountPWO = 0;
VOID VOID
FASTCALL FASTCALL
IntEngWndCallChangeProc( IntEngWndCallChangeProc(
IN WNDOBJ *pwo, IN WNDOBJ *pwo,
IN FLONG flChanged) IN FLONG flChanged)
{ {
WNDGDI *WndObjInt = ObjToGDI(pwo, WND); WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
if (WndObjInt->ChangeProc == NULL) if (WndObjInt->ChangeProc == NULL)
{ {
return; return;
} }
/* check flags of the WNDOBJ */ /* check flags of the WNDOBJ */
flChanged &= WndObjInt->Flags; flChanged &= WndObjInt->Flags;
if (flChanged == 0) if (flChanged == 0)
{ {
return; return;
} }
/* Call the WNDOBJCHANGEPROC */ /* Call the WNDOBJCHANGEPROC */
if (flChanged == WOC_CHANGED) if (flChanged == WOC_CHANGED)
{ {
pwo = NULL; pwo = NULL;
} }
DPRINT("Calling WNDOBJCHANGEPROC (0x%p), Changed = 0x%x\n", DPRINT("Calling WNDOBJCHANGEPROC (0x%p), Changed = 0x%x\n",
WndObjInt->ChangeProc, flChanged); WndObjInt->ChangeProc, flChanged);
WndObjInt->ChangeProc(pwo, flChanged); WndObjInt->ChangeProc(pwo, flChanged);
} }
/* /*
@ -56,74 +53,74 @@ IntEngWndCallChangeProc(
BOOLEAN BOOLEAN
FASTCALL FASTCALL
IntEngWndUpdateClipObj( IntEngWndUpdateClipObj(
WNDGDI *WndObjInt, WNDGDI *WndObjInt,
PWND Window) PWND Window)
{ {
HRGN hVisRgn; HRGN hVisRgn;
PROSRGNDATA visRgn; PROSRGNDATA visRgn;
CLIPOBJ *ClipObj = NULL; CLIPOBJ *ClipObj = NULL;
CLIPOBJ *OldClipObj; CLIPOBJ *OldClipObj;
DPRINT("IntEngWndUpdateClipObj\n"); DPRINT("IntEngWndUpdateClipObj\n");
hVisRgn = VIS_ComputeVisibleRegion(Window, TRUE, TRUE, TRUE); hVisRgn = VIS_ComputeVisibleRegion(Window, TRUE, TRUE, TRUE);
if (hVisRgn != NULL) if (hVisRgn != NULL)
{
NtGdiOffsetRgn(hVisRgn, Window->rcClient.left, Window->rcClient.top);
visRgn = RGNOBJAPI_Lock(hVisRgn, NULL);
if (visRgn != NULL)
{ {
if (visRgn->rdh.nCount > 0) NtGdiOffsetRgn(hVisRgn, Window->rcClient.left, Window->rcClient.top);
{ visRgn = RGNOBJAPI_Lock(hVisRgn, NULL);
ClipObj = IntEngCreateClipRegion(visRgn->rdh.nCount, visRgn->Buffer, if (visRgn != NULL)
&visRgn->rdh.rcBound);
DPRINT("Created visible region with %lu rects\n", visRgn->rdh.nCount);
DPRINT(" BoundingRect: %d, %d %d, %d\n",
visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top,
visRgn->rdh.rcBound.right, visRgn->rdh.rcBound.bottom);
{ {
ULONG i; if (visRgn->rdh.nCount > 0)
for (i = 0; i < visRgn->rdh.nCount; i++) {
{ ClipObj = IntEngCreateClipRegion(visRgn->rdh.nCount, visRgn->Buffer,
DPRINT(" Rect #%lu: %ld,%ld %ld,%ld\n", i+1, &visRgn->rdh.rcBound);
visRgn->Buffer[i].left, visRgn->Buffer[i].top, DPRINT("Created visible region with %lu rects\n", visRgn->rdh.nCount);
visRgn->Buffer[i].right, visRgn->Buffer[i].bottom); DPRINT(" BoundingRect: %d, %d %d, %d\n",
} visRgn->rdh.rcBound.left, visRgn->rdh.rcBound.top,
visRgn->rdh.rcBound.right, visRgn->rdh.rcBound.bottom);
{
ULONG i;
for (i = 0; i < visRgn->rdh.nCount; i++)
{
DPRINT(" Rect #%lu: %ld,%ld %ld,%ld\n", i+1,
visRgn->Buffer[i].left, visRgn->Buffer[i].top,
visRgn->Buffer[i].right, visRgn->Buffer[i].bottom);
}
}
}
RGNOBJAPI_Unlock(visRgn);
} }
} else
RGNOBJAPI_Unlock(visRgn); {
DPRINT1("Warning: Couldn't lock visible region of window DC\n");
}
GreDeleteObject(hVisRgn);
} }
else else
{ {
DPRINT1("Warning: Couldn't lock visible region of window DC\n"); DPRINT1("Warning: VIS_ComputeVisibleRegion failed!\n");
} }
GreDeleteObject(hVisRgn);
}
else
{
DPRINT1("Warning: VIS_ComputeVisibleRegion failed!\n");
}
if (ClipObj == NULL) if (ClipObj == NULL)
{ {
/* Fall back to client rect */ /* Fall back to client rect */
ClipObj = IntEngCreateClipRegion(1, &Window->rcClient, ClipObj = IntEngCreateClipRegion(1, &Window->rcClient,
&Window->rcClient); &Window->rcClient);
} }
if (ClipObj == NULL) if (ClipObj == NULL)
{ {
DPRINT1("Warning: IntEngCreateClipRegion() failed!\n"); DPRINT1("Warning: IntEngCreateClipRegion() failed!\n");
return FALSE; return FALSE;
} }
RtlCopyMemory(&WndObjInt->WndObj.coClient, ClipObj, sizeof (CLIPOBJ)); RtlCopyMemory(&WndObjInt->WndObj.coClient, ClipObj, sizeof (CLIPOBJ));
RtlCopyMemory(&WndObjInt->WndObj.rclClient, &Window->rcClient, sizeof (RECT)); RtlCopyMemory(&WndObjInt->WndObj.rclClient, &Window->rcClient, sizeof (RECT));
OldClipObj = InterlockedExchangePointer((PVOID*)&WndObjInt->ClientClipObj, ClipObj); OldClipObj = InterlockedExchangePointer((PVOID*)&WndObjInt->ClientClipObj, ClipObj);
if (OldClipObj != NULL) if (OldClipObj != NULL)
IntEngDeleteClipRegion(OldClipObj); IntEngDeleteClipRegion(OldClipObj);
return TRUE; return TRUE;
} }
/* /*
@ -132,49 +129,49 @@ IntEngWndUpdateClipObj(
VOID VOID
FASTCALL FASTCALL
IntEngWindowChanged( IntEngWindowChanged(
PWND Window, _In_ PWND Window,
FLONG flChanged) _In_ FLONG flChanged)
{ {
PPROPERTY pprop; PPROPERTY pprop;
WNDGDI *Current; WNDGDI *Current;
HWND hWnd; HWND hWnd;
ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL); ASSERT_IRQL_LESS_OR_EQUAL(PASSIVE_LEVEL);
hWnd = Window->head.h; hWnd = Window->head.h;
pprop = IntGetProp(Window, AtomWndObj); pprop = IntGetProp(Window, AtomWndObj);
if (!pprop) if (!pprop)
{ {
return; return;
} }
Current = (WNDGDI *)pprop->Data; Current = (WNDGDI *)pprop->Data;
if ( gcountPWO && if ( gcountPWO &&
Current && Current &&
Current->Hwnd == hWnd && Current->Hwnd == hWnd &&
Current->WndObj.pvConsumer != NULL ) Current->WndObj.pvConsumer != NULL )
{ {
/* Update the WNDOBJ */ /* Update the WNDOBJ */
switch (flChanged) switch (flChanged)
{ {
case WOC_RGN_CLIENT: case WOC_RGN_CLIENT:
/* Update the clipobj and client rect of the WNDOBJ */ /* Update the clipobj and client rect of the WNDOBJ */
IntEngWndUpdateClipObj(Current, Window); IntEngWndUpdateClipObj(Current, Window);
break; break;
case WOC_DELETE: case WOC_DELETE:
/* FIXME: Should the WNDOBJs be deleted by win32k or by the driver? */ /* FIXME: Should the WNDOBJs be deleted by win32k or by the driver? */
break; break;
} }
/* Call the change proc */ /* Call the change proc */
IntEngWndCallChangeProc(&Current->WndObj, flChanged); IntEngWndCallChangeProc(&Current->WndObj, flChanged);
/* HACK: Send WOC_CHANGED after WOC_RGN_CLIENT */ /* HACK: Send WOC_CHANGED after WOC_RGN_CLIENT */
if (flChanged == WOC_RGN_CLIENT) if (flChanged == WOC_RGN_CLIENT)
{ {
IntEngWndCallChangeProc(&Current->WndObj, WOC_CHANGED); IntEngWndCallChangeProc(&Current->WndObj, WOC_CHANGED);
} }
} }
} }
/* /*
@ -183,75 +180,75 @@ IntEngWindowChanged(
WNDOBJ* WNDOBJ*
APIENTRY APIENTRY
EngCreateWnd( EngCreateWnd(
SURFOBJ *pso, SURFOBJ *pso,
HWND hWnd, HWND hWnd,
WNDOBJCHANGEPROC pfn, WNDOBJCHANGEPROC pfn,
FLONG fl, FLONG fl,
int iPixelFormat) int iPixelFormat)
{ {
WNDGDI *WndObjInt = NULL; WNDGDI *WndObjInt = NULL;
WNDOBJ *WndObjUser = NULL; WNDOBJ *WndObjUser = NULL;
PWND Window; PWND Window;
BOOL calledFromUser; BOOL calledFromUser;
DECLARE_RETURN(WNDOBJ*); DECLARE_RETURN(WNDOBJ*);
DPRINT("EngCreateWnd: pso = 0x%p, hwnd = 0x%p, pfn = 0x%p, fl = 0x%lx, pixfmt = %d\n", DPRINT1("EngCreateWnd: pso = 0x%p, hwnd = 0x%p, pfn = 0x%p, fl = 0x%lx, pixfmt = %d\n",
pso, hWnd, pfn, fl, iPixelFormat); pso, hWnd, pfn, fl, iPixelFormat);
calledFromUser = UserIsEntered(); calledFromUser = UserIsEntered();
if (!calledFromUser){ if (!calledFromUser) {
UserEnterShared(); UserEnterShared();
}
/* Get window object */
Window = UserGetWindowObject(hWnd);
if (Window == NULL)
{
RETURN( NULL);
} }
/* Create WNDOBJ */ /* Get window object */
WndObjInt = EngAllocMem(0, sizeof (WNDGDI), GDITAG_WNDOBJ); Window = UserGetWindowObject(hWnd);
if (WndObjInt == NULL) if (Window == NULL)
{ {
DPRINT1("Failed to allocate memory for a WND structure!\n"); RETURN( NULL);
RETURN( NULL);
} }
/* Fill the clipobj */ /* Create WNDOBJ */
WndObjInt->ClientClipObj = NULL; WndObjInt = EngAllocMem(0, sizeof (WNDGDI), GDITAG_WNDOBJ);
if (!IntEngWndUpdateClipObj(WndObjInt, Window)) if (WndObjInt == NULL)
{ {
EngFreeMem(WndObjInt); DPRINT1("Failed to allocate memory for a WND structure!\n");
RETURN( NULL); RETURN( NULL);
} }
/* Fill user object */ /* Fill the clipobj */
WndObjUser = GDIToObj(WndObjInt, WND); WndObjInt->ClientClipObj = NULL;
WndObjUser->psoOwner = pso; if (!IntEngWndUpdateClipObj(WndObjInt, Window))
WndObjUser->pvConsumer = NULL; {
EngFreeMem(WndObjInt);
RETURN( NULL);
}
/* Fill internal object */ /* Fill user object */
WndObjInt->Hwnd = hWnd; WndObjUser = GDIToObj(WndObjInt, WND);
WndObjInt->ChangeProc = pfn; WndObjUser->psoOwner = pso;
WndObjInt->Flags = fl; WndObjUser->pvConsumer = NULL;
WndObjInt->PixelFormat = iPixelFormat;
/* associate object with window */ /* Fill internal object */
IntSetProp(Window, AtomWndObj, WndObjInt); WndObjInt->Hwnd = hWnd;
++gcountPWO; WndObjInt->ChangeProc = pfn;
WndObjInt->Flags = fl;
WndObjInt->PixelFormat = iPixelFormat;
DPRINT("EngCreateWnd: SUCCESS!\n"); /* associate object with window */
IntSetProp(Window, AtomWndObj, WndObjInt);
++gcountPWO;
RETURN( WndObjUser); DPRINT("EngCreateWnd: SUCCESS!\n");
RETURN( WndObjUser);
CLEANUP: CLEANUP:
if (!calledFromUser){ if (!calledFromUser) {
UserLeave(); UserLeave();
} }
END_CLEANUP; END_CLEANUP;
} }
@ -261,39 +258,39 @@ CLEANUP:
VOID VOID
APIENTRY APIENTRY
EngDeleteWnd( EngDeleteWnd(
IN WNDOBJ *pwo) IN WNDOBJ *pwo)
{ {
WNDGDI *WndObjInt = ObjToGDI(pwo, WND); WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
PWND Window; PWND Window;
BOOL calledFromUser; BOOL calledFromUser;
DPRINT("EngDeleteWnd: pwo = 0x%p\n", pwo); DPRINT("EngDeleteWnd: pwo = 0x%p\n", pwo);
calledFromUser = UserIsEntered(); calledFromUser = UserIsEntered();
if (!calledFromUser){ if (!calledFromUser) {
UserEnterExclusive(); UserEnterExclusive();
} }
/* Get window object */ /* Get window object */
Window = UserGetWindowObject(WndObjInt->Hwnd); Window = UserGetWindowObject(WndObjInt->Hwnd);
if (Window == NULL) if (Window == NULL)
{ {
DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n"); DPRINT1("Warning: Couldnt get window object for WndObjInt->Hwnd!!!\n");
} }
else else
{ {
/* Remove object from window */ /* Remove object from window */
IntRemoveProp(Window, AtomWndObj); IntRemoveProp(Window, AtomWndObj);
--gcountPWO; --gcountPWO;
} }
if (!calledFromUser){ if (!calledFromUser) {
UserLeave(); UserLeave();
} }
/* Free resources */ /* Free resources */
IntEngDeleteClipRegion(WndObjInt->ClientClipObj); IntEngDeleteClipRegion(WndObjInt->ClientClipObj);
EngFreeMem(WndObjInt); EngFreeMem(WndObjInt);
} }
@ -303,18 +300,18 @@ EngDeleteWnd(
BOOL BOOL
APIENTRY APIENTRY
WNDOBJ_bEnum( WNDOBJ_bEnum(
IN WNDOBJ *pwo, IN WNDOBJ *pwo,
IN ULONG cj, IN ULONG cj,
OUT ULONG *pul) OUT ULONG *pul)
{ {
WNDGDI *WndObjInt = ObjToGDI(pwo, WND); WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
BOOL Ret; BOOL Ret;
DPRINT("WNDOBJ_bEnum: pwo = 0x%p, cj = %lu, pul = 0x%p\n", pwo, cj, pul); DPRINT("WNDOBJ_bEnum: pwo = 0x%p, cj = %lu, pul = 0x%p\n", pwo, cj, pul);
Ret = CLIPOBJ_bEnum(WndObjInt->ClientClipObj, cj, pul); Ret = CLIPOBJ_bEnum(WndObjInt->ClientClipObj, cj, pul);
DPRINT("WNDOBJ_bEnum: Returning %s\n", Ret ? "True" : "False"); DPRINT("WNDOBJ_bEnum: Returning %s\n", Ret ? "True" : "False");
return Ret; return Ret;
} }
@ -324,22 +321,22 @@ WNDOBJ_bEnum(
ULONG ULONG
APIENTRY APIENTRY
WNDOBJ_cEnumStart( WNDOBJ_cEnumStart(
IN WNDOBJ *pwo, IN WNDOBJ *pwo,
IN ULONG iType, IN ULONG iType,
IN ULONG iDirection, IN ULONG iDirection,
IN ULONG cLimit) IN ULONG cLimit)
{ {
WNDGDI *WndObjInt = ObjToGDI(pwo, WND); WNDGDI *WndObjInt = ObjToGDI(pwo, WND);
ULONG Ret; ULONG Ret;
DPRINT("WNDOBJ_cEnumStart: pwo = 0x%p, iType = %lu, iDirection = %lu, cLimit = %lu\n", DPRINT("WNDOBJ_cEnumStart: pwo = 0x%p, iType = %lu, iDirection = %lu, cLimit = %lu\n",
pwo, iType, iDirection, cLimit); pwo, iType, iDirection, cLimit);
/* FIXME: Should we enumerate all rectangles or not? */ /* FIXME: Should we enumerate all rectangles or not? */
Ret = CLIPOBJ_cEnumStart(WndObjInt->ClientClipObj, FALSE, iType, iDirection, cLimit); Ret = CLIPOBJ_cEnumStart(WndObjInt->ClientClipObj, FALSE, iType, iDirection, cLimit);
DPRINT("WNDOBJ_cEnumStart: Returning 0x%lx\n", Ret); DPRINT("WNDOBJ_cEnumStart: Returning 0x%lx\n", Ret);
return Ret; return Ret;
} }
@ -349,29 +346,29 @@ WNDOBJ_cEnumStart(
VOID VOID
APIENTRY APIENTRY
WNDOBJ_vSetConsumer( WNDOBJ_vSetConsumer(
IN WNDOBJ *pwo, IN WNDOBJ *pwo,
IN PVOID pvConsumer) IN PVOID pvConsumer)
{ {
BOOL Hack; BOOL Hack;
DPRINT("WNDOBJ_vSetConsumer: pwo = 0x%p, pvConsumer = 0x%p\n", pwo, pvConsumer); DPRINT("WNDOBJ_vSetConsumer: pwo = 0x%p, pvConsumer = 0x%p\n", pwo, pvConsumer);
Hack = (pwo->pvConsumer == NULL); Hack = (pwo->pvConsumer == NULL);
pwo->pvConsumer = pvConsumer; pwo->pvConsumer = pvConsumer;
/* HACKHACKHACK /* HACKHACKHACK
* *
* MSDN says that the WNDOBJCHANGEPROC will be called with the most recent state * MSDN says that the WNDOBJCHANGEPROC will be called with the most recent state
* when a WNDOBJ is created - we do it here because most drivers will need pvConsumer * when a WNDOBJ is created - we do it here because most drivers will need pvConsumer
* in the callback to identify the WNDOBJ I think. * in the callback to identify the WNDOBJ I think.
* *
* - blight * - blight
*/ */
if (Hack) if (Hack)
{ {
IntEngWndCallChangeProc(pwo, WOC_RGN_CLIENT); IntEngWndCallChangeProc(pwo, WOC_RGN_CLIENT);
IntEngWndCallChangeProc(pwo, WOC_CHANGED); IntEngWndCallChangeProc(pwo, WOC_CHANGED);
IntEngWndCallChangeProc(pwo, WOC_DRAWN); IntEngWndCallChangeProc(pwo, WOC_DRAWN);
} }
} }