Mouse pointer fix:
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 7 Apr 2009 01:36:22 +0000 (01:36 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 7 Apr 2009 01:36:22 +0000 (01:36 +0000)
- Remove useless Status from the GDIPOINTER struct
- Remove MovePointer and use PDEVOBJ.pfnMovePointer instead, which is always set to a valid function.
- Implement IntEngSetPointerShape, calling either the Eng or the Drv function if available, set pfnMovePointer according to the result.
- Use IntEngSetPointerShape instead of doing the atuff in IntSetCursor.
- Don't misuse gpsi->ptCursor in IntShow/HideMousePointer and EngMovePointer, use ppdev->ptlPointer instead.
- Dont Lock and unlock the surface evertime the pointer is drwn, instead keep a shared lock.
- Implement IntEngCopyBits, that does the MouseSafety stuff and calls EngCopyBits.
Fixes the broken mouse cursor with VBox display driver and improves mouse performance

svn path=/trunk/; revision=40409

reactos/subsystems/win32/win32k/eng/copybits.c
reactos/subsystems/win32/win32k/eng/mouse.c
reactos/subsystems/win32/win32k/include/inteng.h
reactos/subsystems/win32/win32k/include/pdevobj.h
reactos/subsystems/win32/win32k/ntuser/cursoricon.c
reactos/subsystems/win32/win32k/objects/device.c
reactos/subsystems/win32/win32k/objects/dibobj.c

index c9f15d9..a05eac7 100644 (file)
@@ -54,9 +54,6 @@ EngCopyBits(SURFOBJ *psoDest,
 
   psurfSource = CONTAINING_RECORD(psoSource, SURFACE, SurfObj);
   SURFACE_LockBitmapBits(psurfSource);
-  MouseSafetyOnDrawStart(psoSource, SourcePoint->x, SourcePoint->y,
-                         (SourcePoint->x + abs(DestRect->right - DestRect->left)),
-                         (SourcePoint->y + abs(DestRect->bottom - DestRect->top)));
 
   psurfDest = CONTAINING_RECORD(psoDest, SURFACE, SurfObj);
   if (psoDest != psoSource)
@@ -64,8 +61,6 @@ EngCopyBits(SURFOBJ *psoDest,
     SURFACE_LockBitmapBits(psurfDest);
   }
 
-  MouseSafetyOnDrawStart(psoDest, DestRect->left, DestRect->top, DestRect->right, DestRect->bottom);
-
   // FIXME: Don't punt to the driver's DrvCopyBits immediately. Instead,
   //        mark the copy block function to be DrvCopyBits instead of the
   //        GDI's copy bit function so as to remove clipping from the
@@ -83,12 +78,10 @@ EngCopyBits(SURFOBJ *psoDest,
         ret = GDIDEVFUNCS(psoDest).CopyBits(
           psoDest, psoSource, Clip, ColorTranslation, DestRect, SourcePoint);
 
-        MouseSafetyOnDrawEnd(psoDest);
         if (psoDest != psoSource)
         {
           SURFACE_UnlockBitmapBits(psurfDest);
         }
-        MouseSafetyOnDrawEnd(psoSource);
         SURFACE_UnlockBitmapBits(psurfSource);
 
         return ret;
@@ -104,12 +97,10 @@ EngCopyBits(SURFOBJ *psoDest,
         ret = GDIDEVFUNCS(psoSource).CopyBits(
           psoDest, psoSource, Clip, ColorTranslation, DestRect, SourcePoint);
 
-        MouseSafetyOnDrawEnd(psoDest);
         if (psoDest != psoSource)
         {
           SURFACE_UnlockBitmapBits(psurfDest);
         }
-        MouseSafetyOnDrawEnd(psoSource);
         SURFACE_UnlockBitmapBits(psurfSource);
 
         return ret;
@@ -121,12 +112,10 @@ EngCopyBits(SURFOBJ *psoDest,
                        NULL, Clip, ColorTranslation, DestRect, SourcePoint,
                        NULL, NULL, NULL, ROP3_TO_ROP4(SRCCOPY));
 
-    MouseSafetyOnDrawEnd(psoDest);
     if (psoDest != psoSource)
     {
       SURFACE_UnlockBitmapBits(psurfDest);
     }
-    MouseSafetyOnDrawEnd(psoSource);
     SURFACE_UnlockBitmapBits(psurfSource);
 
     return ret;
@@ -160,7 +149,6 @@ EngCopyBits(SURFOBJ *psoDest,
         {
           SURFACE_UnlockBitmapBits(psurfDest);
         }
-        MouseSafetyOnDrawEnd(psoSource);
         SURFACE_UnlockBitmapBits(psurfSource);
 
         return(TRUE);
@@ -174,12 +162,10 @@ EngCopyBits(SURFOBJ *psoDest,
 
         DibFunctionsForBitmapFormat[psoDest->iBitmapFormat].DIB_BitBltSrcCopy(&BltInfo);
 
-        MouseSafetyOnDrawEnd(psoDest);
         if (psoDest != psoSource)
         {
           SURFACE_UnlockBitmapBits(psurfDest);
         }
-        MouseSafetyOnDrawEnd(psoSource);
         SURFACE_UnlockBitmapBits(psurfSource);
 
         return(TRUE);
@@ -212,26 +198,48 @@ EngCopyBits(SURFOBJ *psoDest,
 
           } while(EnumMore);
 
-          MouseSafetyOnDrawEnd(psoDest);
           if (psoDest != psoSource)
           {
             SURFACE_UnlockBitmapBits(psurfDest);
           }
-          MouseSafetyOnDrawEnd(psoSource);
           SURFACE_UnlockBitmapBits(psurfSource);
 
           return(TRUE);
     }
 
-  MouseSafetyOnDrawEnd(psoDest);
   if (psoDest != psoSource)
   {
     SURFACE_UnlockBitmapBits(psurfDest);
   }
-  MouseSafetyOnDrawEnd(psoSource);
   SURFACE_UnlockBitmapBits(psurfSource);
 
   return FALSE;
 }
 
+BOOL APIENTRY
+IntEngCopyBits(
+    SURFOBJ *psoDest,
+    SURFOBJ *psoSource,
+    CLIPOBJ *pco,
+    XLATEOBJ *pxlo,
+    RECTL *prclDest,
+    POINTL *ptlSource)
+{
+    BOOL bResult;
+
+    MouseSafetyOnDrawStart(psoSource, ptlSource->x, ptlSource->y,
+                         (ptlSource->x + abs(prclDest->right - prclDest->left)),
+                         (ptlSource->y + abs(prclDest->bottom - prclDest->top)));
+
+    MouseSafetyOnDrawStart(psoDest, prclDest->left, prclDest->top, prclDest->right, prclDest->bottom);
+
+    bResult = EngCopyBits(psoDest, psoSource, pco, pxlo, prclDest, ptlSource);
+
+    MouseSafetyOnDrawEnd(psoDest);
+    MouseSafetyOnDrawEnd(psoSource);
+
+    return bResult;
+}
+
+
 /* EOF */
index f0470c8..399a47c 100644 (file)
@@ -3,6 +3,7 @@
  * PURPOSE:          Mouse pointer functions
  * FILE:             subsystems/win32k/eng/mouse.c
  * PROGRAMER:        Casper S. Hornstrup (chorns@users.sourceforge.net)
+ *                   Timo Kreuzer (timo.kreuzer@reactos.org)
  * REVISION HISTORY:
  *       06-06-2001  CSH  Created
  */
@@ -21,7 +22,7 @@
  */
 INT INTERNAL_CALL
 MouseSafetyOnDrawStart(
-    SURFOBJ *SurfObj,
+    SURFOBJ *pso,
     LONG HazardX1,
     LONG HazardY1,
     LONG HazardX2,
@@ -31,20 +32,26 @@ MouseSafetyOnDrawStart(
     PDEVOBJ *ppdev;
     GDIPOINTER *pgp;
 
-    ASSERT(SurfObj != NULL);
+    ASSERT(pso != NULL);
 
-    ppdev = GDIDEV(SurfObj);
+    ppdev = GDIDEV(pso);
     if (ppdev == NULL)
     {
-        return(FALSE);
+        return FALSE;
     }
 
     pgp = &ppdev->Pointer;
 
-    if (SPS_ACCEPT_NOEXCLUDE == pgp->Status ||
-            pgp->Exclude.right == -1)
+    if (pgp->Exclude.right == -1)
     {
-        return(FALSE);
+        return FALSE;
+    }
+
+    ppdev->SafetyRemoveCount++;
+
+    if (ppdev->SafetyRemoveLevel != 0)
+    {
+        return FALSE;
     }
 
     if (HazardX1 > HazardX2)
@@ -60,24 +67,13 @@ MouseSafetyOnDrawStart(
         HazardY1 = tmp;
     }
 
-    if (ppdev->SafetyRemoveLevel != 0)
-    {
-        ppdev->SafetyRemoveCount++;
-        return FALSE;
-    }
-
-    ppdev->SafetyRemoveCount++;
-
     if (pgp->Exclude.right >= HazardX1
             && pgp->Exclude.left <= HazardX2
             && pgp->Exclude.bottom >= HazardY1
             && pgp->Exclude.top <= HazardY2)
     {
         ppdev->SafetyRemoveLevel = ppdev->SafetyRemoveCount;
-        if (pgp->MovePointer)
-            pgp->MovePointer(SurfObj, -1, -1, NULL);
-        else
-            EngMovePointer(SurfObj, -1, -1, NULL);
+        ppdev->pfnMovePointer(pso, -1, -1, NULL);
     }
 
     return(TRUE);
@@ -88,14 +84,14 @@ MouseSafetyOnDrawStart(
  */
 INT INTERNAL_CALL
 MouseSafetyOnDrawEnd(
-    SURFOBJ *SurfObj)
+    SURFOBJ *pso)
 {
     PDEVOBJ *ppdev;
     GDIPOINTER *pgp;
 
-    ASSERT(SurfObj != NULL);
+    ASSERT(pso != NULL);
 
-    ppdev = GDIDEV(SurfObj);
+    ppdev = (PDEVOBJ*)pso->hdev;
 
     if (ppdev == NULL)
     {
@@ -104,8 +100,7 @@ MouseSafetyOnDrawEnd(
 
     pgp = &ppdev->Pointer;
 
-    if (SPS_ACCEPT_NOEXCLUDE == pgp->Status ||
-            pgp->Exclude.right == -1)
+    if (pgp->Exclude.right == -1)
     {
         return FALSE;
     }
@@ -114,10 +109,8 @@ MouseSafetyOnDrawEnd(
     {
         return FALSE;
     }
-    if (pgp->MovePointer)
-        pgp->MovePointer(SurfObj, gpsi->ptCursor.x, gpsi->ptCursor.y, &pgp->Exclude);
-    else
-        EngMovePointer(SurfObj, gpsi->ptCursor.x, gpsi->ptCursor.y, &pgp->Exclude);
+
+    ppdev->pfnMovePointer(pso, gpsi->ptCursor.x, gpsi->ptCursor.y, &pgp->Exclude);
 
     ppdev->SafetyRemoveLevel = 0;
 
@@ -126,13 +119,16 @@ MouseSafetyOnDrawEnd(
 
 /* SOFTWARE MOUSE POINTER IMPLEMENTATION **************************************/
 
-VOID INTERNAL_CALL
+VOID
+INTERNAL_CALL
 IntHideMousePointer(
     PDEVOBJ *ppdev,
     SURFOBJ *psoDest)
 {
     GDIPOINTER *pgp;
     POINTL pt;
+    RECTL rclDest;
+    POINTL ptlSave;
 
     ASSERT(ppdev);
     ASSERT(psoDest);
@@ -149,53 +145,48 @@ IntHideMousePointer(
     /* The mouse is hide from ShowCours and it is frist ?? */
     if (pgp->ShowPointer < 0)
     {
-        return ;
+        return;
     }
 
-    /* Hide the cours */
-    pt.x = gpsi->ptCursor.x - pgp->HotSpot.x;
-    pt.y = gpsi->ptCursor.y - pgp->HotSpot.y;
-
-
-    if (pgp->SaveSurface != NULL)
+    if (!pgp->psurfSave)
     {
-        RECTL DestRect;
-        POINTL SrcPoint;
-        SURFOBJ *SaveSurface;
-        SURFOBJ *MaskSurface;
-
-        DestRect.left = max(pt.x, 0);
-        DestRect.top = max(pt.y, 0);
-        DestRect.right = min(
-                             pt.x + pgp->Size.cx,
-                             psoDest->sizlBitmap.cx);
-        DestRect.bottom = min(
-                              pt.y + pgp->Size.cy,
-                              psoDest->sizlBitmap.cy);
-
-        SrcPoint.x = max(-pt.x, 0);
-        SrcPoint.y = max(-pt.y, 0);
-
-        if ((SaveSurface = EngLockSurface(pgp->SaveSurface)))
-        {
-            if ((MaskSurface = EngLockSurface(pgp->MaskSurface)))
-            {
-                IntEngBitBltEx(psoDest, SaveSurface, MaskSurface, NULL, NULL,
-                               &DestRect, &SrcPoint, &SrcPoint, NULL, NULL,
-                               ROP3_TO_ROP4(SRCCOPY), FALSE);
-                EngUnlockSurface(MaskSurface);
-            }
-            EngUnlockSurface(SaveSurface);
-        }
+        DPRINT1("No SaveSurface!\n");
+        return;
     }
+
+    /* Calculate cursor coordinates */
+    pt.x = ppdev->ptlPointer.x - pgp->HotSpot.x;
+    pt.y = ppdev->ptlPointer.y - pgp->HotSpot.y;
+
+    rclDest.left = max(pt.x, 0);
+    rclDest.top = max(pt.y, 0);
+    rclDest.right = min(pt.x + pgp->Size.cx, psoDest->sizlBitmap.cx);
+    rclDest.bottom = min(pt.y + pgp->Size.cy, psoDest->sizlBitmap.cy);
+
+    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);
 }
 
-VOID INTERNAL_CALL
+VOID
+INTERNAL_CALL
 IntShowMousePointer(PDEVOBJ *ppdev, SURFOBJ *psoDest)
 {
     GDIPOINTER *pgp;
-    SURFOBJ *SaveSurface;
     POINTL pt;
+    RECTL rclSurf, rclPointer;
 
     ASSERT(ppdev);
     ASSERT(psoDest);
@@ -209,87 +200,87 @@ IntShowMousePointer(PDEVOBJ *ppdev, SURFOBJ *psoDest)
 
     pgp->Enabled = TRUE;
 
-    /* Do not blt the mouse if it in hide */
+    /* Do not blt the pointer, if it is hidden */
     if (pgp->ShowPointer < 0)
     {
         return ;
     }
 
-    pt.x = gpsi->ptCursor.x - pgp->HotSpot.x;
-    pt.y = gpsi->ptCursor.y - pgp->HotSpot.y;
+    /* Calculate pointer coordinates */
+    pt.x = ppdev->ptlPointer.x - pgp->HotSpot.x;
+    pt.y = ppdev->ptlPointer.y - pgp->HotSpot.y;
 
-    /* Copy the pixels under the cursor to temporary surface. */
-    if (pgp->SaveSurface != NULL &&
-            (SaveSurface = EngLockSurface(pgp->SaveSurface)))
-    {
-        RECTL DestRect;
-        POINTL SrcPoint;
-
-        SrcPoint.x = max(pt.x, 0);
-        SrcPoint.y = max(pt.y, 0);
-
-        DestRect.left = SrcPoint.x - pt.x;
-        DestRect.top = SrcPoint.y - pt.y;
-        DestRect.right = min(
-                             pgp->Size.cx,
-                             psoDest->sizlBitmap.cx - pt.x);
-        DestRect.bottom = min(
-                              pgp->Size.cy,
-                              psoDest->sizlBitmap.cy - pt.y);
-
-        IntEngBitBltEx(SaveSurface, psoDest, NULL, NULL, NULL,
-                       &DestRect, &SrcPoint, NULL, NULL, NULL,
-                       ROP3_TO_ROP4(SRCCOPY), FALSE);
-        EngUnlockSurface(SaveSurface);
-    }
+    /* Calculate the rect on the surface */
+    rclSurf.left = max(pt.x, 0);
+    rclSurf.top = max(pt.y, 0);
+    rclSurf.right = min(pt.x + pgp->Size.cx, psoDest->sizlBitmap.cx);
+    rclSurf.bottom = min(pt.y + pgp->Size.cy, psoDest->sizlBitmap.cy);
 
+    /* Calculate the rect in the pointer bitmap */
+    rclPointer.left = rclSurf.left - pt.x;
+    rclPointer.top = rclSurf.top - pt.y;
+    rclPointer.right = min(pgp->Size.cx, psoDest->sizlBitmap.cx - pt.x);
+    rclPointer.bottom = min(pgp->Size.cy, psoDest->sizlBitmap.cy - pt.y);
 
-    /* Blit the cursor on the screen. */
+    /* 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);
+
+    /* Blt the pointer on the screen. */
+    if (pgp->psurfColor)
+    {
+        IntEngBitBltEx(psoDest,
+                       &pgp->psurfColor->SurfObj,
+                       &pgp->psurfMask->SurfObj,
+                       NULL,
+                       pgp->XlateObject,
+                       &rclSurf,
+                       (POINTL*)&rclPointer,
+                       (POINTL*)&rclPointer,
+                       NULL,
+                       NULL,
+                       R4_MASK,
+                       FALSE);
+    }
+    else
     {
-        RECTL DestRect;
-        POINTL SrcPoint;
-        SURFOBJ *psoColor;
-        SURFOBJ *psoMask = NULL;
-
-        DestRect.left = max(pt.x, 0);
-        DestRect.top = max(pt.y, 0);
-        DestRect.right = min(
-                             pt.x + pgp->Size.cx,
-                             psoDest->sizlBitmap.cx);
-        DestRect.bottom = min(
-                              pt.y + pgp->Size.cy,
-                              psoDest->sizlBitmap.cy);
-
-        SrcPoint.x = max(-pt.x, 0);
-        SrcPoint.y = max(-pt.y, 0);
-
-        if (pgp->MaskSurface)
-            psoMask = EngLockSurface(pgp->MaskSurface);
-
-        if (psoMask != NULL)
-        {
-            if (pgp->ColorSurface != NULL)
-            {
-                if ((psoColor = EngLockSurface(pgp->ColorSurface)))
-                {
-                    IntEngBitBltEx(psoDest, psoColor, psoMask, NULL,
-                                   pgp->XlateObject, &DestRect, &SrcPoint, &SrcPoint,
-                                   NULL, NULL, R4_MASK, FALSE);
-                    EngUnlockSurface(psoColor);
-                }
-            }
-            else
-            {
-                IntEngBitBltEx(psoDest, psoMask, NULL, NULL, pgp->XlateObject,
-                               &DestRect, &SrcPoint, NULL, NULL, NULL,
-                               ROP3_TO_ROP4(SRCAND), FALSE);
-                SrcPoint.y += pgp->Size.cy;
-                IntEngBitBltEx(psoDest, psoMask, NULL, NULL, pgp->XlateObject,
-                               &DestRect, &SrcPoint, NULL, NULL, NULL,
-                               ROP3_TO_ROP4(SRCINVERT), FALSE);
-            }
-            EngUnlockSurface(psoMask);
-        }
+        IntEngBitBltEx(psoDest,
+                       &pgp->psurfMask->SurfObj,
+                       NULL,
+                       NULL,
+                       pgp->XlateObject,
+                       &rclSurf,
+                       (POINTL*)&rclPointer,
+                       NULL,
+                       NULL,
+                       NULL,
+                       ROP3_TO_ROP4(SRCAND),
+                       FALSE);
+
+        rclPointer.top += pgp->Size.cy;
+
+        IntEngBitBltEx(psoDest,
+                       &pgp->psurfMask->SurfObj,
+                       NULL,
+                       NULL,
+                       pgp->XlateObject,
+                       &rclSurf,
+                       (POINTL*)&rclPointer,
+                       NULL,
+                       NULL,
+                       NULL,
+                       ROP3_TO_ROP4(SRCINVERT),
+                       FALSE);
     }
 }
 
@@ -310,8 +301,11 @@ EngSetPointerShape(
     IN FLONG fl)
 {
     PDEVOBJ *ppdev;
-    SURFOBJ *psoTemp;
     GDIPOINTER *pgp;
+    PBYTE Bits;
+    SIZEL Size;
+    LONG lDelta;
+    HBITMAP hbmp;
 
     ASSERT(pso);
 
@@ -320,38 +314,33 @@ EngSetPointerShape(
 
     IntHideMousePointer(ppdev, pso);
 
-    if (pgp->ColorSurface != NULL)
+    if (pgp->psurfColor)
     {
-        /* FIXME: Is this really needed? */
-        if ((psoTemp = EngLockSurface(pgp->ColorSurface)))
-        {
-            EngFreeMem(psoTemp->pvBits);
-            psoTemp->pvBits = 0;
-            EngUnlockSurface(psoTemp);
-        }
+        /* FIXME: let GDI allocate/free memory */
+        EngFreeMem(pgp->psurfColor->SurfObj.pvBits);
+        pgp->psurfColor->SurfObj.pvBits = 0;
 
-        EngDeleteSurface(pgp->ColorSurface);
-        pgp->MaskSurface = NULL;
+        EngDeleteSurface(pgp->psurfColor->BaseObject.hHmgr);
+        SURFACE_ShareUnlockSurface(pgp->psurfColor);
+        pgp->psurfColor = NULL;
     }
 
-    if (pgp->MaskSurface != NULL)
+    if (pgp->psurfMask)
     {
-        /* FIXME: Is this really needed? */
-        if ((psoTemp = EngLockSurface(pgp->MaskSurface)))
-        {
-            EngFreeMem(psoTemp->pvBits);
-            psoTemp->pvBits = 0;
-            EngUnlockSurface(psoTemp);
-        }
+        /* FIXME: let GDI allocate/free memory */
+        EngFreeMem(pgp->psurfMask->SurfObj.pvBits);
+        pgp->psurfMask->SurfObj.pvBits = 0;
 
-        EngDeleteSurface(pgp->MaskSurface);
-        pgp->MaskSurface = NULL;
+        EngDeleteSurface(pgp->psurfMask->BaseObject.hHmgr);
+        SURFACE_ShareUnlockSurface(pgp->psurfMask);
+        pgp->psurfMask = NULL;
     }
 
-    if (pgp->SaveSurface != NULL)
+    if (pgp->psurfSave != NULL)
     {
-        EngDeleteSurface(pgp->SaveSurface);
-        pgp->SaveSurface = NULL;
+        EngDeleteSurface(pgp->psurfSave->BaseObject.hHmgr);
+        SURFACE_ShareUnlockSurface(pgp->psurfSave);
+        pgp->psurfSave = NULL;
     }
 
     if (pgp->XlateObject != NULL)
@@ -369,12 +358,10 @@ EngSetPointerShape(
     pgp->HotSpot.x = xHot;
     pgp->HotSpot.y = yHot;
 
-    /* Actually this should be set by 'the other side', but it would be
-     * done right after this. It helps IntShowMousePointer. */
     if (x != -1)
     {
-        gpsi->ptCursor.x = x;
-        gpsi->ptCursor.y = y;
+        ppdev->ptlPointer.x = x;
+        ppdev->ptlPointer.y = y;
     }
 
     pgp->Size.cx = abs(psoMask->lDelta) << 3;
@@ -382,8 +369,7 @@ EngSetPointerShape(
 
     if (psoColor != NULL)
     {
-        PBYTE Bits;
-
+        /* FIXME: let GDI allocate/free memory */
         Bits = EngAllocMem(0, psoColor->cjBits, TAG_MOUSE);
         if (Bits == NULL)
         {
@@ -392,33 +378,36 @@ EngSetPointerShape(
 
         memcpy(Bits, psoColor->pvBits, psoColor->cjBits);
 
-        pgp->ColorSurface = (HSURF)EngCreateBitmap(pgp->Size,
-                            psoColor->lDelta, psoColor->iBitmapFormat,
-                            psoColor->lDelta < 0 ? 0 : BMF_TOPDOWN, Bits);
+        hbmp = EngCreateBitmap(pgp->Size,
+                               psoColor->lDelta,
+                               psoColor->iBitmapFormat,
+                               psoColor->lDelta < 0 ? 0 : BMF_TOPDOWN,
+                               Bits);
+
+        pgp->psurfColor = SURFACE_ShareLockSurface(hbmp);
     }
     else
     {
-        pgp->ColorSurface = NULL;
+        pgp->psurfColor = NULL;
     }
 
+    Size.cx = pgp->Size.cx;
+    Size.cy = pgp->Size.cy << 1;
+    Bits = EngAllocMem(0, psoMask->cjBits, TAG_MOUSE);
+    if (Bits == NULL)
     {
-        SIZEL Size;
-        PBYTE Bits;
+        return SPS_ERROR;
+    }
 
-        Size.cx = pgp->Size.cx;
-        Size.cy = pgp->Size.cy << 1;
-        Bits = EngAllocMem(0, psoMask->cjBits, TAG_MOUSE);
-        if (Bits == NULL)
-        {
-            return SPS_ERROR;
-        }
+    memcpy(Bits, psoMask->pvBits, psoMask->cjBits);
 
-        memcpy(Bits, psoMask->pvBits, psoMask->cjBits);
+    hbmp = EngCreateBitmap(Size,
+                           psoMask->lDelta,
+                           psoMask->iBitmapFormat,
+                           psoMask->lDelta < 0 ? 0 : BMF_TOPDOWN,
+                           Bits);
 
-        pgp->MaskSurface = (HSURF)EngCreateBitmap(Size,
-                           psoMask->lDelta, psoMask->iBitmapFormat,
-                           psoMask->lDelta < 0 ? 0 : BMF_TOPDOWN, Bits);
-    }
+    pgp->psurfMask = SURFACE_ShareLockSurface(hbmp);
 
     /* Create an XLATEOBJ that will be used for drawing masks.
      * FIXME: We should get this in pxlo parameter! */
@@ -441,39 +430,38 @@ EngSetPointerShape(
     }
 
     /* Create surface for saving the pixels under the cursor. */
-    {
-        LONG lDelta;
+    switch (pso->iBitmapFormat)
+    {
+        case BMF_1BPP:
+            lDelta = pgp->Size.cx >> 3;
+            break;
+        case BMF_4BPP:
+            lDelta = pgp->Size.cx >> 1;
+            break;
+        case BMF_8BPP:
+            lDelta = pgp->Size.cx;
+            break;
+        case BMF_16BPP:
+            lDelta = pgp->Size.cx << 1;
+            break;
+        case BMF_24BPP:
+            lDelta = pgp->Size.cx * 3;
+            break;
+        case BMF_32BPP:
+            lDelta = pgp->Size.cx << 2;
+            break;
+        default:
+            lDelta = 0;
+            break;
+    }
 
-        switch (pso->iBitmapFormat)
-        {
-            case BMF_1BPP:
-                lDelta = pgp->Size.cx >> 3;
-                break;
-            case BMF_4BPP:
-                lDelta = pgp->Size.cx >> 1;
-                break;
-            case BMF_8BPP:
-                lDelta = pgp->Size.cx;
-                break;
-            case BMF_16BPP:
-                lDelta = pgp->Size.cx << 1;
-                break;
-            case BMF_24BPP:
-                lDelta = pgp->Size.cx * 3;
-                break;
-            case BMF_32BPP:
-                lDelta = pgp->Size.cx << 2;
-                break;
-            default:
-                lDelta = 0;
-                break;
-        }
+    hbmp = EngCreateBitmap(pgp->Size,
+                           lDelta,
+                           pso->iBitmapFormat,
+                           BMF_TOPDOWN | BMF_NOZEROINIT,
+                           NULL);
 
-        pgp->SaveSurface = (HSURF)EngCreateBitmap(pgp->Size,
-                                                  lDelta,
-                                                  pso->iBitmapFormat,
-                                                  BMF_TOPDOWN | BMF_NOZEROINIT, NULL);
-    }
+    pgp->psurfSave = SURFACE_ShareLockSurface(hbmp);
 
     if (x != -1)
     {
@@ -489,7 +477,7 @@ EngSetPointerShape(
     } else if (prcl != NULL)
         prcl->left = prcl->top = prcl->right = prcl->bottom = -1;
 
-    return SPS_ACCEPT_EXCLUDE;
+    return SPS_ACCEPT_NOEXCLUDE;
 }
 
 /*
@@ -509,18 +497,17 @@ EngMovePointer(
     ASSERT(pso);
 
     ppdev = GDIDEV(pso);
-
     ASSERT(ppdev);
 
     pgp = &ppdev->Pointer;
 
     IntHideMousePointer(ppdev, pso);
+
+    ppdev->ptlPointer.x = x;
+    ppdev->ptlPointer.y = y;
+
     if (x != -1)
     {
-        /* Actually this should be set by 'the other side', but it would be
-         * done right after this. It helps IntShowMousePointer. */
-        gpsi->ptCursor.x = x;
-        gpsi->ptCursor.y = y;
         IntShowMousePointer(ppdev, pso);
         if (prcl != NULL)
         {
@@ -531,7 +518,6 @@ EngMovePointer(
         }
     } else if (prcl != NULL)
         prcl->left = prcl->top = prcl->right = prcl->bottom = -1;
-
 }
 
 VOID APIENTRY
@@ -542,17 +528,74 @@ IntEngMovePointer(
     IN RECTL *prcl)
 {
     SURFACE *psurf = CONTAINING_RECORD(pso, SURFACE, SurfObj);
+    PPDEVOBJ ppdev = (PPDEVOBJ)pso->hdev;
 
     SURFACE_LockBitmapBits(psurf);
-    if (GDIDEV(pso)->Pointer.MovePointer)
+    ppdev->pfnMovePointer(pso, x, y, prcl);
+    SURFACE_UnlockBitmapBits(psurf);
+}
+
+ULONG APIENTRY
+IntEngSetPointerShape(
+   IN SURFOBJ *pso,
+   IN SURFOBJ *psoMask,
+   IN SURFOBJ *psoColor,
+   IN XLATEOBJ *pxlo,
+   IN LONG xHot,
+   IN LONG yHot,
+   IN LONG x,
+   IN LONG y,
+   IN RECTL *prcl,
+   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,
+                                      psoMask,
+                                      psoColor,
+                                      pxlo,
+                                      xHot,
+                                      yHot,
+                                      x,
+                                      y,
+                                      prcl,
+                                      fl);
+    }
+
+    /* Check if the driver accepted it */
+    if (ulResult == SPS_ACCEPT_NOEXCLUDE)
     {
-        GDIDEV(pso)->Pointer.MovePointer(pso, x, y, prcl);
+        /* Set MovePointer to the driver function */
+        ppdev->pfnMovePointer = GDIDEVFUNCS(pso).MovePointer;
     }
     else
     {
-        EngMovePointer(pso, x, y, prcl);
+        /* Set software pointer */
+        ulResult = EngSetPointerShape(pso,
+                                      psoMask,
+                                      psoColor,
+                                      pxlo,
+                                      xHot,
+                                      yHot,
+                                      x,
+                                      y,
+                                      prcl,
+                                      fl);
+        /* Set MovePointer to the eng function */
+        ppdev->pfnMovePointer = EngMovePointer;
     }
+
     SURFACE_UnlockBitmapBits(psurf);
+
+    return ulResult;
 }
 
 /* EOF */
index 88e9a3f..164cc06 100644 (file)
@@ -156,6 +156,19 @@ IntEngMovePointer(IN SURFOBJ *pso,
                   IN LONG y,
                   IN RECTL *prcl);
 
+ULONG APIENTRY
+IntEngSetPointerShape(
+   IN SURFOBJ *pso,
+   IN SURFOBJ *psoMask,
+   IN SURFOBJ *psoColor,
+   IN XLATEOBJ *pxlo,
+   IN LONG xHot,
+   IN LONG yHot,
+   IN LONG x,
+   IN LONG y,
+   IN RECTL *prcl,
+   IN FLONG fl);
+
 BOOL APIENTRY
 IntEngAlphaBlend(IN SURFOBJ *Dest,
                  IN SURFOBJ *Source,
@@ -165,5 +178,12 @@ IntEngAlphaBlend(IN SURFOBJ *Dest,
                  IN PRECTL SourceRect,
                  IN BLENDOBJ *BlendObj);
 
+BOOL APIENTRY
+IntEngCopyBits(SURFOBJ *psoDest,
+           SURFOBJ *psoSource,
+           CLIPOBJ *pco,
+           XLATEOBJ *pxlo,
+           RECTL *prclDest,
+           POINTL *ptlSource);
 
 #endif /* _WIN32K_INTENG_H */
index 33287d2..ce25b7e 100644 (file)
@@ -28,15 +28,13 @@ typedef struct _GDIPOINTER /* should stay private to ENG? No, part of PDEVOBJ ak
   SIZEL    Size;
   POINTL   HotSpot;
   XLATEOBJ *XlateObject;
-  HSURF    ColorSurface;
-  HSURF    MaskSurface;
-  HSURF    SaveSurface;
+  SURFACE  *psurfColor;
+  SURFACE  *psurfMask;
+  SURFACE  *psurfSave;
   int      ShowPointer; /* counter negtive  do not show the mouse postive show the mouse */
 
   /* public pointer information */
   RECTL    Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */
-  PFN_DrvMovePointer MovePointer;
-  ULONG    Status;
 } GDIPOINTER, *PGDIPOINTER;
 
 typedef struct _GRAPHICS_DEVICE
@@ -59,7 +57,7 @@ typedef struct _PDEVOBJ
 //  FLONG                     flAccelerated;
     PERESOURCE                hsemDevLock;    /* Device lock. */
 //  HSEMAPHORE                hsemPointer;
-//  POINTL                    ptlPointer;
+    POINTL                    ptlPointer;
 //  SIZEL                     szlPointer;
 //  SPRITESTATE               SpriteState;
 //  HFONT                     hlfntDefault;
@@ -80,7 +78,7 @@ typedef struct _PDEVOBJ
 //  ULONG                     ulVertRes;
 //  PFN_DrvSetPointerShape    pfnDrvSetPointerShape;
 //  PFN_DrvMovePointer        pfnDrvMovePointer;
-//  PFN_DrvMovePointer        pfnMovePointer;
+    PFN_DrvMovePointer        pfnMovePointer;
 //  PFN_DrvSynchronize        pfnDrvSynchronize;
 //  PFN_DrvSynchronizeSurface pfnDrvSynchronizeSurface;
 //  PFN_DrvSetPalette         pfnDrvSetPalette;
index e680873..72fd2bf 100644 (file)
@@ -95,6 +95,7 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
    XLATEOBJ *XlateObj = NULL;
    HDC Screen;
    PDC dc;
+   ULONG Status;
 
    CurInfo = IntGetSysCursorInfo(WinSta);
    OldCursor = CurInfo->CurrentCursorObject;
@@ -137,14 +138,12 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
             UserDereferenceObject(CurInfo->CurrentCursorObject);
             if (CurInfo->ShowingCursor)
             {
-                DPRINT1("Removing pointer!\n");
+                DPRINT("Removing pointer!\n");
                /* Remove the cursor if it was displayed */
                IntEngMovePointer(pso, -1, -1, &GDIDEV(pso)->Pointer.Exclude);
             }
          }
 
-         GDIDEV(pso)->Pointer.Status = SPS_ACCEPT_NOEXCLUDE;
-
          CurInfo->CurrentCursorObject = NewCursor; /* i.e. CurrentCursorObject = NULL */
          CurInfo->ShowingCursor = 0;
       }
@@ -212,7 +211,7 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
                   return (HCURSOR)0;
                }
                soMask = EngLockSurface((HSURF)hMask);
-               EngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
+               IntEngCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL,
                            &DestRect, &SourcePoint);
                SURFACE_UnlockSurface(MaskBmpObj);
             }
@@ -234,40 +233,20 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
       UserDereferenceObject(OldCursor);
    }
 
-   if (GDIDEVFUNCS(pso).SetPointerShape)
-   {
-      GDIDEV(pso)->Pointer.Status =
-         GDIDEVFUNCS(pso).SetPointerShape(
-            pso, soMask, soColor, XlateObj,
-            NewCursor->IconInfo.xHotspot,
-            NewCursor->IconInfo.yHotspot,
-            gpsi->ptCursor.x,
-            gpsi->ptCursor.y,
-            &(GDIDEV(pso)->Pointer.Exclude),
-            SPS_CHANGE);
-      DPRINT("SetCursor: DrvSetPointerShape() returned %x\n",
-             GDIDEV(pso)->Pointer.Status);
-   }
-   else
-   {
-      GDIDEV(pso)->Pointer.Status = SPS_DECLINE;
-   }
+   Status  = IntEngSetPointerShape(pso,
+                                   soMask,
+                                   soColor,
+                                   XlateObj,
+                                   NewCursor->IconInfo.xHotspot,
+                                   NewCursor->IconInfo.yHotspot,
+                                   gpsi->ptCursor.x,
+                                   gpsi->ptCursor.y,
+                                   &(GDIDEV(pso)->Pointer.Exclude),
+                                   SPS_CHANGE);
 
-   if(GDIDEV(pso)->Pointer.Status == SPS_DECLINE)
+   if (Status != SPS_ACCEPT_NOEXCLUDE)
    {
-      GDIDEV(pso)->Pointer.Status = EngSetPointerShape(
-                                           pso, soMask, soColor, XlateObj,
-                                           NewCursor->IconInfo.xHotspot,
-                                           NewCursor->IconInfo.yHotspot,
-                                           gpsi->ptCursor.x,
-                                           gpsi->ptCursor.y,
-                                           &(GDIDEV(pso)->Pointer.Exclude),
-                                           SPS_CHANGE);
-      GDIDEV(pso)->Pointer.MovePointer = NULL;
-   }
-   else
-   {
-      GDIDEV(pso)->Pointer.MovePointer = GDIDEVFUNCS(pso).MovePointer;
+       DPRINT1("IntEngSetPointerShape returned %lx\n", Status);
    }
 
    SURFACE_UnlockSurface(psurf);
@@ -281,9 +260,6 @@ IntSetCursor(PWINSTATION_OBJECT WinSta, PCURICON_OBJECT NewCursor,
       EngDeleteXlate(XlateObj);
    }
 
-   if(GDIDEV(pso)->Pointer.Status == SPS_ERROR)
-      DPRINT1("SetCursor: DrvSetPointerShape() returned SPS_ERROR\n");
-
    return Ret;
 }
 
@@ -1804,7 +1780,7 @@ UserShowCursor(BOOL bShow)
         {
             //ppdev->SafetyRemoveCount = 1;
             //ppdev->SafetyRemoveLevel = 1;
-            EngMovePointer(SurfObj,-1,-1,NULL);
+            IntEngMovePointer(SurfObj,-1,-1,NULL);
             CurInfo->ShowingCursor = 0;
         }
 
@@ -1819,7 +1795,7 @@ UserShowCursor(BOOL bShow)
         {
             //ppdev->SafetyRemoveCount = 0;
             //ppdev->SafetyRemoveLevel = 0;
-            EngMovePointer(SurfObj,-1,-1,NULL);
+            IntEngMovePointer(SurfObj,-1,-1,NULL);
             CurInfo->ShowingCursor = CURSOR_SHOWING;
         }
     }
index e2dbd3d..d7c9cea 100644 (file)
@@ -553,6 +553,11 @@ IntCreatePrimarySurface()
     gpsi->ptCursor.x = (SurfaceRect.right - SurfaceRect.left) / 2;
     gpsi->ptCursor.y = (SurfaceRect.bottom - SurfaceRect.top) / 2;
 
+    /* Give the PDEV a MovePointer function */
+    PrimarySurface.pfnMovePointer = PrimarySurface.DriverFunctions.MovePointer;
+    if (!PrimarySurface.pfnMovePointer)
+        PrimarySurface.pfnMovePointer = EngMovePointer;
+
     EngUnlockSurface(SurfObj);
     co_IntShowDesktop(IntGetActiveDesktop(), SurfSize.cx, SurfSize.cy);
 
index 52ac082..5f64e34 100644 (file)
@@ -329,7 +329,7 @@ IntSetDIBits(
   DestRect.right       = SourceSize.cx;
   DestRect.bottom      = DestRect.top + ScanLines;
 
-  copyBitsResult = EngCopyBits(DestSurf, SourceSurf, NULL, XlateObj, &DestRect, &ZeroPoint);
+  copyBitsResult = IntEngCopyBits(DestSurf, SourceSurf, NULL, XlateObj, &DestRect, &ZeroPoint);
 
   // If it succeeded, return number of scanlines copies
   if(copyBitsResult == TRUE)
@@ -952,7 +952,7 @@ NtGdiGetDIBitsInternal(HDC hDC,
 
           DestSurfObj = EngLockSurface((HSURF)hDestBitmap);
 
-          if (EngCopyBits( DestSurfObj,
+          if (IntEngCopyBits( DestSurfObj,
                           &psurf->SurfObj,
                            NULL,
                            XlateObj,