Commit ae26d9de authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

wined3d: Use RECT instead of WINED3DRECT in stretch_rect_fbo.

parent 2f375cc6
...@@ -5692,8 +5692,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice ...@@ -5692,8 +5692,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice
} }
} }
void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect, void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const RECT *src_rect_in,
IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) IWineD3DSurface *dst_surface, const RECT *dst_rect_in, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
{ {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */ GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */
...@@ -5701,11 +5701,15 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED ...@@ -5701,11 +5701,15 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
struct wined3d_context *context; struct wined3d_context *context;
GLenum gl_filter; GLenum gl_filter;
POINT offset = {0, 0}; POINT offset = {0, 0};
RECT src_rect, dst_rect;
TRACE("(%p) : src_surface %p, src_rect %p, dst_surface %p, dst_rect %p, filter %s (0x%08x), flip %u\n", TRACE("(%p) : src_surface %p, src_rect_in %p, dst_surface %p, dst_rect_in %p, filter %s (0x%08x), flip %u\n",
This, src_surface, src_rect, dst_surface, dst_rect, debug_d3dtexturefiltertype(filter), filter, flip); This, src_surface, src_rect_in, dst_surface, dst_rect_in, debug_d3dtexturefiltertype(filter), filter, flip);
TRACE("src_rect [%u, %u]->[%u, %u]\n", src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2); TRACE("src_rect_in %s\n", wine_dbgstr_rect(src_rect_in));
TRACE("dst_rect [%u, %u]->[%u, %u]\n", dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2); TRACE("dst_rect_in %s\n", wine_dbgstr_rect(dst_rect_in));
src_rect = *src_rect_in;
dst_rect = *dst_rect_in;
switch (filter) { switch (filter) {
case WINED3DTEXF_LINEAR: case WINED3DTEXF_LINEAR:
...@@ -5751,12 +5755,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED ...@@ -5751,12 +5755,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
ClientToScreen(context->win_handle, &offset); ClientToScreen(context->win_handle, &offset);
GetClientRect(context->win_handle, &windowsize); GetClientRect(context->win_handle, &windowsize);
h = windowsize.bottom - windowsize.top; h = windowsize.bottom - windowsize.top;
src_rect->x1 -= offset.x; src_rect->x2 -=offset.x; src_rect.left -= offset.x; src_rect.right -=offset.x;
src_rect->y1 = offset.y + h - src_rect->y1; src_rect.top = offset.y + h - src_rect.top;
src_rect->y2 = offset.y + h - src_rect->y2; src_rect.bottom = offset.y + h - src_rect.bottom;
} else { } else {
src_rect->y1 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y1; src_rect.top = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.top;
src_rect->y2 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y2; src_rect.bottom = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.bottom;
} }
ENTER_GL(); ENTER_GL();
...@@ -5787,13 +5791,13 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED ...@@ -5787,13 +5791,13 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
ClientToScreen(context->win_handle, &offset); ClientToScreen(context->win_handle, &offset);
GetClientRect(context->win_handle, &windowsize); GetClientRect(context->win_handle, &windowsize);
h = windowsize.bottom - windowsize.top; h = windowsize.bottom - windowsize.top;
dst_rect->x1 -= offset.x; dst_rect->x2 -=offset.x; dst_rect.left -= offset.x; dst_rect.right -=offset.x;
dst_rect->y1 = offset.y + h - dst_rect->y1; dst_rect.top = offset.y + h - dst_rect.top;
dst_rect->y2 = offset.y + h - dst_rect->y2; dst_rect.bottom = offset.y + h - dst_rect.bottom;
} else { } else {
/* Screen coords = window coords, surface height = window height */ /* Screen coords = window coords, surface height = window height */
dst_rect->y1 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y1; dst_rect.top = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.top;
dst_rect->y2 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y2; dst_rect.bottom = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.bottom;
} }
ENTER_GL(); ENTER_GL();
...@@ -5814,12 +5818,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED ...@@ -5814,12 +5818,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE)); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
if (flip) { if (flip) {
gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2, gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
dst_rect->x1, dst_rect->y2, dst_rect->x2, dst_rect->y1, mask, gl_filter); dst_rect.left, dst_rect.bottom, dst_rect.right, dst_rect.top, mask, gl_filter);
checkGLcall("glBlitFramebuffer()"); checkGLcall("glBlitFramebuffer()");
} else { } else {
gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2, gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2, mask, gl_filter); dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom, mask, gl_filter);
checkGLcall("glBlitFramebuffer()"); checkGLcall("glBlitFramebuffer()");
} }
......
...@@ -3769,7 +3769,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -3769,7 +3769,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
WINED3DRECT rect; WINED3DRECT rect;
IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL; IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface; IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
RECT dst_rect; RECT dst_rect, src_rect;
TRACE("(%p)->(%p,%p,%p,%08x,%p)\n", This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx); TRACE("(%p)->(%p,%p,%p,%08x,%p)\n", This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx);
...@@ -3815,6 +3815,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -3815,6 +3815,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
rect.y2 = This->currentDesc.Height; rect.y2 = This->currentDesc.Height;
} }
surface_get_rect(This, DestRect, &dst_rect); surface_get_rect(This, DestRect, &dst_rect);
if(Src) surface_get_rect(Src, SrcRect, &src_rect);
/* The only case where both surfaces on a swapchain are supported is a back buffer -> front buffer blit on the same swapchain */ /* The only case where both surfaces on a swapchain are supported is a back buffer -> front buffer blit on the same swapchain */
if(dstSwapchain && dstSwapchain == srcSwapchain && dstSwapchain->backBuffer && if(dstSwapchain && dstSwapchain == srcSwapchain && dstSwapchain->backBuffer &&
...@@ -3935,7 +3936,6 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -3935,7 +3936,6 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
if((srcSwapchain || SrcSurface == myDevice->render_targets[0]) && !dstSwapchain) { if((srcSwapchain || SrcSurface == myDevice->render_targets[0]) && !dstSwapchain) {
/* Blit from render target to texture */ /* Blit from render target to texture */
WINED3DRECT srect;
BOOL upsideDown = FALSE, stretchx; BOOL upsideDown = FALSE, stretchx;
BOOL paletteOverride = FALSE; BOOL paletteOverride = FALSE;
...@@ -3945,29 +3945,17 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -3945,29 +3945,17 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
/* Destination color key is checked above */ /* Destination color key is checked above */
} }
if(SrcRect) {
srect.y1 = SrcRect->top;
srect.y2 = SrcRect->bottom;
srect.x1 = SrcRect->left;
srect.x2 = SrcRect->right;
} else {
srect.x1 = 0;
srect.y1 = 0;
srect.x2 = Src->currentDesc.Width;
srect.y2 = Src->currentDesc.Height;
}
/* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag /* Make sure that the top pixel is always above the bottom pixel, and keep a separate upside down flag
* glCopyTexSubImage is a bit picky about the parameters we pass to it * glCopyTexSubImage is a bit picky about the parameters we pass to it
*/ */
if(rect.y1 > rect.y2) { if(dst_rect.top > dst_rect.bottom) {
UINT tmp = rect.y2; UINT tmp = dst_rect.bottom;
rect.y2 = rect.y1; dst_rect.bottom = dst_rect.top;
rect.y1 = tmp; dst_rect.top = tmp;
upsideDown = TRUE; upsideDown = TRUE;
} }
if(rect.x2 - rect.x1 != srect.x2 - srect.x1) { if(dst_rect.right - dst_rect.left != src_rect.right - src_rect.left) {
stretchx = TRUE; stretchx = TRUE;
} else { } else {
stretchx = FALSE; stretchx = FALSE;
...@@ -4001,15 +3989,15 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -4001,15 +3989,15 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
&& myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
&& surface_can_stretch_rect(Src, This)) && surface_can_stretch_rect(Src, This))
{ {
stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &srect, stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
(IWineD3DSurface *)This, &rect, Filter, upsideDown); (IWineD3DSurface *)This, &dst_rect, Filter, upsideDown);
} else if((!stretchx) || rect.x2 - rect.x1 > Src->currentDesc.Width || } else if((!stretchx) || dst_rect.right - dst_rect.left > Src->currentDesc.Width ||
rect.y2 - rect.y1 > Src->currentDesc.Height) { dst_rect.bottom - dst_rect.top > Src->currentDesc.Height) {
TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n"); TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n");
fb_copy_to_texture_direct(This, SrcSurface, &srect, &rect, upsideDown, Filter); fb_copy_to_texture_direct(This, SrcSurface, (WINED3DRECT*)&src_rect, (WINED3DRECT*)&dst_rect, upsideDown, Filter);
} else { } else {
TRACE("Using hardware stretching to flip / stretch the texture\n"); TRACE("Using hardware stretching to flip / stretch the texture\n");
fb_copy_to_texture_hwstretch(This, SrcSurface, srcSwapchain, &srect, &rect, upsideDown, Filter); fb_copy_to_texture_hwstretch(This, SrcSurface, srcSwapchain, (WINED3DRECT*)&src_rect, (WINED3DRECT*)&dst_rect, upsideDown, Filter);
} }
/* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */ /* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */
...@@ -4030,13 +4018,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -4030,13 +4018,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
DWORD oldCKeyFlags = Src->CKeyFlags; DWORD oldCKeyFlags = Src->CKeyFlags;
WINEDDCOLORKEY oldBltCKey = Src->SrcBltCKey; WINEDDCOLORKEY oldBltCKey = Src->SrcBltCKey;
struct wined3d_context *context; struct wined3d_context *context;
RECT SourceRectangle;
BOOL paletteOverride = FALSE; BOOL paletteOverride = FALSE;
TRACE("Blt from surface %p to rendertarget %p\n", Src, This); TRACE("Blt from surface %p to rendertarget %p\n", Src, This);
surface_get_rect(Src, SrcRect, &SourceRectangle);
/* When blitting from an offscreen surface to a rendertarget, the source /* When blitting from an offscreen surface to a rendertarget, the source
* surface is not required to have a palette. Our rendering / conversion * surface is not required to have a palette. Our rendering / conversion
* code further down the road retrieves the palette from the surface, so * code further down the road retrieves the palette from the surface, so
...@@ -4057,8 +4042,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -4057,8 +4042,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
/* The source is always a texture, but never the currently active render target, and the texture /* The source is always a texture, but never the currently active render target, and the texture
* contents are never upside down * contents are never upside down
*/ */
stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, (WINED3DRECT *) &SourceRectangle, stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
(IWineD3DSurface *)This, &rect, Filter, FALSE); (IWineD3DSurface *)This, &dst_rect, Filter, FALSE);
/* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */ /* Clear the palette as the surface didn't have a palette attached, it would confuse GetPalette and other calls */
if(paletteOverride) if(paletteOverride)
...@@ -4147,7 +4132,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const ...@@ -4147,7 +4132,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
/* Draw a textured quad /* Draw a textured quad
*/ */
draw_textured_quad(Src, &SourceRectangle, &dst_rect, Filter); draw_textured_quad(Src, &src_rect, &dst_rect, Filter);
if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) { if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
......
...@@ -3022,7 +3022,7 @@ static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock) ...@@ -3022,7 +3022,7 @@ static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
} }
void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface,
WINED3DRECT *src_rect, IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const RECT *src_rect, IWineD3DSurface *dst_surface, const RECT *dst_rect,
const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) DECLSPEC_HIDDEN; const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) DECLSPEC_HIDDEN;
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */ /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment