Rename framebuf.def to framebuf_acc.def, framebuf.h to framebuf_acc.h, framebuf.rbuild to framebuf_acc.h

Start add hw mouse cures support
Deleted all old mouse pointer code that was disable. 

Disable the new cached code for now


svn path=/trunk/; revision=30040
This commit is contained in:
Magnus Olsen 2007-11-01 14:40:22 +00:00
parent fc74dc4764
commit 75d64c3e09
9 changed files with 137 additions and 363 deletions

View file

@ -18,20 +18,20 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "framebuf.h"
#include "framebuf_acc.h"
static DRVFN DrvFunctionTable[] =
{
{INDEX_DrvEnablePDEV, (PFN)DrvEnablePDEV},
{INDEX_DrvCompletePDEV, (PFN)DrvCompletePDEV},
{INDEX_DrvDisablePDEV, (PFN)DrvDisablePDEV},
{INDEX_DrvEnableSurface, (PFN)DrvEnableSurface},
{INDEX_DrvDisableSurface, (PFN)DrvDisableSurface},
{INDEX_DrvAssertMode, (PFN)DrvAssertMode},
{INDEX_DrvGetModes, (PFN)DrvGetModes},
{INDEX_DrvSetPalette, (PFN)DrvSetPalette},
{INDEX_DrvSetPointerShape, (PFN)DrvSetPointerShape},
{INDEX_DrvMovePointer, (PFN)DrvMovePointer}
{INDEX_DrvEnablePDEV, (PFN)DrvEnablePDEV},
{INDEX_DrvCompletePDEV, (PFN)DrvCompletePDEV},
{INDEX_DrvDisablePDEV, (PFN)DrvDisablePDEV},
{INDEX_DrvEnableSurface, (PFN)DrvEnableSurface},
{INDEX_DrvDisableSurface, (PFN)DrvDisableSurface},
{INDEX_DrvAssertMode, (PFN)DrvAssertMode},
{INDEX_DrvGetModes, (PFN)DrvGetModes},
{INDEX_DrvSetPalette, (PFN)DrvSetPalette},
{INDEX_DrvSetPointerShape, (PFN)DrvSetPointerShape},
{INDEX_DrvMovePointer, (PFN)DrvMovePointer}
};
@ -91,6 +91,7 @@ DrvEnablePDEV(
PPDEV ppdev;
GDIINFO GdiInfo;
DEVINFO DevInfo;
ULONG returnedDataLength = 0;
ppdev = EngAllocMem(FL_ZERO_MEMORY, sizeof(PDEV), ALLOC_TAG);
if (ppdev == NULL)
@ -106,6 +107,35 @@ DrvEnablePDEV(
return NULL;
}
/* hw mouse pointer */
ppdev->pPointerAttributes = NULL;
ppdev->PointerAttributesSize = 0;
/* Test see if the driver support hw mouse or not */
if (!EngDeviceIoControl(ppdev->hDriver,IOCTL_VIDEO_QUERY_POINTER_CAPABILITIES,
&ppdev->ModeIndex, sizeof(PVIDEO_MODE),
&ppdev->PointerCapabilities,
sizeof(VIDEO_POINTER_CAPABILITIES),
&returnedDataLength))
{
/* Test see if we got a hw mouse or not */
if ( (ppdev->PointerCapabilities.Flags & VIDEO_MODE_MONO_POINTER) ||
(ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER) )
{
/* determent the hw mouse mode */
if (!(ppdev->PointerCapabilities.Flags & VIDEO_MODE_ASYNC_POINTER))
{
DevInfo.flGraphicsCaps &= ~GCAPS_ASYNCMOVE;
}
else
{
DevInfo.flGraphicsCaps |= GCAPS_ASYNCMOVE;
}
}
}
/* setup paletted */
if (!IntInitDefaultPalette(ppdev, &DevInfo))
{
EngFreeMem(ppdev);

View file

@ -29,13 +29,18 @@
#include <winioctl.h>
#include <ntddvdeo.h>
//#define EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
//#define EXPERIMENTAL_ACC_SUPPORT
typedef struct _PDEV
{
/* Driver stuff */
HANDLE hDriver;
HDEV hDevEng;
HSURF hSurfEng;
ULONG dwHooks;
/* Screen Data */
ULONG ModeIndex;
ULONG ScreenWidth;
ULONG ScreenHeight;
@ -46,16 +51,24 @@ typedef struct _PDEV
ULONG BlueMask;
BYTE PaletteShift;
PVOID ScreenPtr;
/* Palette data */
HPALETTE DefaultPalette;
PALETTEENTRY *PaletteEntries;
/* hw mouse acclartions support */
VIDEO_POINTER_CAPABILITIES PointerCapabilities;
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes;
ULONG PointerAttributesSize;
POINTL PointerHotSpot;
BOOL HwMouseActive;
#ifdef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
VIDEO_POINTER_ATTRIBUTES PointerAttributes;
XLATEOBJ *PointerXlateObject;
HSURF PointerColorSurface;
HSURF PointerMaskSurface;
HSURF PointerSaveSurface;
POINTL PointerHotSpot;
#endif
/* DirectX Support */

View file

@ -1,8 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../../tools/rbuild/project.dtd">
<module name="framebuf" type="kernelmodedll" entrypoint="_DrvEnableDriver@12" installbase="system32" installname="framebuf.dll">
<importlibrary definition="framebuf.def" />
<include base="framebuf">.</include>
<module name="framebuf_acc" type="kernelmodedll" entrypoint="_DrvEnableDriver@12" installbase="system32" installname="framebuf.dll">
<importlibrary definition="framebuf_acc.def" />
<include base="framebuf_acc">.</include>
<library>win32k</library>
<library>libcntpr</library>
<file>enable.c</file>
@ -10,5 +10,5 @@
<file>pointer.c</file>
<file>screen.c</file>
<file>surface.c</file>
<file>framebuf.rc</file>
<file>framebuf_acc.rc</file>
</module>

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "framebuf.h"
#include "framebuf_acc.h"
/*
* Standard color that must be in palette, because they're used for

View file

@ -18,9 +18,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "framebuf.h"
#include "framebuf_acc.h"
#ifndef EXPERIMENTAL_MOUSE_CURSOR_SUPPORT
/*
* DrvSetPointerShape
@ -68,303 +68,4 @@ DrvMovePointer(
return EngMovePointer(pso, x, y, prcl);
}
#else
VOID FASTCALL
IntHideMousePointer(PPDEV ppdev, SURFOBJ *DestSurface)
{
if (ppdev->PointerAttributes.Enable == FALSE)
{
return;
}
ppdev->PointerAttributes.Enable = FALSE;
if (ppdev->PointerSaveSurface != NULL)
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *SaveSurface;
SURFOBJ *MaskSurface;
DestRect.left = max(ppdev->PointerAttributes.Column, 0);
DestRect.top = max(ppdev->PointerAttributes.Row, 0);
DestRect.right = min(
ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
ppdev->ScreenWidth - 1);
DestRect.bottom = min(
ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
ppdev->ScreenHeight - 1);
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
MaskSurface = EngLockSurface(ppdev->PointerMaskSurface);
EngBitBlt(DestSurface, SaveSurface, MaskSurface, NULL, NULL,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL, SRCCOPY);
EngUnlockSurface(MaskSurface);
EngUnlockSurface(SaveSurface);
}
}
VOID FASTCALL
IntShowMousePointer(PPDEV ppdev, SURFOBJ *DestSurface)
{
if (ppdev->PointerAttributes.Enable == TRUE)
{
return;
}
ppdev->PointerAttributes.Enable = TRUE;
/*
* Copy the pixels under the cursor to temporary surface.
*/
if (ppdev->PointerSaveSurface != NULL)
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *SaveSurface;
SrcPoint.x = max(ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(ppdev->PointerAttributes.Row, 0);
DestRect.left = SrcPoint.x - ppdev->PointerAttributes.Column;
DestRect.top = SrcPoint.y - ppdev->PointerAttributes.Row;
DestRect.right = min(
ppdev->PointerAttributes.Width,
ppdev->ScreenWidth - ppdev->PointerAttributes.Column - 1);
DestRect.bottom = min(
ppdev->PointerAttributes.Height,
ppdev->ScreenHeight - ppdev->PointerAttributes.Row - 1);
SaveSurface = EngLockSurface(ppdev->PointerSaveSurface);
EngBitBlt(SaveSurface, DestSurface, NULL, NULL, NULL,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCCOPY);
EngUnlockSurface(SaveSurface);
}
/*
* Blit the cursor on the screen.
*/
{
RECTL DestRect;
POINTL SrcPoint;
SURFOBJ *ColorSurf;
SURFOBJ *MaskSurf;
DestRect.left = max(ppdev->PointerAttributes.Column, 0);
DestRect.top = max(ppdev->PointerAttributes.Row, 0);
DestRect.right = min(
ppdev->PointerAttributes.Column + ppdev->PointerAttributes.Width,
ppdev->ScreenWidth - 1);
DestRect.bottom = min(
ppdev->PointerAttributes.Row + ppdev->PointerAttributes.Height,
ppdev->ScreenHeight - 1);
SrcPoint.x = max(-ppdev->PointerAttributes.Column, 0);
SrcPoint.y = max(-ppdev->PointerAttributes.Row, 0);
MaskSurf = EngLockSurface(ppdev->PointerMaskSurface);
if (ppdev->PointerColorSurface != NULL)
{
ColorSurf = EngLockSurface(ppdev->PointerColorSurface);
EngBitBlt(DestSurface, ColorSurf, MaskSurf, NULL, ppdev->PointerXlateObject,
&DestRect, &SrcPoint, &SrcPoint, NULL, NULL, 0xAACC);
EngUnlockSurface(ColorSurf);
}
else
{
/* FIXME */
EngBitBlt(DestSurface, MaskSurf, NULL, NULL, ppdev->PointerXlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCAND);
SrcPoint.y += ppdev->PointerAttributes.Height;
EngBitBlt(DestSurface, MaskSurf, NULL, NULL, ppdev->PointerXlateObject,
&DestRect, &SrcPoint, NULL, NULL, NULL, SRCINVERT);
}
EngUnlockSurface(MaskSurf);
}
}
/*
* DrvSetPointerShape
*
* Sets the new pointer shape.
*
* Status
* @implemented
*/
ULONG APIENTRY
DrvSetPointerShape(
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)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
SURFOBJ *TempSurfObj;
IntHideMousePointer(ppdev, pso);
if (ppdev->PointerColorSurface != NULL)
{
/* FIXME: Is this really needed? */
TempSurfObj = EngLockSurface(ppdev->PointerColorSurface);
EngFreeMem(TempSurfObj->pvBits);
TempSurfObj->pvBits = 0;
EngUnlockSurface(TempSurfObj);
EngDeleteSurface(ppdev->PointerColorSurface);
ppdev->PointerMaskSurface = NULL;
}
if (ppdev->PointerMaskSurface != NULL)
{
/* FIXME: Is this really needed? */
TempSurfObj = EngLockSurface(ppdev->PointerMaskSurface);
EngFreeMem(TempSurfObj->pvBits);
TempSurfObj->pvBits = 0;
EngUnlockSurface(TempSurfObj);
EngDeleteSurface(ppdev->PointerMaskSurface);
ppdev->PointerMaskSurface = NULL;
}
if (ppdev->PointerSaveSurface != NULL)
{
EngDeleteSurface(ppdev->PointerSaveSurface);
ppdev->PointerSaveSurface = NULL;
}
/*
* See if we are being asked to hide the pointer.
*/
if (psoMask == NULL)
{
return SPS_ACCEPT_EXCLUDE;
}
ppdev->PointerHotSpot.x = xHot;
ppdev->PointerHotSpot.y = yHot;
ppdev->PointerXlateObject = pxlo;
ppdev->PointerAttributes.Column = x - xHot;
ppdev->PointerAttributes.Row = y - yHot;
ppdev->PointerAttributes.Width = psoMask->lDelta << 3;
ppdev->PointerAttributes.Height = (psoMask->cjBits / psoMask->lDelta) >> 1;
if (psoColor != NULL)
{
SIZEL Size;
PBYTE Bits;
Size.cx = ppdev->PointerAttributes.Width;
Size.cy = ppdev->PointerAttributes.Height;
Bits = EngAllocMem(0, psoColor->cjBits, ALLOC_TAG);
memcpy(Bits, psoColor->pvBits, psoColor->cjBits);
ppdev->PointerColorSurface = (HSURF)EngCreateBitmap(Size,
psoColor->lDelta, psoColor->iBitmapFormat, 0, Bits);
}
else
{
ppdev->PointerColorSurface = NULL;
}
if (psoMask != NULL)
{
SIZEL Size;
PBYTE Bits;
Size.cx = ppdev->PointerAttributes.Width;
Size.cy = ppdev->PointerAttributes.Height << 1;
Bits = EngAllocMem(0, psoMask->cjBits, ALLOC_TAG);
memcpy(Bits, psoMask->pvBits, psoMask->cjBits);
ppdev->PointerMaskSurface = (HSURF)EngCreateBitmap(Size,
psoMask->lDelta, psoMask->iBitmapFormat, 0, Bits);
}
else
{
ppdev->PointerMaskSurface = NULL;
}
/*
* Create surface for saving the pixels under the cursor.
*/
{
SIZEL Size;
LONG lDelta;
Size.cx = ppdev->PointerAttributes.Width;
Size.cy = ppdev->PointerAttributes.Height;
switch (pso->iBitmapFormat)
{
case BMF_8BPP: lDelta = Size.cx; break;
case BMF_16BPP: lDelta = Size.cx << 1; break;
case BMF_24BPP: lDelta = Size.cx * 3; break;
case BMF_32BPP: lDelta = Size.cx << 2; break;
}
ppdev->PointerSaveSurface = (HSURF)EngCreateBitmap(
Size, lDelta, pso->iBitmapFormat, BMF_NOZEROINIT, NULL);
}
IntShowMousePointer(ppdev, pso);
return SPS_ACCEPT_EXCLUDE;
}
/*
* DrvMovePointer
*
* Moves the pointer to a new position and ensures that GDI does not interfere
* with the display of the pointer.
*
* Status
* @implemented
*/
VOID APIENTRY
DrvMovePointer(
IN SURFOBJ *pso,
IN LONG x,
IN LONG y,
IN RECTL *prcl)
{
PPDEV ppdev = (PPDEV)pso->dhpdev;
BOOL WasVisible;
WasVisible = ppdev->PointerAttributes.Enable;
if (WasVisible)
{
IntHideMousePointer(ppdev, pso);
}
if (x == -1)
{
return;
}
ppdev->PointerAttributes.Column = x - ppdev->PointerHotSpot.x;
ppdev->PointerAttributes.Row = y - ppdev->PointerHotSpot.y;
if (WasVisible)
{
IntShowMousePointer(ppdev, pso);
}
}
#endif

View file

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "framebuf.h"
#include "framebuf_acc.h"
/*
* GetAvailableModes

View file

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "framebuf.h"
#include "framebuf_acc.h"
BOOL
InitSurface(PPDEV ppdev,
@ -29,6 +29,8 @@ InitSurface(PPDEV ppdev,
VIDEO_MEMORY_INFORMATION VideoMemoryInfo;
ULONG returnedDataLength;
ULONG RemappingNeeded = 0;
ULONG PointerMaxWidth = 0;
ULONG PointerMaxHeight = 0;
/*
* Set video mode of our adapter.
@ -72,11 +74,16 @@ InitSurface(PPDEV ppdev,
ppdev->pRealVideoMem = VideoMemoryInfo.FrameBufferBase;
ppdev->VideoMemSize = VideoMemoryInfo.VideoRamLength;
/*
* Video memory cached
*
* We maby should only ask max 8MB as cached ?, think of the video ram length is 256MB
*/
ppdev->pVideoMemCache = NULL;
#ifdef EXPERIMENTAL_ACC_SUPPORT
ppdev->pVideoMemCache = EngAllocMem(0, (ULONG)VideoMemoryInfo.VideoRamLength, ALLOC_TAG);
if (ppdev->pVideoMemCache == NULL)
{
@ -84,12 +91,40 @@ InitSurface(PPDEV ppdev,
ppdev->ScreenPtr = VideoMemoryInfo.FrameBufferBase;
}
else
#endif
{
/* cached on, system memory is avail */
ppdev->ScreenPtr = ppdev->pRealVideoMem;
}
/* FIXME hw mouse pointer */
/* hw mouse pointer support */
PointerMaxHeight = ppdev->PointerCapabilities.MaxHeight;
PointerMaxWidth = ppdev->PointerCapabilities.MaxWidth * sizeof(ULONG);
if (ppdev->PointerCapabilities.Flags & VIDEO_MODE_COLOR_POINTER)
{
PointerMaxWidth = (ppdev->PointerCapabilities.MaxWidth + 7) / 8;
}
ppdev->PointerAttributesSize = sizeof(VIDEO_POINTER_ATTRIBUTES) + ((sizeof(UCHAR) * PointerMaxWidth * PointerMaxHeight) << 1);
ppdev->pPointerAttributes = EngAllocMem(0, ppdev->PointerAttributesSize, ALLOC_TAG);
if (ppdev->pPointerAttributes != NULL)
{
ppdev->pPointerAttributes->Flags = ppdev->PointerCapabilities.Flags;
ppdev->pPointerAttributes->WidthInBytes = PointerMaxWidth;
ppdev->pPointerAttributes->Width = ppdev->PointerCapabilities.MaxWidth;
ppdev->pPointerAttributes->Height = PointerMaxHeight;
ppdev->pPointerAttributes->Column = 0;
ppdev->pPointerAttributes->Row = 0;
ppdev->pPointerAttributes->Enable = 0;
}
else
{
/* no hw mouse was avail */
ppdev->PointerAttributesSize = 0;
}
return TRUE;
}
@ -157,13 +192,15 @@ DrvEnableSurface(
return FALSE;
}
/* Which api we hooking to */
ppdev->dwHooks = HOOK_BITBLT | HOOK_COPYBITS | HOOK_FILLPATH | HOOK_TEXTOUT | HOOK_STROKEPATH | HOOK_LINETO ;
/*
* Associate the surface with our device.
*/
if (!EngAssociateSurface(hSurface, ppdev->hDevEng, HOOK_BITBLT | HOOK_COPYBITS |
HOOK_FILLPATH | HOOK_TEXTOUT |
HOOK_STROKEPATH | HOOK_LINETO))
if (!EngAssociateSurface(hSurface, ppdev->hDevEng, ppdev->dwHooks))
{
EngDeleteSurface(hSurface);
return FALSE;
@ -232,52 +269,43 @@ DrvAssertMode(
{
PPDEV ppdev = (PPDEV)dhpdev;
ULONG ulTemp;
BOOLEAN Result = TRUE;
if (bEnable)
{
BOOLEAN Result;
PBYTE pRealVideoMem = ppdev->pRealVideoMem;
PVOID pRealVideoMem = ppdev->pRealVideoMem;
/* Setup surface and remapping if it need it */
if (!InitSurface(ppdev, FALSE))
{
return FALSE;
Result = FALSE;
}
/* Check if we got same surface or not */
if (pRealVideoMem != ppdev->pRealVideoMem)
else
{
if (ppdev->pVideoMemCache == NULL)
{
if ( !EngModifySurface(ppdev->hsurfEng,
ppdev->hdevEng,
ppdev->flHooks | HOOK_SYNCHRONIZE,
MS_NOTSYSTEMMEMORY,
(DHSURF)ppdev,
ppdev->pRealVideoMem,
ppdev->lDeltaScreen,
NULL))
{
return FALSE;
}
}
else
{
if ( !EngModifySurface(ppdev->hsurfEng,
ppdev->hdevEng,
ppdev->flHooks | HOOK_SYNCHRONIZE,
0,
(DHSURF)ppdev,
ppdev->pVideoMemCache,
ppdev->lDeltaScreen,
NULL))
{
return FALSE;
}
}
}
/* Check if we got same surface or not */
if (pRealVideoMem != ppdev->pRealVideoMem)
{
PVOID pVideoMem= NULL;
return TRUE;
if (ppdev->pVideoMemCache == NULL)
{
pVideoMem = ppdev->pRealVideoMem;
}
else
{
pVideoMem = ppdev->pVideoMemCache;
}
Result = !EngModifySurface(ppdev->hSurfEng, ppdev->hDevEng,
ppdev->dwHooks | HOOK_SYNCHRONIZE,
0, (DHSURF)ppdev, pVideoMem,
ppdev->ScreenDelta, NULL);
}
/* if the pRealVideoMem == ppdev->pRealVideoMem are
* the Result is then TRUE
*/
}
}
else
@ -286,7 +314,9 @@ DrvAssertMode(
* Call the miniport driver to reset the device to a known state.
*/
return !EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_RESET_DEVICE,
Result = !EngDeviceIoControl(ppdev->hDriver, IOCTL_VIDEO_RESET_DEVICE,
NULL, 0, NULL, 0, &ulTemp);
}
return Result;
}