xref: /reactos/dll/directx/wine/d3dx9_36/animation.c (revision fb5d5ecd)
1 /*
2  * Animation Controller operations specific to D3DX9.
3  *
4  * Copyright (C) 2015 Christian Costa
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #include "config.h"
22 #include "wine/port.h"
23 
24 #include "d3dx9_private.h"
25 
26 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
27 
28 struct d3dx9_animation_controller
29 {
30     ID3DXAnimationController ID3DXAnimationController_iface;
31     LONG ref;
32 
33     UINT max_outputs;
34     UINT max_sets;
35     UINT max_tracks;
36     UINT max_events;
37 };
38 
39 static inline struct d3dx9_animation_controller *impl_from_ID3DXAnimationController(ID3DXAnimationController *iface)
40 {
41     return CONTAINING_RECORD(iface, struct d3dx9_animation_controller, ID3DXAnimationController_iface);
42 }
43 
44 static HRESULT WINAPI d3dx9_animation_controller_QueryInterface(ID3DXAnimationController *iface, REFIID riid, void **out)
45 {
46     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
47 
48     if (IsEqualGUID(riid, &IID_IUnknown) ||
49         IsEqualGUID(riid, &IID_ID3DXAnimationController))
50     {
51         iface->lpVtbl->AddRef(iface);
52         *out = iface;
53         return D3D_OK;
54     }
55 
56     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
57     *out = NULL;
58     return E_NOINTERFACE;
59 }
60 
61 static ULONG WINAPI d3dx9_animation_controller_AddRef(ID3DXAnimationController *iface)
62 {
63     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
64     ULONG refcount = InterlockedIncrement(&animation->ref);
65 
66     TRACE("%p increasing refcount to %u.\n", animation, refcount);
67 
68     return refcount;
69 }
70 
71 static ULONG WINAPI d3dx9_animation_controller_Release(ID3DXAnimationController *iface)
72 {
73     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
74     ULONG refcount = InterlockedDecrement(&animation->ref);
75 
76     TRACE("%p decreasing refcount to %u.\n", animation, refcount);
77 
78     if (!refcount)
79     {
80         HeapFree(GetProcessHeap(), 0, animation);
81     }
82 
83     return refcount;
84 }
85 
86 static UINT WINAPI d3dx9_animation_controller_GetMaxNumAnimationOutputs(ID3DXAnimationController *iface)
87 {
88     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
89 
90     TRACE("iface %p.\n", iface);
91 
92     return animation->max_outputs;
93 }
94 
95 static UINT WINAPI d3dx9_animation_controller_GetMaxNumAnimationSets(ID3DXAnimationController *iface)
96 {
97     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
98 
99     TRACE("iface %p.\n", iface);
100 
101     return animation->max_sets;
102 }
103 
104 static UINT WINAPI d3dx9_animation_controller_GetMaxNumTracks(ID3DXAnimationController *iface)
105 {
106     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
107 
108     TRACE("iface %p.\n", iface);
109 
110     return animation->max_tracks;
111 }
112 
113 static UINT WINAPI d3dx9_animation_controller_GetMaxNumEvents(ID3DXAnimationController *iface)
114 {
115     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
116 
117     TRACE("iface %p.\n", iface);
118 
119     return animation->max_events;
120 }
121 
122 static HRESULT WINAPI d3dx9_animation_controller_RegisterAnimationOutput(ID3DXAnimationController *iface,
123         const char *name, D3DXMATRIX *matrix, D3DXVECTOR3 *scale, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation)
124 {
125     FIXME("iface %p, name %s, matrix %p, scale %p, rotation %p, translation %p stub.\n", iface, debugstr_a(name),
126             matrix, scale, rotation, translation);
127 
128     return E_NOTIMPL;
129 }
130 
131 static HRESULT WINAPI d3dx9_animation_controller_RegisterAnimationSet(ID3DXAnimationController *iface,
132         ID3DXAnimationSet *anim_set)
133 {
134     FIXME("iface %p, anim_set %p stub.\n", iface, anim_set);
135 
136     return E_NOTIMPL;
137 }
138 
139 static HRESULT WINAPI d3dx9_animation_controller_UnregisterAnimationSet(ID3DXAnimationController *iface,
140         ID3DXAnimationSet *anim_set)
141 {
142     FIXME("iface %p, anim_set %p stub.\n", iface, anim_set);
143 
144     return E_NOTIMPL;
145 }
146 
147 static UINT WINAPI d3dx9_animation_controller_GetNumAnimationSets(ID3DXAnimationController *iface)
148 {
149     FIXME("iface %p stub.\n", iface);
150 
151     return 0;
152 }
153 
154 static HRESULT WINAPI d3dx9_animation_controller_GetAnimationSet(ID3DXAnimationController *iface,
155         UINT index, ID3DXAnimationSet **anim_set)
156 {
157     FIXME("iface %p, index %u, anim_set %p stub.\n", iface, index, anim_set);
158 
159     return E_NOTIMPL;
160 }
161 
162 static HRESULT WINAPI d3dx9_animation_controller_GetAnimationSetByName(ID3DXAnimationController *iface,
163         const char *name, ID3DXAnimationSet **anim_set)
164 {
165     FIXME("iface %p, name %s, anim_set %p stub.\n", iface, debugstr_a(name), anim_set);
166 
167     return E_NOTIMPL;
168 }
169 
170 static HRESULT WINAPI d3dx9_animation_controller_AdvanceTime(ID3DXAnimationController *iface, double time_delta,
171         ID3DXAnimationCallbackHandler *callback_handler)
172 {
173     FIXME("iface %p, time_delta %.16e, callback_handler %p stub.\n", iface, time_delta, callback_handler);
174 
175     return E_NOTIMPL;
176 }
177 
178 static HRESULT WINAPI d3dx9_animation_controller_Reset(ID3DXAnimationController *iface)
179 {
180     FIXME("iface %p stub.\n", iface);
181 
182     return E_NOTIMPL;
183 }
184 
185 static double WINAPI d3dx9_animation_controller_GetTime(ID3DXAnimationController *iface)
186 {
187     FIXME("iface %p stub.\n", iface);
188 
189     return 0.0;
190 }
191 
192 static HRESULT WINAPI d3dx9_animation_controller_SetTrackAnimationSet(ID3DXAnimationController *iface,
193         UINT track, ID3DXAnimationSet *anim_set)
194 {
195     FIXME("iface %p, track %u, anim_set %p stub.\n", iface, track, anim_set);
196 
197     return E_NOTIMPL;
198 }
199 
200 static HRESULT WINAPI d3dx9_animation_controller_GetTrackAnimationSet(ID3DXAnimationController *iface,
201         UINT track, ID3DXAnimationSet **anim_set)
202 {
203     FIXME("iface %p, track %u, anim_set %p stub.\n", iface, track, anim_set);
204 
205     return E_NOTIMPL;
206 }
207 
208 static HRESULT WINAPI d3dx9_animation_controller_SetTrackPriority(ID3DXAnimationController *iface,
209         UINT track, D3DXPRIORITY_TYPE priority)
210 {
211     FIXME("iface %p, track %u, priority %u stub.\n", iface, track, priority);
212 
213     return E_NOTIMPL;
214 }
215 
216 static HRESULT WINAPI d3dx9_animation_controller_SetTrackSpeed(ID3DXAnimationController *iface,
217         UINT track, float speed)
218 {
219     FIXME("iface %p, track %u, speed %.8e stub.\n", iface, track, speed);
220 
221     return E_NOTIMPL;
222 }
223 
224 static HRESULT WINAPI d3dx9_animation_controller_SetTrackWeight(ID3DXAnimationController *iface,
225         UINT track, float weight)
226 {
227     FIXME("iface %p, track %u, weight %.8e stub.\n", iface, track, weight);
228 
229     return E_NOTIMPL;
230 }
231 
232 static HRESULT WINAPI d3dx9_animation_controller_SetTrackPosition(ID3DXAnimationController *iface,
233         UINT track, double position)
234 {
235     FIXME("iface %p, track %u, position %.16e stub.\n", iface, track, position);
236 
237     return E_NOTIMPL;
238 }
239 
240 static HRESULT WINAPI d3dx9_animation_controller_SetTrackEnable(ID3DXAnimationController *iface,
241         UINT track, BOOL enable)
242 {
243     FIXME("iface %p, track %u, enable %#x stub.\n", iface, track, enable);
244 
245     return E_NOTIMPL;
246 }
247 
248 static HRESULT WINAPI d3dx9_animation_controller_SetTrackDesc(ID3DXAnimationController *iface,
249         UINT track, D3DXTRACK_DESC *desc)
250 {
251     FIXME("iface %p, track %u, desc %p stub.\n", iface, track, desc);
252 
253     return E_NOTIMPL;
254 }
255 
256 static HRESULT WINAPI d3dx9_animation_controller_GetTrackDesc(ID3DXAnimationController *iface,
257         UINT track, D3DXTRACK_DESC *desc)
258 {
259     FIXME("iface %p, track %u, desc %p stub.\n", iface, track, desc);
260 
261     return E_NOTIMPL;
262 }
263 
264 static HRESULT WINAPI d3dx9_animation_controller_SetPriorityBlend(ID3DXAnimationController *iface,
265         float blend_weight)
266 {
267     FIXME("iface %p, blend_weight %.8e stub.\n", iface, blend_weight);
268 
269     return E_NOTIMPL;
270 }
271 
272 static float WINAPI d3dx9_animation_controller_GetPriorityBlend(ID3DXAnimationController *iface)
273 {
274     FIXME("iface %p stub.\n", iface);
275 
276     return 0.0f;
277 }
278 
279 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackSpeed(ID3DXAnimationController *iface,
280         UINT track, float new_speed, double start_time, double duration, D3DXTRANSITION_TYPE transition)
281 {
282     FIXME("iface %p, track %u, new_speed %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface,
283             track, new_speed, start_time, duration, transition);
284 
285     return 0;
286 }
287 
288 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackWeight(ID3DXAnimationController *iface,
289         UINT track, float new_weight, double start_time, double duration, D3DXTRANSITION_TYPE transition)
290 {
291     FIXME("iface %p, track %u, new_weight %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface,
292             track, new_weight, start_time, duration, transition);
293 
294     return 0;
295 }
296 
297 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackPosition(ID3DXAnimationController *iface,
298         UINT track, double new_position, double start_time)
299 {
300     FIXME("iface %p, track %u, new_position %.16e, start_time %.16e stub.\n", iface,
301             track, new_position, start_time);
302 
303     return 0;
304 }
305 
306 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackEnable(ID3DXAnimationController *iface,
307         UINT track, BOOL new_enable, double start_time)
308 {
309     FIXME("iface %p, track %u, new_enable %#x, start_time %.16e stub.\n", iface,
310             track, new_enable, start_time);
311 
312     return 0;
313 }
314 
315 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackBlend(ID3DXAnimationController *iface,
316         float new_blend_weight, double start_time, double duration, D3DXTRANSITION_TYPE transition)
317 {
318     FIXME("iface %p, new_blend_weight %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface,
319             new_blend_weight, start_time, duration, transition);
320 
321     return 0;
322 }
323 
324 static HRESULT WINAPI d3dx9_animation_controller_UnkeyEvent(ID3DXAnimationController *iface, D3DXEVENTHANDLE event)
325 {
326     FIXME("iface %p, event %u stub.\n", iface, event);
327 
328     return E_NOTIMPL;
329 }
330 
331 static HRESULT WINAPI d3dx9_animation_controller_UnkeyAllTrackEvents(ID3DXAnimationController *iface, UINT track)
332 {
333     FIXME("iface %p, track %u stub.\n", iface, track);
334 
335     return E_NOTIMPL;
336 }
337 
338 static HRESULT WINAPI d3dx9_animation_controller_UnkeyAllPriorityBlends(ID3DXAnimationController *iface)
339 {
340     FIXME("iface %p stub.\n", iface);
341 
342     return E_NOTIMPL;
343 }
344 
345 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetCurrentTrackEvent(ID3DXAnimationController *iface,
346         UINT track, D3DXEVENT_TYPE event_type)
347 {
348     FIXME("iface %p, track %u, event_type %u stub.\n", iface, track, event_type);
349 
350     return 0;
351 }
352 
353 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetCurrentPriorityBlend(ID3DXAnimationController *iface)
354 {
355     FIXME("iface %p stub.\n", iface);
356 
357     return 0;
358 }
359 
360 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetUpcomingTrackEvent(ID3DXAnimationController *iface,
361         UINT track, D3DXEVENTHANDLE event)
362 {
363     FIXME("iface %p, track %u, event %u stub.\n", iface, track, event);
364 
365     return 0;
366 }
367 
368 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetUpcomingPriorityBlend(ID3DXAnimationController *iface,
369         D3DXEVENTHANDLE event)
370 {
371     FIXME("iface %p, event %u stub.\n", iface, event);
372 
373     return 0;
374 }
375 
376 static HRESULT WINAPI d3dx9_animation_controller_ValidateEvent(ID3DXAnimationController *iface, D3DXEVENTHANDLE event)
377 {
378     FIXME("iface %p, event %u stub.\n", iface, event);
379 
380     return E_NOTIMPL;
381 }
382 
383 static HRESULT WINAPI d3dx9_animation_controller_GetEventDesc(ID3DXAnimationController *iface,
384         D3DXEVENTHANDLE event, D3DXEVENT_DESC *desc)
385 {
386     FIXME("iface %p, event %u, desc %p stub.\n", iface, event, desc);
387 
388     return E_NOTIMPL;
389 }
390 
391 static HRESULT WINAPI d3dx9_animation_controller_CloneAnimationController(ID3DXAnimationController *iface, UINT max_outputs,
392         UINT max_sets, UINT max_tracks, UINT max_events, ID3DXAnimationController **anim_controller)
393 {
394     FIXME("iface %p, max_outputs %u, max_sets %u, max_tracks %u, max_events %u, anim_controller %p stub.\n",
395             iface, max_outputs, max_sets, max_tracks, max_events, anim_controller);
396 
397     return E_NOTIMPL;
398 }
399 
400 static const struct ID3DXAnimationControllerVtbl d3dx9_animation_controller_vtbl =
401 {
402     d3dx9_animation_controller_QueryInterface,
403     d3dx9_animation_controller_AddRef,
404     d3dx9_animation_controller_Release,
405     d3dx9_animation_controller_GetMaxNumAnimationOutputs,
406     d3dx9_animation_controller_GetMaxNumAnimationSets,
407     d3dx9_animation_controller_GetMaxNumTracks,
408     d3dx9_animation_controller_GetMaxNumEvents,
409     d3dx9_animation_controller_RegisterAnimationOutput,
410     d3dx9_animation_controller_RegisterAnimationSet,
411     d3dx9_animation_controller_UnregisterAnimationSet,
412     d3dx9_animation_controller_GetNumAnimationSets,
413     d3dx9_animation_controller_GetAnimationSet,
414     d3dx9_animation_controller_GetAnimationSetByName,
415     d3dx9_animation_controller_AdvanceTime,
416     d3dx9_animation_controller_Reset,
417     d3dx9_animation_controller_GetTime,
418     d3dx9_animation_controller_SetTrackAnimationSet,
419     d3dx9_animation_controller_GetTrackAnimationSet,
420     d3dx9_animation_controller_SetTrackPriority,
421     d3dx9_animation_controller_SetTrackSpeed,
422     d3dx9_animation_controller_SetTrackWeight,
423     d3dx9_animation_controller_SetTrackPosition,
424     d3dx9_animation_controller_SetTrackEnable,
425     d3dx9_animation_controller_SetTrackDesc,
426     d3dx9_animation_controller_GetTrackDesc,
427     d3dx9_animation_controller_SetPriorityBlend,
428     d3dx9_animation_controller_GetPriorityBlend,
429     d3dx9_animation_controller_KeyTrackSpeed,
430     d3dx9_animation_controller_KeyTrackWeight,
431     d3dx9_animation_controller_KeyTrackPosition,
432     d3dx9_animation_controller_KeyTrackEnable,
433     d3dx9_animation_controller_KeyTrackBlend,
434     d3dx9_animation_controller_UnkeyEvent,
435     d3dx9_animation_controller_UnkeyAllTrackEvents,
436     d3dx9_animation_controller_UnkeyAllPriorityBlends,
437     d3dx9_animation_controller_GetCurrentTrackEvent,
438     d3dx9_animation_controller_GetCurrentPriorityBlend,
439     d3dx9_animation_controller_GetUpcomingTrackEvent,
440     d3dx9_animation_controller_GetUpcomingPriorityBlend,
441     d3dx9_animation_controller_ValidateEvent,
442     d3dx9_animation_controller_GetEventDesc,
443     d3dx9_animation_controller_CloneAnimationController
444 };
445 
446 HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets,
447         UINT max_tracks, UINT max_events, ID3DXAnimationController **controller)
448 {
449     struct d3dx9_animation_controller *object;
450 
451     TRACE("max_outputs %u, max_sets %u, max_tracks %u, max_events %u, controller %p.\n",
452             max_outputs, max_sets, max_tracks, max_events, controller);
453 
454     if (!max_outputs || !max_sets || !max_tracks || !max_events || !controller)
455         return D3D_OK;
456 
457     object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
458     if (!object)
459         return E_OUTOFMEMORY;
460 
461     object->ID3DXAnimationController_iface.lpVtbl = &d3dx9_animation_controller_vtbl;
462     object->ref = 1;
463     object->max_outputs = max_outputs;
464     object->max_sets    = max_sets;
465     object->max_tracks  = max_tracks;
466     object->max_events  = max_events;
467 
468     *controller = &object->ID3DXAnimationController_iface;
469 
470     return D3D_OK;
471 }
472 
473 HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_per_second,
474         D3DXPLAYBACK_TYPE playback_type, UINT animation_count, UINT callback_key_count,
475         const D3DXKEY_CALLBACK *callback_keys, ID3DXKeyframedAnimationSet **animation_set)
476 {
477     FIXME("name %s, ticks_per_second %.16e, playback_type %u, animation_count %u, "
478             "callback_key_count %u, callback_keys %p, animation_set %p stub.\n",
479             debugstr_a(name), ticks_per_second, playback_type, animation_count,
480             callback_key_count, callback_keys, animation_set);
481 
482     return E_NOTIMPL;
483 }
484