Commit 7524258a authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Implement flips inside ddraw.

parent f637c229
...@@ -1175,6 +1175,8 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra ...@@ -1175,6 +1175,8 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface7(iface); struct ddraw_surface *dst_impl = impl_from_IDirectDrawSurface7(iface);
struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src); struct ddraw_surface *src_impl = unsafe_impl_from_IDirectDrawSurface7(src);
DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, 0}; DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, 0};
struct wined3d_surface *tmp, *rt;
struct wined3d_texture *texture;
IDirectDrawSurface7 *current; IDirectDrawSurface7 *current;
HRESULT hr; HRESULT hr;
...@@ -1185,6 +1187,10 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra ...@@ -1185,6 +1187,10 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
wined3d_mutex_lock(); wined3d_mutex_lock();
tmp = dst_impl->wined3d_surface;
texture = dst_impl->wined3d_texture;
rt = wined3d_device_get_render_target(dst_impl->ddraw->wined3d_device, 0);
if (src_impl) if (src_impl)
{ {
for (current = iface; current != src;) for (current = iface; current != src;)
...@@ -1216,9 +1222,37 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra ...@@ -1216,9 +1222,37 @@ static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDra
ddraw_surface7_Release(current); ddraw_surface7_Release(current);
} }
if (SUCCEEDED(hr = wined3d_surface_flip(dst_impl->wined3d_surface, src_impl->wined3d_surface, flags)) if (rt == dst_impl->wined3d_surface)
&& (dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, src_impl->wined3d_surface, FALSE);
wined3d_resource_set_parent(wined3d_surface_get_resource(src_impl->wined3d_surface), dst_impl);
dst_impl->wined3d_surface = src_impl->wined3d_surface;
wined3d_resource_set_parent(wined3d_texture_get_resource(src_impl->wined3d_texture),
wined3d_texture_get_parent(dst_impl->wined3d_texture));
dst_impl->wined3d_texture = src_impl->wined3d_texture;
/* We don't have to worry about potential texture bindings, since
* flippable surfaces can never be textures. */
if (rt == src_impl->wined3d_surface)
wined3d_device_set_render_target(dst_impl->ddraw->wined3d_device, 0, tmp, FALSE);
wined3d_resource_set_parent(wined3d_surface_get_resource(tmp), src_impl);
src_impl->wined3d_surface = tmp;
wined3d_resource_set_parent(wined3d_texture_get_resource(texture),
wined3d_texture_get_parent(src_impl->wined3d_texture));
src_impl->wined3d_texture = texture;
if (flags)
{
static UINT once;
if (!once++)
FIXME("Ignoring flags %#x.\n", flags);
else
WARN("Ignoring flags %#x.\n", flags);
}
if (dst_impl->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(dst_impl, NULL, FALSE); hr = ddraw_surface_update_frontbuffer(dst_impl, NULL, FALSE);
else
hr = DD_OK;
wined3d_mutex_unlock(); wined3d_mutex_unlock();
......
...@@ -328,6 +328,11 @@ void * CDECL wined3d_resource_get_parent(const struct wined3d_resource *resource ...@@ -328,6 +328,11 @@ void * CDECL wined3d_resource_get_parent(const struct wined3d_resource *resource
return resource->parent; return resource->parent;
} }
void CDECL wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent)
{
resource->parent = parent;
}
void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc) void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, struct wined3d_resource_desc *desc)
{ {
desc->resource_type = resource->type; desc->resource_type = resource->type;
......
...@@ -3414,29 +3414,6 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc) ...@@ -3414,29 +3414,6 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
return WINED3D_OK; return WINED3D_OK;
} }
HRESULT CDECL wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags)
{
TRACE("surface %p, override %p, flags %#x.\n", surface, override, flags);
if (flags)
{
static UINT once;
if (!once++)
FIXME("Ignoring flags %#x.\n", flags);
else
WARN("Ignoring flags %#x.\n", flags);
}
if (surface->swapchain)
{
ERR("Not supported on swapchain surfaces.\n");
return WINEDDERR_NOTFLIPPABLE;
}
flip_surface(surface, override);
return WINED3D_OK;
}
static void read_from_framebuffer(struct wined3d_surface *surface) static void read_from_framebuffer(struct wined3d_surface *surface)
{ {
struct wined3d_device *device = surface->resource.device; struct wined3d_device *device = surface->resource.device;
......
...@@ -176,6 +176,7 @@ ...@@ -176,6 +176,7 @@
@ cdecl wined3d_resource_get_desc(ptr ptr) @ cdecl wined3d_resource_get_desc(ptr ptr)
@ cdecl wined3d_resource_get_parent(ptr) @ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_resource_get_private_data(ptr ptr ptr ptr) @ cdecl wined3d_resource_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_resource_set_parent(ptr ptr)
@ cdecl wined3d_resource_set_private_data(ptr ptr ptr long long) @ cdecl wined3d_resource_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr) @ cdecl wined3d_rendertarget_view_create(ptr ptr ptr)
...@@ -206,7 +207,6 @@ ...@@ -206,7 +207,6 @@
@ cdecl wined3d_surface_blt(ptr ptr ptr ptr long ptr long) @ cdecl wined3d_surface_blt(ptr ptr ptr ptr long ptr long)
@ cdecl wined3d_surface_decref(ptr) @ cdecl wined3d_surface_decref(ptr)
@ cdecl wined3d_surface_flip(ptr ptr long)
@ cdecl wined3d_surface_from_resource(ptr) @ cdecl wined3d_surface_from_resource(ptr)
@ cdecl wined3d_surface_get_blt_status(ptr long) @ cdecl wined3d_surface_get_blt_status(ptr long)
@ cdecl wined3d_surface_get_flip_status(ptr long) @ cdecl wined3d_surface_get_flip_status(ptr long)
......
...@@ -2261,6 +2261,7 @@ void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource, ...@@ -2261,6 +2261,7 @@ void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource); void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
HRESULT __cdecl wined3d_resource_get_private_data(const struct wined3d_resource *resource, HRESULT __cdecl wined3d_resource_get_private_data(const struct wined3d_resource *resource,
REFGUID guid, void *data, DWORD *data_size); REFGUID guid, void *data, DWORD *data_size);
void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent);
HRESULT __cdecl wined3d_resource_set_private_data(struct wined3d_resource *resource, HRESULT __cdecl wined3d_resource_set_private_data(struct wined3d_resource *resource,
REFGUID guid, const void *data, DWORD data_size, DWORD flags); REFGUID guid, const void *data, DWORD data_size, DWORD flags);
...@@ -2304,7 +2305,6 @@ HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const R ...@@ -2304,7 +2305,6 @@ HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const R
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const WINEDDBLTFX *blt_fx, enum wined3d_texture_filter_type filter); const WINEDDBLTFX *blt_fx, enum wined3d_texture_filter_type filter);
ULONG __cdecl wined3d_surface_decref(struct wined3d_surface *surface); ULONG __cdecl wined3d_surface_decref(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags);
struct wined3d_surface * __cdecl wined3d_surface_from_resource(struct wined3d_resource *resource); struct wined3d_surface * __cdecl wined3d_surface_from_resource(struct wined3d_resource *resource);
HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags); HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags);
HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags); HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags);
......
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