*/
/* INCLUDES ******************************************************************/
-#include <w32k.h>
+#include <win32k.h>
#define NDEBUG
#include <debug.h>
*/
INT INTERNAL_CALL
MouseSafetyOnDrawStart(
- SURFOBJ *pso,
+ PPDEVOBJ ppdev,
LONG HazardX1,
LONG HazardY1,
LONG HazardX2,
LONG HazardY2)
{
LONG tmp;
- PDEVOBJ *ppdev;
GDIPOINTER *pgp;
- ASSERT(pso != NULL);
-
- ppdev = GDIDEV(pso);
- if (ppdev == NULL)
- {
- return FALSE;
- }
+ ASSERT(ppdev != NULL);
+ ASSERT(ppdev->pSurface != NULL);
pgp = &ppdev->Pointer;
}
if (pgp->Exclude.right >= HazardX1
- && pgp->Exclude.left <= HazardX2
- && pgp->Exclude.bottom >= HazardY1
- && pgp->Exclude.top <= HazardY2)
+ && pgp->Exclude.left <= HazardX2
+ && pgp->Exclude.bottom >= HazardY1
+ && pgp->Exclude.top <= HazardY2)
{
ppdev->SafetyRemoveLevel = ppdev->SafetyRemoveCount;
- ppdev->pfnMovePointer(pso, -1, -1, NULL);
+ ppdev->pfnMovePointer(&ppdev->pSurface->SurfObj, -1, -1, NULL);
}
return(TRUE);
*/
INT INTERNAL_CALL
MouseSafetyOnDrawEnd(
- SURFOBJ *pso)
+ PPDEVOBJ ppdev)
{
- PDEVOBJ *ppdev;
GDIPOINTER *pgp;
- ASSERT(pso != NULL);
-
- ppdev = (PDEVOBJ*)pso->hdev;
-
- if (ppdev == NULL)
- {
- return(FALSE);
- }
+ ASSERT(ppdev != NULL);
+ ASSERT(ppdev->pSurface != NULL);
pgp = &ppdev->Pointer;
return FALSE;
}
- ppdev->pfnMovePointer(pso, gpsi->ptCursor.x, gpsi->ptCursor.y, &pgp->Exclude);
+ ppdev->pfnMovePointer(&ppdev->pSurface->SurfObj,
+ gpsi->ptCursor.x,
+ gpsi->ptCursor.y,
+ &pgp->Exclude);
ppdev->SafetyRemoveLevel = 0;
ptlSave.x = rclDest.left - pt.x;
ptlSave.y = rclDest.top - pt.y;
- IntEngBitBltEx(psoDest,
- &pgp->psurfSave->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclDest,
- &ptlSave,
- &ptlSave,
- NULL,
- NULL,
- ROP3_TO_ROP4(SRCCOPY),
- FALSE);
+ IntEngBitBlt(psoDest,
+ &pgp->psurfSave->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclDest,
+ &ptlSave,
+ &ptlSave,
+ NULL,
+ NULL,
+ ROP3_TO_ROP4(SRCCOPY));
}
VOID
pgp->Enabled = TRUE;
+ /* Check if we have any mouse pointer */
+ if (!pgp->psurfSave) return;
+
/* Calculate pointer coordinates */
pt.x = ppdev->ptlPointer.x - pgp->HotSpot.x;
pt.y = ppdev->ptlPointer.y - pgp->HotSpot.y;
rclPointer.bottom = min(pgp->Size.cy, psoDest->sizlBitmap.cy - pt.y);
/* Copy the pixels under the cursor to temporary surface. */
- IntEngBitBltEx(&pgp->psurfSave->SurfObj,
- psoDest,
- NULL,
- NULL,
- NULL,
- &rclPointer,
- (POINTL*)&rclSurf,
- NULL,
- NULL,
- NULL,
- ROP3_TO_ROP4(SRCCOPY),
- FALSE);
+ IntEngBitBlt(&pgp->psurfSave->SurfObj,
+ psoDest,
+ NULL,
+ NULL,
+ NULL,
+ &rclPointer,
+ (POINTL*)&rclSurf,
+ NULL,
+ NULL,
+ NULL,
+ ROP3_TO_ROP4(SRCCOPY));
/* Blt the pointer on the screen. */
if (pgp->psurfColor)
{
- IntEngBitBltEx(psoDest,
- &pgp->psurfMask->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclSurf,
- (POINTL*)&rclPointer,
- NULL,
- NULL,
- NULL,
- ROP3_TO_ROP4(SRCAND),
- FALSE);
-
- IntEngBitBltEx(psoDest,
- &pgp->psurfColor->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclSurf,
- (POINTL*)&rclPointer,
- NULL,
- NULL,
- NULL,
- ROP3_TO_ROP4(SRCINVERT),
- FALSE);
+ IntEngBitBlt(psoDest,
+ &pgp->psurfMask->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclSurf,
+ (POINTL*)&rclPointer,
+ NULL,
+ NULL,
+ NULL,
+ ROP3_TO_ROP4(SRCAND));
+
+ IntEngBitBlt(psoDest,
+ &pgp->psurfColor->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclSurf,
+ (POINTL*)&rclPointer,
+ NULL,
+ NULL,
+ NULL,
+ ROP3_TO_ROP4(SRCINVERT));
}
else
{
- IntEngBitBltEx(psoDest,
- &pgp->psurfMask->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclSurf,
- (POINTL*)&rclPointer,
- NULL,
- NULL,
- NULL,
- ROP3_TO_ROP4(SRCAND),
- FALSE);
+ IntEngBitBlt(psoDest,
+ &pgp->psurfMask->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclSurf,
+ (POINTL*)&rclPointer,
+ NULL,
+ NULL,
+ NULL,
+ ROP3_TO_ROP4(SRCAND));
rclPointer.top += pgp->Size.cy;
- IntEngBitBltEx(psoDest,
- &pgp->psurfMask->SurfObj,
- NULL,
- NULL,
- NULL,
- &rclSurf,
- (POINTL*)&rclPointer,
- NULL,
- NULL,
- NULL,
- ROP3_TO_ROP4(SRCINVERT),
- FALSE);
+ IntEngBitBlt(psoDest,
+ &pgp->psurfMask->SurfObj,
+ NULL,
+ NULL,
+ NULL,
+ &rclSurf,
+ (POINTL*)&rclPointer,
+ NULL,
+ NULL,
+ NULL,
+ ROP3_TO_ROP4(SRCINVERT));
}
}
{
PDEVOBJ *ppdev;
GDIPOINTER *pgp;
- LONG lDelta;
- HBITMAP hbmp;
- RECTL rcl;
+ LONG lDelta = 0;
+ HBITMAP hbmSave = NULL, hbmColor = NULL, hbmMask = NULL;
+ PSURFACE psurfSave = NULL, psurfColor = NULL, psurfMask = NULL;
+ RECTL rectl;
+ SIZEL sizel = {0, 0};
ASSERT(pso);
ppdev = GDIDEV(pso);
pgp = &ppdev->Pointer;
- if (psoColor)
+ /* Do we have any bitmap at all? */
+ if (psoColor || psoMask)
{
- pgp->Size.cx = psoColor->sizlBitmap.cx;
- pgp->Size.cy = psoColor->sizlBitmap.cy;
- if (psoMask)
+ /* Get the size of the new pointer */
+ if (psoColor)
+ {
+ sizel.cx = psoColor->sizlBitmap.cx;
+ sizel.cy = psoColor->sizlBitmap.cy;
+ }
+ else// if (psoMask)
{
- // CHECKME: Is this really required? if we have a color surface,
- // we only need the AND part of the mask.
- /* Check if the sizes match as they should */
- if (psoMask->sizlBitmap.cx != psoColor->sizlBitmap.cx ||
- psoMask->sizlBitmap.cy != psoColor->sizlBitmap.cy * 2)
- {
- DPRINT("Sizes of mask (%ld,%ld) and color (%ld,%ld) don't match\n",
- psoMask->sizlBitmap.cx, psoMask->sizlBitmap.cy,
- psoColor->sizlBitmap.cx, psoColor->sizlBitmap.cy);
-// return SPS_ERROR;
- }
+ sizel.cx = psoMask->sizlBitmap.cx;
+ sizel.cy = psoMask->sizlBitmap.cy / 2;
}
+
+ rectl.left = 0;
+ rectl.top = 0;
+ rectl.right = sizel.cx;
+ rectl.bottom = sizel.cy;
+
+ /* Calculate lDelta for our surfaces. */
+ lDelta = WIDTH_BYTES_ALIGN32(sizel.cx,
+ BitsPerFormat(pso->iBitmapFormat));
+
+ /* Create a bitmap for saving the pixels under the cursor. */
+ hbmSave = EngCreateBitmap(sizel,
+ lDelta,
+ pso->iBitmapFormat,
+ BMF_TOPDOWN | BMF_NOZEROINIT,
+ NULL);
+ psurfSave = SURFACE_ShareLockSurface(hbmSave);
+ if (!psurfSave) goto failure;
}
- else if (psoMask)
+
+ if (psoColor)
+ {
+ /* Color bitmap must have the same format as the dest surface */
+ if (psoColor->iBitmapFormat != pso->iBitmapFormat) goto failure;
+
+ /* Create a bitmap to copy the color bitmap to */
+ hbmColor = EngCreateBitmap(psoColor->sizlBitmap,
+ lDelta,
+ pso->iBitmapFormat,
+ BMF_TOPDOWN | BMF_NOZEROINIT,
+ NULL);
+ psurfColor = SURFACE_ShareLockSurface(hbmColor);
+ if (!psurfColor) goto failure;
+
+ /* Now copy the given bitmap */
+ rectl.bottom = psoColor->sizlBitmap.cy;
+ IntEngCopyBits(&psurfColor->SurfObj,
+ psoColor,
+ NULL,
+ pxlo,
+ &rectl,
+ (POINTL*)&rectl);
+ }
+
+ /* Create a mask surface */
+ if (psoMask)
{
- pgp->Size.cx = psoMask->sizlBitmap.cx;
- pgp->Size.cy = psoMask->sizlBitmap.cy / 2;
+ EXLATEOBJ exlo;
+ PPALETTE ppal;
+
+ /* Create a bitmap for the mask */
+ hbmMask = EngCreateBitmap(psoMask->sizlBitmap,
+ lDelta,
+ pso->iBitmapFormat,
+ BMF_TOPDOWN | BMF_NOZEROINIT,
+ NULL);
+ psurfMask = SURFACE_ShareLockSurface(hbmMask);
+ if (!psurfMask) goto failure;
+
+ /* Initialize an EXLATEOBJ */
+ ppal = PALETTE_LockPalette(ppdev->devinfo.hpalDefault);
+ EXLATEOBJ_vInitialize(&exlo,
+ &gpalMono,
+ ppal,
+ 0,
+ RGB(0xff,0xff,0xff),
+ RGB(0,0,0));
+
+ /* Copy the mask bitmap */
+ rectl.bottom = psoMask->sizlBitmap.cy;
+ IntEngCopyBits(&psurfMask->SurfObj,
+ psoMask,
+ NULL,
+ &exlo.xlo,
+ &rectl,
+ (POINTL*)&rectl);
+
+ /* Cleanup */
+ EXLATEOBJ_vCleanup(&exlo);
+ if (ppal) PALETTE_UnlockPalette(ppal);
}
+ /* Hide mouse pointer */
IntHideMousePointer(ppdev, pso);
+ /* Free old color bitmap */
if (pgp->psurfColor)
{
EngDeleteSurface(pgp->psurfColor->BaseObject.hHmgr);
pgp->psurfColor = NULL;
}
+ /* Free old mask bitmap */
if (pgp->psurfMask)
{
EngDeleteSurface(pgp->psurfMask->BaseObject.hHmgr);
pgp->psurfMask = NULL;
}
- if (pgp->psurfSave != NULL)
+ /* Free old save bitmap */
+ if (pgp->psurfSave)
{
EngDeleteSurface(pgp->psurfSave->BaseObject.hHmgr);
SURFACE_ShareUnlockSurface(pgp->psurfSave);
/* See if we are being asked to hide the pointer. */
if (psoMask == NULL && psoColor == NULL)
{
+ /* We're done */
return SPS_ACCEPT_NOEXCLUDE;
}
+ /* Now set the new cursor */
+ pgp->psurfColor = psurfColor;
+ pgp->psurfMask = psurfMask;
+ pgp->psurfSave = psurfSave;
pgp->HotSpot.x = xHot;
pgp->HotSpot.y = yHot;
-
- /* Calculate lDelta for our surfaces. */
- lDelta = DIB_GetDIBWidthBytes(pgp->Size.cx,
- BitsPerFormat(pso->iBitmapFormat));
-
- rcl.left = 0;
- rcl.top = 0;
- rcl.right = pgp->Size.cx;
- rcl.bottom = pgp->Size.cy;
-
- /* Create surface for saving the pixels under the cursor. */
- hbmp = EngCreateBitmap(pgp->Size,
- lDelta,
- pso->iBitmapFormat,
- BMF_TOPDOWN | BMF_NOZEROINIT,
- NULL);
- pgp->psurfSave = SURFACE_ShareLockSurface(hbmp);
-
- /* Create a mask surface */
- if (psoMask)
- {
- EXLATEOBJ exlo;
- PPALETTE ppal;
-
- hbmp = EngCreateBitmap(psoMask->sizlBitmap,
- lDelta,
- pso->iBitmapFormat,
- BMF_TOPDOWN | BMF_NOZEROINIT,
- NULL);
- pgp->psurfMask = SURFACE_ShareLockSurface(hbmp);
-
- if(pgp->psurfMask)
- {
- ppal = PALETTE_LockPalette(ppdev->devinfo.hpalDefault);
- EXLATEOBJ_vInitialize(&exlo,
- &gpalMono,
- ppal,
- 0,
- RGB(0xff,0xff,0xff),
- RGB(0,0,0));
-
- rcl.bottom = psoMask->sizlBitmap.cy;
- IntEngCopyBits(&pgp->psurfMask->SurfObj,
- psoMask,
- NULL,
- &exlo.xlo,
- &rcl,
- (POINTL*)&rcl);
-
- EXLATEOBJ_vCleanup(&exlo);
- if (ppal)
- PALETTE_UnlockPalette(ppal);
- }
- }
- else
- {
- pgp->psurfMask = NULL;
- }
-
- /* Create a color surface */
- if (psoColor)
- {
- hbmp = EngCreateBitmap(psoColor->sizlBitmap,
- lDelta,
- pso->iBitmapFormat,
- BMF_TOPDOWN | BMF_NOZEROINIT,
- NULL);
- pgp->psurfColor = SURFACE_ShareLockSurface(hbmp);
- if (pgp->psurfColor)
- {
- rcl.bottom = psoColor->sizlBitmap.cy;
- IntEngCopyBits(&pgp->psurfColor->SurfObj,
- psoColor,
- NULL,
- pxlo,
- &rcl,
- (POINTL*)&rcl);
- }
- }
- else
- {
- pgp->psurfColor = NULL;
- }
+ pgp->Size = sizel;
if (x != -1)
{
}
return SPS_ACCEPT_NOEXCLUDE;
+
+failure:
+ /* Cleanup surfaces */
+ if (hbmMask) EngDeleteSurface(hbmMask);
+ if (psurfMask) SURFACE_ShareUnlockSurface(psurfMask);
+ if (hbmColor) EngDeleteSurface(hbmColor);
+ if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
+ if (hbmSave) EngDeleteSurface(hbmSave);
+ if (psurfSave) SURFACE_ShareUnlockSurface(psurfSave);
+
+ return SPS_ERROR;
}
/*
prcl->right = prcl->left + pgp->Size.cx;
prcl->bottom = prcl->top + pgp->Size.cy;
}
- }
+ }
else if (prcl != NULL)
{
prcl->left = prcl->top = prcl->right = prcl->bottom = -1;
}
}
-VOID APIENTRY
-IntEngMovePointer(
- IN SURFOBJ *pso,
- IN LONG x,
- IN LONG y,
- IN RECTL *prcl)
-{
- SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
- PPDEVOBJ ppdev = (PPDEVOBJ)pso->hdev;
-
- SURFACE_LockBitmapBits(psurf);
- ppdev->pfnMovePointer(pso, x, y, prcl);
- SURFACE_UnlockBitmapBits(psurf);
-}
-
ULONG APIENTRY
IntEngSetPointerShape(
IN SURFOBJ *pso,
IN FLONG fl)
{
ULONG ulResult = SPS_DECLINE;
- SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
PFN_DrvSetPointerShape pfnSetPointerShape;
PPDEVOBJ ppdev = GDIDEV(pso);
pfnSetPointerShape = GDIDEVFUNCS(pso).SetPointerShape;
- SURFACE_LockBitmapBits(psurf);
if (pfnSetPointerShape)
{
ulResult = pfnSetPointerShape(pso,
ppdev->pfnMovePointer = EngMovePointer;
}
- SURFACE_UnlockBitmapBits(psurf);
-
return ulResult;
}
return 0;
}
- psurf = pdc->dclevel.pSurface;
+ ASSERT(pdc->dctype == DCTYPE_DIRECT);
+ EngAcquireSemaphore(pdc->ppdev->hsemDevLock);
+ /* We're not sure DC surface is the good one */
+ psurf = pdc->ppdev->pSurface;
if (!psurf)
{
DPRINT1("DC has no surface.\n");
+ EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
DC_UnlockDc(pdc);
return 0;
}
{
/* We have one, lock it */
psurfColor = SURFACE_ShareLockSurface(hbmColor);
-
+
if (psurfColor)
{
/* Create an XLATEOBJ, no mono support */
if (psurfMask)
SURFACE_ShareUnlockSurface(psurfMask);
+ EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
+
/* Unlock the DC */
DC_UnlockDc(pdc);
DPRINT1("Failed to lock the DC.\n");
return;
}
+ ASSERT(pdc->dctype == DCTYPE_DIRECT);
+
+ /* Acquire PDEV lock */
+ EngAcquireSemaphore(pdc->ppdev->hsemDevLock);
- /* Store the cursor exclude position in the PDEV */
- prcl = &pdc->ppdev->Pointer.Exclude;
+ /* Check if we need to move it */
+ if(pdc->ppdev->SafetyRemoveLevel == 0)
+ {
+ /* Store the cursor exclude position in the PDEV */
+ prcl = &pdc->ppdev->Pointer.Exclude;
+
+ /* Call Eng/Drv function */
+ pdc->ppdev->pfnMovePointer(&pdc->ppdev->pSurface->SurfObj, x, y, prcl);
+ }
- /* Call Eng/Drv function */
- IntEngMovePointer(&pdc->dclevel.pSurface->SurfObj, x, y, prcl);
+ /* Release PDEV lock */
+ EngReleaseSemaphore(pdc->ppdev->hsemDevLock);
/* Unlock the DC */
DC_UnlockDc(pdc);