ReactOS  0.4.14-dev-49-gfb4591c
d3drm_main.c File Reference
#include "config.h"
#include "wine/port.h"
#include "initguid.h"
#include "d3drm_private.h"
Include dependency graph for d3drm_main.c:

Go to the source code of this file.

Classes

struct  destroy_callback
 

Functions

BOOL WINAPI DllMain (HINSTANCE inst, DWORD reason, void *reserved)
 
void d3drm_object_init (struct d3drm_object *object, const char *classname)
 
HRESULT d3drm_object_add_destroy_callback (struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
 
HRESULT d3drm_object_delete_destroy_callback (struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx)
 
HRESULT d3drm_object_get_class_name (struct d3drm_object *object, DWORD *size, char *name)
 
HRESULT d3drm_object_get_name (struct d3drm_object *object, DWORD *size, char *name)
 
HRESULT d3drm_object_set_name (struct d3drm_object *object, const char *name)
 
void d3drm_object_cleanup (IDirect3DRMObject *iface, struct d3drm_object *object)
 

Function Documentation

◆ d3drm_object_add_destroy_callback()

HRESULT d3drm_object_add_destroy_callback ( struct d3drm_object object,
D3DRMOBJECTCALLBACK  cb,
void ctx 
)

Definition at line 58 of file d3drm_main.c.

59 {
60  struct destroy_callback *callback;
61 
62  if (!cb)
63  return D3DRMERR_BADVALUE;
64 
65  if (!(callback = heap_alloc(sizeof(*callback))))
66  return E_OUTOFMEMORY;
67 
68  callback->cb = cb;
69  callback->ctx = ctx;
70 
71  list_add_head(&object->destroy_callbacks, &callback->entry);
72  return D3DRM_OK;
73 }
__WINE_SERVER_LIST_INLINE void list_add_head(struct list *list, struct list *elem)
Definition: list.h:96
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define D3DRM_OK
Definition: d3drm.h:486
static DWORD cb
Definition: integrity.c:41
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496

Referenced by d3drm_animation2_AddDestroyCallback(), d3drm_device3_AddDestroyCallback(), d3drm_face2_AddDestroyCallback(), d3drm_frame3_AddDestroyCallback(), d3drm_light_AddDestroyCallback(), d3drm_material_AddDestroyCallback(), d3drm_mesh_AddDestroyCallback(), d3drm_mesh_builder3_AddDestroyCallback(), d3drm_texture3_AddDestroyCallback(), d3drm_viewport2_AddDestroyCallback(), and d3drm_wrap_AddDestroyCallback().

◆ d3drm_object_cleanup()

void d3drm_object_cleanup ( IDirect3DRMObject *  iface,
struct d3drm_object object 
)

Definition at line 156 of file d3drm_main.c.

157 {
158  struct destroy_callback *callback, *callback2;
159 
160  LIST_FOR_EACH_ENTRY_SAFE(callback, callback2, &object->destroy_callbacks, struct destroy_callback, entry)
161  {
162  callback->cb(iface, callback->ctx);
163  list_remove(&callback->entry);
165  }
166 
167  heap_free(object->name);
168  object->name = NULL;
169 }
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:204
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by d3drm_animation2_Release(), d3drm_device_destroy(), d3drm_face1_Release(), d3drm_frame3_Release(), d3drm_light_Release(), d3drm_material_Release(), d3drm_mesh_builder2_Release(), d3drm_mesh_Release(), d3drm_texture_destroy(), d3drm_viewport_destroy(), and d3drm_wrap_Release().

◆ d3drm_object_delete_destroy_callback()

HRESULT d3drm_object_delete_destroy_callback ( struct d3drm_object object,
D3DRMOBJECTCALLBACK  cb,
void ctx 
)

Definition at line 75 of file d3drm_main.c.

76 {
77  struct destroy_callback *callback;
78 
79  if (!cb)
80  return D3DRMERR_BADVALUE;
81 
82  LIST_FOR_EACH_ENTRY(callback, &object->destroy_callbacks, struct destroy_callback, entry)
83  {
84  if (callback->cb == cb && callback->ctx == ctx)
85  {
86  list_remove(&callback->entry);
88  break;
89  }
90  }
91 
92  return D3DRM_OK;
93 }
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:198
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
Definition: list.h:108
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define D3DRM_OK
Definition: d3drm.h:486
static DWORD cb
Definition: integrity.c:41
#define D3DRMERR_BADVALUE
Definition: d3drm.h:496
uint32_t entry
Definition: isohybrid.c:63
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by d3drm_animation2_DeleteDestroyCallback(), d3drm_device3_DeleteDestroyCallback(), d3drm_face2_DeleteDestroyCallback(), d3drm_frame3_DeleteDestroyCallback(), d3drm_light_DeleteDestroyCallback(), d3drm_material_DeleteDestroyCallback(), d3drm_mesh_builder3_DeleteDestroyCallback(), d3drm_mesh_DeleteDestroyCallback(), d3drm_texture3_DeleteDestroyCallback(), d3drm_viewport2_DeleteDestroyCallback(), and d3drm_wrap_DeleteDestroyCallback().

◆ d3drm_object_get_class_name()

HRESULT d3drm_object_get_class_name ( struct d3drm_object object,
DWORD size,
char name 
)

Definition at line 95 of file d3drm_main.c.

96 {
97  DWORD req_size;
98 
99  if (!size)
100  return E_INVALIDARG;
101 
102  req_size = strlen(object->classname) + 1;
103  if (name && *size < req_size)
104  return E_INVALIDARG;
105 
106  *size = req_size;
107 
108  if (name)
109  memcpy(name, object->classname, req_size);
110 
111  return D3DRM_OK;
112 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define E_INVALIDARG
Definition: ddrawi.h:101
GLsizeiptr size
Definition: glext.h:5919
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: name.c:36

Referenced by d3drm_animation2_GetClassName(), d3drm_device3_GetClassName(), d3drm_face2_GetClassName(), d3drm_frame3_GetClassName(), d3drm_light_GetClassName(), d3drm_material_GetClassName(), d3drm_mesh_builder3_GetClassName(), d3drm_mesh_GetClassName(), d3drm_texture3_GetClassName(), d3drm_viewport2_GetClassName(), and d3drm_wrap_GetClassName().

◆ d3drm_object_get_name()

HRESULT d3drm_object_get_name ( struct d3drm_object object,
DWORD size,
char name 
)

Definition at line 114 of file d3drm_main.c.

115 {
116  DWORD req_size;
117 
118  if (!size)
119  return E_INVALIDARG;
120 
121  req_size = object->name ? strlen(object->name) + 1 : 0;
122  if (name && *size < req_size)
123  return E_INVALIDARG;
124 
125  if (name)
126  {
127  if (object->name)
128  memcpy(name, object->name, req_size);
129  else if (*size)
130  *name = 0;
131  }
132 
133  *size = req_size;
134 
135  return D3DRM_OK;
136 }
char * name
Definition: wpp.c:36
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define E_INVALIDARG
Definition: ddrawi.h:101
GLsizeiptr size
Definition: glext.h:5919
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: name.c:36

Referenced by d3drm_animation2_GetName(), d3drm_device3_GetName(), d3drm_face2_GetName(), d3drm_frame3_GetName(), d3drm_light_GetName(), d3drm_material_GetName(), d3drm_mesh_builder3_GetName(), d3drm_mesh_GetName(), d3drm_texture3_GetName(), d3drm_viewport2_GetName(), and d3drm_wrap_GetName().

◆ d3drm_object_init()

void d3drm_object_init ( struct d3drm_object object,
const char classname 
)

Definition at line 42 of file d3drm_main.c.

43 {
44  object->ref = 1;
45  object->appdata = 0;
46  list_init(&object->destroy_callbacks);
47  object->classname = classname;
48  object->name = NULL;
49 }
WCHAR classname[128]
Definition: startup.c:15
smooth NULL
Definition: ftsmooth.c:416
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
Definition: list.h:149

Referenced by d3drm_animation_create(), d3drm_device_create(), d3drm_face_create(), d3drm_frame_create(), d3drm_light_create(), d3drm_material_create(), d3drm_mesh_builder_create(), d3drm_mesh_create(), d3drm_texture_create(), d3drm_viewport_create(), and d3drm_wrap_create().

◆ d3drm_object_set_name()

HRESULT d3drm_object_set_name ( struct d3drm_object object,
const char name 
)

Definition at line 138 of file d3drm_main.c.

139 {
140  DWORD req_size;
141 
142  heap_free(object->name);
143  object->name = NULL;
144 
145  if (name)
146  {
147  req_size = strlen(name) + 1;
148  if (!(object->name = heap_alloc(req_size)))
149  return E_OUTOFMEMORY;
150  memcpy(object->name, name, req_size);
151  }
152 
153  return D3DRM_OK;
154 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
#define D3DRM_OK
Definition: d3drm.h:486
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: name.c:36
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by d3drm_animation2_SetName(), d3drm_device3_SetName(), d3drm_face2_SetName(), d3drm_frame3_SetName(), d3drm_light_SetName(), d3drm_material_SetName(), d3drm_mesh_builder3_SetName(), d3drm_mesh_SetName(), d3drm_texture3_SetName(), d3drm_viewport2_SetName(), and d3drm_wrap_SetName().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  inst,
DWORD  reason,
void reserved 
)

Definition at line 29 of file d3drm_main.c.

30 {
31  switch(reason)
32  {
33  case DLL_WINE_PREATTACH:
34  return FALSE; /* prefer native version */
35  case DLL_PROCESS_ATTACH:
37  break;
38  }
39  return TRUE;
40 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904