mirror of
https://github.com/reactos/reactos.git
synced 2024-09-08 11:50:08 +00:00
fixing some problem with backbuffer, we still can not draw to primary or backbuffer surface when we create a backbuffer why ??
svn path=/trunk/; revision=25184
This commit is contained in:
parent
c038f82dad
commit
2d38ffdb35
|
@ -22,7 +22,6 @@ CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This,
|
|||
That[0]->lpLcl->lpSurfMore->slist = lpLcl;
|
||||
|
||||
That[0]->lpVtbl = &DirectDrawSurface7_Vtable;
|
||||
That[0]->lpLcl->lpGbl = &ddSurfGbl;
|
||||
That[0]->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
|
||||
That[0]->lpLcl->lpSurfMore->lpDD_int = This;
|
||||
That[0]->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
|
||||
|
@ -78,12 +77,16 @@ CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This,
|
|||
|
||||
That[0]->lpLcl->lpSurfMore->slist = mDdCreateSurface.lplpSList ;
|
||||
|
||||
That[0]->lpLink = This->lpLcl->lpGbl->dsList;
|
||||
This->lpLcl->lpGbl->dsList = That[0];
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT
|
||||
CreateBackBufferSurface(LPDDRAWI_DIRECTDRAW_INT This,
|
||||
LPDDRAWI_DDRAWSURFACE_INT *That,
|
||||
LPDDRAWI_DDRAWSURFACE_LCL *lpLcl,
|
||||
LPDDSURFACEDESC2 pDDSD)
|
||||
{
|
||||
DDHAL_CANCREATESURFACEDATA mDdCanCreateSurface;
|
||||
|
@ -95,95 +98,76 @@ CreateBackBufferSurface(LPDDRAWI_DIRECTDRAW_INT This,
|
|||
* and create the backbuffer surface and set it up
|
||||
*/
|
||||
|
||||
for (t=1;t<pDDSD->dwBackBufferCount+1;t++)
|
||||
That[0]->lpLcl->dwBackBufferCount = pDDSD->dwBackBufferCount;
|
||||
|
||||
for (t=0;t<pDDSD->dwBackBufferCount+1;t++)
|
||||
{
|
||||
|
||||
|
||||
That[t]->lpLcl->lpSurfMore = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_MORE));
|
||||
if (That[t]->lpLcl->lpSurfMore == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
That[t]->lpLcl->lpSurfMore = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_MORE));
|
||||
if (That[t]->lpLcl->lpSurfMore == NULL)
|
||||
{
|
||||
DxHeapMemFree(That);
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
That[t]->lpLcl->lpSurfMore->slist = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_LCL)<<1);
|
||||
if (That[t]->lpLcl->lpSurfMore->slist == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
That[t]->lpLcl->lpSurfMore->slist = lpLcl;
|
||||
|
||||
That[t]->lpLcl->lpGbl = DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_GBL));
|
||||
if (That[t]->lpLcl->lpGbl == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
That[t]->lpVtbl = &DirectDrawSurface7_Vtable;
|
||||
That[t]->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
|
||||
That[t]->lpLcl->lpSurfMore->lpDD_int = This;
|
||||
That[t]->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
|
||||
That[t]->lpLcl->lpSurfMore->slist[0] = That[t]->lpLcl;
|
||||
That[t]->lpLcl->dwProcessId = GetCurrentProcessId();
|
||||
|
||||
memcpy(That[t]->lpLcl->lpGbl, &ddSurfGbl,sizeof(DDRAWI_DDRAWSURFACE_GBL));
|
||||
That[t]->lpVtbl = &DirectDrawSurface7_Vtable;
|
||||
That[t]->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
|
||||
That[t]->lpLcl->lpSurfMore->lpDD_int = This;
|
||||
That[t]->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
|
||||
That[t]->lpLcl->lpSurfMore->slist[0] = That[t]->lpLcl;
|
||||
That[t]->lpLcl->dwProcessId = GetCurrentProcessId();
|
||||
mDdCanCreateSurface.lpDD = This->lpLcl->lpGbl;
|
||||
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
|
||||
{
|
||||
That[t]->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
|
||||
mDdCanCreateSurface.bIsDifferentPixelFormat = TRUE; //isDifferentPixelFormat;
|
||||
}
|
||||
else
|
||||
{
|
||||
mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE; //isDifferentPixelFormat;
|
||||
}
|
||||
mDdCanCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
|
||||
mDdCanCreateSurface.CanCreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CanCreateSurface;
|
||||
mDdCanCreateSurface.ddRVal = DDERR_GENERIC;
|
||||
|
||||
That[t]->lpVtbl = &DirectDrawSurface7_Vtable;
|
||||
That[t]->lpLcl->lpSurfMore->dwSize = sizeof(DDRAWI_DDRAWSURFACE_MORE);
|
||||
That[t]->lpLcl->lpSurfMore->lpDD_int = This;
|
||||
That[t]->lpLcl->lpSurfMore->lpDD_lcl = This->lpLcl;
|
||||
That[t]->lpLcl->lpSurfMore->slist[0] = That[t]->lpLcl;
|
||||
That[t]->lpLcl->dwProcessId = GetCurrentProcessId();
|
||||
mDdCreateSurface.lpDD = This->lpLcl->lpGbl;
|
||||
mDdCreateSurface.CreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CreateSurface;
|
||||
mDdCreateSurface.ddRVal = DDERR_GENERIC;
|
||||
mDdCreateSurface.dwSCnt = That[t]->dwIntRefCnt + 1; // is this correct
|
||||
mDdCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
|
||||
|
||||
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
|
||||
{
|
||||
That[t]->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
|
||||
}
|
||||
mDdCreateSurface.lplpSList = That[t]->lpLcl->lpSurfMore->slist;
|
||||
|
||||
mDdCanCreateSurface.lpDD = This->lpLcl->lpGbl;
|
||||
That[t]->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
|
||||
|
||||
if (pDDSD->dwFlags & DDSD_PIXELFORMAT)
|
||||
{
|
||||
That[t]->lpLcl->dwFlags |= DDRAWISURF_HASPIXELFORMAT;
|
||||
mDdCanCreateSurface.bIsDifferentPixelFormat = TRUE; //isDifferentPixelFormat;
|
||||
}
|
||||
else
|
||||
{
|
||||
mDdCanCreateSurface.bIsDifferentPixelFormat = FALSE; //isDifferentPixelFormat;
|
||||
}
|
||||
This->lpLcl->lpPrimary = That[0];
|
||||
if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED)
|
||||
{
|
||||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
That[t]->lpLcl->ddsCaps.dwCaps = pDDSD->ddsCaps.dwCaps;
|
||||
if (mDdCanCreateSurface.ddRVal != DD_OK)
|
||||
{
|
||||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
mDdCanCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
|
||||
mDdCanCreateSurface.CanCreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CanCreateSurface;
|
||||
mDdCanCreateSurface.ddRVal = DDERR_GENERIC;
|
||||
mDdCreateSurface.lplpSList = That[t]->lpLcl->lpSurfMore->slist;
|
||||
|
||||
mDdCreateSurface.lpDD = This->lpLcl->lpGbl;
|
||||
mDdCreateSurface.CreateSurface = This->lpLcl->lpDDCB->cbDDCallbacks.CreateSurface;
|
||||
mDdCreateSurface.ddRVal = DDERR_GENERIC;
|
||||
mDdCreateSurface.dwSCnt = That[t]->dwIntRefCnt + 1; // is this correct
|
||||
mDdCreateSurface.lpDDSurfaceDesc = (LPDDSURFACEDESC) pDDSD;
|
||||
if (mDdCreateSurface.CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED)
|
||||
{
|
||||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
mDdCreateSurface.lplpSList = That[t]->lpLcl->lpSurfMore->slist;
|
||||
if (mDdCreateSurface.ddRVal != DD_OK)
|
||||
{
|
||||
return mDdCreateSurface.ddRVal;
|
||||
}
|
||||
|
||||
if (mDdCanCreateSurface.CanCreateSurface(&mDdCanCreateSurface)== DDHAL_DRIVER_NOTHANDLED)
|
||||
{
|
||||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
if (mDdCanCreateSurface.ddRVal != DD_OK)
|
||||
{
|
||||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
mDdCreateSurface.lplpSList = That[t]->lpLcl->lpSurfMore->slist;
|
||||
|
||||
if (mDdCreateSurface.CreateSurface(&mDdCreateSurface) == DDHAL_DRIVER_NOTHANDLED)
|
||||
{
|
||||
return DDERR_NOTINITIALIZED;
|
||||
}
|
||||
|
||||
if (mDdCreateSurface.ddRVal != DD_OK)
|
||||
{
|
||||
return mDdCreateSurface.ddRVal;
|
||||
}
|
||||
That[t]->lpLcl->lpSurfMore->slist = mDdCreateSurface.lplpSList ;
|
||||
|
||||
/* Build the linking buffer */
|
||||
That[t]->lpLink = This->lpLcl->lpGbl->dsList;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<library>ole32</library>
|
||||
<library>user32</library>
|
||||
<library>advapi32</library>
|
||||
<library>msvcrt</library>
|
||||
|
||||
<file>ddraw.rc</file>
|
||||
<file>main.c</file>
|
||||
|
|
|
@ -171,7 +171,7 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
|
|||
LPDDRAWI_DDRAWSURFACE_LCL *lpLcl;
|
||||
DWORD dwHowManySurface = 1;
|
||||
DWORD i;
|
||||
|
||||
LPDDRAWI_DDRAWSURFACE_LCL *xlpLcl;
|
||||
if (pUnkOuter!=NULL)
|
||||
{
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
@ -198,44 +198,6 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
|
|||
return DDERR_INVALIDCAPS;
|
||||
}
|
||||
|
||||
/* Calc how many surface we need setup */
|
||||
if (pDDSD->ddsCaps.dwCaps &DDSD_BACKBUFFERCOUNT)
|
||||
{
|
||||
/* One primary + xx backbuffer */
|
||||
dwHowManySurface |= pDDSD->dwBackBufferCount;
|
||||
}
|
||||
|
||||
/* Alloc all memory we need for all createsurface here */
|
||||
lpLcl = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_LCL) * dwHowManySurface);
|
||||
if (lpLcl == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
That = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_INT) * dwHowManySurface);
|
||||
if (That == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for (i=0;i<dwHowManySurface;i++)
|
||||
{
|
||||
That[i] = (LPDDRAWI_DDRAWSURFACE_INT) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_INT));
|
||||
lpLcl[i] = (LPDDRAWI_DDRAWSURFACE_LCL) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL));
|
||||
if ( (lpLcl[i] == NULL) ||
|
||||
(That[i] == NULL))
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
That[i]->lpLcl = lpLcl[i];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* here we need start fixing bugs
|
||||
* the code above is 100% correct behovir
|
||||
* checked how ms ddraw behivor
|
||||
*/
|
||||
|
||||
/* this two line should be move to startup code */
|
||||
ddSurfGbl.lpDD = &ddgbl;
|
||||
|
@ -269,8 +231,61 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
|
|||
memcpy(&ddSurfGbl.ddpfSurface,&pDDSD->ddpfPixelFormat, sizeof(DDPIXELFORMAT));
|
||||
}
|
||||
|
||||
/* Calc how many surface we need setup */
|
||||
if (pDDSD->ddsCaps.dwCaps &DDSD_BACKBUFFERCOUNT)
|
||||
{
|
||||
/* One primary + xx backbuffer */
|
||||
dwHowManySurface |= pDDSD->dwBackBufferCount;
|
||||
}
|
||||
|
||||
/* Alloc all memory we need for all createsurface here */
|
||||
lpLcl = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_LCL) * dwHowManySurface);
|
||||
if (lpLcl == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
That = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_INT) * dwHowManySurface);
|
||||
if (That == NULL)
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
for (i=0;i<dwHowManySurface+1;i++)
|
||||
{
|
||||
That[i] = (LPDDRAWI_DDRAWSURFACE_INT) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_INT));
|
||||
lpLcl[i] = (LPDDRAWI_DDRAWSURFACE_LCL) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL));
|
||||
if ( (lpLcl[i] == NULL) ||
|
||||
(That[i] == NULL))
|
||||
{
|
||||
return DDERR_OUTOFMEMORY;
|
||||
}
|
||||
That[i]->lpLcl = lpLcl[i];
|
||||
|
||||
That[i]->lpLcl->lpGbl = &ddSurfGbl;
|
||||
//That[i]->lpLcl->lpGbl = (LPDDRAWI_DDRAWSURFACE_GBL) DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_GBL));
|
||||
//if (That[i]->lpLcl->lpGbl == NULL)
|
||||
//{
|
||||
// return DDERR_OUTOFMEMORY;
|
||||
//}
|
||||
|
||||
//That[i]->lpLcl->lpGbl->lpDD = &ddgbl;
|
||||
//That[i]->lpLcl->lpGbl->lpDDHandle = This->lpLcl->lpGbl;
|
||||
//memmove(That[i]->lpLcl->lpGbl,&ddSurfGbl,sizeof(LPDDRAWI_DDRAWSURFACE_GBL));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* here we need start fixing bugs
|
||||
* the code above is 100% correct behovir
|
||||
* checked how ms ddraw behivor
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* Create the surface */
|
||||
if (pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
||||
if (((pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
||||
&& (!(pDDSD->ddsCaps.dwCaps & DDSCAPS_BACKBUFFER)))
|
||||
{
|
||||
CreatePrimarySurface(This,That,lpLcl,pDDSD);
|
||||
}
|
||||
|
@ -301,7 +316,8 @@ HRESULT WINAPI Main_DirectDraw_CreateSurface (LPDIRECTDRAW7 iface, LPDDSURFACEDE
|
|||
{
|
||||
return DDERR_INVALIDSURFACETYPE;
|
||||
}
|
||||
retValue = CreateBackBufferSurface(This,That,pDDSD);
|
||||
retValue = CreateBackBufferSurface(This,That,lpLcl,pDDSD);
|
||||
//CreatePrimarySurface(This,That,lpLcl,pDDSD);
|
||||
if (retValue != DD_OK)
|
||||
{
|
||||
DX_STUB_str( "Fail to create backbuffer surface");
|
||||
|
|
|
@ -415,7 +415,7 @@ Main_DDrawSurface_GetAttachedSurface(LPDIRECTDRAWSURFACE7 iface,
|
|||
*ppSurface = (LPDIRECTDRAWSURFACE7) This->lpLcl->lpGbl->lpDD->dsList;
|
||||
|
||||
|
||||
return DDERR_ALREADYINITIALIZED;
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT WINAPI
|
||||
|
|
|
@ -128,7 +128,7 @@ HRESULT WINAPI DirectDrawClipper_Initialize( LPDIRECTDRAWCLIPPER iface, LPDIREC
|
|||
|
||||
|
||||
HRESULT CreateOverlaySurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT *That, LPDDSURFACEDESC2 pDDSD);
|
||||
HRESULT CreateBackBufferSurface(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);
|
||||
|
||||
/* DirectDraw Object struct
|
||||
|
|
|
@ -593,7 +593,6 @@ StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable)
|
|||
}
|
||||
|
||||
/* Fill some basic info for Surface */
|
||||
ddSurfGbl.lpDD = &ddgbl;
|
||||
|
||||
/* FIXME
|
||||
We need setup this also
|
||||
|
|
Loading…
Reference in a new issue