wined3d: Properly determine the viewport size for front buffer blits in SetupForBlit().

This commit is contained in:
Henri Verbeet 2012-04-04 20:37:20 +02:00 committed by Alexandre Julliard
parent 81ca5d09b6
commit baff64a27a
1 changed files with 36 additions and 12 deletions

View File

@ -1638,6 +1638,26 @@ static void set_blit_dimension(UINT width, UINT height)
checkGLcall("glViewport"); 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 * SetupForBlit
* *
@ -1659,21 +1679,24 @@ static void SetupForBlit(const struct wined3d_device *device, struct wined3d_con
{ {
int i; int i;
const struct wined3d_gl_info *gl_info = context->gl_info; 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; DWORD sampler;
SIZE rt_size;
TRACE("Setting up context %p for blitting\n", context); 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(); ENTER_GL();
set_blit_dimension(width, height); set_blit_dimension(rt_size.cx, rt_size.cy);
LEAVE_GL(); LEAVE_GL();
context->blit_w = width; context->blit_h = height; context->blit_w = rt_size.cx;
/* No need to dirtify here, the states are still dirtified because they weren't context->blit_h = rt_size.cy;
* applied since the last SetupForBlit call. Otherwise last_was_blit would not /* No need to dirtify here, the states are still dirtified because
* be set * they weren't applied since the last SetupForBlit() call. */
*/
} }
TRACE("Context is already set up for blitting, nothing to do\n"); TRACE("Context is already set up for blitting, nothing to do\n");
return; 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)"); glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)");
context_invalidate_state(context, STATE_RENDER(WINED3D_RS_CLIPPING)); 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); device->frag_pipe->enable_extension(FALSE);
LEAVE_GL(); 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_VIEWPORT);
context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION)); context_invalidate_state(context, STATE_TRANSFORM(WINED3D_TS_PROJECTION));
} }