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

d3drm: Get rid of the IDirect3DRMLightArrayImpl typedef.

parent 7320f3b8
...@@ -72,12 +72,13 @@ typedef struct { ...@@ -72,12 +72,13 @@ typedef struct {
IDirect3DRMVisual **visuals; IDirect3DRMVisual **visuals;
} IDirect3DRMVisualArrayImpl; } IDirect3DRMVisualArrayImpl;
typedef struct { struct d3drm_light_array
{
IDirect3DRMLightArray IDirect3DRMLightArray_iface; IDirect3DRMLightArray IDirect3DRMLightArray_iface;
LONG ref; LONG ref;
ULONG size; ULONG size;
IDirect3DRMLight **lights; IDirect3DRMLight **lights;
} IDirect3DRMLightArrayImpl; };
static inline IDirect3DRMFrameImpl *impl_from_IDirect3DRMFrame2(IDirect3DRMFrame2 *iface) static inline IDirect3DRMFrameImpl *impl_from_IDirect3DRMFrame2(IDirect3DRMFrame2 *iface)
{ {
...@@ -91,9 +92,9 @@ static inline IDirect3DRMFrameImpl *impl_from_IDirect3DRMFrame3(IDirect3DRMFrame ...@@ -91,9 +92,9 @@ static inline IDirect3DRMFrameImpl *impl_from_IDirect3DRMFrame3(IDirect3DRMFrame
static inline IDirect3DRMFrameImpl *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface); static inline IDirect3DRMFrameImpl *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface);
static inline IDirect3DRMLightArrayImpl *impl_from_IDirect3DRMLightArray(IDirect3DRMLightArray *iface) static inline struct d3drm_light_array *impl_from_IDirect3DRMLightArray(IDirect3DRMLightArray *iface)
{ {
return CONTAINING_RECORD(iface, IDirect3DRMLightArrayImpl, IDirect3DRMLightArray_iface); return CONTAINING_RECORD(iface, struct d3drm_light_array, IDirect3DRMLightArray_iface);
} }
/*** IUnknown methods ***/ /*** IUnknown methods ***/
...@@ -328,122 +329,106 @@ static HRESULT Direct3DRMVisualArray_create(IDirect3DRMVisualArray** ret_iface) ...@@ -328,122 +329,106 @@ static HRESULT Direct3DRMVisualArray_create(IDirect3DRMVisualArray** ret_iface)
return S_OK; return S_OK;
} }
/*** IUnknown methods ***/ static HRESULT WINAPI d3drm_light_array_QueryInterface(IDirect3DRMLightArray *iface, REFIID riid, void **out)
static HRESULT WINAPI IDirect3DRMLightArrayImpl_QueryInterface(IDirect3DRMLightArray* iface,
REFIID riid, void** object)
{ {
IDirect3DRMLightArrayImpl *This = impl_from_IDirect3DRMLightArray(iface); TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
TRACE("(%p/%p)->(%s, %p)\n", iface, This, debugstr_guid(riid), object);
*object = NULL;
if (IsEqualGUID(riid, &IID_IUnknown) || if (IsEqualGUID(riid, &IID_IDirect3DRMLightArray)
IsEqualGUID(riid, &IID_IDirect3DRMLightArray)) || IsEqualGUID(riid, &IID_IUnknown))
{
*object = &This->IDirect3DRMLightArray_iface;
}
else
{ {
FIXME("interface %s not implemented\n", debugstr_guid(riid)); IDirect3DRMLightArray_AddRef(iface);
return E_NOINTERFACE; *out = iface;
return S_OK;
} }
IDirect3DRMLightArray_AddRef(iface); WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
return S_OK;
*out = NULL;
return E_NOINTERFACE;
} }
static ULONG WINAPI IDirect3DRMLightArrayImpl_AddRef(IDirect3DRMLightArray* iface) static ULONG WINAPI d3drm_light_array_AddRef(IDirect3DRMLightArray *iface)
{ {
IDirect3DRMLightArrayImpl *This = impl_from_IDirect3DRMLightArray(iface); struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
ULONG ref = InterlockedIncrement(&This->ref); ULONG refcount = InterlockedIncrement(&array->ref);
TRACE("(%p)->(): new ref = %u\n", This, ref); TRACE("%p increasing refcount to %u.\n", iface, refcount);
return ref; return refcount;
} }
static ULONG WINAPI IDirect3DRMLightArrayImpl_Release(IDirect3DRMLightArray* iface) static ULONG WINAPI d3drm_light_array_Release(IDirect3DRMLightArray *iface)
{ {
IDirect3DRMLightArrayImpl *This = impl_from_IDirect3DRMLightArray(iface); struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
ULONG ref = InterlockedDecrement(&This->ref); ULONG refcount = InterlockedDecrement(&array->ref);
ULONG i; ULONG i;
TRACE("(%p)->(): new ref = %u\n", This, ref); TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!ref) if (!refcount)
{ {
for (i = 0; i < This->size; i++) for (i = 0; i < array->size; ++i)
IDirect3DRMLight_Release(This->lights[i]); {
HeapFree(GetProcessHeap(), 0, This->lights); IDirect3DRMLight_Release(array->lights[i]);
HeapFree(GetProcessHeap(), 0, This); }
HeapFree(GetProcessHeap(), 0, array->lights);
HeapFree(GetProcessHeap(), 0, array);
} }
return ref; return refcount;
} }
/*** IDirect3DRMArray methods ***/ static DWORD WINAPI d3drm_light_array_GetSize(IDirect3DRMLightArray *iface)
static DWORD WINAPI IDirect3DRMLightArrayImpl_GetSize(IDirect3DRMLightArray* iface)
{ {
IDirect3DRMLightArrayImpl *This = impl_from_IDirect3DRMLightArray(iface); struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
TRACE("(%p)->() = %d\n", This, This->size); TRACE("iface %p.\n", iface);
return This->size; return array->size;
} }
/*** IDirect3DRMLightArray methods ***/ static HRESULT WINAPI d3drm_light_array_GetElement(IDirect3DRMLightArray *iface,
static HRESULT WINAPI IDirect3DRMLightArrayImpl_GetElement(IDirect3DRMLightArray *iface,
DWORD index, IDirect3DRMLight **light) DWORD index, IDirect3DRMLight **light)
{ {
IDirect3DRMLightArrayImpl *This = impl_from_IDirect3DRMLightArray(iface); struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
TRACE("(%p)->(%u, %p)\n", This, index, light); TRACE("iface %p, index %u, light %p.\n", iface, index, light);
if (!light) if (!light)
return D3DRMERR_BADVALUE; return D3DRMERR_BADVALUE;
*light = NULL; if (index >= array->size)
{
if (index >= This->size) *light = NULL;
return D3DRMERR_BADVALUE; return D3DRMERR_BADVALUE;
}
IDirect3DRMLight_AddRef(This->lights[index]); IDirect3DRMLight_AddRef(array->lights[index]);
*light = This->lights[index]; *light = array->lights[index];
return D3DRM_OK; return D3DRM_OK;
} }
static const struct IDirect3DRMLightArrayVtbl Direct3DRMLightArray_Vtbl = static const struct IDirect3DRMLightArrayVtbl d3drm_light_array_vtbl =
{ {
/*** IUnknown methods ***/ d3drm_light_array_QueryInterface,
IDirect3DRMLightArrayImpl_QueryInterface, d3drm_light_array_AddRef,
IDirect3DRMLightArrayImpl_AddRef, d3drm_light_array_Release,
IDirect3DRMLightArrayImpl_Release, d3drm_light_array_GetSize,
/*** IDirect3DRMArray methods ***/ d3drm_light_array_GetElement,
IDirect3DRMLightArrayImpl_GetSize,
/*** IDirect3DRMLightArray methods ***/
IDirect3DRMLightArrayImpl_GetElement
}; };
static HRESULT Direct3DRMLightArray_create(IDirect3DRMLightArray** obj) static struct d3drm_light_array *d3drm_light_array_create(void)
{ {
IDirect3DRMLightArrayImpl* object; struct d3drm_light_array *array;
TRACE("(%p)\n", obj);
*obj = NULL;
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DRMLightArrayImpl));
if (!object)
return E_OUTOFMEMORY;
object->IDirect3DRMLightArray_iface.lpVtbl = &Direct3DRMLightArray_Vtbl; if (!(array = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*array))))
object->ref = 1; return NULL;
*obj = &object->IDirect3DRMLightArray_iface; array->IDirect3DRMLightArray_iface.lpVtbl = &d3drm_light_array_vtbl;
array->ref = 1;
return S_OK; return array;
} }
/*** IUnknown methods ***/ /*** IUnknown methods ***/
...@@ -1678,32 +1663,32 @@ static D3DCOLOR WINAPI IDirect3DRMFrame3Impl_GetColor(IDirect3DRMFrame3* iface) ...@@ -1678,32 +1663,32 @@ static D3DCOLOR WINAPI IDirect3DRMFrame3Impl_GetColor(IDirect3DRMFrame3* iface)
static HRESULT WINAPI IDirect3DRMFrame3Impl_GetLights(IDirect3DRMFrame3 *iface, IDirect3DRMLightArray **lights) static HRESULT WINAPI IDirect3DRMFrame3Impl_GetLights(IDirect3DRMFrame3 *iface, IDirect3DRMLightArray **lights)
{ {
IDirect3DRMFrameImpl *This = impl_from_IDirect3DRMFrame3(iface); IDirect3DRMFrameImpl *frame = impl_from_IDirect3DRMFrame3(iface);
IDirect3DRMLightArrayImpl* obj; struct d3drm_light_array *array;
HRESULT hr;
TRACE("(%p/%p)->(%p)\n", iface, This, lights); TRACE("iface %p, lights %p.\n", iface, lights);
if (!lights) if (!lights)
return D3DRMERR_BADVALUE; return D3DRMERR_BADVALUE;
hr = Direct3DRMLightArray_create(lights); if (!(array = d3drm_light_array_create()))
return E_OUTOFMEMORY;
if (hr != D3DRM_OK)
return hr;
obj = (IDirect3DRMLightArrayImpl*)*lights;
obj->size = This->nb_lights; array->size = frame->nb_lights;
if (This->nb_lights) if (frame->nb_lights)
{ {
ULONG i; ULONG i;
if (!(obj->lights = HeapAlloc(GetProcessHeap(), 0, This->nb_lights * sizeof(*obj->lights))))
if (!(array->lights = HeapAlloc(GetProcessHeap(), 0, frame->nb_lights * sizeof(*array->lights))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
for (i = 0; i < This->nb_lights; i++) for (i = 0; i < frame->nb_lights; ++i)
IDirect3DRMLight_QueryInterface(This->lights[i], &IID_IDirect3DRMLight, (void**)&obj->lights[i]); {
IDirect3DRMLight_QueryInterface(frame->lights[i], &IID_IDirect3DRMLight, (void **)&array->lights[i]);
}
} }
*lights = &array->IDirect3DRMLightArray_iface;
return D3DRM_OK; return D3DRM_OK;
} }
......
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