server: Try to get a read lock if we can't get a write lock.
[wine/multimedia.git] / dlls / d3drm / light.c
blob53accbfaeb30252fedbabf4d72e152eb957e20c5
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 "wine/debug.h"
23 #define COBJMACROS
25 #include "winbase.h"
26 #include "wingdi.h"
28 #include "d3drm_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(d3drm);
32 struct d3drm_light
34 IDirect3DRMLight IDirect3DRMLight_iface;
35 LONG ref;
36 D3DRMLIGHTTYPE type;
37 D3DCOLOR color;
38 D3DVALUE range;
39 D3DVALUE cattenuation;
40 D3DVALUE lattenuation;
41 D3DVALUE qattenuation;
42 D3DVALUE umbra;
43 D3DVALUE penumbra;
46 static inline struct d3drm_light *impl_from_IDirect3DRMLight(IDirect3DRMLight *iface)
48 return CONTAINING_RECORD(iface, struct d3drm_light, IDirect3DRMLight_iface);
51 static HRESULT WINAPI d3drm_light_QueryInterface(IDirect3DRMLight *iface, REFIID riid, void **out)
53 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
55 if (IsEqualGUID(riid, &IID_IDirect3DRMLight)
56 || IsEqualGUID(riid, &IID_IUnknown))
58 IDirect3DRMLight_AddRef(iface);
59 *out = iface;
60 return S_OK;
63 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
65 *out = NULL;
66 return E_NOINTERFACE;
69 static ULONG WINAPI d3drm_light_AddRef(IDirect3DRMLight *iface)
71 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
72 ULONG refcount = InterlockedIncrement(&light->ref);
74 TRACE("%p increasing refcount to %u.\n", iface, refcount);
76 return refcount;
79 static ULONG WINAPI d3drm_light_Release(IDirect3DRMLight *iface)
81 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
82 ULONG refcount = InterlockedDecrement(&light->ref);
84 TRACE("%p decreasing refcount to %u.\n", iface, refcount);
86 if (!refcount)
87 HeapFree(GetProcessHeap(), 0, light);
89 return refcount;
92 static HRESULT WINAPI d3drm_light_Clone(IDirect3DRMLight *iface,
93 IUnknown *outer, REFIID iid, void **out)
95 FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
97 return E_NOTIMPL;
100 static HRESULT WINAPI d3drm_light_AddDestroyCallback(IDirect3DRMLight *iface,
101 D3DRMOBJECTCALLBACK cb, void *ctx)
103 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
105 return E_NOTIMPL;
108 static HRESULT WINAPI d3drm_light_DeleteDestroyCallback(IDirect3DRMLight *iface,
109 D3DRMOBJECTCALLBACK cb, void *ctx)
111 FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
113 return E_NOTIMPL;
116 static HRESULT WINAPI d3drm_light_SetAppData(IDirect3DRMLight *iface, DWORD data)
118 FIXME("iface %p, data %#x stub!\n", iface, data);
120 return E_NOTIMPL;
123 static DWORD WINAPI d3drm_light_GetAppData(IDirect3DRMLight *iface)
125 FIXME("iface %p stub!\n", iface);
127 return 0;
130 static HRESULT WINAPI d3drm_light_SetName(IDirect3DRMLight *iface, const char *name)
132 FIXME("iface %p, name %s stub!\n", iface, debugstr_a(name));
134 return E_NOTIMPL;
137 static HRESULT WINAPI d3drm_light_GetName(IDirect3DRMLight *iface, DWORD *size, char *name)
139 FIXME("iface %p, size %p, name %p stub!\n", iface, size, name);
141 return E_NOTIMPL;
144 static HRESULT WINAPI d3drm_light_GetClassName(IDirect3DRMLight *iface, DWORD *size, char *name)
146 TRACE("iface %p, size %p, name %p.\n", iface, size, name);
148 if (!size || *size < strlen("Light") || !name)
149 return E_INVALIDARG;
151 strcpy(name, "Light");
152 *size = sizeof("Light");
154 return D3DRM_OK;
157 static HRESULT WINAPI d3drm_light_SetType(IDirect3DRMLight *iface, D3DRMLIGHTTYPE type)
159 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
161 TRACE("iface %p, type %#x.\n", iface, type);
163 light->type = type;
165 return D3DRM_OK;
168 static HRESULT WINAPI d3drm_light_SetColor(IDirect3DRMLight *iface, D3DCOLOR color)
170 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
172 TRACE("iface %p, color 0x%08x.\n", iface, color);
174 light->color = color;
176 return D3DRM_OK;
179 static HRESULT WINAPI d3drm_light_SetColorRGB(IDirect3DRMLight *iface,
180 D3DVALUE red, D3DVALUE green, D3DVALUE blue)
182 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
184 TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
186 light->color = RGBA_MAKE((BYTE)(red * 255.0f), (BYTE)(green * 255.0f), (BYTE)(blue * 255.0f), 0xff);
188 return D3DRM_OK;
191 static HRESULT WINAPI d3drm_light_SetRange(IDirect3DRMLight *iface, D3DVALUE range)
193 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
195 TRACE("iface %p, range %.8e.\n", iface, range);
197 light->range = range;
199 return D3DRM_OK;
202 static HRESULT WINAPI d3drm_light_SetUmbra(IDirect3DRMLight *iface, D3DVALUE umbra)
204 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
206 TRACE("iface %p, umbra %.8e.\n", iface, umbra);
208 light->umbra = umbra;
210 return D3DRM_OK;
213 static HRESULT WINAPI d3drm_light_SetPenumbra(IDirect3DRMLight *iface, D3DVALUE penumbra)
215 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
217 TRACE("iface %p, penumbra %.8e.\n", iface, penumbra);
219 light->penumbra = penumbra;
221 return D3DRM_OK;
224 static HRESULT WINAPI d3drm_light_SetConstantAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
226 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
228 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
230 light->cattenuation = attenuation;
232 return D3DRM_OK;
235 static HRESULT WINAPI d3drm_light_SetLinearAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
237 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
239 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
241 light->lattenuation = attenuation;
243 return D3DRM_OK;
246 static HRESULT WINAPI d3drm_light_SetQuadraticAttenuation(IDirect3DRMLight *iface, D3DVALUE attenuation)
248 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
250 TRACE("iface %p, attenuation %.8e.\n", iface, attenuation);
252 light->qattenuation = attenuation;
254 return D3DRM_OK;
257 static D3DVALUE WINAPI d3drm_light_GetRange(IDirect3DRMLight *iface)
259 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
261 TRACE("iface %p.\n", iface);
263 return light->range;
266 static D3DVALUE WINAPI d3drm_light_GetUmbra(IDirect3DRMLight *iface)
268 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
270 TRACE("iface %p.\n", light);
272 return light->umbra;
275 static D3DVALUE WINAPI d3drm_light_GetPenumbra(IDirect3DRMLight *iface)
277 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
279 TRACE("iface %p.\n", iface);
281 return light->penumbra;
284 static D3DVALUE WINAPI d3drm_light_GetConstantAttenuation(IDirect3DRMLight *iface)
286 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
288 TRACE("iface %p.\n", iface);
290 return light->cattenuation;
293 static D3DVALUE WINAPI d3drm_light_GetLinearAttenuation(IDirect3DRMLight *iface)
295 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
297 TRACE("iface %p.\n", iface);
299 return light->lattenuation;
302 static D3DVALUE WINAPI d3drm_light_GetQuadraticAttenuation(IDirect3DRMLight *iface)
304 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
306 TRACE("iface %p.\n", iface);
308 return light->qattenuation;
311 static D3DCOLOR WINAPI d3drm_light_GetColor(IDirect3DRMLight *iface)
313 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
315 TRACE("iface %p.\n", iface);
317 return light->color;
320 static D3DRMLIGHTTYPE WINAPI d3drm_light_GetType(IDirect3DRMLight *iface)
322 struct d3drm_light *light = impl_from_IDirect3DRMLight(iface);
324 TRACE("iface %p.\n", iface);
326 return light->type;
329 static HRESULT WINAPI d3drm_light_SetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame *frame)
331 FIXME("iface %p, frame %p stub!\n", iface, frame);
333 return E_NOTIMPL;
336 static HRESULT WINAPI d3drm_light_GetEnableFrame(IDirect3DRMLight *iface, IDirect3DRMFrame **frame)
338 FIXME("iface %p, frame %p stub!\n", iface, frame);
340 return E_NOTIMPL;
343 static const struct IDirect3DRMLightVtbl d3drm_light_vtbl =
345 d3drm_light_QueryInterface,
346 d3drm_light_AddRef,
347 d3drm_light_Release,
348 d3drm_light_Clone,
349 d3drm_light_AddDestroyCallback,
350 d3drm_light_DeleteDestroyCallback,
351 d3drm_light_SetAppData,
352 d3drm_light_GetAppData,
353 d3drm_light_SetName,
354 d3drm_light_GetName,
355 d3drm_light_GetClassName,
356 d3drm_light_SetType,
357 d3drm_light_SetColor,
358 d3drm_light_SetColorRGB,
359 d3drm_light_SetRange,
360 d3drm_light_SetUmbra,
361 d3drm_light_SetPenumbra,
362 d3drm_light_SetConstantAttenuation,
363 d3drm_light_SetLinearAttenuation,
364 d3drm_light_SetQuadraticAttenuation,
365 d3drm_light_GetRange,
366 d3drm_light_GetUmbra,
367 d3drm_light_GetPenumbra,
368 d3drm_light_GetConstantAttenuation,
369 d3drm_light_GetLinearAttenuation,
370 d3drm_light_GetQuadraticAttenuation,
371 d3drm_light_GetColor,
372 d3drm_light_GetType,
373 d3drm_light_SetEnableFrame,
374 d3drm_light_GetEnableFrame,
377 HRESULT Direct3DRMLight_create(IUnknown **out)
379 struct d3drm_light *object;
381 TRACE("out %p.\n", out);
383 if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
384 return E_OUTOFMEMORY;
386 object->IDirect3DRMLight_iface.lpVtbl = &d3drm_light_vtbl;
387 object->ref = 1;
389 *out = (IUnknown *)&object->IDirect3DRMLight_iface;
391 return S_OK;