Module: wine Branch: master Commit: 06a44abc19b748b3cb4111e4696d6139247105e2 URL: http://source.winehq.org/git/wine.git/?a=commit;h=06a44abc19b748b3cb4111e469...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Aug 17 19:03:23 2010 +0200
ddraw: Remove useless light callbacks.
---
dlls/ddraw/ddraw.c | 5 -- dlls/ddraw/ddraw_private.h | 10 +--- dlls/ddraw/light.c | 137 +++++++++++++++++++++---------------------- dlls/ddraw/viewport.c | 15 +++-- 4 files changed, 77 insertions(+), 90 deletions(-)
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index 4921519..ff44960 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4397,11 +4397,6 @@ static HRESULT WINAPI d3d3_CreateLight(IDirect3D3 *iface, IDirect3DLight **light object->ref = 1; object->ddraw = ddraw_from_d3d3(iface);
- /* Update functions */ - object->activate = light_update; - object->desactivate = light_activate; - object->update = light_desactivate; - TRACE("Created light %p.\n", object); *light = (IDirect3DLight *)object;
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h index 9ff703d..220d1bb 100644 --- a/dlls/ddraw/ddraw_private.h +++ b/dlls/ddraw/ddraw_private.h @@ -525,20 +525,14 @@ struct IDirect3DLightImpl
/* Chained list used for adding / removing from viewports */ IDirect3DLightImpl *next; - - /* Activation function */ - void (*activate)(IDirect3DLightImpl*); - void (*desactivate)(IDirect3DLightImpl*); - void (*update)(IDirect3DLightImpl*); };
/* Vtable */ extern const IDirect3DLightVtbl IDirect3DLight_Vtbl DECLSPEC_HIDDEN;
/* Helper functions */ -void light_update(IDirect3DLightImpl *This) DECLSPEC_HIDDEN; -void light_activate(IDirect3DLightImpl *This) DECLSPEC_HIDDEN; -void light_desactivate(IDirect3DLightImpl *This) DECLSPEC_HIDDEN; +void light_activate(IDirect3DLightImpl *light) DECLSPEC_HIDDEN; +void light_deactivate(IDirect3DLightImpl *light) DECLSPEC_HIDDEN;
/****************************************************************************** * IDirect3DMaterial implementation structure - Wraps to D3D7 diff --git a/dlls/ddraw/light.c b/dlls/ddraw/light.c index 030dcf0..dd41ffe 100644 --- a/dlls/ddraw/light.c +++ b/dlls/ddraw/light.c @@ -44,6 +44,71 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d7);
/***************************************************************************** + * light_update + * + * Updates the Direct3DDevice7 lighting parameters + * + *****************************************************************************/ +static void light_update(IDirect3DLightImpl *light) +{ + IDirect3DDeviceImpl *device; + + TRACE("light %p.\n", light); + + if (!light->active_viewport || !light->active_viewport->active_device) return; + device = light->active_viewport->active_device; + + IDirect3DDevice7_SetLight((IDirect3DDevice7 *)device, light->dwLightIndex, &light->light7); +} + +/***************************************************************************** + * light_activate + * + * Uses the Direct3DDevice7::LightEnable method to active the light + * + *****************************************************************************/ +void light_activate(IDirect3DLightImpl *light) +{ + IDirect3DDeviceImpl *device; + + TRACE("light %p.\n", light); + + if (!light->active_viewport || !light->active_viewport->active_device) return; + device = light->active_viewport->active_device; + + light_update(light); + if (!(light->light.dwFlags & D3DLIGHT_ACTIVE)) + { + IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, light->dwLightIndex, TRUE); + light->light.dwFlags |= D3DLIGHT_ACTIVE; + } +} + +/***************************************************************************** + * + * light_deactivate + * + * Uses the Direct3DDevice7::LightEnable method to deactivate the light + * + *****************************************************************************/ +void light_deactivate(IDirect3DLightImpl *light) +{ + IDirect3DDeviceImpl *device; + + TRACE("light %p.\n", light); + + if (!light->active_viewport || !light->active_viewport->active_device) return; + device = light->active_viewport->active_device; + + /* If was not active, activate it */ + if (light->light.dwFlags & D3DLIGHT_ACTIVE) + { + IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, light->dwLightIndex, FALSE); + light->light.dwFlags &= ~D3DLIGHT_ACTIVE; + } +} + +/***************************************************************************** * IUnknown Methods. *****************************************************************************/
@@ -203,9 +268,8 @@ IDirect3DLightImpl_SetLight(IDirect3DLight *iface,
EnterCriticalSection(&ddraw_cs); memcpy(&This->light, lpLight, lpLight->dwSize); - if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) { - This->update(This); - } + if (This->light.dwFlags & D3DLIGHT_ACTIVE) + light_update(This); LeaveCriticalSection(&ddraw_cs); return D3D_OK; } @@ -240,73 +304,6 @@ IDirect3DLightImpl_GetLight(IDirect3DLight *iface, return DD_OK; }
-/***************************************************************************** - * light_update - * - * Updates the Direct3DDevice7 lighting parameters - * - *****************************************************************************/ -void light_update(IDirect3DLightImpl* This) -{ - IDirect3DDeviceImpl* device; - - TRACE("(%p)\n", This); - - if (!This->active_viewport || !This->active_viewport->active_device) - return; - device = This->active_viewport->active_device; - - IDirect3DDevice7_SetLight((IDirect3DDevice7 *)device, This->dwLightIndex, &(This->light7)); -} - -/***************************************************************************** - * light_activate - * - * Uses the Direct3DDevice7::LightEnable method to active the light - * - *****************************************************************************/ -void light_activate(IDirect3DLightImpl* This) -{ - IDirect3DDeviceImpl* device; - - TRACE("(%p)\n", This); - - if (!This->active_viewport || !This->active_viewport->active_device) - return; - device = This->active_viewport->active_device; - - light_update(This); - /* If was not active, activate it */ - if ((This->light.dwFlags & D3DLIGHT_ACTIVE) == 0) { - IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, This->dwLightIndex, TRUE); - This->light.dwFlags |= D3DLIGHT_ACTIVE; - } -} - -/***************************************************************************** - * - * light_desactivate - * - * Uses the Direct3DDevice7::LightEnable method to deactivate the light - * - *****************************************************************************/ -void light_desactivate(IDirect3DLightImpl* This) -{ - IDirect3DDeviceImpl* device; - - TRACE("(%p)\n", This); - - if (!This->active_viewport || !This->active_viewport->active_device) - return; - device = This->active_viewport->active_device; - - /* If was not active, activate it */ - if ((This->light.dwFlags & D3DLIGHT_ACTIVE) != 0) { - IDirect3DDevice7_LightEnable((IDirect3DDevice7 *)device, This->dwLightIndex, FALSE); - This->light.dwFlags &= ~D3DLIGHT_ACTIVE; - } -} - const IDirect3DLightVtbl IDirect3DLight_Vtbl = { /*** IUnknown Methods ***/ diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c index 5e17bd0..01319f5 100644 --- a/dlls/ddraw/viewport.c +++ b/dlls/ddraw/viewport.c @@ -62,8 +62,9 @@ void viewport_activate(IDirect3DViewportImpl* This, BOOL ignore_lights) { /* Activate all the lights associated with this context */ light = This->lights;
- while (light != NULL) { - light->activate(light); + while (light) + { + light_activate(light); light = light->next; } } @@ -762,9 +763,8 @@ IDirect3DViewportImpl_AddLight(IDirect3DViewport3 *iface, lpDirect3DLightImpl->active_viewport = This;
/* If active, activate the light */ - if (This->active_device != NULL) { - lpDirect3DLightImpl->activate(lpDirect3DLightImpl); - } + if (This->active_device) + light_activate(lpDirect3DLightImpl);
LeaveCriticalSection(&ddraw_cs); return D3D_OK; @@ -796,8 +796,9 @@ IDirect3DViewportImpl_DeleteLight(IDirect3DViewport3 *iface, EnterCriticalSection(&ddraw_cs); cur_light = This->lights; while (cur_light != NULL) { - if (cur_light == lpDirect3DLightImpl) { - lpDirect3DLightImpl->desactivate(lpDirect3DLightImpl); + if (cur_light == lpDirect3DLightImpl) + { + light_deactivate(lpDirect3DLightImpl); if (prev_light == NULL) This->lights = cur_light->next; else prev_light->next = cur_light->next; /* Detach the light to the viewport */