Stefan Dösinger : ddraw: Move the additional surface creation into a seperate function.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Apr 30 07:11:16 CDT 2007


Module: wine
Branch: master
Commit: 87544190a5ff61312b0972b828483eba47646007
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=87544190a5ff61312b0972b828483eba47646007

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Mon Apr 23 19:53:09 2007 +0200

ddraw: Move the additional surface creation into a seperate function.

---

 dlls/ddraw/ddraw.c |   93 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 54 insertions(+), 39 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index 0194736..f6e153b 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -1950,6 +1950,54 @@ IDirectDrawImpl_CreateNewSurface(IDirectDrawImpl *This,
     return DD_OK;
 }
 
+static HRESULT
+CreateAdditionalSurfaces(IDirectDrawImpl *This,
+                         IDirectDrawSurfaceImpl *root,
+                         UINT count,
+                         DDSURFACEDESC2 *DDSD)
+{
+    UINT i, level = 0;
+    HRESULT hr;
+    for(i = 0; i < count; i++)
+    {
+        IDirectDrawSurfaceImpl *object2 = NULL;
+        IDirectDrawSurfaceImpl *iterator;
+
+        /* increase the mipmap level, but only if a mipmap is created
+         * In this case, also halve the size
+         */
+        if(DDSD->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
+        {
+            level++;
+            if(DDSD->dwWidth > 1) DDSD->dwWidth /= 2;
+            if(DDSD->dwHeight > 1) DDSD->dwHeight /= 2;
+        }
+
+        hr = IDirectDrawImpl_CreateNewSurface(This,
+                                              DDSD,
+                                              &object2,
+                                              level);
+        if(hr != DD_OK)
+        {
+            return hr;
+        }
+
+        /* Add the new surface to the complex attachment list */
+        object2->first_complex = root;
+        object2->next_complex = NULL;
+        iterator = root;
+        while(iterator->next_complex) iterator = iterator->next_complex;
+        iterator->next_complex = object2;
+
+        /* Remove the (possible) back buffer cap from the new surface description,
+         * because only one surface in the flipping chain is a back buffer, one
+         * is a front buffer, the others are just primary surfaces.
+         */
+        DDSD->ddsCaps.dwCaps &= ~DDSCAPS_BACKBUFFER;
+    }
+    return DD_OK;
+}
+
 /*****************************************************************************
  * IDirectDraw7::CreateSurface
  *
@@ -2036,9 +2084,8 @@ IDirectDrawImpl_CreateSurface(IDirectDraw7 *iface,
     ICOM_THIS_FROM(IDirectDrawImpl, IDirectDraw7, iface);
     IDirectDrawSurfaceImpl *object = NULL;
     HRESULT hr;
-    LONG extra_surfaces = 0, i;
+    LONG extra_surfaces = 0;
     DDSURFACEDESC2 desc2;
-    UINT level = 0;
     WINED3DDISPLAYMODE Mode;
 
     TRACE("(%p)->(%p,%p,%p)\n", This, DDSD, Surf, UnkOuter);
@@ -2279,44 +2326,12 @@ IDirectDrawImpl_CreateSurface(IDirectDraw7 *iface,
         desc2.ddsCaps.dwCaps2 |= DDSCAPS2_MIPMAPSUBLEVEL;
     }
 
-    for(i = 0; i < extra_surfaces; i++)
+    hr = CreateAdditionalSurfaces(This, object, extra_surfaces, &desc2);
+    if(hr != DD_OK)
     {
-        IDirectDrawSurfaceImpl *object2 = NULL;
-        IDirectDrawSurfaceImpl *iterator;
-
-        /* increase the mipmap level, but only if a mipmap is created
-         * In this case, also halve the size
-         */
-        if(DDSD->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
-        {
-            level++;
-            if(desc2.dwWidth > 1) desc2.dwWidth /= 2;
-            if(desc2.dwHeight > 1) desc2.dwHeight /= 2;
-        }
-
-        hr = IDirectDrawImpl_CreateNewSurface(This,
-                                              &desc2,
-                                              &object2,
-                                              level);
-        if(hr != DD_OK)
-        {
-            /* This destroys and possibly created surfaces too */
-            IDirectDrawSurface_Release( ICOM_INTERFACE(object, IDirectDrawSurface7) );
-            return hr;
-        }
-
-        /* Add the new surface to the complex attachment list */
-        object2->first_complex = object;
-        object2->next_complex = NULL;
-        iterator = object;
-        while(iterator->next_complex) iterator = iterator->next_complex;
-        iterator->next_complex = object2;
-
-        /* Remove the (possible) back buffer cap from the new surface description,
-         * because only one surface in the flipping chain is a back buffer, one
-         * is a front buffer, the others are just primary surfaces.
-         */
-        desc2.ddsCaps.dwCaps &= ~DDSCAPS_BACKBUFFER;
+        /* This destroys and possibly created surfaces too */
+        IDirectDrawSurface_Release( ICOM_INTERFACE(object, IDirectDrawSurface7) );
+        return hr;
     }
 
     /* Addref the ddraw interface to keep an reference for each surface */




More information about the wine-cvs mailing list