Remove typecasts PBITMAPOBJ <-> PSURFOBJ. Use GDIOBJ_ShareLockObj / _UnlockObjByPtr instead of Eng(Un)LockSurface as BITMAPOBJ_Un/LockObj. Add BASEOBJECT to the BITMAPOBJ structure.

svn path=/trunk/; revision=32428
This commit is contained in:
Timo Kreuzer 2008-02-19 22:21:39 +00:00
parent 71719dc6bd
commit 1bd028f33b
5 changed files with 69 additions and 64 deletions

View file

@ -47,7 +47,7 @@ EngCopyBits(SURFOBJ *Dest,
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 @@ EngCopyBits(SURFOBJ *Dest,
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 @@ EngCopyBits(SURFOBJ *Dest,
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);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
@ -98,17 +99,16 @@ EngCopyBits(SURFOBJ *Dest,
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);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
@ -123,9 +123,9 @@ EngCopyBits(SURFOBJ *Dest,
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
@ -157,9 +157,9 @@ EngCopyBits(SURFOBJ *Dest,
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
@ -176,9 +176,9 @@ EngCopyBits(SURFOBJ *Dest,
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
@ -214,9 +214,9 @@ EngCopyBits(SURFOBJ *Dest,
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
@ -225,9 +225,9 @@ EngCopyBits(SURFOBJ *Dest,
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);

View file

@ -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 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
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 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
return FALSE;
}
*OutputObj = EngLockSurface((HSURF)EnterLeave->OutputBitmap);
*OutputSurf = EngLockSurface((HSURF)EnterLeave->OutputBitmap);
EnterLeave->DestRect.left = 0;
EnterLeave->DestRect.top = 0;
@ -89,35 +89,35 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
ClippedDestRect.left -= SrcPoint.x;
SrcPoint.x = 0;
}
if (DestObj->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left)
if (DestSurf->sizlBitmap.cx < SrcPoint.x + ClippedDestRect.right - ClippedDestRect.left)
{
ClippedDestRect.right = ClippedDestRect.left + DestObj->sizlBitmap.cx - SrcPoint.x;
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)
if (DestSurf->sizlBitmap.cy < SrcPoint.y + ClippedDestRect.bottom - ClippedDestRect.top)
{
ClippedDestRect.bottom = ClippedDestRect.top + DestObj->sizlBitmap.cy - SrcPoint.y;
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 @@ IntEngEnter(PINTENG_ENTER_LEAVE EnterLeave,
{
Translate->x = 0;
Translate->y = 0;
*OutputObj = DestObj;
*OutputSurf = DestSurf;
}
if (NULL != *OutputObj
&& 0 != (((BITMAPOBJ*) *OutputObj)->flHooks & HOOK_SYNCHRONIZE))
if (NULL != *OutputSurf)
{
BITMAPOBJ* OutputBmp = CONTAINING_RECORD(*OutputSurf, BITMAPOBJ, SurfObj);
if (0 != (OutputBmp->flHooks & HOOK_SYNCHRONIZE))
{
if (NULL != GDIDEVFUNCS(*OutputObj).SynchronizeSurface)
if (NULL != GDIDEVFUNCS(*OutputSurf).SynchronizeSurface)
{
GDIDEVFUNCS(*OutputObj).SynchronizeSurface(*OutputObj, DestRect, 0);
GDIDEVFUNCS(*OutputSurf).SynchronizeSurface(*OutputSurf, DestRect, 0);
}
else if (STYPE_BITMAP == (*OutputObj)->iType
&& NULL != GDIDEVFUNCS(*OutputObj).Synchronize)
else if (STYPE_BITMAP == (*OutputSurf)->iType
&& NULL != GDIDEVFUNCS(*OutputSurf).Synchronize)
{
GDIDEVFUNCS(*OutputObj).Synchronize((*OutputObj)->dhpdev, DestRect);
GDIDEVFUNCS(*OutputSurf).Synchronize((*OutputSurf)->dhpdev, DestRect);
}
}
}
EnterLeave->DestObj = DestObj;
EnterLeave->OutputObj = *OutputObj;
EnterLeave->DestObj = DestSurf;
EnterLeave->OutputObj = *OutputSurf;
EnterLeave->ReadOnly = ReadOnly;
return TRUE;

View file

@ -575,7 +575,10 @@ VOID STDCALL
EngUnlockSurface(IN SURFOBJ *Surface)
{
if (Surface != NULL)
GDIOBJ_UnlockObjByPtr(GdiHandleTable, Surface);
{
BITMAPOBJ *bmp = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj);
GDIOBJ_UnlockObjByPtr(GdiHandleTable, bmp);
}
}

View file

@ -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 @@ typedef struct _BITMAPOBJ
#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);

View file

@ -928,7 +928,6 @@ GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
#ifdef GDI_DEBUG
CaptureStackBackTace((PVOID*)GDIHandleLocker[GDI_HANDLE_GET_INDEX(hObj)], GDI_STACK_LEVELS);
#endif
Object = Entry->KernelData;
}
else
{
@ -943,8 +942,8 @@ GDIOBJ_LockObj (PGDI_HANDLE_TABLE HandleTable, HGDIOBJ hObj, DWORD ExpectedType)
DelayExecution();
continue;
}
Object = Entry->KernelData;
}
Object = Entry->KernelData;
}
else
{