Author: greatlrd
Date: Mon Jun 18 01:49:35 2007
New Revision: 27218
URL:
http://svn.reactos.org/svn/reactos?rev=27218&view=rev
Log:
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
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c
trunk/reactos/dll/directx/ddraw/Surface/createsurface.c
trunk/reactos/dll/directx/ddraw/Surface/surface.h
trunk/reactos/dll/directx/ddraw/main.c
trunk/reactos/dll/directx/ddraw/startup.c
Modified: trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/Ge…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/GetCaps.c Mon Jun 18 01:49:35 2007
@@ -98,7 +98,7 @@
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 @@
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 @@
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 @@
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))
{
Modified: trunk/reactos/dll/directx/ddraw/Surface/createsurface.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Surface/…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Surface/createsurface.c (original)
+++ trunk/reactos/dll/directx/ddraw/Surface/createsurface.c Mon Jun 18 01:49:35 2007
@@ -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 @@
{
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))))
- {
- return DDERR_INVALIDPARAMS;
- }
-
- /* 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))
- {
- return DDERR_INVALIDCAPS;
- }
-
- /* check if pDDSD.dwFlags DDSD_LPSURFACE is set or not */
- if (desc.dwFlags & DDSD_LPSURFACE)
- {
- /*
- * 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)))
+ 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_OUTOFMEMORY;
+ }
+
+ DxHeapMemAlloc(slist_lcl, num_of_surf * sizeof( LPDDRAWI_DDRAWSURFACE_LCL ) );
+ if( slist_lcl == NULL )
+ {
+ DxHeapMemFree(slist_int);
+ return DDERR_OUTOFMEMORY;
+ }
+
+ /* 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 )
+ {
+ 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
- */
-
- desc.dwFlags = desc.dwFlags & DDSD_ALL;
- }
-
- /* more code will follow */
-
-
-
- return DDERR_GENERIC;
+ DxHeapMemAlloc(ThisSurfaceMore, sizeof( DDRAWI_DDRAWSURFACE_MORE ) );
+ if( ThisSurfaceMore == NULL )
+ {
+ /* Fixme free the memory */
+ return DDERR_OUTOFMEMORY;
+ }
+
+ /* 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 */
+ }
+
+
+ /* Fixme call on DdCanCreate then on DdCreateSurface createsurface data here */
+
+
+ *ppSurf = &slist_int[0]->lpVtbl;
+ return DD_FALSE;
}
void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc)
@@ -101,34 +154,34 @@
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[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->lpLcl->lpSurfMore->slist = lpLcl;
+
+ 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 @@
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;
-
- That[0]->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
-
- This->lpLcl->lpPrimary = That[0];
+ mDdCreateSurface.lplpSList = That->lpLcl->lpSurfMore->slist;
+
+ That->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
+
+ This->lpLcl->lpPrimary = That;
if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)==
DDHAL_DRIVER_NOTHANDLED)
{
return DDERR_NOTINITIALIZED;
@@ -160,7 +213,7 @@
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 @@
return mDdCreateSurface.ddRVal;
}
- That[0]->lpLcl->lpSurfMore->slist = mDdCreateSurface.lplpSList ;
-
- That[0]->lpLink = This->lpLcl->lpGbl->dsList;
- This->lpLcl->lpGbl->dsList = That[0];
+ That->lpLcl->lpSurfMore->slist = mDdCreateSurface.lplpSList ;
+
+ That->lpLink = This->lpLcl->lpGbl->dsList;
+ This->lpLcl->lpGbl->dsList = That;
return DD_OK;
}
Modified: trunk/reactos/dll/directx/ddraw/Surface/surface.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Surface/…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Surface/surface.h (original)
+++ trunk/reactos/dll/directx/ddraw/Surface/surface.h Mon Jun 18 01:49:35 2007
@@ -71,5 +71,6 @@
// 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);
+
Modified: trunk/reactos/dll/directx/ddraw/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main.c?r…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/main.c (original)
+++ trunk/reactos/dll/directx/ddraw/main.c Mon Jun 18 01:49:35 2007
@@ -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 @@
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 @@
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,
@@ -187,6 +240,46 @@
sizeof(D3DHAL_DP2COMMAND) + ( D3DHAL_DP2COMMAND->wStateCount *
sizeof(D3DHAL_DP2VIEWPORTINFO));
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,
Modified: trunk/reactos/dll/directx/ddraw/startup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/startup.…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/startup.c (original)
+++ trunk/reactos/dll/directx/ddraw/startup.c Mon Jun 18 01:49:35 2007
@@ -127,7 +127,7 @@
}
else if (IsEqualGUID(&IID_IDirectDraw, id))
{
- /* DirectDraw4 Vtable */
+ /* DirectDraw Vtable */
This->lpVtbl = &DirectDraw_Vtable;
*pIface = (LPDIRECTDRAW)&This->lpVtbl;
Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);