Exclusively lock surface bits before reading or writing them

svn path=/trunk/; revision=16143
This commit is contained in:
Gé van Geldorp 2005-06-20 08:31:48 +00:00
parent 113cab2be5
commit 59057f2e70
20 changed files with 367 additions and 187 deletions

View file

@ -11,10 +11,12 @@ typedef struct _BITMAPOBJ
SURFOBJ SurfObj;
FLONG flHooks;
FLONG flFlags;
SIZE dimension; /* For SetBitmapDimension(), do NOT use
to get width/height of bitmap, use
bitmap.bmWidth/bitmap.bmHeight for
that */
SIZE dimension; /* For SetBitmapDimension(), do NOT use
to get width/height of bitmap, use
bitmap.bmWidth/bitmap.bmHeight for
that */
PFAST_MUTEX BitsLock; /* You need to hold this lock before you touch
the actual bits in the bitmap */
/* For device-independent bitmaps: */
DIBSECTION *dib;
@ -34,6 +36,11 @@ typedef struct _BITMAPOBJ
#define BITMAPOBJ_UnlockBitmap(pBMObj) EngUnlockSurface(&pBMObj->SurfObj)
BOOL INTERNAL_CALL BITMAP_Cleanup(PVOID ObjectBody);
BOOL INTERNAL_CALL BITMAPOBJ_InitBitsLock(BITMAPOBJ *pBMObj);
#define BITMAPOBJ_LockBitmapBits(pBMObj) ExAcquireFastMutex((pBMObj)->BitsLock)
#define BITMAPOBJ_UnlockBitmapBits(pBMObj) ExReleaseFastMutex((pBMObj)->BitsLock)
void INTERNAL_CALL BITMAPOBJ_CleanupBitsLock(BITMAPOBJ *pBMObj);
INT FASTCALL BITMAPOBJ_GetWidthBytes (INT bmWidth, INT bpp);
HBITMAP FASTCALL BITMAPOBJ_CopyBitmap (HBITMAP hBitmap);
INT FASTCALL DIB_GetDIBWidthBytes (INT width, INT depth);

View file

