[PATCH 07/10] ddraw: Allow creating back buffer for DirectX 1 interfaces. (try 2)
Oldřich Jedlička
oldium.pro at seznam.cz
Mon Aug 2 15:05:43 CDT 2010
DirectX 1 interface allowed creation of explicit back buffers, so move the
restrictive checks to DirectX 2+ implementations. Don't permit creating of
primary surface back buffer.
This fixes bug #9008.
---
dlls/ddraw/ddraw.c | 78 +++++++++++++++++++++++++++++++++++++++----
dlls/ddraw/tests/d3d.c | 4 +-
dlls/ddraw/tests/dsurface.c | 4 +-
dlls/ddraw/tests/visual.c | 2 +-
4 files changed, 76 insertions(+), 12 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 502cc84..f32ec78 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -2967,7 +2967,7 @@ static HRESULT ddraw_create_gdi_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSur
* DDERR_* if an error occurs
*
*****************************************************************************/
-static HRESULT WINAPI ddraw7_CreateSurface(IDirectDraw7 *iface,
+static HRESULT WINAPI CreateSurface(IDirectDraw7 *iface,
DDSURFACEDESC2 *DDSD, IDirectDrawSurface7 **Surf, IUnknown *UnkOuter)
{
IDirectDrawImpl *This = (IDirectDrawImpl *)iface;
@@ -3030,8 +3030,15 @@ 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");
+ 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;
+ }
+
+
+ if(DDSD->ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER) {
+ WARN("Application tried to create an explicit front buffer\n");
LeaveCriticalSection(&ddraw_cs);
return DDERR_INVALIDCAPS;
}
@@ -3391,6 +3398,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)
{
@@ -3401,7 +3429,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)
{
@@ -3425,7 +3465,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;
@@ -3453,7 +3505,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;
@@ -3483,7 +3547,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 60a105f..a5ebaac 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -3578,7 +3578,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);
@@ -3635,7 +3635,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 dc175dc..f4bf6fe 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -3414,7 +3414,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);
@@ -3471,7 +3471,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 c6b3af6..0ed0880 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -2973,7 +2973,7 @@ static void DX1_BackBufferFlipTest(void)
ddsd.dwWidth = 640;
ddsd.dwHeight = 480;
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);
--
1.7.2
More information about the wine-patches
mailing list