1. fixed typo in DD->GetCaps

2. Started implement Createsurface for real this time. 
   thanks to all old try and error the new desgin make more sent 
   and are more clean. still Createsruface does not working yet. 

3. Fixed some comment tags for some whant start writing doc for thuse api 
   you are wellcome

svn path=/trunk/; revision=27218
This commit is contained in:
Magnus Olsen
2007-06-17 21:49:35 +00:00
parent f8757ee824
commit 2f7fc5300c
5 changed files with 226 additions and 79 deletions

View File

@@ -98,7 +98,7 @@ Main_DirectDraw_GetCaps( LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
memcpy(&myCaps->dwNLVBCaps, This->lpLcl->lpGbl->lpddNLVCaps, sizeof(DDNONLOCALVIDMEMCAPS));
}
*/
memset(myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
memset(&myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{
@@ -124,7 +124,7 @@ Main_DirectDraw_GetCaps( LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
memcpy(&myCaps->dwNLVBCaps, This->lpLcl->lpGbl->lpddNLVCaps, sizeof(DDNONLOCALVIDMEMCAPS));
}
*/
memset(myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
memset(&myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{
@@ -206,7 +206,7 @@ Main_DirectDraw_GetCaps( LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
memcpy(&myCaps->dwNLVBCaps, This->lpLcl->lpGbl->lpddNLVHELCaps, sizeof(DDNONLOCALVIDMEMCAPS));
}
*/
memset(myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
memset(&myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{
@@ -232,7 +232,7 @@ Main_DirectDraw_GetCaps( LPDIRECTDRAW7 iface, LPDDCAPS pDriverCaps,
memcpy(&myCaps->dwNLVBCaps, This->lpLcl->lpGbl->lpddNLVHELCaps, sizeof(DDNONLOCALVIDMEMCAPS));
}
*/
memset(myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
memset(&myCaps->dwNLVBCaps,0,sizeof(DDNONLOCALVIDMEMCAPS));
if (CoreCaps->dwSize == sizeof(DDCORECAPS))
{

View File

@@ -12,6 +12,7 @@
/* PSEH for SEH Support */
#include <pseh/pseh.h>
/*
* all param have been checked if they are vaild before they are call to
* Internal_CreateSurface, if not please fix the code in the functions
@@ -25,71 +26,123 @@ Internal_CreateSurface( LPDDRAWI_DIRECTDRAW_INT pDDraw, LPDDSURFACEDESC2 pDDSD,
{
DDSURFACEDESC2 desc;
/* Test se if the pointers are vaild */
if ((IsBadReadPtr(pDDraw,sizeof(LPDDRAWI_DIRECTDRAW_INT))) ||
(IsBadReadPtr(pDDSD,sizeof(LPDDSURFACEDESC2))) ||
(IsBadWritePtr(ppSurf,sizeof(LPDIRECTDRAWSURFACE7))) ||
(IsBadReadPtr(ppSurf,sizeof(LPDIRECTDRAWSURFACE7))))
DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface = { 0 };
DDHAL_CREATESURFACEDATA mDdCreateSurface = { 0 };
LPDDRAWI_DDRAWSURFACE_INT ThisSurfInt;
LPDDRAWI_DDRAWSURFACE_LCL ThisSurfLcl;
LPDDRAWI_DDRAWSURFACE_GBL ThisSurfaceGbl;
LPDDRAWI_DDRAWSURFACE_MORE ThisSurfaceMore;
LPDDRAWI_DDRAWSURFACE_INT * slist_int;
LPDDRAWI_DDRAWSURFACE_LCL * slist_lcl;
LPDDRAWI_DDRAWSURFACE_GBL * slist_gbl;
LPDDRAWI_DDRAWSURFACE_MORE * slist_more;
DWORD num_of_surf=1;
DWORD count;
/* Fixme adding vaidlate of income param */
/* FIXME count our how many surface we need */
DxHeapMemAlloc(slist_int, num_of_surf * sizeof( LPDDRAWI_DDRAWSURFACE_INT ) );
if( slist_int == NULL)
{
return DDERR_INVALIDPARAMS;
return DDERR_OUTOFMEMORY;
}
/* make local backup of DDSURFACEDESC2 */
RtlCopyMemory(&desc, pDDSD, sizeof(DDSURFACEDESC2));
/*
* pDDSD->dwCaps can not contain both DDSCAPS_SYSTEMMEMORY and DDSCAPS_VIDEOMEMORY
* if both are define ddraw.dll will return error code 0x88760064
*/
if ( (desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) &&
(desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
DxHeapMemAlloc(slist_lcl, num_of_surf * sizeof( LPDDRAWI_DDRAWSURFACE_LCL ) );
if( slist_lcl == NULL )
{
return DDERR_INVALIDCAPS;
DxHeapMemFree(slist_int);
return DDERR_OUTOFMEMORY;
}
/* check if pDDSD.dwFlags DDSD_LPSURFACE is set or not */
if (desc.dwFlags & DDSD_LPSURFACE)
/* for more easy to free the memory if something goes wrong */
DxHeapMemAlloc(slist_gbl, num_of_surf * sizeof( LPDDRAWI_DDRAWSURFACE_GBL ) );
if( slist_lcl == NULL )
{
/*
* DDSD_LPSURFACE flag is set now we start vaildate see if
* pDDSD->lpSurface are a pointer or not
*/
if (IsBadReadPtr(desc.lpSurface,sizeof(LPVOID)) ||
(desc.dwFlags - (desc.dwFlags & DDSD_ALL)))
DxHeapMemFree(slist_int);
return DDERR_OUTOFMEMORY;
}
/* for more easy to free the memory if something goes wrong */
DxHeapMemAlloc(slist_more, num_of_surf * sizeof( LPDDRAWI_DDRAWSURFACE_MORE ) );
if( slist_lcl == NULL )
{
DxHeapMemFree(slist_int);
return DDERR_OUTOFMEMORY;
}
for( count=0; count < num_of_surf; count++ )
{
/* Alloc the surface interface and need members */
DxHeapMemAlloc(ThisSurfInt, sizeof( DDRAWI_DDRAWSURFACE_INT ) );
if( ThisSurfInt == NULL )
{
return DDERR_INVALIDPARAMS;
/* Fixme free the memory */
return DDERR_OUTOFMEMORY;
}
/* only support dx7 interface for DDSD_LPSURFACE older interface do not support it */
if (pDDraw->lpVtbl != &DirectDraw7_Vtable)
DxHeapMemAlloc(ThisSurfLcl, sizeof( DDRAWI_DDRAWSURFACE_LCL ) );
if( ThisSurfLcl == NULL )
{
return DDERR_INVALIDPARAMS;
/* Fixme free the memory */
return DDERR_OUTOFMEMORY;
}
/* vaildate the caps */
if (desc.ddsCaps.dwCaps & ( DDSCAPS_COMPLEX | DDSCAPS_RESERVED2 | DDSCAPS_RESERVED3 |
DDSCAPS_VIDEOPORT | DDSCAPS_PRIMARYSURFACE | DDSCAPS_OVERLAY ))
DxHeapMemAlloc(ThisSurfaceGbl, sizeof( DDRAWI_DDRAWSURFACE_GBL ) );
if( ThisSurfaceGbl == NULL )
{
return DDERR_INVALIDCAPS;
/* Fixme free the memory */
return DDERR_OUTOFMEMORY;
}
/* more code will follow */
}
else
{
/*
* DDSD_LPSURFACE flag are not set
* remove all wrong flags are being set
*/
DxHeapMemAlloc(ThisSurfaceMore, sizeof( DDRAWI_DDRAWSURFACE_MORE ) );
if( ThisSurfaceMore == NULL )
{
/* Fixme free the memory */
return DDERR_OUTOFMEMORY;
}
desc.dwFlags = desc.dwFlags & DDSD_ALL;
/* setup a list only one we really need is slist_lcl
rest of slist shall be release before a return */
slist_int[count] = ThisSurfInt;
slist_lcl[count] = ThisSurfLcl;
slist_gbl[count] = ThisSurfaceGbl;
slist_more[count] = ThisSurfaceMore;
/* Start now fill in the member as they shall look like before call to createsurface */
ThisSurfInt->lpLcl = ThisSurfLcl;
ThisSurfLcl->lpGbl = ThisSurfaceGbl;
ThisSurfLcl->lpSurfMore = ThisSurfaceMore;
/* FIXME set right version */
ThisSurfInt->lpVtbl = &DirectDrawSurface7_Vtable;
ThisSurfaceMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
ThisSurfaceMore->lpDD_int = pDDraw;
ThisSurfaceMore->lpDD_lcl = pDDraw->lpLcl;
ThisSurfaceMore->slist = slist_lcl;
ThisSurfLcl->dwProcessId = GetCurrentProcessId();
/* FIXME the lpLnk */
/* FIXME the ref counter */
}
/* more code will follow */
/* Fixme call on DdCanCreate then on DdCreateSurface createsurface data here */
return DDERR_GENERIC;
*ppSurf = &slist_int[0]->lpVtbl;
return DD_FALSE;
}
void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc)
@@ -101,34 +154,34 @@ void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src
HRESULT
CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This,
LPDDRAWI_DDRAWSURFACE_INT *That,
LPDDRAWI_DDRAWSURFACE_LCL *lpLcl,
LPDDRAWI_DDRAWSURFACE_INT That,
LPDDRAWI_DDRAWSURFACE_LCL lpLcl,
LPDDSURFACEDESC2 pDDSD)
{
DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface;
DDHAL_CREATESURFACEDATA mDdCreateSurface;
DxHeapMemAlloc( That[0]->lpLcl->lpSurfMore, sizeof(DDRAWI_DDRAWSURFACE_MORE));
if (That[0]->lpLcl->lpSurfMore == NULL)
DxHeapMemAlloc( That->lpLcl->lpSurfMore, sizeof(DDRAWI_DDRAWSURFACE_MORE));
if (That->lpLcl->lpSurfMore == NULL)
{
DxHeapMemFree(That);
return DDERR_OUTOFMEMORY;
}
That[0]->lpLcl->lpSurfMore->slist = lpLcl;
// That->lpLcl->lpSurfMore->slist = lpLcl;
That[0]->lpVtbl = &DirectDrawSurface7_Vtable;
That[0]->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That[0]->lpLcl->lpSurfMore->lpDD_int = This;
That[0]->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That[0]->lpLcl->lpSurfMore->slist[0] = That[0]->lpLcl;
That[0]->lpLcl->dwProcessId = GetCurrentProcessId();
That->lpVtbl = &DirectDrawSurface7_Vtable;
That->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
That->lpLcl->lpSurfMore->lpDD_int = This;
That->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
That->lpLcl->lpSurfMore->slist[0] = That->lpLcl;
That->lpLcl->dwProcessId = GetCurrentProcessId();
mDdCanCreateSurface.lpDD = This->lpLcl->lpGbl;
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
{
That[0]->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
That->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
mDdCanCreateSurface.bIsDifferentPixelFormat = TRUE; //isDifferentPixelFormat;
}
else
@@ -142,14 +195,14 @@ CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This,
mDdCreateSurface.lpDD = This->lpLcl->lpGbl;
mDdCreateSurface.CreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CreateSurface;
mDdCreateSurface.ddRVal = DDERR_GENERIC;
mDdCreateSurface.dwSCnt = That[0]->dwIntRefCnt + 1; // is this correct
mDdCreateSurface.dwSCnt = That->dwIntRefCnt + 1; // is this correct
mDdCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
mDdCreateSurface.lplpSList = That[0]->lpLcl->lpSurfMore->slist;
mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
That[0]->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
That->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
This->lpLcl->lpPrimary = That[0];
This->lpLcl->lpPrimary = That;
if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED)
{
return DDERR_NOTINITIALIZED;
@@ -160,7 +213,7 @@ CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This,
return DDERR_NOTINITIALIZED;
}
mDdCreateSurface.lplpSList = That[0]->lpLcl->lpSurfMore->slist;
mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
if (mDdCreateSurface.CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED)
{
@@ -172,10 +225,10 @@ CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This,
return mDdCreateSurface.ddRVal;
}
That[0]->lpLcl->lpSurfMore->slist = mDdCreateSurface.lplpSList ;
That->lpLcl->lpSurfMore->slist = mDdCreateSurface.lplpSList ;
That[0]->lpLink = This->lpLcl->lpGbl->dsList;
This->lpLcl->lpGbl->dsList = That[0];
That->lpLink = This->lpLcl->lpGbl->dsList;
This->lpLcl->lpGbl->dsList = That;
return DD_OK;
}

View File

@@ -71,5 +71,6 @@ DWORD CALLBACK HelDdFlipToGDISurface(LPDDHAL_FLIPTOGDISURFACEDATA lpFlipToGDISu
// internal functions
HRESULT CreateOverlaySurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT *That, LPDDSURFACEDESC2 pDDSD);
HRESULT CreateBackBufferSurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT *That, LPDDRAWI_DDRAWSURFACE_LCL *lpLcl, LPDDSURFACEDESC2 pDDSD);
HRESULT CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT *That,LPDDRAWI_DDRAWSURFACE_LCL *lpLcl, LPDDSURFACEDESC2 pDDSD);
HRESULT CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT That,LPDDRAWI_DDRAWSURFACE_LCL lpLcl, LPDDSURFACEDESC2 pDDSD);

View File

@@ -18,6 +18,28 @@
CRITICAL_SECTION ddcs;
// This function is exported by the dll
/*++
* @name DirectDrawCreateClipper
*
* The DirectDrawCreateClipper routine <FILLMEIN>.
*
* @param dwFlags
* <FILLMEIN>.
*
* @param lplpDDClipper
* <FILLMEIN>.
*
* @param pUnkOuter
* <FILLMEIN>.
*
* @return <FILLMEIN>.
*
* @remarks None.
*
*--*/
HRESULT WINAPI DirectDrawCreateClipper (DWORD dwFlags,
LPDIRECTDRAWCLIPPER* lplpDDClipper, LPUNKNOWN pUnkOuter)
{
@@ -26,10 +48,26 @@ HRESULT WINAPI DirectDrawCreateClipper (DWORD dwFlags,
return Main_DirectDraw_CreateClipper(NULL, dwFlags, lplpDDClipper, pUnkOuter);
}
/*
* IMPLEMENT
* Status this api is finish and is 100% correct
*/
/*++
* @name DirectDrawCreate
*
* The DirectDrawCreate routine <FILLMEIN>.
*
* @param lpGUID
* <FILLMEIN>.
*
* @param lplpDD
* <FILLMEIN>.
*
* @param pUnkOuter
* Alwas set to NULL other wise will DirectDrawCreate fail it return
* errror code CLASS_E_NOAGGREGATION
*
* @return <FILLMEIN>.
*
* @remarks None.
*
*--*/
HRESULT
WINAPI
@@ -64,11 +102,26 @@ DirectDrawCreate (LPGUID lpGUID,
return retVal;
}
/*
* IMPLEMENT
* Status this api is finish and is 100% correct
*/
/*++
* @name DirectDrawCreateEx
*
* The DirectDrawCreateEx routine <FILLMEIN>.
*
* @param lpGUID
* <FILLMEIN>.
*
* @param lplpDD
* <FILLMEIN>.
*
* @param pUnkOuter
* Alwas set to NULL other wise will DirectDrawCreateEx fail it return
* errror code CLASS_E_NOAGGREGATION
*
* @return <FILLMEIN>.
*
* @remarks None.
*
*--*/
HRESULT
WINAPI
DirectDrawCreateEx(LPGUID lpGUID,
@@ -188,6 +241,46 @@ DirectDrawEnumerateExW(LPDDENUMCALLBACKEXW lpCallback,
to get the xxxx end positions.
*/
/*++
* @name D3DParseUnknownCommand
*
* The D3DParseUnknownCommand routine <FILLMEIN>.
*
* @param lpCmd
* Is a typcast to LPD3DHAL_DP2COMMAND struct
* typedef struct _D3DHAL_DP2COMMAND
* {
* BYTE bCommand;
* BYTE bReserved;
* union
* {
* WORD wPrimitiveCount;
* WORD wStateCount;
* };
* } D3DHAL_DP2COMMAND, *LPD3DHAL_DP2COMMAND;
*
* lpCmd->bCommand
* only accpect D3DDP2OP_VIEWPORTINFO, and undocument command 0x0D
* rest of the command will be return error code for.
*
Command 0x0D
* dp2command->bReserved
* is how big struect we got in wStateCount or how many wStateCount we got
* do not known more about it, no info in msdn about it either.
*
* Command D3DDP2OP_VIEWPORTINFO
* <FILLMEIN>.
*
* @param lpRetCmd
* <FILLMEIN>.
*
* @return <FILLMEIN>.
*
* @remarks
*
*--*/
HRESULT WINAPI
D3DParseUnknownCommand( LPVOID lpCmd,
LPVOID *lpRetCmd)

View File

@@ -127,7 +127,7 @@ Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
}
else if (IsEqualGUID(&IID_IDirectDraw, id))
{
/* DirectDraw4 Vtable */
/* DirectDraw Vtable */
This->lpVtbl = &DirectDraw_Vtable;
*pIface = (LPDIRECTDRAW)&This->lpVtbl;
Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);