Module: wine Branch: master Commit: 6f95f05aaf31e06267446a9aa8b9ae81c35c8460 URL: http://source.winehq.org/git/wine.git/?a=commit;h=6f95f05aaf31e06267446a9aa8...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Jan 19 19:20:11 2011 +0100
wined3d: Move swapchain context retrieval to swapchain.c.
---
dlls/wined3d/context.c | 39 ++++----------------------------------- dlls/wined3d/swapchain.c | 17 ++++++++++++++++- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 21 insertions(+), 37 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 2265188..a438a88 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1859,32 +1859,10 @@ static void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *conte This->frag_pipe->enable_extension(FALSE); }
-/***************************************************************************** - * findThreadContextForSwapChain - * - * Searches a swapchain for all contexts and picks one for the thread tid. - * If none can be found the swapchain is requested to create a new context - * - *****************************************************************************/ -static struct wined3d_context *findThreadContextForSwapChain(struct IWineD3DSwapChainImpl *swapchain, DWORD tid) -{ - unsigned int i; - - for (i = 0; i < swapchain->num_contexts; ++i) - { - if (swapchain->context[i]->tid == tid) - return swapchain->context[i]; - } - - /* Create a new context for the thread */ - return swapchain_create_context_for_thread(swapchain); -} - /* Do not call while under the GL lock. */ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target) { struct wined3d_context *current_context = context_get_current(); - DWORD tid = GetCurrentThreadId(); struct wined3d_context *context;
if (current_context && current_context->destroyed) current_context = NULL; @@ -1915,27 +1893,18 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur { TRACE("Rendering onscreen\n");
- context = findThreadContextForSwapChain(target->container.u.swapchain, tid); + context = swapchain_get_context(target->container.u.swapchain); } else { TRACE("Rendering offscreen\n");
- /* Stay with the currently active context. */ + /* Stay with the current context if possible. Otherwise use the + * context for the primary swapchain. */ if (current_context && current_context->swapchain->device == This) - { context = current_context; - } else - { - /* This may happen if the app jumps straight into offscreen rendering - * Start using the context of the primary swapchain. tid == 0 is no problem - * for findThreadContextForSwapChain. - * - * Can also happen on thread switches - in that case findThreadContextForSwapChain - * is perfect to call. */ - context = findThreadContextForSwapChain((IWineD3DSwapChainImpl *)This->swapchains[0], tid); - } + context = swapchain_get_context((IWineD3DSwapChainImpl *)This->swapchains[0]); }
context_validate(context); diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 430c751..f613dfe 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -783,7 +783,7 @@ err: }
/* Do not call while under the GL lock. */ -struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChainImpl *swapchain) +static struct wined3d_context *swapchain_create_context(struct IWineD3DSwapChainImpl *swapchain) { struct wined3d_context **newArray; struct wined3d_context *ctx; @@ -813,6 +813,21 @@ struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChainImp return ctx; }
+struct wined3d_context *swapchain_get_context(struct IWineD3DSwapChainImpl *swapchain) +{ + DWORD tid = GetCurrentThreadId(); + unsigned int i; + + for (i = 0; i < swapchain->num_contexts; ++i) + { + if (swapchain->context[i]->tid == tid) + return swapchain->context[i]; + } + + /* Create a new context for the thread */ + return swapchain_create_context(swapchain); +} + void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) { /* The drawable size of an onscreen drawable is the surface size. diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 7ea5067..819a6ab 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(struct IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN; +struct wined3d_context *swapchain_get_context(struct IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN; HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type, IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent) DECLSPEC_HIDDEN;