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

ddraw: Store the primary surface.

parent 9ea45ac6
......@@ -1974,41 +1974,21 @@ static HRESULT WINAPI ddraw4_TestCooperativeLevel(IDirectDraw4 *iface)
static HRESULT WINAPI ddraw7_GetGDISurface(IDirectDraw7 *iface, IDirectDrawSurface7 **GDISurface)
{
IDirectDrawImpl *This = impl_from_IDirectDraw7(iface);
struct wined3d_surface *wined3d_surface;
IDirectDrawSurface7 *ddsurf;
HRESULT hr;
DDSCAPS2 ddsCaps;
TRACE("iface %p, surface %p.\n", iface, GDISurface);
/* Get the back buffer from the wineD3DDevice and search its
* attached surfaces for the front buffer. */
EnterCriticalSection(&ddraw_cs);
hr = wined3d_device_get_back_buffer(This->wined3d_device,
0, 0, WINED3DBACKBUFFER_TYPE_MONO, &wined3d_surface);
if (FAILED(hr) || !wined3d_surface)
if (!(*GDISurface = &This->primary->IDirectDrawSurface7_iface))
{
ERR("IWineD3DDevice::GetBackBuffer failed\n");
WARN("Primary not created yet.\n");
LeaveCriticalSection(&ddraw_cs);
return DDERR_NOTFOUND;
}
IDirectDrawSurface7_AddRef(*GDISurface);
ddsurf = wined3d_surface_get_parent(wined3d_surface);
wined3d_surface_decref(wined3d_surface);
/* Find the front buffer */
ddsCaps.dwCaps = DDSCAPS_FRONTBUFFER;
hr = IDirectDrawSurface7_GetAttachedSurface(ddsurf,
&ddsCaps,
GDISurface);
if(hr != DD_OK)
{
ERR("IDirectDrawSurface7::GetAttachedSurface failed, hr = %x\n", hr);
}
/* The AddRef is OK this time */
LeaveCriticalSection(&ddraw_cs);
return hr;
return DD_OK;
}
static HRESULT WINAPI ddraw4_GetGDISurface(IDirectDraw4 *iface, IDirectDrawSurface4 **surface)
......@@ -2803,19 +2783,11 @@ static HRESULT ddraw_create_swapchain(IDirectDrawImpl *ddraw, IDirectDrawSurface
WINED3DPRESENT_PARAMETERS presentation_parameters;
IDirectDrawSurfaceImpl *target = surface;
HRESULT hr = WINED3D_OK;
struct list *entry;
/* Search for the primary to use as render target. */
LIST_FOR_EACH(entry, &ddraw->surface_list)
if (ddraw->primary)
{
IDirectDrawSurfaceImpl *primary = LIST_ENTRY(entry, IDirectDrawSurfaceImpl, surface_list_entry);
if ((primary->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER))
== (DDSCAPS_PRIMARYSURFACE | DDSCAPS_FRONTBUFFER))
{
TRACE("Using primary %p as render target.\n", target);
target = primary;
break;
}
TRACE("Using primary %p.\n", ddraw->primary);
target = ddraw->primary;
}
memset(&presentation_parameters, 0, sizeof(presentation_parameters));
......@@ -3251,6 +3223,9 @@ static HRESULT CreateSurface(IDirectDrawImpl *ddraw, DDSURFACEDESC2 *DDSD,
}
}
if (desc2.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
ddraw->primary = object;
/* Create a WineD3DTexture if a texture was requested */
if (desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
{
......
......@@ -88,6 +88,8 @@ struct IDirectDrawImpl
struct wined3d_device *wined3d_device;
BOOL d3d_initialized;
IDirectDrawSurfaceImpl *primary;
/* DirectDraw things, which are not handled by WineD3D */
DWORD cooperative_level;
......
......@@ -5100,6 +5100,9 @@ static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *paren
/* Reduce the ddraw surface count. */
list_remove(&surface->surface_list_entry);
if (surface == surface->ddraw->primary)
surface->ddraw->primary = NULL;
HeapFree(GetProcessHeap(), 0, surface);
}
......
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