Commit 0459a327 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3drm: Use existing helper to manage lights array.

parent b3903a13
...@@ -71,8 +71,8 @@ struct d3drm_frame ...@@ -71,8 +71,8 @@ struct d3drm_frame
ULONG nb_visuals; ULONG nb_visuals;
ULONG visuals_capacity; ULONG visuals_capacity;
IDirect3DRMVisual **visuals; IDirect3DRMVisual **visuals;
ULONG nb_lights; SIZE_T nb_lights;
ULONG lights_capacity; SIZE_T lights_size;
IDirect3DRMLight **lights; IDirect3DRMLight **lights;
D3DRMMATRIX4D transform; D3DRMMATRIX4D transform;
D3DCOLOR scenebackground; D3DCOLOR scenebackground;
......
...@@ -875,9 +875,8 @@ static HRESULT WINAPI d3drm_frame1_AddChild(IDirect3DRMFrame *iface, IDirect3DRM ...@@ -875,9 +875,8 @@ static HRESULT WINAPI d3drm_frame1_AddChild(IDirect3DRMFrame *iface, IDirect3DRM
static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DRMLight *light) static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DRMLight *light)
{ {
struct d3drm_frame *This = impl_from_IDirect3DRMFrame3(iface); struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
ULONG i; ULONG i;
IDirect3DRMLight** lights;
TRACE("iface %p, light %p.\n", iface, light); TRACE("iface %p, light %p.\n", iface, light);
...@@ -885,33 +884,15 @@ static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DR ...@@ -885,33 +884,15 @@ static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DR
return D3DRMERR_BADOBJECT; return D3DRMERR_BADOBJECT;
/* Check if already existing and return gracefully without increasing ref count */ /* Check if already existing and return gracefully without increasing ref count */
for (i = 0; i < This->nb_lights; i++) for (i = 0; i < frame->nb_lights; i++)
if (This->lights[i] == light) if (frame->lights[i] == light)
return D3DRM_OK; return D3DRM_OK;
if ((This->nb_lights + 1) > This->lights_capacity) if (!d3drm_array_reserve((void **)&frame->lights, &frame->lights_size,
{ frame->nb_lights + 1, sizeof(*frame->lights)))
ULONG new_capacity;
if (!This->lights_capacity)
{
new_capacity = 16;
lights = HeapAlloc(GetProcessHeap(), 0, new_capacity * sizeof(IDirect3DRMLight*));
}
else
{
new_capacity = This->lights_capacity * 2;
lights = HeapReAlloc(GetProcessHeap(), 0, This->lights, new_capacity * sizeof(IDirect3DRMLight*));
}
if (!lights)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->lights_capacity = new_capacity; frame->lights[frame->nb_lights++] = light;
This->lights = lights;
}
This->lights[This->nb_lights++] = light;
IDirect3DRMLight_AddRef(light); IDirect3DRMLight_AddRef(light);
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