Commit bec3b769 authored by Oldřich Jedlička's avatar Oldřich Jedlička Committed by Alexandre Julliard

ddraw: Allow creating back buffer for DirectX 1 interfaces.

parent 8d255346
...@@ -2880,7 +2880,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur ...@@ -2880,7 +2880,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
* DDERR_* if an error occurs * DDERR_* if an error occurs
* *
*****************************************************************************/ *****************************************************************************/
static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, static HRESULT CreateSurface(IDirectDraw7 *iface,
DDSURFACEDESC2 *DDSD, IDirectDrawSurface7 **Surf, IUnknown *UnkOuter) DDSURFACEDESC2 *DDSD, IDirectDrawSurface7 **Surf, IUnknown *UnkOuter)
{ {
IDirectDrawImpl *This = (IDirectDrawImpl *)iface; IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
...@@ -2944,9 +2944,9 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, ...@@ -2944,9 +2944,9 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
return DDERR_NOEXCLUSIVEMODE; return DDERR_NOEXCLUSIVEMODE;
} }
if(DDSD->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER)) { if((DDSD->ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE)) == (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE))
WARN("Application tried to create an explicit front or back buffer\n"); {
LeaveCriticalSection(&ddraw_cs); WARN("Application wanted to create back buffer primary surface\n");
return DDERR_INVALIDCAPS; return DDERR_INVALIDCAPS;
} }
...@@ -3305,6 +3305,27 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface, ...@@ -3305,6 +3305,27 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
return hr; return hr;
} }
static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
DDSURFACEDESC2 *surface_desc, IDirectDrawSurface7 **surface, IUnknown *outer_unknown)
{
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
iface, surface_desc, surface, outer_unknown);
if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
{
if (TRACE_ON(ddraw))
{
TRACE(" (%p) Requesting surface desc :\n", iface);
DDRAW_dump_surface_desc(surface_desc);
}
WARN("Application tried to create an explicit front or back buffer\n");
return DDERR_INVALIDCAPS;
}
return CreateSurface(iface, surface_desc, surface, outer_unknown);
}
static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface, static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
DDSURFACEDESC2 *surface_desc, IDirectDrawSurface4 **surface, IUnknown *outer_unknown) DDSURFACEDESC2 *surface_desc, IDirectDrawSurface4 **surface, IUnknown *outer_unknown)
{ {
...@@ -3315,7 +3336,19 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface, ...@@ -3315,7 +3336,19 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n", TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
iface, surface_desc, surface, outer_unknown); iface, surface_desc, surface, outer_unknown);
hr = ddraw7_CreateSurface((IDirectDraw7 *)ddraw, surface_desc, (IDirectDrawSurface7 **)surface, outer_unknown); if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
{
if (TRACE_ON(ddraw))
{
TRACE(" (%p) Requesting surface desc :\n", iface);
DDRAW_dump_surface_desc(surface_desc);
}
WARN("Application tried to create an explicit front or back buffer\n");
return DDERR_INVALIDCAPS;
}
hr = CreateSurface((IDirectDraw7 *)ddraw, surface_desc, (IDirectDrawSurface7 **)surface, outer_unknown);
impl = (IDirectDrawSurfaceImpl *)*surface; impl = (IDirectDrawSurfaceImpl *)*surface;
if (SUCCEEDED(hr) && impl) if (SUCCEEDED(hr) && impl)
{ {
...@@ -3339,7 +3372,19 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface, ...@@ -3339,7 +3372,19 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n", TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
iface, surface_desc, surface, outer_unknown); iface, surface_desc, surface, outer_unknown);
hr = ddraw7_CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown); if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
{
if (TRACE_ON(ddraw))
{
TRACE(" (%p) Requesting surface desc :\n", iface);
DDRAW_dump_surface_desc((LPDDSURFACEDESC2)surface_desc);
}
WARN("Application tried to create an explicit front or back buffer\n");
return DDERR_INVALIDCAPS;
}
hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
if (FAILED(hr)) if (FAILED(hr))
{ {
*surface = NULL; *surface = NULL;
...@@ -3367,7 +3412,19 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface, ...@@ -3367,7 +3412,19 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n", TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
iface, surface_desc, surface, outer_unknown); iface, surface_desc, surface, outer_unknown);
hr = ddraw7_CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown); if(surface_desc->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER))
{
if (TRACE_ON(ddraw))
{
TRACE(" (%p) Requesting surface desc :\n", iface);
DDRAW_dump_surface_desc((LPDDSURFACEDESC2)surface_desc);
}
WARN("Application tried to create an explicit front or back buffer\n");
return DDERR_INVALIDCAPS;
}
hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
if (FAILED(hr)) if (FAILED(hr))
{ {
*surface = NULL; *surface = NULL;
...@@ -3397,7 +3454,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface, ...@@ -3397,7 +3454,7 @@ static HRESULT WINAPI ddraw1_CreateSurface(IDirectDraw *iface,
/* Remove front buffer flag, this causes failure in v7, and its added to normal /* Remove front buffer flag, this causes failure in v7, and its added to normal
* primaries anyway. */ * primaries anyway. */
surface_desc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER; surface_desc->ddsCaps.dwCaps &= ~DDSCAPS_FRONTBUFFER;
hr = ddraw7_CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown); hr = CreateSurface((IDirectDraw7 *)ddraw, (DDSURFACEDESC2 *)surface_desc, &surface7, outer_unknown);
if (FAILED(hr)) if (FAILED(hr))
{ {
*surface = NULL; *surface = NULL;
......
...@@ -3569,7 +3569,7 @@ static void BackBuffer3DCreateSurfaceTest(void) ...@@ -3569,7 +3569,7 @@ static void BackBuffer3DCreateSurfaceTest(void)
created_ddsd.dwSize = sizeof(DDSURFACEDESC); created_ddsd.dwSize = sizeof(DDSURFACEDESC);
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surf, NULL); hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surf, NULL);
todo_wine ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr); ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
if (surf != NULL) if (surf != NULL)
{ {
hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd); hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd);
...@@ -3636,7 +3636,7 @@ static void BackBuffer3DAttachmentTest(void) ...@@ -3636,7 +3636,7 @@ static void BackBuffer3DAttachmentTest(void)
ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN); ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN); ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surface2, NULL); hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surface2, NULL);
todo_wine ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr); ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr);
if (surface2 != NULL) if (surface2 != NULL)
{ {
......
...@@ -3425,7 +3425,7 @@ static void BackBufferCreateSurfaceTest(void) ...@@ -3425,7 +3425,7 @@ static void BackBufferCreateSurfaceTest(void)
created_ddsd.dwSize = sizeof(DDSURFACEDESC); created_ddsd.dwSize = sizeof(DDSURFACEDESC);
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surf, NULL); hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surf, NULL);
todo_wine ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr); ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr);
if (surf != NULL) if (surf != NULL)
{ {
hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd); hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd);
...@@ -3482,7 +3482,7 @@ static void BackBufferAttachmentFlipTest(void) ...@@ -3482,7 +3482,7 @@ static void BackBufferAttachmentFlipTest(void)
ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN); ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN); ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface2, NULL); hr = IDirectDraw_CreateSurface(lpDD, &ddsd, &surface2, NULL);
todo_wine ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr); ok(SUCCEEDED(hr), "CreateSurface returned: %x\n",hr);
if (surface2 != NULL) if (surface2 != NULL)
{ {
......
...@@ -2980,7 +2980,7 @@ static void DX1_BackBufferFlipTest(void) ...@@ -2980,7 +2980,7 @@ static void DX1_BackBufferFlipTest(void)
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Backbuffer, NULL); hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &Backbuffer, NULL);
todo_wine ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08x\n", hr); ok(hr==DD_OK, "IDirectDraw_CreateSurface returned: %08x\n", hr);
if(FAILED(hr)) goto out; if(FAILED(hr)) goto out;
hr = IDirectDrawSurface_AddAttachedSurface(Primary, Backbuffer); hr = IDirectDrawSurface_AddAttachedSurface(Primary, Backbuffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment