Module: wine Branch: master Commit: aee3c0faeb743b6f1b797f508a602fcb622e2e9f URL: http://source.winehq.org/git/wine.git/?a=commit;h=aee3c0faeb743b6f1b797f508a...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Aug 26 09:23:39 2013 +0200
wined3d: Introduce a separate function for cleaning up a wined3d_state structure.
---
dlls/wined3d/stateblock.c | 38 ++++++++++++++++++++++---------------- 1 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index 3685a2e..8abd8e5 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -588,6 +588,27 @@ void state_unbind_resources(struct wined3d_state *state) } }
+static void state_cleanup(struct wined3d_state *state) +{ + unsigned int counter; + + state_unbind_resources(state); + + for (counter = 0; counter < LIGHTMAP_SIZE; ++counter) + { + struct list *e1, *e2; + LIST_FOR_EACH_SAFE(e1, e2, &state->light_map[counter]) + { + struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry); + list_remove(&light->entry); + HeapFree(GetProcessHeap(), 0, light); + } + } + + HeapFree(GetProcessHeap(), 0, state->vs_consts_f); + HeapFree(GetProcessHeap(), 0, state->ps_consts_f); +} + ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock) { ULONG refcount = InterlockedDecrement(&stateblock->ref); @@ -596,24 +617,9 @@ ULONG CDECL wined3d_stateblock_decref(struct wined3d_stateblock *stateblock)
if (!refcount) { - int counter; - - state_unbind_resources(&stateblock->state); - - for (counter = 0; counter < LIGHTMAP_SIZE; ++counter) - { - struct list *e1, *e2; - LIST_FOR_EACH_SAFE(e1, e2, &stateblock->state.light_map[counter]) - { - struct wined3d_light_info *light = LIST_ENTRY(e1, struct wined3d_light_info, entry); - list_remove(&light->entry); - HeapFree(GetProcessHeap(), 0, light); - } - } + state_cleanup(&stateblock->state);
- HeapFree(GetProcessHeap(), 0, stateblock->state.vs_consts_f); HeapFree(GetProcessHeap(), 0, stateblock->changed.vertexShaderConstantsF); - HeapFree(GetProcessHeap(), 0, stateblock->state.ps_consts_f); HeapFree(GetProcessHeap(), 0, stateblock->changed.pixelShaderConstantsF); HeapFree(GetProcessHeap(), 0, stateblock->contained_vs_consts_f); HeapFree(GetProcessHeap(), 0, stateblock->contained_ps_consts_f);