Oldřich Jedlička : ddraw: Allow creating back buffer for DirectX 1 interfaces.
Alexandre Julliard
julliard at winehq.org
Thu Sep 16 14:09:07 CDT 2010
Module: wine
Branch: master
Commit: bec3b7692d02b343936c42d08a5c48b92335e182
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bec3b7692d02b343936c42d08a5c48b92335e182
Author: Oldřich Jedlička <oldium.pro at seznam.cz>
Date: Wed Sep 15 21:33:02 2010 +0200
ddraw: Allow creating back buffer for DirectX 1 interfaces.
---
dlls/ddraw/ddraw.c | 73 ++++++++++++++++++++++++++++++++++++++-----
dlls/ddraw/tests/d3d.c | 4 +-
dlls/ddraw/tests/dsurface.c | 4 +-
dlls/ddraw/tests/visual.c | 2 +-
4 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index cb942d4..5449d84 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2880,7 +2880,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
* DDERR_* if an error occurs
*
*****************************************************************************/
-static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
+static HRESULT CreateSurface(IDirectDraw7 *iface,
DDSURFACEDESC2 *DDSD, IDirectDrawSurface7 **Surf, IUnknown *UnkOuter)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
@@ -2944,9 +2944,9 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
return DDERR_NOEXCLUSIVEMODE;
}
- if(DDSD->ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_BACKBUFFER)) {
- WARN("Application tried to create an explicit front or back buffer\n");
- LeaveCriticalSection(&ddraw_cs);
+ if((DDSD->ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE)) == (DDSCAPS_BACKBUFFER | DDSCAPS_PRIMARYSURFACE))
+ {
+ WARN("Application wanted to create back buffer primary surface\n");
return DDERR_INVALIDCAPS;
}
@@ -3305,6 +3305,27 @@ static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
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,
DDSURFACEDESC2 *surface_desc, IDirectDrawSurface4 **surface, IUnknown *outer_unknown)
{
@@ -3315,7 +3336,19 @@ static HRESULT WINAPI ddraw4_CreateSurface(IDirectDraw4 *iface,
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
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;
if (SUCCEEDED(hr) && impl)
{
@@ -3339,7 +3372,19 @@ static HRESULT WINAPI ddraw3_CreateSurface(IDirectDraw3 *iface,
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
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))
{
*surface = NULL;
@@ -3367,7 +3412,19 @@ static HRESULT WINAPI ddraw2_CreateSurface(IDirectDraw2 *iface,
TRACE("iface %p, surface_desc %p, surface %p, outer_unknown %p.\n",
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))
{
*surface = NULL;
@@ -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
* primaries anyway. */
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))
{
*surface = NULL;
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index d291705..5043a01 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -3569,7 +3569,7 @@ static void BackBuffer3DCreateSurfaceTest(void)
created_ddsd.dwSize = sizeof(DDSURFACEDESC);
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)
{
hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd);
@@ -3636,7 +3636,7 @@ static void BackBuffer3DAttachmentTest(void)
ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
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)
{
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index 95b0f26..1c219a4 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -3425,7 +3425,7 @@ static void BackBufferCreateSurfaceTest(void)
created_ddsd.dwSize = sizeof(DDSURFACEDESC);
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)
{
hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd);
@@ -3482,7 +3482,7 @@ static void BackBufferAttachmentFlipTest(void)
ddsd.dwWidth = GetSystemMetrics(SM_CXSCREEN);
ddsd.dwHeight = GetSystemMetrics(SM_CYSCREEN);
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)
{
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 2616a36..e668691 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -2980,7 +2980,7 @@ static void DX1_BackBufferFlipTest(void)
U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff;
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;
hr = IDirectDrawSurface_AddAttachedSurface(Primary, Backbuffer);
More information about the wine-cvs
mailing list