Commit db0784e1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Introduce a separate function for translating front buffer coordinates to GL coordinates.

parent 62d80660
...@@ -7004,17 +7004,7 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_ ...@@ -7004,17 +7004,7 @@ HRESULT arbfp_blit_surface(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_
* whereas the real gl drawable size is the size of the window. */ * whereas the real gl drawable size is the size of the window. */
dst_swapchain = (dst_surface->Flags & SFLAG_SWAPCHAIN) ? (IWineD3DSwapChainImpl *)dst_surface->container : NULL; dst_swapchain = (dst_surface->Flags & SFLAG_SWAPCHAIN) ? (IWineD3DSwapChainImpl *)dst_surface->container : NULL;
if (dst_swapchain && dst_surface == dst_swapchain->front_buffer) if (dst_swapchain && dst_surface == dst_swapchain->front_buffer)
{ surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
RECT windowsize;
POINT offset = {0,0};
UINT h;
ClientToScreen(context->win_handle, &offset);
GetClientRect(context->win_handle, &windowsize);
h = windowsize.bottom - windowsize.top;
dst_rect.left -= offset.x; dst_rect.right -=offset.x;
dst_rect.top -= offset.y; dst_rect.bottom -=offset.y;
dst_rect.top += dst_surface->currentDesc.Height - h; dst_rect.bottom += dst_surface->currentDesc.Height - h;
}
arbfp_blit_set((IWineD3DDevice *)device, src_surface); arbfp_blit_set((IWineD3DDevice *)device, src_surface);
......
...@@ -5740,7 +5740,6 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa ...@@ -5740,7 +5740,6 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
struct wined3d_context *context; struct wined3d_context *context;
GLenum gl_filter; GLenum gl_filter;
POINT offset = {0, 0};
RECT src_rect, dst_rect; RECT src_rect, dst_rect;
TRACE("device %p, src_surface %p, src_rect_in %s, dst_surface %p, dst_rect_in %s, filter %s (0x%08x).\n", TRACE("device %p, src_surface %p, src_rect_in %s, dst_surface %p, dst_rect_in %s, filter %s (0x%08x).\n",
...@@ -5788,19 +5787,11 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa ...@@ -5788,19 +5787,11 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa
TRACE("Source surface %p is onscreen\n", src_surface); TRACE("Source surface %p is onscreen\n", src_surface);
if(buffer == GL_FRONT) { if (buffer == GL_FRONT)
RECT windowsize; surface_translate_frontbuffer_coords(src_surface, context->win_handle, &src_rect);
UINT h;
ClientToScreen(context->win_handle, &offset); src_rect.top = src_surface->currentDesc.Height - src_rect.top;
GetClientRect(context->win_handle, &windowsize); src_rect.bottom = src_surface->currentDesc.Height - src_rect.bottom;
h = windowsize.bottom - windowsize.top;
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.top = src_surface->currentDesc.Height - src_rect.top;
src_rect.bottom = src_surface->currentDesc.Height - src_rect.bottom;
}
ENTER_GL(); ENTER_GL();
context_bind_fbo(context, GL_READ_FRAMEBUFFER, NULL); context_bind_fbo(context, GL_READ_FRAMEBUFFER, NULL);
...@@ -5822,20 +5813,11 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa ...@@ -5822,20 +5813,11 @@ void stretch_rect_fbo(IWineD3DDeviceImpl *device, IWineD3DSurfaceImpl *src_surfa
TRACE("Destination surface %p is onscreen\n", dst_surface); TRACE("Destination surface %p is onscreen\n", dst_surface);
if(buffer == GL_FRONT) { if (buffer == GL_FRONT)
RECT windowsize; surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
UINT h;
ClientToScreen(context->win_handle, &offset); dst_rect.top = dst_surface->currentDesc.Height - dst_rect.top;
GetClientRect(context->win_handle, &windowsize); dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
h = windowsize.bottom - windowsize.top;
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.top = dst_surface->currentDesc.Height - dst_rect.top;
dst_rect.bottom = dst_surface->currentDesc.Height - dst_rect.bottom;
}
ENTER_GL(); ENTER_GL();
context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL); context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL);
......
...@@ -3380,6 +3380,21 @@ static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_ ...@@ -3380,6 +3380,21 @@ static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum blit_
const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool, const RECT *dst_rect, DWORD dst_usage, WINED3DPOOL dst_pool,
const struct wined3d_format_desc *dst_format_desc); const struct wined3d_format_desc *dst_format_desc);
/* Front buffer coordinates are always full screen coordinates, but our GL
* drawable is limited to the window's client area. The sysmem and texture
* copies do have the full screen size. Note that GL has a bottom-left
* origin, while D3D has a top-left origin. */
void surface_translate_frontbuffer_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect)
{
POINT offset = {0, surface->currentDesc.Height};
RECT windowsize;
GetClientRect(window, &windowsize);
offset.y -= windowsize.bottom - windowsize.top;
ScreenToClient(window, &offset);
OffsetRect(rect, offset.x, offset.y);
}
/* Not called from the VTable */ /* Not called from the VTable */
static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface, const RECT *DestRect, static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface, const RECT *DestRect,
IWineD3DSurfaceImpl *src_surface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, IWineD3DSurfaceImpl *src_surface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx,
...@@ -3674,25 +3689,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface, ...@@ -3674,25 +3689,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *dst_surface,
context = context_acquire(device, dst_surface); context = context_acquire(device, dst_surface);
context_apply_blit_state(context, device); context_apply_blit_state(context, device);
/* The coordinates of the ddraw front buffer are always fullscreen ('screen coordinates',
* while OpenGL coordinates are window relative.
* Also beware of the origin difference(top left vs bottom left).
* Also beware that the front buffer's surface size is screen width x screen height,
* whereas the real gl drawable size is the size of the window.
*/
if (dstSwapchain && dst_surface == dstSwapchain->front_buffer) if (dstSwapchain && dst_surface == dstSwapchain->front_buffer)
{ surface_translate_frontbuffer_coords(dst_surface, context->win_handle, &dst_rect);
RECT windowsize;
POINT offset = {0,0};
UINT h;
ClientToScreen(context->win_handle, &offset);
GetClientRect(context->win_handle, &windowsize);
h = windowsize.bottom - windowsize.top;
dst_rect.left -= offset.x; dst_rect.right -=offset.x;
dst_rect.top -= offset.y; dst_rect.bottom -=offset.y;
dst_rect.top += dst_surface->currentDesc.Height - h;
dst_rect.bottom += dst_surface->currentDesc.Height - h;
}
if (!device->blitter->blit_supported(&device->adapter->gl_info, BLIT_OP_BLIT, if (!device->blitter->blit_supported(&device->adapter->gl_info, BLIT_OP_BLIT,
&src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format_desc, &src_rect, src_surface->resource.usage, src_surface->resource.pool, src_surface->resource.format_desc,
...@@ -4351,22 +4349,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT ...@@ -4351,22 +4349,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT
} }
if ((This->Flags & SFLAG_SWAPCHAIN) && This == ((IWineD3DSwapChainImpl *)This->container)->front_buffer) if ((This->Flags & SFLAG_SWAPCHAIN) && This == ((IWineD3DSwapChainImpl *)This->container)->front_buffer)
{ surface_translate_frontbuffer_coords(This, context->win_handle, &dst_rect);
RECT windowsize;
POINT offset = {0, 0};
UINT h;
ClientToScreen(context->win_handle, &offset);
GetClientRect(context->win_handle, &windowsize);
h = windowsize.bottom - windowsize.top;
dst_rect.left -= offset.x;
dst_rect.right -=offset.x;
dst_rect.top -= offset.y;
dst_rect.bottom -=offset.y;
dst_rect.top += This->currentDesc.Height - h;
dst_rect.bottom += This->currentDesc.Height - h;
}
device->blitter->set_shader((IWineD3DDevice *) device, This); device->blitter->set_shader((IWineD3DDevice *) device, This);
......
...@@ -2101,6 +2101,7 @@ HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, ...@@ -2101,6 +2101,7 @@ HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type,
UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type, UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
void surface_translate_frontbuffer_coords(IWineD3DSurfaceImpl *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
/* Predeclare the shared Surface functions */ /* Predeclare the shared Surface functions */
HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface, HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface,
......
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