@ -526,30 +526,30 @@ EngBitBlt(SURFOBJ *DestObj,
}
BOOL STDCALL
IntEngBitBlt(BITMAPOBJ *DestObj,
BITMAPOBJ *SourceObj,
BITMAPOBJ *MaskObj,
CLIPOBJ *ClipRegion,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
POINTL *SourcePoint,
POINTL *MaskOrigin,
BRUSHOBJ *Brush,
POINTL *BrushOrigin,
ROP4 Rop4)
IntEngBitBltEx(SURFOBJ *DestSurf,
SURFOBJ *SourceSurf,
SURFOBJ *MaskSurf,
CLIPOBJ *ClipRegion,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
POINTL *SourcePoint,
POINTL *MaskOrigin,
BRUSHOBJ *Brush,
POINTL *BrushOrigin,
ROP4 Rop4,
BOOL RemoveMouse)
{
BOOLEAN ret;
RECTL InputClippedRect;
RECTL OutputRect;
POINTL InputPoint;
BOOLEAN UsesSource;
SURFOBJ *DestSurf;
SURFOBJ *SourceSurf = SourceObj ? &SourceObj->SurfObj : NULL;
SURFOBJ *MaskSurf = MaskObj ? &MaskObj->SurfObj : NULL;
BITMAPOBJ *DestObj;
BITMAPOBJ *SourceObj = NULL;
ASSERT(DestObj);
DestSurf = &DestObj->SurfObj;
ASSERT(DestSurf);
DestObj = CONTAINING_RECORD(DestSurf, BITMAPOBJ, SurfObj);
ASSERT(DestObj);
InputClippedRect = *DestRect;
if (InputClippedRect.right < InputClippedRect.left)
@ -623,17 +623,27 @@ IntEngBitBlt(BITMAPOBJ *DestObj,
OutputRect = InputClippedRect;
}
if (UsesSource)
if (RemoveMouse)
{
MouseSafetyOnDrawStart(SourceSurf, InputPoint.x, InputPoint.y,
(InputPoint.x + abs(DestRect->right - DestRect->left)),
(InputPoint.y + abs(DestRect->bottom - DestRect->top)));
BITMAPOBJ_LockBitmapBits(DestObj);
if (UsesSource)
{
if (SourceSurf != DestSurf)
{
SourceObj = CONTAINING_RECORD(SourceSurf, BITMAPOBJ, SurfObj);
BITMAPOBJ_LockBitmapBits(SourceObj);
}
MouseSafetyOnDrawStart(SourceSurf, InputPoint.x, InputPoint.y,
(InputPoint.x + abs(DestRect->right - DestRect->left)),
(InputPoint.y + abs(DestRect->bottom - DestRect->top)));
}
MouseSafetyOnDrawStart(DestSurf, OutputRect.left, OutputRect.top,
OutputRect.right, OutputRect.bottom);
}
/* No success yet */
ret = FALSE;
MouseSafetyOnDrawStart(DestSurf, OutputRect.left, OutputRect.top,
OutputRect.right, OutputRect.bottom);
/* Call the driver's DrvBitBlt if available */
if (DestObj->flHooks & HOOK_BITBLT)
@ -651,10 +661,19 @@ IntEngBitBlt(BITMAPOBJ *DestObj,
Rop4);
}
MouseSafetyOnDrawEnd(DestSurf);
if (UsesSource)
if (RemoveMouse)
{
MouseSafetyOnDrawEnd(SourceSurf);
MouseSafetyOnDrawEnd(DestSurf);
if (UsesSource)
{
MouseSafetyOnDrawEnd(SourceSurf);
if (SourceSurf != DestSurf)
{
BITMAPOBJ_UnlockBitmapBits(SourceObj);
}
}
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
return ret;
@ -786,9 +805,9 @@ EngStretchBlt(
}
BOOL STDCALL
IntEngStretchBlt(BITMAPOBJ *DestObj,
BITMAPOBJ *SourceObj,
BITMAPOBJ *MaskObj,
IntEngStretchBlt(SURFOBJ *DestSurf,
SURFOBJ *SourceSurf,
SURFOBJ *MaskSurf,
CLIPOBJ *ClipRegion,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
@ -801,32 +820,37 @@ IntEngStretchBlt(BITMAPOBJ *DestObj,
BOOLEAN ret;
COLORADJUSTMENT ca;
POINT MaskOrigin;
SURFOBJ *DestSurf;
SURFOBJ *SourceSurf = SourceObj ? &SourceObj->SurfObj : NULL;
SURFOBJ *MaskSurf = MaskObj ? &MaskObj->SurfObj : NULL;
BITMAPOBJ *DestObj;
BITMAPOBJ *SourceObj = NULL;
ASSERT(DestObj);
DestSurf = &DestObj->SurfObj;
ASSERT(DestSurf);
DestObj = CONTAINING_RECORD(DestSurf, BITMAPOBJ, SurfObj);
ASSERT(DestObj);
if (pMaskOrigin != NULL)
{
MaskOrigin.x = pMaskOrigin->x; MaskOrigin.y = pMaskOrigin->y;
}
if (NULL != SourceSurf)
{
ASSERT(SourceRect);
MouseSafetyOnDrawStart(SourceSurf, SourceRect->left, SourceRect->top,
SourceRect->right, SourceRect->bottom);
}
/* No success yet */
ret = FALSE;
ASSERT(DestRect);
BITMAPOBJ_LockBitmapBits(DestObj);
MouseSafetyOnDrawStart(DestSurf, DestRect->left, DestRect->top,
DestRect->right, DestRect->bottom);
if (NULL != SourceSurf)
{
SourceObj = CONTAINING_RECORD(SourceSurf, BITMAPOBJ, SurfObj);
ASSERT(SourceRect);
if (SourceSurf != DestSurf)
{
BITMAPOBJ_LockBitmapBits(SourceObj);
}
MouseSafetyOnDrawStart(SourceSurf, SourceRect->left, SourceRect->top,
SourceRect->right, SourceRect->bottom);
}
/* Prepare color adjustment */
/* Call the driver's DrvStretchBlt if available */
@ -847,11 +871,16 @@ IntEngStretchBlt(BITMAPOBJ *DestObj,
&ca, BrushOrigin, DestRect, SourceRect, NULL, Mode);
}
MouseSafetyOnDrawEnd(DestSurf);
if (NULL != SourceSurf)
{
MouseSafetyOnDrawEnd(SourceSurf);
if (SourceSurf != DestSurf)
{
BITMAPOBJ_UnlockBitmapBits(SourceObj);
}
}
MouseSafetyOnDrawEnd(DestSurf);
BITMAPOBJ_UnlockBitmapBits(DestObj);
return ret;
}
@ -1147,7 +1176,7 @@ EngMaskBitBlt(SURFOBJ *DestObj,
}
BOOL STDCALL
IntEngMaskBlt(SURFOBJ *DestObj,
IntEngMaskBlt(SURFOBJ *DestSurf,
SURFOBJ *Mask,
CLIPOBJ *ClipRegion,
XLATEOBJ *DestColorTranslation,
@ -1161,6 +1190,7 @@ IntEngMaskBlt(SURFOBJ *DestObj,
BOOLEAN ret;
RECTL OutputRect;
POINTL InputPoint;
BITMAPOBJ *DestObj;
ASSERT(Mask);
@ -1187,26 +1217,30 @@ IntEngMaskBlt(SURFOBJ *DestObj,
/* No success yet */
ret = FALSE;
ASSERT(DestObj);
MouseSafetyOnDrawStart(DestObj, OutputRect.left, OutputRect.top,
ASSERT(DestSurf);
DestObj = CONTAINING_RECORD(DestSurf, BITMAPOBJ, SurfObj);
BITMAPOBJ_LockBitmapBits(DestObj);
MouseSafetyOnDrawStart(DestSurf, OutputRect.left, OutputRect.top,
OutputRect.right, OutputRect.bottom);
/* Dummy BitBlt to let driver know that it should flush its changes.
This should really be done using a call to DrvSynchronizeSurface,
but the VMware driver doesn't hook that call. */
/* FIXME: Remove the typecast! */
IntEngBitBlt((BITMAPOBJ*)DestObj, NULL, (BITMAPOBJ*)Mask, ClipRegion, DestColorTranslation,
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, R4_NOOP);
IntEngBitBltEx(DestSurf, NULL, Mask, ClipRegion, DestColorTranslation,
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin,
R4_NOOP, FALSE);
ret = EngMaskBitBlt(DestObj, Mask, ClipRegion, DestColorTranslation, SourceColorTranslation,
ret = EngMaskBitBlt(DestSurf, Mask, ClipRegion, DestColorTranslation, SourceColorTranslation,
&OutputRect, &InputPoint, MaskOrigin, Brush, BrushOrigin);
/* Dummy BitBlt to let driver know that something has changed. */
/* FIXME: Remove the typecast! */
IntEngBitBlt((BITMAPOBJ*)DestObj, NULL, (BITMAPOBJ*)Mask, ClipRegion, DestColorTranslation,
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, R4_NOOP);
IntEngBitBltEx(DestSurf, NULL, Mask, ClipRegion, DestColorTranslation,
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin,
R4_NOOP, FALSE);
MouseSafetyOnDrawEnd(DestObj);
MouseSafetyOnDrawEnd(DestSurf);
BITMAPOBJ_UnlockBitmapBits(DestObj);
return ret;
}

View file

@ -16,8 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id$
*
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* PURPOSE: GDI EngCopyBits Function
@ -44,12 +43,21 @@ EngCopyBits(SURFOBJ *Dest,
RECT_ENUM RectEnum;
BOOL EnumMore;
BLTINFO BltInfo;
BITMAPOBJ *DestObj = NULL;
BITMAPOBJ *SourceObj;
ASSERT(Dest != NULL && Source != NULL && DestRect != NULL && SourcePoint != NULL);
SourceObj = CONTAINING_RECORD(Source, BITMAPOBJ, SurfObj);
BITMAPOBJ_LockBitmapBits(SourceObj);
MouseSafetyOnDrawStart(Source, SourcePoint->x, SourcePoint->y,
(SourcePoint->x + abs(DestRect->right - DestRect->left)),
(SourcePoint->y + abs(DestRect->bottom - DestRect->top)));
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,
@ -71,7 +79,12 @@ EngCopyBits(SURFOBJ *Dest,
Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return ret;
}
@ -88,20 +101,29 @@ EngCopyBits(SURFOBJ *Dest,
Dest, Source, Clip, ColorTranslation, DestRect, SourcePoint);
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return ret;
}
}
// If CopyBits wasn't hooked, BitBlt must be
/* FIXME: Remove the typecast! */
ret = IntEngBitBlt((BITMAPOBJ*)Dest, (BITMAPOBJ*)Source,
ret = IntEngBitBlt(Dest, Source,
NULL, Clip, ColorTranslation, DestRect, SourcePoint,
NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return ret;
}
@ -130,7 +152,12 @@ EngCopyBits(SURFOBJ *Dest,
DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return(TRUE);
@ -144,7 +171,12 @@ EngCopyBits(SURFOBJ *Dest,
DibFunctionsForBitmapFormat[Dest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return(TRUE);
@ -177,13 +209,23 @@ EngCopyBits(SURFOBJ *Dest,
} while(EnumMore);
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return(TRUE);
}
MouseSafetyOnDrawEnd(Dest);
if (Dest != Source)
{
BITMAPOBJ_UnlockBitmapBits(DestObj);
}
MouseSafetyOnDrawEnd(Source);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
return FALSE;
}

View file

@ -516,7 +516,7 @@ EngGradientFill(
BOOL STDCALL
IntEngGradientFill(
IN BITMAPOBJ *pboDest,
IN SURFOBJ *psoDest,
IN CLIPOBJ *pco,
IN XLATEOBJ *pxlo,
IN TRIVERTEX *pVertex,
@ -528,13 +528,14 @@ IntEngGradientFill(
IN ULONG ulMode)
{
BOOL Ret;
SURFOBJ *psoDest;
ASSERT(pboDest);
BITMAPOBJ *pboDest;
ASSERT(psoDest);
ASSERT(pco);
psoDest = &pboDest->SurfObj;
ASSERT(psoDest);
pboDest = CONTAINING_RECORD(psoDest, BITMAPOBJ, SurfObj);
ASSERT(pboDest);
BITMAPOBJ_LockBitmapBits(pboDest);
MouseSafetyOnDrawStart(
psoDest,
pco->rclBounds.left,
@ -552,5 +553,7 @@ IntEngGradientFill(
Ret = EngGradientFill(psoDest, pco, pxlo, pVertex, nVertex, pMesh, nMesh, prclExtents,
pptlDitherOrg, ulMode);
MouseSafetyOnDrawEnd(psoDest);
BITMAPOBJ_UnlockBitmapBits(pboDest);
return Ret;
}

View file

@ -485,7 +485,7 @@ EngLineTo(SURFOBJ *DestObj,
}
BOOL STDCALL
IntEngLineTo(BITMAPOBJ *DestObj,
IntEngLineTo(SURFOBJ *DestSurf,
CLIPOBJ *ClipObj,
BRUSHOBJ *Brush,
LONG x1,
@ -496,13 +496,13 @@ IntEngLineTo(BITMAPOBJ *DestObj,
MIX Mix)
{
BOOLEAN ret;
SURFOBJ *DestSurf;
BITMAPOBJ *DestObj;
PGDIBRUSHINST GdiBrush;
RECTL b;
ASSERT(DestObj);
DestSurf = &DestObj->SurfObj;
ASSERT(DestSurf);
DestObj = CONTAINING_RECORD(DestSurf, BITMAPOBJ, SurfObj);
ASSERT(DestObj);
GdiBrush = CONTAINING_RECORD(
Brush,
@ -543,6 +543,8 @@ IntEngLineTo(BITMAPOBJ *DestObj,
b.bottom = max(y1, y2);
if (b.left == b.right) b.right++;
if (b.top == b.bottom) b.bottom++;
BITMAPOBJ_LockBitmapBits(DestObj);
MouseSafetyOnDrawStart(DestSurf, x1, y1, x2, y2);
if (DestObj->flHooks & HOOK_LINETO)
@ -565,12 +567,13 @@ IntEngLineTo(BITMAPOBJ *DestObj,
}
MouseSafetyOnDrawEnd(DestSurf);
BITMAPOBJ_UnlockBitmapBits(DestObj);
return ret;
}
BOOL STDCALL
IntEngPolyline(BITMAPOBJ *DestObj,
IntEngPolyline(SURFOBJ *DestSurf,
CLIPOBJ *Clip,
BRUSHOBJ *Brush,
CONST LPPOINT pt,
@ -588,7 +591,7 @@ IntEngPolyline(BITMAPOBJ *DestObj,
rect.top = min(pt[i-1].y, pt[i].y);
rect.right = max(pt[i-1].x, pt[i].x);
rect.bottom = max(pt[i-1].y, pt[i].y);
ret = IntEngLineTo(DestObj,
ret = IntEngLineTo(DestSurf,
Clip,
Brush,
pt[i-1].x,

View file

@ -177,8 +177,9 @@ IntHideMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
{
if((MaskSurface = EngLockSurface(pgp->MaskSurface)))
{
EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
IntEngBitBltEx(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL,
ROP3_TO_ROP4(SRCCOPY), FALSE);
EngUnlockSurface(MaskSurface);
}
EngUnlockSurface(SaveSurface);
@ -230,8 +231,9 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
pgp->Size.cy,
DestSurface->sizlBitmap.cy - pt.y);
EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
&DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
IntEngBitBltEx(SaveSurface, DestSurface, NULL, NULL, NULL,
&DestRect, &SrcPoint, NULL, NULL, NULL,
ROP3_TO_ROP4(SRCCOPY), FALSE);
EngUnlockSurface(SaveSurface);
}
@ -266,18 +268,21 @@ IntShowMousePointer(GDIDEVICE *ppdev, SURFOBJ *DestSurface)
{
if((ColorSurf = EngLockSurface(pgp->ColorSurface)))
{
EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, pgp->XlateObject,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL, R4_MASK);
IntEngBitBltEx(DestSurface, ColorSurf, MaskSurf, NULL,
pgp->XlateObject, &DestRect, &SrcPoint, &SrcPoint,
NULL, NULL, R4_MASK, FALSE);
EngUnlockSurface(ColorSurf);
}
}
else
{
EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCAND));
IntEngBitBltEx(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL,
ROP3_TO_ROP4(SRCAND), FALSE);
SrcPoint.y += pgp->Size.cy;
EngBitBlt(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL, ROP3_TO_ROP4(SRCINVERT));
IntEngBitBltEx(DestSurface, MaskSurf, NULL, NULL, pgp->XlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL,
ROP3_TO_ROP4(SRCINVERT), FALSE);
}
EngUnlockSurface(MaskSurf);
}
@ -523,4 +528,25 @@ EngMovePointer(
}
VOID STDCALL
IntEngMovePointer(
IN SURFOBJ *SurfObj,
IN LONG x,
IN LONG y,
IN RECTL *prcl)
{
BITMAPOBJ *BitmapObj = CONTAINING_RECORD(SurfObj, BITMAPOBJ, SurfObj);
BITMAPOBJ_LockBitmapBits(BitmapObj);
if (GDIDEV(SurfObj)->Pointer.MovePointer)
{
GDIDEV(SurfObj)->Pointer.MovePointer(SurfObj, x, y, prcl);
}
else
{
EngMovePointer(SurfObj, x, y, prcl);
}
BITMAPOBJ_UnlockBitmapBits(BitmapObj);
}
/* EOF */

View file

@ -33,9 +33,12 @@ BOOL STDCALL FillSolid(SURFOBJ *Surface, PRECTL pRect, ULONG iColor)
{
LONG y;
ULONG LineWidth;
BITMAPOBJ *BitmapObj;
ASSERT ( Surface );
ASSERT ( pRect );
BitmapObj = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj);
BITMAPOBJ_LockBitmapBits(BitmapObj);
MouseSafetyOnDrawStart(Surface, pRect->left, pRect->top, pRect->right, pRect->bottom);
LineWidth = pRect->right - pRect->left;
DPRINT(" LineWidth: %d, top: %d, bottom: %d\n", LineWidth, pRect->top, pRect->bottom);
@ -45,6 +48,7 @@ BOOL STDCALL FillSolid(SURFOBJ *Surface, PRECTL pRect, ULONG iColor)
Surface, pRect->left, pRect->right, y, iColor);
}
MouseSafetyOnDrawEnd(Surface);
BITMAPOBJ_UnlockBitmapBits(BitmapObj);
return TRUE;
}
@ -111,13 +115,13 @@ EngPaint(IN SURFOBJ *Surface,
}
BOOL STDCALL
IntEngPaint(IN BITMAPOBJ *BitmapObj,
IntEngPaint(IN SURFOBJ *Surface,
IN CLIPOBJ *ClipRegion,
IN BRUSHOBJ *Brush,
IN POINTL *BrushOrigin,
IN MIX Mix)
{
SURFOBJ *Surface = &BitmapObj->SurfObj;
BITMAPOBJ *BitmapObj = CONTAINING_RECORD(Surface, BITMAPOBJ, SurfObj);
BOOL ret;
DPRINT("SurfGDI type: %d\n", Surface->iType);
@ -125,6 +129,7 @@ IntEngPaint(IN BITMAPOBJ *BitmapObj,
if((Surface->iType!=STYPE_BITMAP) && (BitmapObj->flHooks & HOOK_PAINT))
{
// Call the driver's DrvPaint
BITMAPOBJ_LockBitmapBits(BitmapObj);
MouseSafetyOnDrawStart(Surface, ClipRegion->rclBounds.left,
ClipRegion->rclBounds.top, ClipRegion->rclBounds.right,
ClipRegion->rclBounds.bottom);
@ -132,6 +137,7 @@ IntEngPaint(IN BITMAPOBJ *BitmapObj,
ret = GDIDEVFUNCS(Surface).Paint(
Surface, ClipRegion, Brush, BrushOrigin, Mix);
MouseSafetyOnDrawEnd(Surface);
BITMAPOBJ_UnlockBitmapBits(BitmapObj);
return ret;
}
return EngPaint( Surface, ClipRegion, Brush, BrushOrigin, Mix );

View file

@ -79,6 +79,33 @@ ULONG FASTCALL BitmapFormat(WORD Bits, DWORD Compression)
}
}
BOOL INTERNAL_CALL
BITMAPOBJ_InitBitsLock(BITMAPOBJ *BitmapObj)
{
BitmapObj->BitsLock = ExAllocatePoolWithTag(NonPagedPool,
sizeof(FAST_MUTEX),
TAG_BITMAPOBJ);
if (NULL == BitmapObj->BitsLock)
{
return FALSE;
}
ExInitializeFastMutex(BitmapObj->BitsLock);
return TRUE;
}
void INTERNAL_CALL
BITMAPOBJ_CleanupBitsLock(BITMAPOBJ *BitmapObj)
{
if (NULL != BitmapObj->BitsLock)
{
ExFreePoolWithTag(BitmapObj->BitsLock, TAG_BITMAPOBJ);
BitmapObj->BitsLock = NULL;
}
}
/*
* @implemented
*/
@ -232,6 +259,12 @@ IntCreateBitmap(IN SIZEL Size,
return 0;
BitmapObj = BITMAPOBJ_LockBitmap(NewBitmap);
if (! BITMAPOBJ_InitBitsLock(BitmapObj))
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
BITMAPOBJ_FreeBitmap(NewBitmap);
return 0;
}
SurfObj = &BitmapObj->SurfObj;
if (Format == BMF_4RLE)
@ -357,11 +390,17 @@ EngCreateDeviceSurface(IN DHSURF dhsurf,
if (NewSurface == NULL)
return 0;
GDIOBJ_SetOwnership(NewSurface, NULL);
BitmapObj = BITMAPOBJ_LockBitmap(NewSurface);
if (! BITMAPOBJ_InitBitsLock(BitmapObj))
{
BITMAPOBJ_UnlockBitmap(BitmapObj);
BITMAPOBJ_FreeBitmap(NewSurface);
return 0;
}
SurfObj = &BitmapObj->SurfObj;
GDIOBJ_SetOwnership(NewSurface, NULL);
SurfObj->dhsurf = dhsurf;
SurfObj->hsurf = NewSurface;
SurfObj->sizlBitmap = Size;

View file

@ -193,8 +193,8 @@ EngTransparentBlt(SURFOBJ *Dest,
}
BOOL FASTCALL
IntEngTransparentBlt(BITMAPOBJ *DestObj,
BITMAPOBJ *SourceObj,
IntEngTransparentBlt(SURFOBJ *DestSurf,
SURFOBJ *SourceSurf,
CLIPOBJ *Clip,
XLATEOBJ *ColorTranslation,
PRECTL DestRect,
@ -204,18 +204,18 @@ IntEngTransparentBlt(BITMAPOBJ *DestObj,
{
BOOL Ret;
RECTL OutputRect, InputClippedRect;
SURFOBJ *DestSurf;
SURFOBJ *SourceSurf;
ASSERT(DestObj);
ASSERT(SourceObj);
ASSERT(DestRect);
DestSurf = &DestObj->SurfObj;
SourceSurf = &SourceObj->SurfObj;
BITMAPOBJ *DestObj;
BITMAPOBJ *SourceObj;
ASSERT(DestSurf);
ASSERT(SourceSurf);
ASSERT(DestRect);
DestObj = CONTAINING_RECORD(DestSurf, BITMAPOBJ, SurfObj);
SourceObj = CONTAINING_RECORD(SourceSurf, BITMAPOBJ, SurfObj);
ASSERT(DestObj);
ASSERT(SourceObj);
InputClippedRect = *DestRect;
if(InputClippedRect.right < InputClippedRect.left)
@ -249,9 +249,11 @@ IntEngTransparentBlt(BITMAPOBJ *DestObj,
if(SourceSurf != DestSurf)
{
BITMAPOBJ_LockBitmapBits(SourceObj);
MouseSafetyOnDrawStart(SourceSurf, SourceRect->left, SourceRect->top,
SourceRect->right, SourceRect->bottom);
}
BITMAPOBJ_LockBitmapBits(DestObj);
MouseSafetyOnDrawStart(DestSurf, OutputRect.left, OutputRect.top,
OutputRect.right, OutputRect.bottom);
@ -271,9 +273,11 @@ IntEngTransparentBlt(BITMAPOBJ *DestObj,
}
MouseSafetyOnDrawEnd(DestSurf);
BITMAPOBJ_UnlockBitmapBits(DestObj);
if(SourceSurf != DestSurf)
{
MouseSafetyOnDrawEnd(SourceSurf);
BITMAPOBJ_UnlockBitmapBits(SourceObj);
}
return Ret;

View file

@ -43,7 +43,7 @@ IntEngCleanupDriverObjs(struct _EPROCESS *Process,
PW32PROCESS Win32Process);
BOOL STDCALL
IntEngLineTo(BITMAPOBJ *Surface,
IntEngLineTo(SURFOBJ *Surface,
CLIPOBJ *Clip,
BRUSHOBJ *Brush,
LONG x1,
@ -54,22 +54,29 @@ IntEngLineTo(BITMAPOBJ *Surface,
MIX mix);
BOOL STDCALL
IntEngBitBlt(BITMAPOBJ *DestObj,
BITMAPOBJ *SourceObj,
BITMAPOBJ *Mask,
CLIPOBJ *ClipRegion,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
POINTL *SourcePoint,
POINTL *MaskOrigin,
BRUSHOBJ *Brush,
POINTL *BrushOrigin,
ROP4 rop4);
IntEngBitBltEx(SURFOBJ *DestObj,
SURFOBJ *SourceObj,
SURFOBJ *Mask,
CLIPOBJ *ClipRegion,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
POINTL *SourcePoint,
POINTL *MaskOrigin,
BRUSHOBJ *Brush,
POINTL *BrushOrigin,
ROP4 Rop4,
BOOL RemoveMouse);
#define IntEngBitBlt(DestObj, SourceObj, Mask, ClipRegion, ColorTranslation, \
DestRect, SourcePoint, MaskOrigin, Brush, BrushOrigin, \
Rop4) \
IntEngBitBltEx((DestObj), (SourceObj), (Mask), (ClipRegion), \
(ColorTranslation), (DestRect), (SourcePoint), \
(MaskOrigin), (Brush), (BrushOrigin), (Rop4), TRUE)
BOOL STDCALL
IntEngStretchBlt(BITMAPOBJ *DestObj,
BITMAPOBJ *SourceObj,
BITMAPOBJ *Mask,
IntEngStretchBlt(SURFOBJ *DestObj,
SURFOBJ *SourceObj,
SURFOBJ *Mask,
CLIPOBJ *ClipRegion,
XLATEOBJ *ColorTranslation,
RECTL *DestRect,
@ -80,7 +87,7 @@ IntEngStretchBlt(BITMAPOBJ *DestObj,
ULONG Mode);
BOOL STDCALL
IntEngGradientFill(BITMAPOBJ *psoDest,
IntEngGradientFill(SURFOBJ *psoDest,
CLIPOBJ *pco,
XLATEOBJ *pxlo,
TRIVERTEX *pVertex,
@ -109,7 +116,7 @@ IntEngCreateSrcMonoXlate(HPALETTE PaletteDest,
ULONG BackgroundColor);
BOOL STDCALL
IntEngPolyline(BITMAPOBJ *DestSurf,
IntEngPolyline(SURFOBJ *DestSurf,
CLIPOBJ *Clip,
BRUSHOBJ *Brush,
CONST LPPOINT pt,
@ -131,8 +138,8 @@ ClipobjToSpans(PSPAN *Spans,
PRECTL Boundary);
BOOL FASTCALL
IntEngTransparentBlt(BITMAPOBJ *Dest,
BITMAPOBJ *Source,
IntEngTransparentBlt(SURFOBJ *Dest,
SURFOBJ *Source,
CLIPOBJ *Clip,
XLATEOBJ *ColorTranslation,
PRECTL DestRect,
@ -141,10 +148,17 @@ IntEngTransparentBlt(BITMAPOBJ *Dest,
ULONG Reserved);
BOOL STDCALL
IntEngPaint(IN BITMAPOBJ *Surface,
IntEngPaint(IN SURFOBJ *Surface,
IN CLIPOBJ *ClipRegion,
IN BRUSHOBJ *Brush,
IN POINTL *BrushOrigin,
IN MIX Mix);
VOID STDCALL
IntEngMovePointer(IN SURFOBJ *pso,
IN LONG x,
IN LONG y,
IN RECTL *prcl);
#endif /* _WIN32K_INTENG_H */

View file

@ -51,6 +51,7 @@
#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 */
#define TAG_BITMAPOBJ TAG('B', 'M', 'P', 'O') /* bitmap object */
/* misc */
#define TAG_DRIVER TAG('G', 'D', 'R', 'V') /* video drivers */

View file

@ -142,10 +142,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
if (NULL != CurInfo->CurrentCursorObject && CurInfo->ShowingCursor)
{
/* Remove the cursor if it was displayed */
if (GDIDEV(SurfObj)->Pointer.MovePointer)
GDIDEV(SurfObj)->Pointer.MovePointer(SurfObj, -1, -1, &GDIDEV(SurfObj)->Pointer.Exclude);
else
EngMovePointer(SurfObj, -1, -1, &GDIDEV(SurfObj)->Pointer.Exclude);
IntEngMovePointer(SurfObj, -1, -1, &GDIDEV(SurfObj)->Pointer.Exclude);
}
GDIDEV(SurfObj)->Pointer.Status = SPS_ACCEPT_NOEXCLUDE;
@ -266,7 +263,7 @@ IntSetCursor(PWINSTATION_OBJECT WinStaObject, PCURICON_OBJECT NewCursor,
GDIDEV(SurfObj)->Pointer.Pos.y,
&(GDIDEV(SurfObj)->Pointer.Exclude),
SPS_CHANGE);
GDIDEV(SurfObj)->Pointer.MovePointer = EngMovePointer;
GDIDEV(SurfObj)->Pointer.MovePointer = NULL;
}
else
{

View file

@ -959,12 +959,7 @@ IntMouseInput(MOUSEINPUT *mi)
{
SurfObj = &BitmapObj->SurfObj;
if (GDIDEV(SurfObj)->Pointer.MovePointer)
{
GDIDEV(SurfObj)->Pointer.MovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
} else {
EngMovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
}
IntEngMovePointer(SurfObj, MousePos.x, MousePos.y, &(GDIDEV(SurfObj)->Pointer.Exclude));
/* Only now, update the info in the GDIDEVICE, so EngMovePointer can
* use the old values to move the pointer image */
GDIDEV(SurfObj)->Pointer.Pos.x = MousePos.x;

View file

@ -213,8 +213,10 @@ NtGdiBitBlt(
}
/* Perform the bitblt operation */
Status = IntEngBitBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip, XlateObj,
&DestRect, &SourcePoint, NULL, BrushObj ? &BrushInst.BrushObject : NULL,
Status = IntEngBitBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj, NULL,
DCDest->CombinedClip, XlateObj, &DestRect,
&SourcePoint, NULL,
BrushObj ? &BrushInst.BrushObject : NULL,
&BrushOrigin, ROP3_TO_ROP4(ROP));
if (UsesSource && XlateObj != NULL)
@ -371,7 +373,8 @@ NtGdiTransparentBlt(
goto done;
}
Ret = IntEngTransparentBlt(BitmapDest, BitmapSrc, DCDest->CombinedClip, XlateObj, &rcDest, &rcSrc,
Ret = IntEngTransparentBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
DCDest->CombinedClip, XlateObj, &rcDest, &rcSrc,
TransparentColor, 0);
done:
@ -469,6 +472,12 @@ BITMAP_Cleanup(PVOID ObjectBody)
}
}
if (NULL != pBmp->BitsLock)
{
ExFreePoolWithTag(pBmp->BitsLock, TAG_BITMAPOBJ);
pBmp->BitsLock = NULL;
}
return TRUE;
}
@ -1246,8 +1255,10 @@ NtGdiStretchBlt(
}
/* Perform the bitblt operation */
Status = IntEngStretchBlt(BitmapDest, BitmapSrc, NULL, DCDest->CombinedClip,
XlateObj, &DestRect, &SourceRect, NULL, NULL, NULL, COLORONCOLOR);
Status = IntEngStretchBlt(&BitmapDest->SurfObj, &BitmapSrc->SurfObj,
NULL, DCDest->CombinedClip, XlateObj,
&DestRect, &SourceRect, NULL, NULL, NULL,
COLORONCOLOR);
if (UsesSource)
EngDeleteXlate(XlateObj);

View file

@ -482,7 +482,7 @@ IntPatBlt(
IntGdiInitBrushInstance(&BrushInst, BrushObj, dc->XlateBrush);
ret = IntEngBitBlt(
BitmapObj,
&BitmapObj->SurfObj,
NULL,
NULL,
dc->CombinedClip,

View file

@ -16,26 +16,25 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id$ */
#include <w32k.h>
/*
* a couple macros to fill a single pixel or a line
*/
#define PUTPIXEL(x,y,BrushInst) \
ret = ret && IntEngLineTo(BitmapObj, \
dc->CombinedClip, \
&BrushInst.BrushObject, \
x, y, (x)+1, y, \
&RectBounds, \
ret = ret && IntEngLineTo(&BitmapObj->SurfObj, \
dc->CombinedClip, \
&BrushInst.BrushObject, \
x, y, (x)+1, y, \
&RectBounds, \
ROP2_TO_MIX(dc->w.ROPmode));
#define PUTLINE(x1,y1,x2,y2,BrushInst) \
ret = ret && IntEngLineTo(BitmapObj, \
dc->CombinedClip, \
&BrushInst.BrushObject, \
x1, y1, x2, y2, \
&RectBounds, \
ret = ret && IntEngLineTo(&BitmapObj->SurfObj, \
dc->CombinedClip, \
&BrushInst.BrushObject, \
x1, y1, x2, y2, \
&RectBounds, \
ROP2_TO_MIX(dc->w.ROPmode));
BOOL FASTCALL
@ -116,7 +115,7 @@ IntGdiPolygon(PDC dc,
To = UnsafePoints[CurrentPoint + 1];
//DPRINT("Polygon Making line from (%d,%d) to (%d,%d)\n", From.x, From.y, To.x, To.y );
ret = IntEngLineTo(BitmapObj,
ret = IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
&PenBrushInst.BrushObject,
From.x,
@ -994,7 +993,7 @@ IntRectangle(PDC dc,
if (!(FillBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
IntGdiInitBrushInstance(&FillBrushInst, FillBrushObj, dc->XlateBrush);
ret = IntEngBitBlt(BitmapObj,
ret = IntEngBitBlt(&BitmapObj->SurfObj,
NULL,
NULL,
dc->CombinedClip,
@ -1028,28 +1027,28 @@ IntRectangle(PDC dc,
if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
Mix = ROP2_TO_MIX(dc->w.ROPmode);
ret = ret && IntEngLineTo(BitmapObj,
ret = ret && IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
&PenBrushInst.BrushObject,
LeftRect, TopRect, RightRect, TopRect,
&DestRect, // Bounding rectangle
Mix);
ret = ret && IntEngLineTo(BitmapObj,
ret = ret && IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
&PenBrushInst.BrushObject,
RightRect, TopRect, RightRect, BottomRect,
&DestRect, // Bounding rectangle
Mix);
ret = ret && IntEngLineTo(BitmapObj,
ret = ret && IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
&PenBrushInst.BrushObject,
RightRect, BottomRect, LeftRect, BottomRect,
&DestRect, // Bounding rectangle
Mix);
ret = ret && IntEngLineTo(BitmapObj,
ret = ret && IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
&PenBrushInst.BrushObject,
LeftRect, BottomRect, LeftRect, TopRect,
@ -1485,7 +1484,7 @@ IntGdiGradientFill(
XlateObj = (XLATEOBJ*)IntEngCreateXlate(Mode, PAL_RGB, dc->w.hPalette, NULL);
ASSERT(XlateObj);
Ret = IntEngGradientFill(BitmapObj,
Ret = IntEngGradientFill(&BitmapObj->SurfObj,
dc->CombinedClip,
XlateObj,
pVertex,

View file

@ -16,7 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id$ */
#include <w32k.h>
// Some code from the WINE project source (www.winehq.com)
@ -104,7 +103,7 @@ IntGdiLineTo(DC *dc,
if (!(PenBrushObj->flAttrs & GDIBRUSH_IS_NULL))
{
IntGdiInitBrushInstance(&PenBrushInst, PenBrushObj, dc->XlatePen);
Ret = IntEngLineTo(BitmapObj,
Ret = IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
&PenBrushInst.BrushObject,
Points[0].x, Points[0].y,
@ -226,9 +225,9 @@ IntGdiPolyline(DC *dc,
}
IntGdiInitBrushInstance(&PenBrushInst, PenBrushObj, dc->XlatePen);
Ret = IntEngPolyline(BitmapObj, dc->CombinedClip,
&PenBrushInst.BrushObject, Points, Count,
ROP2_TO_MIX(dc->w.ROPmode));
Ret = IntEngPolyline(&BitmapObj->SurfObj, dc->CombinedClip,
&PenBrushInst.BrushObject, Points, Count,
ROP2_TO_MIX(dc->w.ROPmode));
BITMAPOBJ_UnlockBitmap(BitmapObj);
EngFreeMem(Points);

View file

@ -422,15 +422,15 @@ POLYGONFILL_FillScanLineAlternate(
BoundRect.right = x2;
//DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine);
IntEngLineTo( BitmapObj,
dc->CombinedClip,
BrushObj,
x1,
ScanLine,
x2,
ScanLine,
&BoundRect, // Bounding rectangle
RopMode); // MIX
IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
BrushObj,
x1,
ScanLine,
x2,
ScanLine,
&BoundRect, // Bounding rectangle
RopMode); // MIX
}
pLeft = pRight->pNext;
pRight = pLeft ? pLeft->pNext : NULL;
@ -495,15 +495,15 @@ POLYGONFILL_FillScanLineWinding(
BoundRect.right = x2;
//DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine);
IntEngLineTo( BitmapObj,
dc->CombinedClip,
BrushObj,
x1,
ScanLine,
x2,
ScanLine,
&BoundRect, // Bounding rectangle
RopMode); // MIX
IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
BrushObj,
x1,
ScanLine,
x2,
ScanLine,
&BoundRect, // Bounding rectangle
RopMode); // MIX
x1 = newx1;
x2 = newx2;
@ -518,15 +518,15 @@ POLYGONFILL_FillScanLineWinding(
BoundRect.right = x2;
//DPRINT("Fill Line (%d, %d) to (%d, %d)\n",x1, ScanLine, x2, ScanLine);
IntEngLineTo( BitmapObj,
dc->CombinedClip,
BrushObj,
x1,
ScanLine,
x2,
ScanLine,
&BoundRect, // Bounding rectangle
RopMode); // MIX
IntEngLineTo(&BitmapObj->SurfObj,
dc->CombinedClip,
BrushObj,
x1,
ScanLine,
x2,
ScanLine,
&BoundRect, // Bounding rectangle
RopMode); // MIX
}
//When the fill mode is ALTERNATE, GDI fills the area between odd-numbered and

View file

@ -2501,7 +2501,7 @@ NtGdiPaintRgn(HDC hDC,
BitmapObj = BITMAPOBJ_LockBitmap(dc->w.hBitmap);
/* FIXME - Handle BitmapObj == NULL !!!! */
bRet = IntEngPaint(BitmapObj,
bRet = IntEngPaint(&BitmapObj->SurfObj,
ClipRegion,
&BrushInst.BrushObject,
&BrushOrigin,

View file

@ -1482,7 +1482,7 @@ NtGdiExtTextOut(
DC *dc;
SURFOBJ *SurfObj;
BITMAPOBJ *BitmapObj;
BITMAPOBJ *BitmapObj = NULL;
int error, glyph_index, n, i;
FT_Face face;
FT_GlyphSlot glyph;
@ -1628,7 +1628,7 @@ NtGdiExtTextOut(
DestRect.right = SpecifiedDestRect.right + dc->w.DCOrgX;
DestRect.bottom = SpecifiedDestRect.bottom + dc->w.DCOrgY;
IntEngBitBlt(
BitmapObj,
&BitmapObj->SurfObj,
NULL,
NULL,
dc->CombinedClip,
@ -1846,7 +1846,7 @@ NtGdiExtTextOut(
DestRect.top = TextTop + yoff - ((face->size->metrics.ascender + 32) >> 6);
DestRect.bottom = TextTop + yoff + ((32 - face->size->metrics.descender) >> 6);
IntEngBitBlt(
BitmapObj,
&BitmapObj->SurfObj,
NULL,
NULL,
dc->CombinedClip,