Start comment how thing works in dx stuff and done some reformat, adding EnableDirectDraw to the directdraw handler hDD

svn path=/trunk/; revision=25215
This commit is contained in:
Magnus Olsen 2006-12-23 19:06:43 +00:00
parent 9e9286ab0d
commit 22dc51bae5
2 changed files with 296 additions and 231 deletions

View file

@ -28,47 +28,48 @@ typedef struct
DD_DIRECTDRAW_LOCAL Local;
DD_DIRECTDRAW_GLOBAL Global;
// Drv callbacks
/* Drv callbacks */
PGD_GETDIRECTDRAWINFO DrvGetDirectDrawInfo;
PGD_DISABLEDIRECTDRAW DrvDisableDirectDraw;
PGD_ENABLEDIRECTDRAW EnableDirectDraw;
// DD callbacks
/* DD callbacks */
DD_CALLBACKS DD;
// Surface callbacks
/* Surface callbacks */
DD_SURFACECALLBACKS Surf;
// Palette callbacks
/* Palette callbacks */
DD_PALETTECALLBACKS Pal;
// HAL
/* HAL */
DD_HALINFO Hal;
// Color Control Callback
/* Color Control Callback */
DD_COLORCONTROLCALLBACKS Color;
// D3DHAL_CALLBACKS
/* D3DHAL_CALLBACKS */
//D3DHAL_CALLBACKS D3dHal;
// D3DHAL_CALLBACKS3 D3dHal3;
// D3DHAL_D3DEXTENDEDCAPS D3dHal3Ext;
// Heap Callback
/* Heap Callback */
PDD_GETHEAPALIGNMENTDATA HeapData;
// Kernel Callback
/* Kernel Callback */
DD_KERNELCALLBACKS Kernel;
DDKERNELCAPS KernelCaps;
// Miscellaneous Callback
/* Miscellaneous Callback */
DD_MISCELLANEOUSCALLBACKS Misc;
// NT-based Callback
/* NT-based Callback */
PDD_FLIPTOGDISURFACE DdFlipToGDISurface;
PDD_FREEDRIVERMEMORY DdFreeDriverMemory;
PDD_SETEXCLUSIVEMODE DdSetExclusiveMode;
// Motion Compensation
/*.Motion Compensation .*/
PDD_MOCOMPCB_BEGINFRAME DdMoCompBeginFrame;
PDD_MOCOMPCB_CREATE DdMoCompCreate;
PDD_MOCOMPCB_DESTROY DdMoCompDestroy;
@ -79,7 +80,8 @@ typedef struct
PDD_MOCOMPCB_GETINTERNALINFO DdMoCompGetInternalInfo;
PDD_MOCOMPCB_QUERYSTATUS DdMoCompQueryStatus;
PDD_MOCOMPCB_RENDER DdMoCompRender;
// Video Port Callback
/* Video Port Callback */
PDD_VPORTCB_CANCREATEVIDEOPORT DdVideoPortCanCreate;
PDD_VPORTCB_COLORCONTROL DdVideoPortColorControl;
PDD_VPORTCB_CREATEVIDEOPORT DdVideoPortCreate;
@ -95,13 +97,9 @@ typedef struct
PDD_VPORTCB_GETSIGNALSTATUS DdVideoPortGetSignalStatus;
PDD_VPORTCB_UPDATE DdVideoPortUpdate;
PDD_VPORTCB_WAITFORSYNC DdVideoPortWaitForSync;
// Notify Callback
/* Notify Callback */
//LPDD_NOTIFYCALLBACK NotifyCallback
} DD_DIRECTDRAW, *PDD_DIRECTDRAW;
BOOL INTERNAL_CALL DD_Cleanup(PVOID pDD);

View file

