vbscript: Fix memory leak in owned safearray iterator.
[wine.git] / dlls / d3drm / light.c
blob704c11c0869e33eac8231ef499fea955c7b9ff90
1 /*
2 * Implementation of IDirect3DRMLight Interface
4 * Copyright 2012 André Hentschel
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "d3drm_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
25 static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
27 return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
30 static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
32 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
34 if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
35 || IsEqualGUID(riid, &IID_IDirect3DRMObject)
36 || IsEqualGUID(riid, &IID_IUnknown))
38 IDirect3DRMLight_AddRef(iface);
39 *out = iface;
40 return S_OK;
43 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
45 *out = NULL;
46 return E_NOINTERFACE;
49 static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
51 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
52 ULONG refcount = InterlockedIncrement(&light->ref);
54 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
56 return refcount;
59 static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
61 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
62 ULONG refcount = InterlockedDecrement(&light->ref);
64 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
66 if (!refcount)
68 d3drm_object_cleanup((IDirect3DRMObject *)iface, &light->obj);
69 IDirect3DRM_Release(light->d3drm);
70 free(light);
73 return refcount;
76 static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
77 IUnknown *outer, REFIID iid, void **out)
79 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
81 return E_NOTIMPL;
84 static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
85 D3DRMOBJECTCALLBACK cb, void *ctx)
87 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
89 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
91 return d3drm_object_add_destroy_callback(&light->obj, cb, ctx);
94 static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
95 D3DRMOBJECTCALLBACK cb, void *ctx)
97 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
99 TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);
101 return d3drm_object_delete_destroy_callback(&light->obj, cb, ctx);
104 static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
106 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
108 TRACE("iface %p, data %#lx.\n", iface, data);
110 light->obj.appdata = data;
112 return D3DRM_OK;
115 static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
117 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
119 TRACE("iface %p.\n", iface);
121 return light->obj.appdata;
124 static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
126 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
128 TRACE("iface %p, name %s.\n", iface, debugstr_a(name));
130 return d3drm_object_set_name(&light->obj, name);
133 static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
135 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
137 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
139 return d3drm_object_get_name(&light->obj, size, name);
142 static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
144 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
146 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
148 return d3drm_object_get_class_name(&light->obj, size, name);
151 static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
153 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
155 TRACE("iface %p, type %#x.\n", iface, type);
157 light->type = type;
159 return D3DRM_OK;
162 static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
164 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
166 TRACE("iface %p, color 0x%08lx.\n", iface, color);
168 light->color = 0xff000000 | color;
170 return D3DRM_OK;
173 static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
174 D3DVALUE red, D3DVALUE green, D3DVALUE blue)
176 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
178 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
180 d3drm_set_color(&light->color, red, green, blue, 1.0f);
182 return D3DRM_OK;
185 static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
187 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
189 TRACE("iface %p, range %.8e.\n", iface, range);
191 light->range = range;
193 return D3DRM_OK;
196 static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
198 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
200 TRACE("iface %p, umbra %.8e.\n", iface, umbra);
202 light->umbra = umbra;
204 return D3DRM_OK;
207 static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
209 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
211 TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
213 light->penumbra = penumbra;
215 return D3DRM_OK;
218 static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
220 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
222 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
224 light->cattenuation = attenuation;
226 return D3DRM_OK;
229 static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
231 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
233 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
235 light->lattenuation = attenuation;
237 return D3DRM_OK;
240 static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
242 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
244 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
246 light->qattenuation = attenuation;
248 return D3DRM_OK;
251 static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
253 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
255 TRACE("iface %p.\n", iface);
257 return light->range;
260 static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
262 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
264 TRACE("iface %p.\n", light);
266 return light->umbra;
269 static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
271 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
273 TRACE("iface %p.\n", iface);
275 return light->penumbra;
278 static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
280 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
282 TRACE("iface %p.\n", iface);
284 return light->cattenuation;
287 static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
289 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
291 TRACE("iface %p.\n", iface);
293 return light->lattenuation;
296 static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
298 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
300 TRACE("iface %p.\n", iface);
302 return light->qattenuation;
305 static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
307 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
309 TRACE("iface %p.\n", iface);
311 return light->color;
314 static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
316 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
318 TRACE("iface %p.\n", iface);
320 return light->type;
323 static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
325 FIXME("iface %p, frame %p stub!\n", iface, frame);
327 return E_NOTIMPL;
330 static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
332 FIXME("iface %p, frame %p stub!\n", iface, frame);
334 return E_NOTIMPL;
337 static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
339 d3drm_light_QueryInterface,
340 d3drm_light_AddRef,
341 d3drm_light_Release,
342 d3drm_light_Clone,
343 d3drm_light_AddDestroyCallback,
344 d3drm_light_DeleteDestroyCallback,
345 d3drm_light_SetAppData,
346 d3drm_light_GetAppData,
347 d3drm_light_SetName,
348 d3drm_light_GetName,
349 d3drm_light_GetClassName,
350 d3drm_light_SetType,
351 d3drm_light_SetColor,
352 d3drm_light_SetColorRGB,
353 d3drm_light_SetRange,
354 d3drm_light_SetUmbra,
355 d3drm_light_SetPenumbra,
356 d3drm_light_SetConstantAttenuation,
357 d3drm_light_SetLinearAttenuation,
358 d3drm_light_SetQuadraticAttenuation,
359 d3drm_light_GetRange,
360 d3drm_light_GetUmbra,
361 d3drm_light_GetPenumbra,
362 d3drm_light_GetConstantAttenuation,
363 d3drm_light_GetLinearAttenuation,
364 d3drm_light_GetQuadraticAttenuation,
365 d3drm_light_GetColor,
366 d3drm_light_GetType,
367 d3drm_light_SetEnableFrame,
368 d3drm_light_GetEnableFrame,
371 HRESULT d3drm_light_create(struct d3drm_light **light, IDirect3DRM *d3drm)
373 static const char classname[] = "Light";
374 struct d3drm_light *object;
376 TRACE("light %p.\n", light);
378 if (!(object = calloc(1, sizeof(*object))))
379 return E_OUTOFMEMORY;
381 object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
382 object->ref = 1;
383 object->d3drm = d3drm;
384 IDirect3DRM_AddRef(object->d3drm);
386 d3drm_object_init(&object->obj, classname);
388 *light = object;
390 return S_OK;