ddraw: Replace the viewport list with a standard Wine list.
This commit is contained in:
parent
f1de9ad621
commit
fd1aac3e75
|
@ -290,7 +290,7 @@ struct IDirect3DDeviceImpl
|
||||||
IDirectDrawSurfaceImpl *target;
|
IDirectDrawSurfaceImpl *target;
|
||||||
|
|
||||||
/* Viewport management */
|
/* Viewport management */
|
||||||
IDirect3DViewportImpl *viewport_list;
|
struct list viewport_list;
|
||||||
IDirect3DViewportImpl *current_viewport;
|
IDirect3DViewportImpl *current_viewport;
|
||||||
D3DVIEWPORT7 active_viewport;
|
D3DVIEWPORT7 active_viewport;
|
||||||
|
|
||||||
|
@ -471,8 +471,7 @@ struct IDirect3DViewportImpl
|
||||||
D3DVIEWPORT2 vp2;
|
D3DVIEWPORT2 vp2;
|
||||||
} viewports;
|
} viewports;
|
||||||
|
|
||||||
/* Field used to chain viewports together */
|
struct list entry;
|
||||||
IDirect3DViewportImpl *next;
|
|
||||||
|
|
||||||
/* Lights list */
|
/* Lights list */
|
||||||
IDirect3DLightImpl *lights;
|
IDirect3DLightImpl *lights;
|
||||||
|
|
|
@ -764,8 +764,7 @@ IDirect3DDeviceImpl_3_AddViewport(IDirect3DDevice3 *iface,
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
|
|
||||||
EnterCriticalSection(&ddraw_cs);
|
EnterCriticalSection(&ddraw_cs);
|
||||||
vp->next = This->viewport_list;
|
list_add_head(&This->viewport_list, &vp->entry);
|
||||||
This->viewport_list = vp;
|
|
||||||
vp->active_device = This; /* Viewport must be usable for Clear() after AddViewport,
|
vp->active_device = This; /* Viewport must be usable for Clear() after AddViewport,
|
||||||
so set active_device here. */
|
so set active_device here. */
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
|
@ -811,35 +810,27 @@ static HRESULT WINAPI IDirect3DDeviceImpl_1_AddViewport(IDirect3DDevice *iface,
|
||||||
* DDERR_INVALIDPARAMS if the viewport wasn't found in the list
|
* DDERR_INVALIDPARAMS if the viewport wasn't found in the list
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
static HRESULT WINAPI
|
static HRESULT WINAPI IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface, IDirect3DViewport3 *viewport)
|
||||||
IDirect3DDeviceImpl_3_DeleteViewport(IDirect3DDevice3 *iface,
|
|
||||||
IDirect3DViewport3 *Viewport)
|
|
||||||
{
|
{
|
||||||
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
IDirect3DDeviceImpl *device = device_from_device3(iface);
|
||||||
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *) Viewport;
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)viewport;
|
||||||
IDirect3DViewportImpl *cur_viewport, *prev_viewport = NULL;
|
|
||||||
|
|
||||||
TRACE("iface %p, viewport %p.\n", iface, Viewport);
|
TRACE("iface %p, viewport %p.\n", iface, viewport);
|
||||||
|
|
||||||
EnterCriticalSection(&ddraw_cs);
|
EnterCriticalSection(&ddraw_cs);
|
||||||
cur_viewport = This->viewport_list;
|
|
||||||
while (cur_viewport != NULL)
|
if (vp->active_device != device)
|
||||||
{
|
{
|
||||||
if (cur_viewport == vp)
|
WARN("Viewport %p active device is %p.\n", vp, vp->active_device);
|
||||||
{
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
if (prev_viewport == NULL) This->viewport_list = cur_viewport->next;
|
return DDERR_INVALIDPARAMS;
|
||||||
else prev_viewport->next = cur_viewport->next;
|
|
||||||
vp->active_device = NULL;
|
|
||||||
/* TODO : add desactivate of the viewport and all associated lights... */
|
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
|
||||||
return D3D_OK;
|
|
||||||
}
|
|
||||||
prev_viewport = cur_viewport;
|
|
||||||
cur_viewport = cur_viewport->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vp->active_device = NULL;
|
||||||
|
list_remove(&vp->entry);
|
||||||
|
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
return DDERR_INVALIDPARAMS;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
|
static HRESULT WINAPI IDirect3DDeviceImpl_2_DeleteViewport(IDirect3DDevice2 *iface,
|
||||||
|
@ -890,7 +881,7 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
|
||||||
{
|
{
|
||||||
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
IDirect3DDeviceImpl *This = device_from_device3(iface);
|
||||||
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport3;
|
IDirect3DViewportImpl *vp = (IDirect3DViewportImpl *)Viewport3;
|
||||||
IDirect3DViewportImpl *res = NULL;
|
struct list *entry;
|
||||||
|
|
||||||
TRACE("iface %p, viewport %p, next %p, flags %#x.\n",
|
TRACE("iface %p, viewport %p, next %p, flags %#x.\n",
|
||||||
iface, Viewport3, lplpDirect3DViewport3, Flags);
|
iface, Viewport3, lplpDirect3DViewport3, Flags);
|
||||||
|
@ -906,32 +897,29 @@ IDirect3DDeviceImpl_3_NextViewport(IDirect3DDevice3 *iface,
|
||||||
switch (Flags)
|
switch (Flags)
|
||||||
{
|
{
|
||||||
case D3DNEXT_NEXT:
|
case D3DNEXT_NEXT:
|
||||||
{
|
entry = list_next(&This->viewport_list, &vp->entry);
|
||||||
res = vp->next;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
case D3DNEXT_HEAD:
|
case D3DNEXT_HEAD:
|
||||||
{
|
entry = list_head(&This->viewport_list);
|
||||||
res = This->viewport_list;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
case D3DNEXT_TAIL:
|
case D3DNEXT_TAIL:
|
||||||
{
|
entry = list_tail(&This->viewport_list);
|
||||||
IDirect3DViewportImpl *cur_viewport = This->viewport_list;
|
break;
|
||||||
if (cur_viewport != NULL)
|
|
||||||
{
|
|
||||||
while (cur_viewport->next != NULL) cur_viewport = cur_viewport->next;
|
|
||||||
}
|
|
||||||
res = cur_viewport;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
|
WARN("Invalid flags %#x.\n", Flags);
|
||||||
*lplpDirect3DViewport3 = NULL;
|
*lplpDirect3DViewport3 = NULL;
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
return DDERR_INVALIDPARAMS;
|
return DDERR_INVALIDPARAMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
*lplpDirect3DViewport3 = (IDirect3DViewport3 *)res;
|
if (entry)
|
||||||
|
*lplpDirect3DViewport3 = (IDirect3DViewport3 *)LIST_ENTRY(entry, IDirect3DViewportImpl, entry);
|
||||||
|
else
|
||||||
|
*lplpDirect3DViewport3 = NULL;
|
||||||
|
|
||||||
LeaveCriticalSection(&ddraw_cs);
|
LeaveCriticalSection(&ddraw_cs);
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
@ -6785,6 +6773,7 @@ HRESULT d3d_device_init(IDirect3DDeviceImpl *device, IDirectDrawImpl *ddraw, IDi
|
||||||
device->ref = 1;
|
device->ref = 1;
|
||||||
device->ddraw = ddraw;
|
device->ddraw = ddraw;
|
||||||
device->target = target;
|
device->target = target;
|
||||||
|
list_init(&device->viewport_list);
|
||||||
|
|
||||||
if (!ddraw_handle_table_init(&device->handle_table, 64))
|
if (!ddraw_handle_table_init(&device->handle_table, 64))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue