[PATCH 08/10] ddraw: Allow attaching backbuffers and primaries. (try 3)

Oldřich Jedlička oldium.pro at seznam.cz
Tue Aug 3 14:26:21 CDT 2010


The allowed combinations are:

  * Backbuffer to primary
  * Backbuffer to other backbuffer
  * Primary to backbuffer
---
 dlls/ddraw/surface.c        |   28 +++++++++++++++++++++++++++-
 dlls/ddraw/tests/d3d.c      |    6 +++---
 dlls/ddraw/tests/dsurface.c |    6 +++---
 dlls/ddraw/tests/visual.c   |    2 +-
 4 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 15ed3c4..f14528d 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -983,7 +983,11 @@ static HRESULT WINAPI ddraw_surface3_AddAttachedSurface(IDirectDrawSurface3 *ifa
      * -> offscreen plain surfaces can be attached to other offscreen plain surfaces
      * -> offscreen plain surfaces can be attached to primaries
      * -> primaries can be attached to offscreen plain surfaces
-     * -> z buffers can be attached to primaries */
+     * -> z buffers can be attached to primaries
+     * -> backbuffers can be attached to other backbuffers
+     * -> backbuffers can be attached to primaries
+     * -> primaries can be attached to backbuffers
+     */
     if (surface->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN)
             && attach_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN))
     {
@@ -1001,6 +1005,28 @@ static HRESULT WINAPI ddraw_surface3_AddAttachedSurface(IDirectDrawSurface3 *ifa
     {
         /* OK */
     }
+    else if (surface->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER)
+            && attach_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER))
+    {
+        /* Not primary to primary */
+        if (!(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
+            || !(attach_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
+        {
+            /* Sizes have to match */
+            if (attach_impl->surface_desc.dwWidth != surface->surface_desc.dwWidth
+                    || attach_impl->surface_desc.dwHeight != surface->surface_desc.dwHeight)
+            {
+                WARN("Surface sizes do not match.\n");
+                return DDERR_CANNOTATTACHSURFACE;
+            }
+            /* OK */
+        }
+        else
+        {
+            WARN("Invalid attachment combination.\n");
+            return DDERR_CANNOTATTACHSURFACE;
+        }
+    }
     else
     {
         WARN("Invalid attachment combination.\n");
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c
index a5ebaac..55e5885 100644
--- a/dlls/ddraw/tests/d3d.c
+++ b/dlls/ddraw/tests/d3d.c
@@ -3667,7 +3667,7 @@ static void BackBuffer3DAttachmentTest(void)
         ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
 
         hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+        ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
            "Attaching a back buffer to a front buffer returned %08x\n", hr);
         if(SUCCEEDED(hr))
         {
@@ -3678,7 +3678,7 @@ static void BackBuffer3DAttachmentTest(void)
             ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+        ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
            "Attaching a front buffer to a back buffer returned %08x\n", hr);
         if(SUCCEEDED(hr))
         {
@@ -3690,7 +3690,7 @@ static void BackBuffer3DAttachmentTest(void)
             ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
-        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+        ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
            "Attaching a back buffer to another back buffer returned %08x\n", hr);
         if(SUCCEEDED(hr))
         {
diff --git a/dlls/ddraw/tests/dsurface.c b/dlls/ddraw/tests/dsurface.c
index f4bf6fe..a6dad72 100644
--- a/dlls/ddraw/tests/dsurface.c
+++ b/dlls/ddraw/tests/dsurface.c
@@ -3503,7 +3503,7 @@ static void BackBufferAttachmentFlipTest(void)
         ok(hr==DD_OK,"CreateSurface returned: %x\n",hr);
 
         hr = IDirectDrawSurface_AddAttachedSurface(surface1, surface2);
-        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+        ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
            "Attaching a back buffer to a front buffer returned %08x\n", hr);
         if(SUCCEEDED(hr))
         {
@@ -3520,7 +3520,7 @@ static void BackBufferAttachmentFlipTest(void)
             ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface1);
-        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+        ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
            "Attaching a front buffer to a back buffer returned %08x\n", hr);
         if(SUCCEEDED(hr))
         {
@@ -3538,7 +3538,7 @@ static void BackBufferAttachmentFlipTest(void)
             ok(hr == DD_OK, "DeleteAttachedSurface failed with %08x\n", hr);
         }
         hr = IDirectDrawSurface_AddAttachedSurface(surface2, surface3);
-        todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+        ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
            "Attaching a back buffer to another back buffer returned %08x\n", hr);
         if(SUCCEEDED(hr))
         {
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c
index 1a34724..6d92895 100644
--- a/dlls/ddraw/tests/visual.c
+++ b/dlls/ddraw/tests/visual.c
@@ -2977,7 +2977,7 @@ static void DX1_BackBufferFlipTest(void)
     if(FAILED(hr)) goto out;
 
     hr = IDirectDrawSurface_AddAttachedSurface(Primary, Backbuffer);
-    todo_wine ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
+    ok(hr == DD_OK || broken(hr == DDERR_CANNOTATTACHSURFACE),
        "Attaching a back buffer to a front buffer returned %08x\n", hr);
     if (FAILED(hr)) goto out;
     
-- 
1.7.2




More information about the wine-patches mailing list