Author: tkreuzer Date: Wed Feb 20 01:21:39 2008 New Revision: 32428
URL: http://svn.reactos.org/svn/reactos?rev=32428&view=rev Log: Remove typecasts PBITMAPOBJ <-> PSURFOBJ. Use GDIOBJ_ShareLockObj / _UnlockObjByPtr instead of Eng(Un)LockSurface as BITMAPOBJ_Un/LockObj. Add BASEOBJECT to the BITMAPOBJ structure.
Modified: trunk/reactos/subsystems/win32/win32k/eng/copybits.c trunk/reactos/subsystems/win32/win32k/eng/engmisc.c trunk/reactos/subsystems/win32/win32k/eng/surface.c trunk/reactos/subsystems/win32/win32k/include/bitmaps.h trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c
Modified: trunk/reactos/subsystems/win32/win32k/eng/copybits.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/copybits.c (original) +++ trunk/reactos/subsystems/win32/win32k/eng/copybits.c Wed Feb 20 01:21:39 2008 @@ -47,7 +47,7 @@ RECT_ENUM RectEnum; BOOL EnumMore; BLTINFO BltInfo; - BITMAPOBJ *DestObj = NULL; + BITMAPOBJ *DestObj; BITMAPOBJ *SourceObj;
ASSERT(Dest != NULL && Source != NULL && DestRect != NULL && SourcePoint != NULL); @@ -57,11 +57,13 @@ MouseSafetyOnDrawStart(Source, SourcePoint->x, SourcePoint->y, (SourcePoint->x + abs(DestRect->right - DestRect->left)), (SourcePoint->y + abs(DestRect->bottom - DestRect->top))); + + DestObj = CONTAINING_RECORD(Dest, BITMAPOBJ, SurfObj); if (Dest != Source) - { - DestObj = CONTAINING_RECORD(Dest, BITMAPOBJ, SurfObj); + { BITMAPOBJ_LockBitmapBits(DestObj); - } + } + MouseSafetyOnDrawStart(Dest, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
// FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead, @@ -76,17 +78,16 @@ if(Dest->iType!=STYPE_BITMAP) { /* FIXME: Eng* functions shouldn't call Drv* functions. ? */ - /* FIXME: Remove typecast. */ - if (((BITMAPOBJ*)Dest)->flHooks & HOOK_COPYBITS) + if (DestObj->flHooks & HOOK_COPYBITS) { ret = GDIDEVFUNCS(Dest).CopyBits( Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { - BITMAPOBJ_UnlockBitmapBits(DestObj); - } + { + BITMAPOBJ_UnlockBitmapBits(DestObj); + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
@@ -98,17 +99,16 @@ if(Source->iType!=STYPE_BITMAP) { /* FIXME: Eng* functions shouldn't call Drv* functions. ? */ - /* FIXME: Remove typecast. */ - if (((BITMAPOBJ*)Source)->flHooks & HOOK_COPYBITS) + if (SourceObj->flHooks & HOOK_COPYBITS) { ret = GDIDEVFUNCS(Source).CopyBits( Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { - BITMAPOBJ_UnlockBitmapBits(DestObj); - } + { + BITMAPOBJ_UnlockBitmapBits(DestObj); + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
@@ -123,9 +123,9 @@
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { + { BITMAPOBJ_UnlockBitmapBits(DestObj); - } + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
@@ -157,9 +157,9 @@
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { - BITMAPOBJ_UnlockBitmapBits(DestObj); - } + { + BITMAPOBJ_UnlockBitmapBits(DestObj); + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
@@ -176,9 +176,9 @@
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { - BITMAPOBJ_UnlockBitmapBits(DestObj); - } + { + BITMAPOBJ_UnlockBitmapBits(DestObj); + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
@@ -214,9 +214,9 @@
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { + { BITMAPOBJ_UnlockBitmapBits(DestObj); - } + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
@@ -225,9 +225,9 @@
MouseSafetyOnDrawEnd(Dest); if (Dest != Source) - { + { BITMAPOBJ_UnlockBitmapBits(DestObj); - } + } MouseSafetyOnDrawEnd(Source); BITMAPOBJ_UnlockBitmapBits(SourceObj);
Modified: trunk/reactos/subsystems/win32/win32k/eng/engmisc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/engmisc.c (original) +++ trunk/reactos/subsystems/win32/win32k/eng/engmisc.c Wed Feb 20 01:21:39 2008 @@ -25,11 +25,11 @@
BOOL STDCALL IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave, - SURFOBJ *DestObj, + SURFOBJ *DestSurf, RECTL *DestRect, BOOL ReadOnly, POINTL *Translate, - SURFOBJ **OutputObj) + SURFOBJ **OutputSurf) { LONG Exchange; SIZEL BitmapSize; @@ -51,22 +51,22 @@ DestRect->bottom = Exchange; }
- if (NULL != DestObj && STYPE_BITMAP != DestObj->iType && - (NULL == DestObj->pvScan0 || 0 == DestObj->lDelta)) + if (NULL != DestSurf && STYPE_BITMAP != DestSurf->iType && + (NULL == DestSurf->pvScan0 || 0 == DestSurf->lDelta)) { /* Driver needs to support DrvCopyBits, else we can't do anything */ - /* FIXME: Remove typecast! */ - if (!(((BITMAPOBJ*)DestObj)->flHooks & HOOK_COPYBITS)) - { + BITMAPOBJ *DestBmp = CONTAINING_RECORD(DestSurf, BITMAPOBJ, SurfObj); + if (!(DestBmp->flHooks & HOOK_COPYBITS)) + { return FALSE; - } + }
/* Allocate a temporary bitmap */ BitmapSize.cx = DestRect->right - DestRect->left; BitmapSize.cy = DestRect->bottom - DestRect->top; - Width = DIB_GetDIBWidthBytes(BitmapSize.cx, BitsPerFormat(DestObj->iBitmapFormat)); + Width = DIB_GetDIBWidthBytes(BitmapSize.cx, BitsPerFormat(DestSurf->iBitmapFormat)); EnterLeave->OutputBitmap = EngCreateBitmap(BitmapSize, Width, - DestObj->iBitmapFormat, + DestSurf->iBitmapFormat, BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
if (!EnterLeave->OutputBitmap) @@ -75,7 +75,7 @@ return FALSE; }
- *OutputObj = EngLockSurface((HSURF)EnterLeave->OutputBitmap); + *OutputSurf = EngLockSurface((HSURF)EnterLeave->OutputBitmap);
EnterLeave->DestRect.left = 0; EnterLeave->DestRect.top = 0; @@ -89,35 +89,35 @@ ClippedDestRect.left -= SrcPoint.x; SrcPoint.x = 0; } - if (DestObj->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left) - { - ClippedDestRect.right = ClippedDestRect.left + DestObj->sizlBitmap.cx - SrcPoint.x; + if (DestSurf->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left) + { + ClippedDestRect.right = ClippedDestRect.left + DestSurf->sizlBitmap.cx - SrcPoint.x; } if (SrcPoint.y < 0) { ClippedDestRect.top -= SrcPoint.y; SrcPoint.y = 0; } - if (DestObj->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top) - { - ClippedDestRect.bottom = ClippedDestRect.top + DestObj->sizlBitmap.cy - SrcPoint.y; + if (DestSurf->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top) + { + ClippedDestRect.bottom = ClippedDestRect.top + DestSurf->sizlBitmap.cy - SrcPoint.y; } EnterLeave->TrivialClipObj = EngCreateClip(); EnterLeave->TrivialClipObj->iDComplexity = DC_TRIVIAL; - if (ClippedDestRect.left < (*OutputObj)->sizlBitmap.cx && + if (ClippedDestRect.left < (*OutputSurf)->sizlBitmap.cx && 0 <= ClippedDestRect.right && - SrcPoint.x < DestObj->sizlBitmap.cx && - ClippedDestRect.top <= (*OutputObj)->sizlBitmap.cy && + SrcPoint.x < DestSurf->sizlBitmap.cx && + ClippedDestRect.top <= (*OutputSurf)->sizlBitmap.cy && 0 <= ClippedDestRect.bottom && - SrcPoint.y < DestObj->sizlBitmap.cy && - ! GDIDEVFUNCS(DestObj).CopyBits( - *OutputObj, DestObj, + SrcPoint.y < DestSurf->sizlBitmap.cy && + ! GDIDEVFUNCS(DestSurf).CopyBits( + *OutputSurf, DestSurf, EnterLeave->TrivialClipObj, NULL, &ClippedDestRect, &SrcPoint)) { EngDeleteClip(EnterLeave->TrivialClipObj); - EngFreeMem((*OutputObj)->pvBits); - EngUnlockSurface(*OutputObj); + EngFreeMem((*OutputSurf)->pvBits); + EngUnlockSurface(*OutputSurf); EngDeleteSurface((HSURF)EnterLeave->OutputBitmap); return FALSE; } @@ -132,25 +132,28 @@ { Translate->x = 0; Translate->y = 0; - *OutputObj = DestObj; - } - - if (NULL != *OutputObj - && 0 != (((BITMAPOBJ*) *OutputObj)->flHooks & HOOK_SYNCHRONIZE)) - { - if (NULL != GDIDEVFUNCS(*OutputObj).SynchronizeSurface) - { - GDIDEVFUNCS(*OutputObj).SynchronizeSurface(*OutputObj, DestRect, 0); - } - else if (STYPE_BITMAP == (*OutputObj)->iType - && NULL != GDIDEVFUNCS(*OutputObj).Synchronize) - { - GDIDEVFUNCS(*OutputObj).Synchronize((*OutputObj)->dhpdev, DestRect); - } - } - - EnterLeave->DestObj = DestObj; - EnterLeave->OutputObj = *OutputObj; + *OutputSurf = DestSurf; + } + + if (NULL != *OutputSurf) + { + BITMAPOBJ* OutputBmp = CONTAINING_RECORD(*OutputSurf, BITMAPOBJ, SurfObj); + if (0 != (OutputBmp->flHooks & HOOK_SYNCHRONIZE)) + { + if (NULL != GDIDEVFUNCS(*OutputSurf).SynchronizeSurface) + { + GDIDEVFUNCS(*OutputSurf).SynchronizeSurface(*OutputSurf, DestRect, 0); + } + else if (STYPE_BITMAP == (*OutputSurf)->iType + && NULL != GDIDEVFUNCS(*OutputSurf).Synchronize) + { + GDIDEVFUNCS(*OutputSurf).Synchronize((*OutputSurf)->dhpdev, DestRect); + } + } + } + + EnterLeave->DestObj = DestSurf; + EnterLeave->OutputObj = *OutputSurf; EnterLeave->ReadOnly = ReadOnly;
return TRUE;
Modified: trunk/reactos/subsystems/win32/win32k/eng/surface.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/eng... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/eng/surface.c (original) +++ trunk/reactos/subsystems/win32/win32k/eng/surface.c Wed Feb 20 01:21:39 2008 @@ -575,7 +575,10 @@ EngUnlockSurface(IN SURFOBJ *Surface) { if (Surface != NULL) - GDIOBJ_UnlockObjByPtr(GdiHandleTable, Surface); + { + BITMAPOBJ *bmp = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj); + GDIOBJ_UnlockObjByPtr(GdiHandleTable, bmp); + } }
Modified: trunk/reactos/subsystems/win32/win32k/include/bitmaps.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/bitmaps.h (original) +++ trunk/reactos/subsystems/win32/win32k/include/bitmaps.h Wed Feb 20 01:21:39 2008 @@ -5,10 +5,7 @@ /* GDI logical bitmap object */ typedef struct _BITMAPOBJ { -// HGDIOBJ hHmgr; -// PVOID pvEntry; -// ULONG lucExcLock; -// ULONG Tid; + BASEOBJECT BaseObject;
SURFOBJ SurfObj; FLONG flHooks; @@ -34,8 +31,11 @@ #define BITMAPOBJ_FreeBitmap(hBMObj) \ GDIOBJ_FreeObj(GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP) /* NOTE: Use shared locks! */ -#define BITMAPOBJ_LockBitmap(hBMObj) (PBITMAPOBJ)EngLockSurface((HSURF)hBMObj) -#define BITMAPOBJ_UnlockBitmap(pBMObj) EngUnlockSurface(&pBMObj->SurfObj) +#define BITMAPOBJ_LockBitmap(hBMObj) \ + ((PBITMAPOBJ) GDIOBJ_ShareLockObj (GdiHandleTable, (HGDIOBJ) hBMObj, GDI_OBJECT_TYPE_BITMAP)) +#define BITMAPOBJ_UnlockBitmap(pBMObj) \ + GDIOBJ_UnlockObjByPtr (GdiHandleTable, pBMObj) + BOOL INTERNAL_CALL BITMAP_Cleanup(PVOID ObjectBody);
BOOL INTERNAL_CALL BITMAPOBJ_InitBitsLock(BITMAPOBJ *pBMObj);
Modified: trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/obj... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c (original) +++ trunk/reactos/subsystems/win32/win32k/objects/gdiobj.c Wed Feb 20 01:21:39 2008 @@ -928,7 +928,6 @@ #ifdef GDI_DEBUG CaptureStackBackTace((PVOID*)GDIHandleLocker[GDI_HANDLE_GET_INDEX(hObj)], GDI_STACK_LEVELS); #endif - Object = Entry->KernelData; } else { @@ -943,8 +942,8 @@ DelayExecution(); continue; } - Object = Entry->KernelData; } + Object = Entry->KernelData; } else {