[PATCH 3/4] wined3d: Pass an IWineD3DSwapChainImpl pointer to swapchain_create_context_for_thread().

Henri Verbeet hverbeet at codeweavers.com
Tue Jan 18 10:55:21 CST 2011


---
 dlls/wined3d/context.c         |    2 +-
 dlls/wined3d/swapchain.c       |   21 ++++++++++-----------
 dlls/wined3d/wined3d_private.h |    2 +-
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 40fd2e3..bd63f9a 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -1878,7 +1878,7 @@ static struct wined3d_context *findThreadContextForSwapChain(IWineD3DSwapChain *
     }
 
     /* Create a new context for the thread */
-    return swapchain_create_context_for_thread(swapchain);
+    return swapchain_create_context_for_thread((IWineD3DSwapChainImpl *)swapchain);
 }
 
 /* Do not call while under the GL lock. */
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 8f594ae..430c751 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -783,32 +783,31 @@ err:
 }
 
 /* Do not call while under the GL lock. */
-struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface)
+struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChainImpl *swapchain)
 {
-    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *) iface;
     struct wined3d_context **newArray;
     struct wined3d_context *ctx;
 
-    TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
+    TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());
 
-    if (!(ctx = context_create(This, This->front_buffer, This->ds_format)))
+    if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
     {
         ERR("Failed to create a new context for the swapchain\n");
         return NULL;
     }
     context_release(ctx);
 
-    newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (This->num_contexts + 1));
+    newArray = HeapAlloc(GetProcessHeap(), 0, sizeof(*newArray) * (swapchain->num_contexts + 1));
     if(!newArray) {
         ERR("Out of memory when trying to allocate a new context array\n");
-        context_destroy(This->device, ctx);
+        context_destroy(swapchain->device, ctx);
         return NULL;
     }
-    memcpy(newArray, This->context, sizeof(*newArray) * This->num_contexts);
-    HeapFree(GetProcessHeap(), 0, This->context);
-    newArray[This->num_contexts] = ctx;
-    This->context = newArray;
-    This->num_contexts++;
+    memcpy(newArray, swapchain->context, sizeof(*newArray) * swapchain->num_contexts);
+    HeapFree(GetProcessHeap(), 0, swapchain->context);
+    newArray[swapchain->num_contexts] = ctx;
+    swapchain->context = newArray;
+    swapchain->num_contexts++;
 
     TRACE("Returning context %p\n", ctx);
     return ctx;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 115846a..7ea5067 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2634,7 +2634,7 @@ HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
         WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
 
-struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
+struct wined3d_context *swapchain_create_context_for_thread(struct IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
 HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
         IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent) DECLSPEC_HIDDEN;
 
-- 
1.7.3.4




More information about the wine-patches mailing list