[PATCH 3/4] ddraw: Allow creating back buffer for pre-DirectX 7 interfaces. (try 3)

Oldřich Jedlička oldium.pro at seznam.cz
Thu Jul 22 14:13:51 CDT 2010


DirectX 1 interface allowed creation of explicit back buffers, so move the
restrictive checks to DirectX 2+ implementations.

This fixes bug #9008.
---
 dlls/ddraw/ddraw.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index e55ac5b..b1f8faa 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,8 @@ 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_FRONTBUFFER) {
+        WARN("Application tried to create an explicit front buffer\n");
         LeaveCriticalSection(&ddraw_cs);
         return DDERR_INVALIDCAPS;
     }
@@ -3391,6 +3391,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 +3422,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 +3458,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(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 +3498,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(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 +3540,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;
-- 
1.7.1.1




More information about the wine-patches mailing list