Author: fireball Date: Sat Aug 15 14:59:07 2009 New Revision: 42697
URL: http://svn.reactos.org/svn/reactos?rev=42697&view=rev Log: - Update mouse pointer code from trunk. Color cursors aren't supported due to absence of EXLATEOBJs.
Modified: branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h
Modified: branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/eng/engpoint.c [iso-8859-1] Sat Aug 15 14:59:07 2009 @@ -13,7 +13,6 @@ #include <debug.h>
#define TAG_MOUSE TAG('M', 'O', 'U', 'S') /* mouse */ -#define GDIDEV(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))
/* PUBLIC FUNCTIONS **********************************************************/
@@ -59,7 +58,7 @@ ptlSave.y = rclDest.top - pt.y;
GrepBitBltEx(psoDest, - pgp->psurfSave, + &pgp->psurfSave->SurfObj, NULL, NULL, NULL, @@ -108,7 +107,7 @@ rclPointer.bottom = min(pgp->Size.cy, psoDest->sizlBitmap.cy - pt.y);
/* Copy the pixels under the cursor to temporary surface. */ - GrepBitBltEx(pgp->psurfSave, + GrepBitBltEx(&pgp->psurfSave->SurfObj, psoDest, NULL, NULL, @@ -125,8 +124,8 @@ if (pgp->psurfColor) { GrepBitBltEx(psoDest, - pgp->psurfColor, - pgp->psurfMask, + &pgp->psurfColor->SurfObj, + &pgp->psurfMask->SurfObj, NULL, pgp->XlateObject, &rclSurf, @@ -140,7 +139,7 @@ else { GrepBitBltEx(psoDest, - pgp->psurfMask, + &pgp->psurfMask->SurfObj, NULL, NULL, pgp->XlateObject, @@ -155,7 +154,7 @@ rclPointer.top += pgp->Size.cy;
GrepBitBltEx(psoDest, - pgp->psurfMask, + &pgp->psurfMask->SurfObj, NULL, NULL, pgp->XlateObject, @@ -272,55 +271,65 @@ { PDEVOBJ *ppdev; GDIPOINTER *pgp; - PBYTE Bits; - SIZEL Size; LONG lDelta; HBITMAP hbmp; + RECTL rcl;
ASSERT(pso);
ppdev = GDIDEV(pso); pgp = &ppdev->Pointer;
+ if (psoColor) + { + pgp->Size.cx = psoColor->sizlBitmap.cx; + pgp->Size.cy = psoColor->sizlBitmap.cy; + 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; + } + } + } + else if (psoMask) + { + pgp->Size.cx = psoMask->sizlBitmap.cx; + pgp->Size.cy = psoMask->sizlBitmap.cy / 2; + } + IntHideMousePointer(ppdev, pso);
if (pgp->psurfColor) { - /* FIXME: let GDI allocate/free memory */ - EngFreeMem(pgp->psurfColor->pvBits); - pgp->psurfColor->pvBits = 0; - - EngDeleteSurface(pgp->psurfColor->hsurf); + EngDeleteSurface(pgp->psurfColor->BaseObject.hHmgr); SURFACE_ShareUnlock(pgp->psurfColor); pgp->psurfColor = NULL; }
if (pgp->psurfMask) { - /* FIXME: let GDI allocate/free memory */ - EngFreeMem(pgp->psurfMask->pvBits); - pgp->psurfMask->pvBits = 0; - - EngDeleteSurface(pgp->psurfMask->hsurf); + EngDeleteSurface(pgp->psurfMask->BaseObject.hHmgr); SURFACE_ShareUnlock(pgp->psurfMask); pgp->psurfMask = NULL; }
if (pgp->psurfSave != NULL) { - EngDeleteSurface(pgp->psurfSave->hsurf); + EngDeleteSurface(pgp->psurfSave->BaseObject.hHmgr); SURFACE_ShareUnlock(pgp->psurfSave); pgp->psurfSave = NULL; }
- if (pgp->XlateObject != NULL) - { - EngDeleteXlate(pgp->XlateObject); - pgp->XlateObject = NULL; - } - /* See if we are being asked to hide the pointer. */ - if (psoMask == NULL) + if (psoMask == NULL && psoColor == NULL) { return SPS_ACCEPT_NOEXCLUDE; } @@ -328,113 +337,94 @@ pgp->HotSpot.x = xHot; pgp->HotSpot.y = yHot;
- if (x != -1) - { - ptlPointer.x = x; - ptlPointer.y = y; - } - - pgp->Size.cx = abs(psoMask->lDelta) << 3; - pgp->Size.cy = (psoMask->cjBits / abs(psoMask->lDelta)) >> 1; - - if (psoColor != NULL) - { - /* FIXME: let GDI allocate/free memory */ - Bits = EngAllocMem(0, psoColor->cjBits, TAG_MOUSE); - if (Bits == NULL) - { - return SPS_ERROR; - } - - memcpy(Bits, psoColor->pvBits, psoColor->cjBits); - - hbmp = EngCreateBitmap(pgp->Size, - psoColor->lDelta, - psoColor->iBitmapFormat, - psoColor->lDelta < 0 ? 0 : BMF_TOPDOWN, - Bits); - - pgp->psurfColor = EngLockSurface(hbmp); - } - else - { - pgp->psurfColor = NULL; - } - - 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); - - hbmp = EngCreateBitmap(Size, - psoMask->lDelta, - psoMask->iBitmapFormat, - psoMask->lDelta < 0 ? 0 : BMF_TOPDOWN, - Bits); - - pgp->psurfMask = EngLockSurface(hbmp); - - /* Create an XLATEOBJ that will be used for drawing masks. - * FIXME: We should get this in pxlo parameter! */ - if (pxlo == NULL) - { - HPALETTE BWPalette, DestPalette; - ULONG BWColors[] = {0, 0xFFFFFF}; - - BWPalette = EngCreatePalette(PAL_INDEXED, sizeof(BWColors) / sizeof(ULONG), - BWColors, 0, 0, 0); - - DestPalette = ppdev->DevInfo.hpalDefault; - pgp->XlateObject = IntEngCreateXlate(0, 0, - DestPalette, BWPalette); - EngDeletePalette(BWPalette); - } - else - { - pgp->XlateObject = pxlo; - } + /* 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. */ - 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->psurfSave = EngLockSurface(hbmp); + pgp->psurfSave = SURFACE_ShareLock(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_ShareLock(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; + GreCopyBits(&pgp->psurfMask->SurfObj, + psoMask, + NULL, + 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_ShareLock(hbmp); + if (pgp->psurfColor) + { + rcl.bottom = psoColor->sizlBitmap.cy; + GreCopyBits(&pgp->psurfColor->SurfObj, + psoColor, + NULL, + pxlo, + &rcl, + (POINTL*)&rcl); + } + } + else + { + pgp->psurfColor = NULL; + }
if (x != -1) { + ptlPointer.x = x; + ptlPointer.y = y; + IntShowMousePointer(ppdev, pso);
if (prcl != NULL) @@ -444,8 +434,11 @@ prcl->right = prcl->left + pgp->Size.cx; prcl->bottom = prcl->top + pgp->Size.cy; } - } else if (prcl != NULL) + } + else if (prcl != NULL) + { prcl->left = prcl->top = prcl->right = prcl->bottom = -1; + }
return SPS_ACCEPT_NOEXCLUDE; }
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/cursoricon.c [iso-8859-1] Sat Aug 15 14:59:07 2009 @@ -26,7 +26,6 @@ SURFACE_UnlockBitmapBits(pSurf); }
- ULONG NTAPI GreSetPointerShape( IN SURFOBJ *pso, @@ -41,9 +40,9 @@ IN FLONG fl) { ULONG ulResult = SPS_DECLINE; + SURFACE *pSurf = CONTAINING_RECORD(pso, SURFACE, SurfObj); PFN_DrvSetPointerShape pfnSetPointerShape; - PPDEVOBJ ppdev = &PrimarySurface; - SURFACE *pSurf = CONTAINING_RECORD(pso, SURFACE, SurfObj); + PPDEVOBJ ppdev = GDIDEV(pso);
pfnSetPointerShape = GDIDEVFUNCS(pso).SetPointerShape;
@@ -96,128 +95,83 @@ NTAPI GreSetCursor(ICONINFO* NewCursor, PSYSTEM_CURSORINFO CursorInfo) { - SURFOBJ *pso; - SURFACE *MaskBmpObj = NULL; - HBITMAP hMask = 0; - SURFOBJ *soMask = NULL, *soColor = NULL; - XLATEOBJ *XlateObj = NULL; - ULONG Status; + SURFOBJ *pso; + HBITMAP hbmMask, hbmColor; + PSURFACE psurfMask, psurfColor; + XLATEOBJ *XlateObj = NULL; + ULONG Status;
- pso = EngLockSurface(PrimarySurface.pSurface); + pso = EngLockSurface(PrimarySurface.pSurface);
- if (!NewCursor) - { - if (CursorInfo->ShowingCursor) - { + if (!NewCursor) + { + if (CursorInfo->ShowingCursor) + { DPRINT("Removing pointer!\n"); /* Remove the cursor if it was displayed */ GreMovePointer(pso, -1, -1, NULL); - } + } + CursorInfo->ShowingCursor = 0; + EngUnlockSurface(pso); + return TRUE; + }
- CursorInfo->ShowingCursor = 0; + CursorInfo->ShowingCursor = TRUE; + CursorInfo->CurrentCursorObject = *NewCursor;
- EngUnlockSurface(pso); + hbmMask = NewCursor->hbmMask; + hbmColor = NewCursor->hbmColor;
- return TRUE; - } + /* Lock the mask bitmap */ + if (hbmMask) + psurfMask = SURFACE_ShareLock(hbmMask); + else + psurfMask = NULL;
- MaskBmpObj = SURFACE_Lock(NewCursor->hbmMask); - if (MaskBmpObj) - { - const int maskBpp = BitsPerFormat(MaskBmpObj->SurfObj.iBitmapFormat); - SURFACE_Unlock(MaskBmpObj); - if (maskBpp != 1) - { - DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n"); - EngUnlockSurface(pso); - return FALSE; - } - - if ((PrimarySurface.DevInfo.flGraphicsCaps2 & GCAPS2_ALPHACURSOR) && - pso->iBitmapFormat >= BMF_16BPP && - pso->iBitmapFormat <= BMF_32BPP) - { - /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits! - Do not pass a mask bitmap to DrvSetPointerShape()! - Create a XLATEOBJ that describes the colors of the bitmap. */ - DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n"); - } - else - { - if(NewCursor->hbmColor) - { - /* FIXME - Create a color pointer, create only one 32bit bitmap! - Do not pass a mask bitmap to DrvSetPointerShape()! - Create a XLATEOBJ that describes the colors of the bitmap. - (16bit bitmaps are propably allowed) */ - DPRINT1("SetCursor: Cursors with colors are not supported!\n"); - } - else - { - MaskBmpObj = SURFACE_Lock((HSURF)NewCursor->hbmMask); - if(MaskBmpObj) - { - RECTL DestRect = {0, 0, MaskBmpObj->SurfObj.sizlBitmap.cx, MaskBmpObj->SurfObj.sizlBitmap.cy}; - POINTL SourcePoint = {0, 0}; - - /* - * NOTE: For now we create the cursor in top-down bitmap, - * because VMware driver rejects it otherwise. This should - * be fixed later. - */ - hMask = EngCreateBitmap( - MaskBmpObj->SurfObj.sizlBitmap, abs(MaskBmpObj->SurfObj.lDelta), - MaskBmpObj->SurfObj.iBitmapFormat, BMF_TOPDOWN, - NULL); - if ( !hMask ) - { - SURFACE_Unlock(MaskBmpObj); - EngUnlockSurface(pso); - return FALSE; - } - soMask = EngLockSurface((HSURF)hMask); - GreCopyBits(soMask, &MaskBmpObj->SurfObj, NULL, NULL, - &DestRect, &SourcePoint); - SURFACE_Unlock(MaskBmpObj); - } - } - } - CursorInfo->ShowingCursor = TRUE; - CursorInfo->CurrentCursorObject = *NewCursor; - } - else - { - CursorInfo->ShowingCursor = FALSE; - } + /* Check for color bitmap */ + if (hbmColor) + { + /* We have one, lock it */ + psurfColor = SURFACE_ShareLock(hbmColor); + + if (psurfColor) + { + /* Create an XLATEOBJ, no mono support */ + //EXLATEOBJ_vInitialize(&exlo, psurfColor->ppal, psurf->ppal, 0, 0, 0); + UNIMPLEMENTED; + } + } + else + psurfColor = NULL;
Status = GreSetPointerShape(pso, - soMask, - soColor, - XlateObj, - NewCursor->xHotspot, - NewCursor->yHotspot, - CursorInfo->CursorPos.x, - CursorInfo->CursorPos.y, - NULL, - SPS_CHANGE); + psurfMask ? &psurfMask->SurfObj : NULL, + psurfColor ? &psurfColor->SurfObj : NULL, + XlateObj, + NewCursor->xHotspot, + NewCursor->yHotspot, + CursorInfo->CursorPos.x, + CursorInfo->CursorPos.y, + NULL, + SPS_CHANGE);
if (Status != SPS_ACCEPT_NOEXCLUDE) { DPRINT1("GreSetPointerShape returned %lx\n", Status); }
- if(hMask) - { - EngUnlockSurface(soMask); - EngDeleteSurface((HSURF)hMask); - } - if(XlateObj) - { - EngDeleteXlate(XlateObj); - } + /* Cleanup */ + if (psurfColor) + { + //EXLATEOBJ_vCleanup(&exlo); + SURFACE_ShareUnlock(psurfColor); + }
- EngUnlockSurface(pso); + if (psurfMask) + SURFACE_ShareUnlock(psurfMask);
- return TRUE; + EngUnlockSurface(pso); + + return TRUE; }
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h [iso-8859-1] Sat Aug 15 14:59:07 2009 @@ -15,8 +15,8 @@ SIZEL Size; POINTL HotSpot; XLATEOBJ *XlateObject; - SURFOBJ *psurfColor; - SURFOBJ *psurfMask; - SURFOBJ *psurfSave; + SURFACE *psurfColor; + SURFACE *psurfMask; + SURFACE *psurfSave; RECTL Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */ } GDIPOINTER, *PGDIPOINTER;
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/surfobj.h [iso-8859-1] Sat Aug 15 14:59:07 2009 @@ -37,6 +37,7 @@ BOOL APIENTRY SURFACE_Cleanup(PVOID ObjectBody);
+#define GDIDEV(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev)) #define GDIDEVFUNCS(SurfObj) ((PDEVOBJ *)((SurfObj)->hdev))->DriverFunctions
#define SURFACE_Lock(hBMObj) \
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] Sat Aug 15 14:59:07 2009 @@ -37,10 +37,10 @@ /* Eng and GRE stuff */ #include <driver.h> #include <engevent.h> +#include <gdiobj.h> +#include <surfobj.h> #include <cursor.h> #include <devobj.h> -#include <gdiobj.h> -#include <surfobj.h> #include <brushobj.h> #include <dc.h> #include <palobj.h>