wined3d: Always check if context window needs to be updated.

Fixes a regression introduced by commit
8673dca87d.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-12-18 00:22:25 +01:00 committed by Alexandre Julliard
parent 56040acaa3
commit 6b94fb1e4a
1 changed files with 11 additions and 15 deletions

View File

@ -1114,18 +1114,21 @@ static void context_restore_gl_context(const struct wined3d_gl_info *gl_info, HD
} }
} }
static void context_update_window(struct wined3d_context *context, HWND win_handle) static void context_update_window(struct wined3d_context *context)
{ {
if (context->win_handle == win_handle) if (!context->swapchain)
return;
if (context->win_handle == context->swapchain->win_handle)
return; return;
TRACE("Updating context %p window from %p to %p.\n", TRACE("Updating context %p window from %p to %p.\n",
context, context->win_handle, win_handle); context, context->win_handle, context->swapchain->win_handle);
if (context->hdc) if (context->hdc)
wined3d_release_dc(context->win_handle, context->hdc); wined3d_release_dc(context->win_handle, context->hdc);
context->win_handle = win_handle; context->win_handle = context->swapchain->win_handle;
context->hdc_is_private = FALSE; context->hdc_is_private = FALSE;
context->hdc_has_format = FALSE; context->hdc_has_format = FALSE;
context->needs_set = 1; context->needs_set = 1;
@ -3616,7 +3619,6 @@ static void context_setup_target(struct wined3d_context *context,
struct wined3d_context *context_acquire(const struct wined3d_device *device, struct wined3d_surface *target) struct wined3d_context *context_acquire(const struct wined3d_device *device, struct wined3d_surface *target)
{ {
struct wined3d_context *current_context = context_get_current(); struct wined3d_context *current_context = context_get_current();
struct wined3d_swapchain *swapchain = NULL;
struct wined3d_texture *target_texture; struct wined3d_texture *target_texture;
unsigned int target_sub_resource_idx; unsigned int target_sub_resource_idx;
struct wined3d_context *context; struct wined3d_context *context;
@ -3656,11 +3658,11 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
{ {
context = current_context; context = current_context;
} }
else if ((swapchain = target_texture->swapchain)) else if (target_texture->swapchain)
{ {
TRACE("Rendering onscreen.\n"); TRACE("Rendering onscreen.\n");
context = swapchain_get_context(swapchain); context = swapchain_get_context(target_texture->swapchain);
} }
else else
{ {
@ -3669,19 +3671,13 @@ struct wined3d_context *context_acquire(const struct wined3d_device *device, str
/* Stay with the current context if possible. Otherwise use the /* Stay with the current context if possible. Otherwise use the
* context for the primary swapchain. */ * context for the primary swapchain. */
if (current_context && current_context->device == device) if (current_context && current_context->device == device)
{
context = current_context; context = current_context;
}
else else
{ context = swapchain_get_context(device->swapchains[0]);
swapchain = device->swapchains[0];
context = swapchain_get_context(swapchain);
}
} }
context_enter(context); context_enter(context);
if (swapchain) context_update_window(context);
context_update_window(context, swapchain->win_handle);
context_setup_target(context, target_texture, target_sub_resource_idx); context_setup_target(context, target_texture, target_sub_resource_idx);
if (!context->valid) return context; if (!context->valid) return context;