krnl386.exe16: Emulate 'mov Eb, Gb' instruction on x86 processor architecture.
[wine.git] / dlls / d3drm / d3drm_main.c
blob67d1ad1d972735ab80af9505403cd1263b0df382
1 /*
2 * Copyright 2004 Ivan Leo Puoti
3 * Copyright 2010 Christian Costa
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
21 #include "d3d.h"
23 #include "dxfile.h"
24 #include "initguid.h"
25 #include "d3drm.h"
27 #include "d3drm_private.h"
28 #include "wine/list.h"
30 /***********************************************************************
31 * DllMain (D3DRM.@)
33 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
35 switch(reason)
37 case DLL_WINE_PREATTACH:
38 return FALSE; /* prefer native version */
39 case DLL_PROCESS_ATTACH:
40 DisableThreadLibraryCalls( inst );
41 break;
43 return TRUE;
46 void d3drm_object_init(struct d3drm_object *object)
48 object->ref = 1;
49 object->appdata = 0;
50 list_init(&object->destroy_callbacks);
53 struct destroy_callback
55 struct list entry;
56 D3DRMOBJECTCALLBACK cb;
57 void *ctx;
60 HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
62 struct destroy_callback *callback;
64 if (!cb)
65 return D3DRMERR_BADVALUE;
67 callback = HeapAlloc(GetProcessHeap(), 0, sizeof(*callback));
68 if (!callback)
69 return E_OUTOFMEMORY;
71 callback->cb = cb;
72 callback->ctx = ctx;
74 list_add_head(&object->destroy_callbacks, &callback->entry);
75 return D3DRM_OK;
78 HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
80 struct destroy_callback *callback;
82 if (!cb)
83 return D3DRMERR_BADVALUE;
85 LIST_FOR_EACH_ENTRY(callback, &object->destroy_callbacks, struct destroy_callback, entry)
87 if (callback->cb == cb && callback->ctx == ctx)
89 list_remove(&callback->entry);
90 HeapFree(GetProcessHeap(), 0, callback);
91 break;
95 return D3DRM_OK;
98 void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object)
100 struct destroy_callback *callback, *callback2;
102 LIST_FOR_EACH_ENTRY_SAFE(callback, callback2, &object->destroy_callbacks, struct destroy_callback, entry)
104 callback->cb(iface, callback->ctx);
105 list_remove(&callback->entry);
106 HeapFree(GetProcessHeap(), 0, callback);