[PATCH 4/4] wined3d: Store a pointer to an array of IWineD3DSwapChainImpl pointers in the device.

Henri Verbeet hverbeet at codeweavers.com
Wed Jan 19 12:20:12 CST 2011


---
 dlls/wined3d/context.c         |    4 ++--
 dlls/wined3d/device.c          |   37 ++++++++++++++++++++++---------------
 dlls/wined3d/surface.c         |    2 +-
 dlls/wined3d/surface_gdi.c     |    2 +-
 dlls/wined3d/wined3d_private.h |    2 +-
 5 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index a438a88..5ecd748 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1877,7 +1877,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
         }
         else
         {
-            IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[0];
+            IWineD3DSwapChainImpl *swapchain = This->swapchains[0];
             if (swapchain->back_buffers) target = swapchain->back_buffers[0];
             else target = swapchain->front_buffer;
         }
@@ -1904,7 +1904,7 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
         if (current_context && current_context->swapchain->device == This)
             context = current_context;
         else
-            context = swapchain_get_context((IWineD3DSwapChainImpl *)This->swapchains[0]);
+            context = swapchain_get_context(This->swapchains[0]);
     }
 
     context_validate(context);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index a099c90..d375ca3 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1305,8 +1305,9 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, U
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     TRACE("(%p) : swapchain %d\n", This, iSwapChain);
 
-    if(iSwapChain < This->NumberOfSwapChains) {
-        *pSwapChain = This->swapchains[iSwapChain];
+    if (iSwapChain < This->NumberOfSwapChains)
+    {
+        *pSwapChain = (IWineD3DSwapChain *)This->swapchains[iSwapChain];
         IWineD3DSwapChain_AddRef(*pSwapChain);
         TRACE("(%p) returning %p\n", This, *pSwapChain);
         return WINED3D_OK;
@@ -1939,12 +1940,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
     }
 
     This->NumberOfSwapChains = 1;
-    This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
-    if(!This->swapchains) {
+    This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(*This->swapchains));
+    if (!This->swapchains)
+    {
         ERR("Out of memory!\n");
         goto err_out;
     }
-    This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
+    This->swapchains[0] = swapchain;
 
     if (swapchain->back_buffers && swapchain->back_buffers[0])
     {
@@ -2079,12 +2081,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_InitGDI(IWineD3DDevice *iface,
     }
 
     This->NumberOfSwapChains = 1;
-    This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(IWineD3DSwapChain *));
-    if(!This->swapchains) {
+    This->swapchains = HeapAlloc(GetProcessHeap(), 0, This->NumberOfSwapChains * sizeof(*This->swapchains));
+    if (!This->swapchains)
+    {
         ERR("Out of memory!\n");
         goto err_out;
     }
-    This->swapchains[0] = (IWineD3DSwapChain *) swapchain;
+    This->swapchains[0] = swapchain;
     return WINED3D_OK;
 
 err_out:
@@ -2227,9 +2230,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
 
     context_release(context);
 
-    for(i=0; i < This->NumberOfSwapChains; i++) {
-        TRACE("Releasing the implicit swapchain %d\n", i);
-        if (D3DCB_DestroySwapChain(This->swapchains[i])  > 0) {
+    for (i = 0; i < This->NumberOfSwapChains; ++i)
+    {
+        TRACE("Releasing the implicit swapchain %u.\n", i);
+        if (D3DCB_DestroySwapChain((IWineD3DSwapChain *)This->swapchains[i]) > 0)
+        {
             FIXME("(%p) Something's still holding the implicit swapchain\n", This);
         }
     }
@@ -2255,9 +2260,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UninitGDI(IWineD3DDevice *iface, D3DCB_
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     unsigned int i;
 
-    for(i=0; i < This->NumberOfSwapChains; i++) {
-        TRACE("Releasing the implicit swapchain %d\n", i);
-        if (D3DCB_DestroySwapChain(This->swapchains[i])  > 0) {
+    for (i = 0; i < This->NumberOfSwapChains; ++i)
+    {
+        TRACE("Releasing the implicit swapchain %u.\n", i);
+        if (D3DCB_DestroySwapChain((IWineD3DSwapChain *)This->swapchains[i]) > 0)
+        {
             FIXME("(%p) Something's still holding the implicit swapchain\n", This);
         }
     }
@@ -5820,7 +5827,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice *
 
     if (This->depth_stencil)
     {
-        if (((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
+        if (This->swapchains[0]->presentParms.Flags & WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL
                 || This->depth_stencil->flags & SFLAG_DISCARD)
         {
             surface_modify_ds_location(This->depth_stencil, SFLAG_DS_DISCARDED,
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7e19a02..cce1a2f 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2014,7 +2014,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHD
         } else {
             IWineD3DSurfaceImpl *dds_primary;
             IWineD3DSwapChainImpl *swapchain;
-            swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[0];
+            swapchain = This->resource.device->swapchains[0];
             dds_primary = swapchain->front_buffer;
             if (dds_primary && dds_primary->palette)
                 pal = dds_primary->palette->palents;
diff --git a/dlls/wined3d/surface_gdi.c b/dlls/wined3d/surface_gdi.c
index 013ff2c..d7a6f4a 100644
--- a/dlls/wined3d/surface_gdi.c
+++ b/dlls/wined3d/surface_gdi.c
@@ -266,7 +266,7 @@ static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHD
         } else {
             IWineD3DSurfaceImpl *dds_primary;
             IWineD3DSwapChainImpl *swapchain;
-            swapchain = (IWineD3DSwapChainImpl *)This->resource.device->swapchains[0];
+            swapchain = This->resource.device->swapchains[0];
             dds_primary = swapchain->front_buffer;
             if (dds_primary && dds_primary->palette)
                 pal = dds_primary->palette->palents;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 819a6ab..baf009f 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1707,7 +1707,7 @@ struct IWineD3DDeviceImpl
     WINED3DDEVTYPE                  devType;
     HWND focus_window;
 
-    IWineD3DSwapChain     **swapchains;
+    IWineD3DSwapChainImpl **swapchains;
     UINT                    NumberOfSwapChains;
 
     struct list             resources; /* a linked list to track resources created by the device */
-- 
1.7.3.4




More information about the wine-patches mailing list