@ -10,7 +10,7 @@
#include <w32k.h>
#define NDEBUG
//#define NDEBUG
#include <debug.h>
GDIDEVICE IntGetPrimarySurface(VOID);
@ -34,13 +34,19 @@ DD_Cleanup(PVOID ObjectBody)
DPRINT1("DD_Cleanup\n");
if (!pDirectDraw)
{
return FALSE;
}
if (pDirectDraw->Global.dhpdev == NULL)
{
return FALSE;
}
if (pDirectDraw->DrvDisableDirectDraw == NULL)
{
return FALSE;
}
pDirectDraw->DrvDisableDirectDraw(pDirectDraw->Global.dhpdev);
return TRUE;
@ -66,17 +72,25 @@ NtGdiDdCreateDirectDrawObject(HDC hdc)
RtlZeroMemory(&palette_callbacks, sizeof(DD_PALETTECALLBACKS));
palette_callbacks.dwSize = sizeof(DD_PALETTECALLBACKS);
/* FIXME hdc can be zero for d3d9 */
/* we need create it, if in that case */
/* Create a hdc if we do not have one */
if (hdc == NULL)
{
HDC newHdc = IntGdiCreateDC(NULL,NULL,NULL,NULL,FALSE);
hdc = newHdc;
if (hdc == NULL)
{
DPRINT1("FIXME hdc is NULL \n");
return NULL;
}
}
/* Look the hdc to gain the internal struct */
pDC = DC_LockDc(hdc);
if (!pDC)
{
/* We did fail look here so return NULL */
return NULL;
}
@ -92,17 +106,21 @@ NtGdiDdCreateDirectDrawObject(HDC hdc)
return NULL;
}
/* test see if driver support DirectDraw interface */
success = pDC->DriverFunctions.EnableDirectDraw(
pDC->PDev, &callbacks, &surface_callbacks, &palette_callbacks);
if (!success)
{
DPRINT1("DirectDraw creation failed\n");
/* DirectDraw creation failed */
DPRINT1("DirectDraw creation failed\n");
DC_UnlockDc(pDC);
return NULL;
}
/* We found a DirectDraw interface
* Alloc a handler for it
*/
hDirectDraw = GDIOBJ_AllocObj(DdHandleTable, GDI_OBJECT_TYPE_DIRECTDRAW);
if (!hDirectDraw)
{
@ -111,6 +129,8 @@ NtGdiDdCreateDirectDrawObject(HDC hdc)
return NULL;
}
/* try look the DirectDraw handler and setup some data later */
pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDraw, GDI_OBJECT_TYPE_DIRECTDRAW);
if (!pDirectDraw)
{
@ -119,11 +139,34 @@ NtGdiDdCreateDirectDrawObject(HDC hdc)
return NULL;
}
/*
* We are caching all callbacks and some data
* reason for it, is we do not trust on the kernel/usermode
* pointer for the callbacks comes back from user mode.
* I perfer more safer way todo it, only safe way is
* to cache the callbacks pointer, and send back the true
* kernel pointer to user mode of the driver api we get back
* Windows is sending back kernel pointer of the driver we
* are doing same, differnt is we also cache it. and only
* use the cached one.
*/
/*
Getting the PDev bad idea we need the hdc instead
if we are doing a dymatic resultions change the
Pdev will get lost, we should cache the HDC instead
in windows, after a resultions change the HAL interface
need be rebuild from scrach, thanks to this.small problem
maybe we in ReactOS can found a solvtions on this later
*/
pDirectDraw->Global.dhpdev = pDC->PDev;
pDirectDraw->Local.lpGbl = &pDirectDraw->Global;
pDirectDraw->DrvGetDirectDrawInfo = pDC->DriverFunctions.GetDirectDrawInfo;
pDirectDraw->DrvDisableDirectDraw = pDC->DriverFunctions.DisableDirectDraw;
pDirectDraw->EnableDirectDraw = pDC->DriverFunctions.EnableDirectDraw;
/* DD_CALLBACKS setup */
RtlMoveMemory(&pDirectDraw->DD, &callbacks, sizeof(DD_CALLBACKS));
@ -144,11 +187,13 @@ NtGdiDdCreateDirectDrawObject(HDC hdc)
BOOL STDCALL
NtGdiDdDeleteDirectDrawObject( HANDLE hDirectDrawLocal)
{
DPRINT1("NtGdiDdDeleteDirectDrawObject\n");
return GDIOBJ_FreeObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
}
BOOL STDCALL NtGdiDdQueryDirectDrawObject(
BOOL STDCALL
NtGdiDdQueryDirectDrawObject(
HANDLE hDirectDrawLocal,
DD_HALINFO *pHalInfo,
DWORD *pCallBackFlags,
@ -185,7 +230,9 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
return FALSE;
}
pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
/* Look the DirectDraw interface */
pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal,
GDI_OBJECT_TYPE_DIRECTDRAW);
if (!pDirectDraw)
{
@ -193,18 +240,26 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
return FALSE;
}
/* lock susseces
* rest the pHalInfo size we do not known
* if we got a NT4 driver or windows 2000/XP/2003 driver yet
*/
pHalInfo->dwSize = 0;
success = pDirectDraw->DrvGetDirectDrawInfo(
pDirectDraw->Global.dhpdev,
/* Getting the request size of all struct at frist call
* Secound call we getting data back
*/
success = pDirectDraw->DrvGetDirectDrawInfo( pDirectDraw->Global.dhpdev,
&HalInfo,
puNumHeaps,
puvmList,
puNumFourCC,
puFourCC);
puNumHeaps, puvmList,
puNumFourCC, puFourCC);
if (!success)
{
/* fail we did not get any DrvGetDirectDrawInfo
* so we assume it is simple 2d DirectDraw interface
*/
DPRINT1("Driver does not fill the Fail to get DirectDraw driver info \n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
@ -213,11 +268,18 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
if (HalInfo.dwSize == 0)
{
/* some driver does not fill it, they only implement the DrvGetDirectDrawInfo
* so they work on Windows 2000/XP/2003
*/
DPRINT1(" Fail for driver does not fill the DD_HALINFO struct \n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return FALSE;
}
/* check see if DD_HALINFO is NT4 version or not
* if it NT4 version we convert it to NT5 version
*/
if (HalInfo.dwSize != sizeof(DD_HALINFO))
{
if (HalInfo.dwSize == sizeof(DD_HALINFO_V4))
@ -231,12 +293,14 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
}
else
{
/* Unknown version found */
DPRINT1(" Fail : did not get DD_HALINFO size \n");
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return FALSE;
}
}
/* Copy it to user mode pointer the data */
RtlMoveMemory(pHalInfo, &HalInfo, sizeof(DD_HALINFO));
/* rest the flag so we do not need do it later */
@ -246,29 +310,33 @@ BOOL STDCALL NtGdiDdQueryDirectDrawObject(
DPRINT1("Found DirectDraw CallBack for 2D and 3D Hal\n");
/* Copy it to the cache */
RtlMoveMemory(&pDirectDraw->Hal, pHalInfo, sizeof(DD_HALINFO));
if (pHalInfo->lpD3DGlobalDriverData)
{
/*
msdn say D3DHAL_GLOBALDRIVERDATA and D3DNTHAL_GLOBALDRIVERDATA are not same
but if u compare these in msdn it is exacly same
msdn say D3DHAL_GLOBALDRIVERDATA and D3DNTHAL_GLOBALDRIVERDATA
are not same but if u compare these in msdn it is exacly same
*/
DPRINT1("Found DirectDraw Global DriverData \n");
RtlMoveMemory(puD3dDriverData, pHalInfo->lpD3DGlobalDriverData, sizeof(D3DNTHAL_GLOBALDRIVERDATA));
RtlMoveMemory(puD3dDriverData, pHalInfo->lpD3DGlobalDriverData,
sizeof(D3DNTHAL_GLOBALDRIVERDATA));
}
if (pHalInfo->lpD3DHALCallbacks )
{
DPRINT1("Found DirectDraw CallBack for 3D Hal\n");
RtlMoveMemory(puD3dCallbacks, pHalInfo->lpD3DHALCallbacks, sizeof( D3DNTHAL_CALLBACKS ) );
RtlMoveMemory(puD3dCallbacks, pHalInfo->lpD3DHALCallbacks,
sizeof( D3DNTHAL_CALLBACKS ) );
}
if (pHalInfo->lpD3DBufCallbacks)
{
DPRINT1("Found DirectDraw CallBack for 3D Hal Bufffer \n");
/* msdn DDHAL_D3DBUFCALLBACKS = DD_D3DBUFCALLBACKS */
RtlMoveMemory(puD3dBufferCallbacks, pHalInfo->lpD3DBufCallbacks, sizeof(DD_D3DBUFCALLBACKS));
RtlMoveMemory(puD3dBufferCallbacks, pHalInfo->lpD3DBufCallbacks,
sizeof(DD_D3DBUFCALLBACKS));
}
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
@ -282,8 +350,8 @@ DWORD STDCALL NtGdiDdGetDriverInfo(
{
DWORD ddRVal = 0;
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal, GDI_OBJECT_TYPE_DIRECTDRAW);
PDD_DIRECTDRAW pDirectDraw = GDIOBJ_LockObj(DdHandleTable, hDirectDrawLocal,
GDI_OBJECT_TYPE_DIRECTDRAW);
DPRINT1("NtGdiDdGetDriverInfo\n");
@ -292,7 +360,6 @@ DWORD STDCALL NtGdiDdGetDriverInfo(
return DDHAL_DRIVER_NOTHANDLED;
}
/* it exsist two version of NtGdiDdGetDriverInfo we need check for both flags */
if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFOSET))
ddRVal++;
@ -300,7 +367,6 @@ DWORD STDCALL NtGdiDdGetDriverInfo(
if (!(pDirectDraw->Hal.dwFlags & DDHALINFO_GETDRIVERINFO2))
ddRVal++;
/* Now we are doing the call to drv DrvGetDriverInfo */
if (ddRVal == 2)
{
@ -311,6 +377,7 @@ DWORD STDCALL NtGdiDdGetDriverInfo(
{
ddRVal = pDirectDraw->Hal.GetDriverInfo(puGetDriverInfoData);
}
GDIOBJ_UnlockObjByPtr(DdHandleTable, pDirectDraw);
return ddRVal;