wined3d: Use RECT instead of WINED3DRECT in stretch_rect_fbo.
This commit is contained in:
parent
2f375cc6ea
commit
ae26d9defd
|
@ -5692,8 +5692,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice
|
|||
}
|
||||
}
|
||||
|
||||
void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect,
|
||||
IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
|
||||
void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, const RECT *src_rect_in,
|
||||
IWineD3DSurface *dst_surface, const RECT *dst_rect_in, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
|
||||
{
|
||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
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
|
|||
struct wined3d_context *context;
|
||||
GLenum gl_filter;
|
||||
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",
|
||||
This, src_surface, src_rect, dst_surface, dst_rect, 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("dst_rect [%u, %u]->[%u, %u]\n", dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2);
|
||||
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_in, dst_surface, dst_rect_in, debug_d3dtexturefiltertype(filter), filter, flip);
|
||||
TRACE("src_rect_in %s\n", wine_dbgstr_rect(src_rect_in));
|
||||
TRACE("dst_rect_in %s\n", wine_dbgstr_rect(dst_rect_in));
|
||||
|
||||
src_rect = *src_rect_in;
|
||||
dst_rect = *dst_rect_in;
|
||||
|
||||
switch (filter) {
|
||||
case WINED3DTEXF_LINEAR:
|
||||
|
@ -5751,12 +5755,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
|
|||
ClientToScreen(context->win_handle, &offset);
|
||||
GetClientRect(context->win_handle, &windowsize);
|
||||
h = windowsize.bottom - windowsize.top;
|
||||
src_rect->x1 -= offset.x; src_rect->x2 -=offset.x;
|
||||
src_rect->y1 = offset.y + h - src_rect->y1;
|
||||
src_rect->y2 = offset.y + h - src_rect->y2;
|
||||
src_rect.left -= offset.x; src_rect.right -=offset.x;
|
||||
src_rect.top = offset.y + h - src_rect.top;
|
||||
src_rect.bottom = offset.y + h - src_rect.bottom;
|
||||
} else {
|
||||
src_rect->y1 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y1;
|
||||
src_rect->y2 = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect->y2;
|
||||
src_rect.top = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.top;
|
||||
src_rect.bottom = ((IWineD3DSurfaceImpl *)src_surface)->currentDesc.Height - src_rect.bottom;
|
||||
}
|
||||
|
||||
ENTER_GL();
|
||||
|
@ -5787,13 +5791,13 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
|
|||
ClientToScreen(context->win_handle, &offset);
|
||||
GetClientRect(context->win_handle, &windowsize);
|
||||
h = windowsize.bottom - windowsize.top;
|
||||
dst_rect->x1 -= offset.x; dst_rect->x2 -=offset.x;
|
||||
dst_rect->y1 = offset.y + h - dst_rect->y1;
|
||||
dst_rect->y2 = offset.y + h - dst_rect->y2;
|
||||
dst_rect.left -= offset.x; dst_rect.right -=offset.x;
|
||||
dst_rect.top = offset.y + h - dst_rect.top;
|
||||
dst_rect.bottom = offset.y + h - dst_rect.bottom;
|
||||
} else {
|
||||
/* Screen coords = window coords, surface height = window height */
|
||||
dst_rect->y1 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y1;
|
||||
dst_rect->y2 = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect->y2;
|
||||
dst_rect.top = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.top;
|
||||
dst_rect.bottom = ((IWineD3DSurfaceImpl *)dst_surface)->currentDesc.Height - dst_rect.bottom;
|
||||
}
|
||||
|
||||
ENTER_GL();
|
||||
|
@ -5814,12 +5818,12 @@ void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED
|
|||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE));
|
||||
|
||||
if (flip) {
|
||||
gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
|
||||
dst_rect->x1, dst_rect->y2, dst_rect->x2, dst_rect->y1, mask, gl_filter);
|
||||
gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
|
||||
dst_rect.left, dst_rect.bottom, dst_rect.right, dst_rect.top, mask, gl_filter);
|
||||
checkGLcall("glBlitFramebuffer()");
|
||||
} else {
|
||||
gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
|
||||
dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2, mask, gl_filter);
|
||||
gl_info->fbo_ops.glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
|
||||
dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom, mask, gl_filter);
|
||||
checkGLcall("glBlitFramebuffer()");
|
||||
}
|
||||
|
||||
|
|
|
@ -3769,7 +3769,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
WINED3DRECT rect;
|
||||
IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
|
||||
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);
|
||||
|
||||
|
@ -3815,6 +3815,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
rect.y2 = This->currentDesc.Height;
|
||||
}
|
||||
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 */
|
||||
if(dstSwapchain && dstSwapchain == srcSwapchain && dstSwapchain->backBuffer &&
|
||||
|
@ -3935,7 +3936,6 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
|
||||
if((srcSwapchain || SrcSurface == myDevice->render_targets[0]) && !dstSwapchain) {
|
||||
/* Blit from render target to texture */
|
||||
WINED3DRECT srect;
|
||||
BOOL upsideDown = FALSE, stretchx;
|
||||
BOOL paletteOverride = FALSE;
|
||||
|
||||
|
@ -3945,29 +3945,17 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
/* 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
|
||||
* glCopyTexSubImage is a bit picky about the parameters we pass to it
|
||||
*/
|
||||
if(rect.y1 > rect.y2) {
|
||||
UINT tmp = rect.y2;
|
||||
rect.y2 = rect.y1;
|
||||
rect.y1 = tmp;
|
||||
if(dst_rect.top > dst_rect.bottom) {
|
||||
UINT tmp = dst_rect.bottom;
|
||||
dst_rect.bottom = dst_rect.top;
|
||||
dst_rect.top = tmp;
|
||||
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;
|
||||
} else {
|
||||
stretchx = FALSE;
|
||||
|
@ -4001,15 +3989,15 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
&& myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
|
||||
&& surface_can_stretch_rect(Src, This))
|
||||
{
|
||||
stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &srect,
|
||||
(IWineD3DSurface *)This, &rect, Filter, upsideDown);
|
||||
} else if((!stretchx) || rect.x2 - rect.x1 > Src->currentDesc.Width ||
|
||||
rect.y2 - rect.y1 > Src->currentDesc.Height) {
|
||||
stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
|
||||
(IWineD3DSurface *)This, &dst_rect, Filter, upsideDown);
|
||||
} else if((!stretchx) || dst_rect.right - dst_rect.left > Src->currentDesc.Width ||
|
||||
dst_rect.bottom - dst_rect.top > Src->currentDesc.Height) {
|
||||
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 {
|
||||
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 */
|
||||
|
@ -4030,13 +4018,10 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
DWORD oldCKeyFlags = Src->CKeyFlags;
|
||||
WINEDDCOLORKEY oldBltCKey = Src->SrcBltCKey;
|
||||
struct wined3d_context *context;
|
||||
RECT SourceRectangle;
|
||||
BOOL paletteOverride = FALSE;
|
||||
|
||||
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
|
||||
* surface is not required to have a palette. Our rendering / conversion
|
||||
* code further down the road retrieves the palette from the surface, so
|
||||
|
@ -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
|
||||
* contents are never upside down
|
||||
*/
|
||||
stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, (WINED3DRECT *) &SourceRectangle,
|
||||
(IWineD3DSurface *)This, &rect, Filter, FALSE);
|
||||
stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
|
||||
(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 */
|
||||
if(paletteOverride)
|
||||
|
@ -4147,7 +4132,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const
|
|||
|
||||
/* 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)) {
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
|
|
@ -3022,7 +3022,7 @@ static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
|
||||
|
|
Loading…
Reference in New Issue