From baff64a27aa18dd76b17017b4977dc22aa3ebad1 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 4 Apr 2012 20:37:20 +0200 Subject: [PATCH] wined3d: Properly determine the viewport size for front buffer blits in SetupForBlit(). --- dlls/wined3d/context.c | 48 +++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 7d16d3c4a53..bba4112f410 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -1638,6 +1638,26 @@ static void set_blit_dimension(UINT width, UINT height) checkGLcall("glViewport"); } +static void context_get_rt_size(const struct wined3d_context *context, SIZE *size) +{ + const struct wined3d_surface *rt = context->current_rt; + + if (rt->container.type == WINED3D_CONTAINER_SWAPCHAIN + && rt->container.u.swapchain->front_buffer == rt) + { + RECT window_size; + + GetClientRect(context->win_handle, &window_size); + size->cx = window_size.right - window_size.left; + size->cy = window_size.bottom - window_size.top; + + return; + } + + size->cx = rt->resource.width; + size->cy = rt->resource.height; +} + /***************************************************************************** * SetupForBlit * @@ -1659,21 +1679,24 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con { int i; const struct wined3d_gl_info *gl_info = context->gl_info; - UINT width = context->current_rt->resource.width; - UINT height = context->current_rt->resource.height; DWORD sampler; + SIZE rt_size; TRACE("Setting up context %p for blitting\n", context); - if(context->last_was_blit) { - if(context->blit_w != width || context->blit_h != height) { + + context_get_rt_size(context, &rt_size); + + if (context->last_was_blit) + { + if (context->blit_w != rt_size.cx || context->blit_h != rt_size.cy) + { ENTER_GL(); - set_blit_dimension(width, height); + set_blit_dimension(rt_size.cx, rt_size.cy); LEAVE_GL(); - context->blit_w = width; context->blit_h = height; - /* No need to dirtify here, the states are still dirtified because they weren't - * applied since the last SetupForBlit call. Otherwise last_was_blit would not - * be set - */ + context->blit_w = rt_size.cx; + context->blit_h = rt_size.cy; + /* No need to dirtify here, the states are still dirtified because + * they weren't applied since the last SetupForBlit() call. */ } TRACE("Context is already set up for blitting, nothing to do\n"); return; @@ -1839,12 +1862,13 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)"); context_invalidate_state(context, STATE_RENDER(WINED3D_RS_CLIPPING)); - set_blit_dimension(width, height); + set_blit_dimension(rt_size.cx, rt_size.cy); device->frag_pipe->enable_extension(FALSE); LEAVE_GL(); - context->blit_w = width; context->blit_h = height; + context->blit_w = rt_size.cx; + context->blit_h = rt_size.cy; context_invalidate_state(context, STATE_VIEWPORT); context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); }