xref: /reactos/dll/directx/wine/d3dx9_36/animation.c (revision 3476cdae)
1 #ifdef __REACTOS__
2 #include "precomp.h"
3 #else
4 /*
5  * Animation Controller operations specific to D3DX9.
6  *
7  * Copyright (C) 2015 Christian Costa
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include "d3dx9_private.h"
26 #endif /* __REACTOS__ */
27 
28 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
29 
30 struct d3dx9_animation_controller
31 {
32     ID3DXAnimationController ID3DXAnimationController_iface;
33     LONG ref;
34 
35     UINT max_outputs;
36     UINT max_sets;
37     UINT max_tracks;
38     UINT max_events;
39 };
40 
41 static inline struct d3dx9_animation_controller *impl_from_ID3DXAnimationController(ID3DXAnimationController *iface)
42 {
43     return CONTAINING_RECORD(iface, struct d3dx9_animation_controller, ID3DXAnimationController_iface);
44 }
45 
46 static HRESULT WINAPI d3dx9_animation_controller_QueryInterface(ID3DXAnimationController *iface, REFIID riid, void **out)
47 {
48     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
49 
50     if (IsEqualGUID(riid, &IID_IUnknown) ||
51         IsEqualGUID(riid, &IID_ID3DXAnimationController))
52     {
53         iface->lpVtbl->AddRef(iface);
54         *out = iface;
55         return D3D_OK;
56     }
57 
58     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
59     *out = NULL;
60     return E_NOINTERFACE;
61 }
62 
63 static ULONG WINAPI d3dx9_animation_controller_AddRef(ID3DXAnimationController *iface)
64 {
65     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
66     ULONG refcount = InterlockedIncrement(&animation->ref);
67 
68     TRACE("%p increasing refcount to %u.\n", animation, refcount);
69 
70     return refcount;
71 }
72 
73 static ULONG WINAPI d3dx9_animation_controller_Release(ID3DXAnimationController *iface)
74 {
75     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
76     ULONG refcount = InterlockedDecrement(&animation->ref);
77 
78     TRACE("%p decreasing refcount to %u.\n", animation, refcount);
79 
80     if (!refcount)
81     {
82         HeapFree(GetProcessHeap(), 0, animation);
83     }
84 
85     return refcount;
86 }
87 
88 static UINT WINAPI d3dx9_animation_controller_GetMaxNumAnimationOutputs(ID3DXAnimationController *iface)
89 {
90     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
91 
92     TRACE("iface %p.\n", iface);
93 
94     return animation->max_outputs;
95 }
96 
97 static UINT WINAPI d3dx9_animation_controller_GetMaxNumAnimationSets(ID3DXAnimationController *iface)
98 {
99     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
100 
101     TRACE("iface %p.\n", iface);
102 
103     return animation->max_sets;
104 }
105 
106 static UINT WINAPI d3dx9_animation_controller_GetMaxNumTracks(ID3DXAnimationController *iface)
107 {
108     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
109 
110     TRACE("iface %p.\n", iface);
111 
112     return animation->max_tracks;
113 }
114 
115 static UINT WINAPI d3dx9_animation_controller_GetMaxNumEvents(ID3DXAnimationController *iface)
116 {
117     struct d3dx9_animation_controller *animation = impl_from_ID3DXAnimationController(iface);
118 
119     TRACE("iface %p.\n", iface);
120 
121     return animation->max_events;
122 }
123 
124 static HRESULT WINAPI d3dx9_animation_controller_RegisterAnimationOutput(ID3DXAnimationController *iface,
125         const char *name, D3DXMATRIX *matrix, D3DXVECTOR3 *scale, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation)
126 {
127     FIXME("iface %p, name %s, matrix %p, scale %p, rotation %p, translation %p stub.\n", iface, debugstr_a(name),
128             matrix, scale, rotation, translation);
129 
130     return E_NOTIMPL;
131 }
132 
133 static HRESULT WINAPI d3dx9_animation_controller_RegisterAnimationSet(ID3DXAnimationController *iface,
134         ID3DXAnimationSet *anim_set)
135 {
136     FIXME("iface %p, anim_set %p stub.\n", iface, anim_set);
137 
138     return E_NOTIMPL;
139 }
140 
141 static HRESULT WINAPI d3dx9_animation_controller_UnregisterAnimationSet(ID3DXAnimationController *iface,
142         ID3DXAnimationSet *anim_set)
143 {
144     FIXME("iface %p, anim_set %p stub.\n", iface, anim_set);
145 
146     return E_NOTIMPL;
147 }
148 
149 static UINT WINAPI d3dx9_animation_controller_GetNumAnimationSets(ID3DXAnimationController *iface)
150 {
151     FIXME("iface %p stub.\n", iface);
152 
153     return 0;
154 }
155 
156 static HRESULT WINAPI d3dx9_animation_controller_GetAnimationSet(ID3DXAnimationController *iface,
157         UINT index, ID3DXAnimationSet **anim_set)
158 {
159     FIXME("iface %p, index %u, anim_set %p stub.\n", iface, index, anim_set);
160 
161     return E_NOTIMPL;
162 }
163 
164 static HRESULT WINAPI d3dx9_animation_controller_GetAnimationSetByName(ID3DXAnimationController *iface,
165         const char *name, ID3DXAnimationSet **anim_set)
166 {
167     FIXME("iface %p, name %s, anim_set %p stub.\n", iface, debugstr_a(name), anim_set);
168 
169     return E_NOTIMPL;
170 }
171 
172 static HRESULT WINAPI d3dx9_animation_controller_AdvanceTime(ID3DXAnimationController *iface, double time_delta,
173         ID3DXAnimationCallbackHandler *callback_handler)
174 {
175     FIXME("iface %p, time_delta %.16e, callback_handler %p stub.\n", iface, time_delta, callback_handler);
176 
177     return E_NOTIMPL;
178 }
179 
180 static HRESULT WINAPI d3dx9_animation_controller_Reset(ID3DXAnimationController *iface)
181 {
182     FIXME("iface %p stub.\n", iface);
183 
184     return E_NOTIMPL;
185 }
186 
187 static double WINAPI d3dx9_animation_controller_GetTime(ID3DXAnimationController *iface)
188 {
189     FIXME("iface %p stub.\n", iface);
190 
191     return 0.0;
192 }
193 
194 static HRESULT WINAPI d3dx9_animation_controller_SetTrackAnimationSet(ID3DXAnimationController *iface,
195         UINT track, ID3DXAnimationSet *anim_set)
196 {
197     FIXME("iface %p, track %u, anim_set %p stub.\n", iface, track, anim_set);
198 
199     return E_NOTIMPL;
200 }
201 
202 static HRESULT WINAPI d3dx9_animation_controller_GetTrackAnimationSet(ID3DXAnimationController *iface,
203         UINT track, ID3DXAnimationSet **anim_set)
204 {
205     FIXME("iface %p, track %u, anim_set %p stub.\n", iface, track, anim_set);
206 
207     return E_NOTIMPL;
208 }
209 
210 static HRESULT WINAPI d3dx9_animation_controller_SetTrackPriority(ID3DXAnimationController *iface,
211         UINT track, D3DXPRIORITY_TYPE priority)
212 {
213     FIXME("iface %p, track %u, priority %u stub.\n", iface, track, priority);
214 
215     return E_NOTIMPL;
216 }
217 
218 static HRESULT WINAPI d3dx9_animation_controller_SetTrackSpeed(ID3DXAnimationController *iface,
219         UINT track, float speed)
220 {
221     FIXME("iface %p, track %u, speed %.8e stub.\n", iface, track, speed);
222 
223     return E_NOTIMPL;
224 }
225 
226 static HRESULT WINAPI d3dx9_animation_controller_SetTrackWeight(ID3DXAnimationController *iface,
227         UINT track, float weight)
228 {
229     FIXME("iface %p, track %u, weight %.8e stub.\n", iface, track, weight);
230 
231     return E_NOTIMPL;
232 }
233 
234 static HRESULT WINAPI d3dx9_animation_controller_SetTrackPosition(ID3DXAnimationController *iface,
235         UINT track, double position)
236 {
237     FIXME("iface %p, track %u, position %.16e stub.\n", iface, track, position);
238 
239     return E_NOTIMPL;
240 }
241 
242 static HRESULT WINAPI d3dx9_animation_controller_SetTrackEnable(ID3DXAnimationController *iface,
243         UINT track, BOOL enable)
244 {
245     FIXME("iface %p, track %u, enable %#x stub.\n", iface, track, enable);
246 
247     return E_NOTIMPL;
248 }
249 
250 static HRESULT WINAPI d3dx9_animation_controller_SetTrackDesc(ID3DXAnimationController *iface,
251         UINT track, D3DXTRACK_DESC *desc)
252 {
253     FIXME("iface %p, track %u, desc %p stub.\n", iface, track, desc);
254 
255     return E_NOTIMPL;
256 }
257 
258 static HRESULT WINAPI d3dx9_animation_controller_GetTrackDesc(ID3DXAnimationController *iface,
259         UINT track, D3DXTRACK_DESC *desc)
260 {
261     FIXME("iface %p, track %u, desc %p stub.\n", iface, track, desc);
262 
263     return E_NOTIMPL;
264 }
265 
266 static HRESULT WINAPI d3dx9_animation_controller_SetPriorityBlend(ID3DXAnimationController *iface,
267         float blend_weight)
268 {
269     FIXME("iface %p, blend_weight %.8e stub.\n", iface, blend_weight);
270 
271     return E_NOTIMPL;
272 }
273 
274 static float WINAPI d3dx9_animation_controller_GetPriorityBlend(ID3DXAnimationController *iface)
275 {
276     FIXME("iface %p stub.\n", iface);
277 
278     return 0.0f;
279 }
280 
281 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackSpeed(ID3DXAnimationController *iface,
282         UINT track, float new_speed, double start_time, double duration, D3DXTRANSITION_TYPE transition)
283 {
284     FIXME("iface %p, track %u, new_speed %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface,
285             track, new_speed, start_time, duration, transition);
286 
287     return 0;
288 }
289 
290 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackWeight(ID3DXAnimationController *iface,
291         UINT track, float new_weight, double start_time, double duration, D3DXTRANSITION_TYPE transition)
292 {
293     FIXME("iface %p, track %u, new_weight %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface,
294             track, new_weight, start_time, duration, transition);
295 
296     return 0;
297 }
298 
299 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackPosition(ID3DXAnimationController *iface,
300         UINT track, double new_position, double start_time)
301 {
302     FIXME("iface %p, track %u, new_position %.16e, start_time %.16e stub.\n", iface,
303             track, new_position, start_time);
304 
305     return 0;
306 }
307 
308 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackEnable(ID3DXAnimationController *iface,
309         UINT track, BOOL new_enable, double start_time)
310 {
311     FIXME("iface %p, track %u, new_enable %#x, start_time %.16e stub.\n", iface,
312             track, new_enable, start_time);
313 
314     return 0;
315 }
316 
317 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_KeyTrackBlend(ID3DXAnimationController *iface,
318         float new_blend_weight, double start_time, double duration, D3DXTRANSITION_TYPE transition)
319 {
320     FIXME("iface %p, new_blend_weight %.8e, start_time %.16e, duration %.16e, transition %u stub.\n", iface,
321             new_blend_weight, start_time, duration, transition);
322 
323     return 0;
324 }
325 
326 static HRESULT WINAPI d3dx9_animation_controller_UnkeyEvent(ID3DXAnimationController *iface, D3DXEVENTHANDLE event)
327 {
328     FIXME("iface %p, event %u stub.\n", iface, event);
329 
330     return E_NOTIMPL;
331 }
332 
333 static HRESULT WINAPI d3dx9_animation_controller_UnkeyAllTrackEvents(ID3DXAnimationController *iface, UINT track)
334 {
335     FIXME("iface %p, track %u stub.\n", iface, track);
336 
337     return E_NOTIMPL;
338 }
339 
340 static HRESULT WINAPI d3dx9_animation_controller_UnkeyAllPriorityBlends(ID3DXAnimationController *iface)
341 {
342     FIXME("iface %p stub.\n", iface);
343 
344     return E_NOTIMPL;
345 }
346 
347 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetCurrentTrackEvent(ID3DXAnimationController *iface,
348         UINT track, D3DXEVENT_TYPE event_type)
349 {
350     FIXME("iface %p, track %u, event_type %u stub.\n", iface, track, event_type);
351 
352     return 0;
353 }
354 
355 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetCurrentPriorityBlend(ID3DXAnimationController *iface)
356 {
357     FIXME("iface %p stub.\n", iface);
358 
359     return 0;
360 }
361 
362 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetUpcomingTrackEvent(ID3DXAnimationController *iface,
363         UINT track, D3DXEVENTHANDLE event)
364 {
365     FIXME("iface %p, track %u, event %u stub.\n", iface, track, event);
366 
367     return 0;
368 }
369 
370 static D3DXEVENTHANDLE WINAPI d3dx9_animation_controller_GetUpcomingPriorityBlend(ID3DXAnimationController *iface,
371         D3DXEVENTHANDLE event)
372 {
373     FIXME("iface %p, event %u stub.\n", iface, event);
374 
375     return 0;
376 }
377 
378 static HRESULT WINAPI d3dx9_animation_controller_ValidateEvent(ID3DXAnimationController *iface, D3DXEVENTHANDLE event)
379 {
380     FIXME("iface %p, event %u stub.\n", iface, event);
381 
382     return E_NOTIMPL;
383 }
384 
385 static HRESULT WINAPI d3dx9_animation_controller_GetEventDesc(ID3DXAnimationController *iface,
386         D3DXEVENTHANDLE event, D3DXEVENT_DESC *desc)
387 {
388     FIXME("iface %p, event %u, desc %p stub.\n", iface, event, desc);
389 
390     return E_NOTIMPL;
391 }
392 
393 static HRESULT WINAPI d3dx9_animation_controller_CloneAnimationController(ID3DXAnimationController *iface, UINT max_outputs,
394         UINT max_sets, UINT max_tracks, UINT max_events, ID3DXAnimationController **anim_controller)
395 {
396     FIXME("iface %p, max_outputs %u, max_sets %u, max_tracks %u, max_events %u, anim_controller %p stub.\n",
397             iface, max_outputs, max_sets, max_tracks, max_events, anim_controller);
398 
399     return E_NOTIMPL;
400 }
401 
402 static const struct ID3DXAnimationControllerVtbl d3dx9_animation_controller_vtbl =
403 {
404     d3dx9_animation_controller_QueryInterface,
405     d3dx9_animation_controller_AddRef,
406     d3dx9_animation_controller_Release,
407     d3dx9_animation_controller_GetMaxNumAnimationOutputs,
408     d3dx9_animation_controller_GetMaxNumAnimationSets,
409     d3dx9_animation_controller_GetMaxNumTracks,
410     d3dx9_animation_controller_GetMaxNumEvents,
411     d3dx9_animation_controller_RegisterAnimationOutput,
412     d3dx9_animation_controller_RegisterAnimationSet,
413     d3dx9_animation_controller_UnregisterAnimationSet,
414     d3dx9_animation_controller_GetNumAnimationSets,
415     d3dx9_animation_controller_GetAnimationSet,
416     d3dx9_animation_controller_GetAnimationSetByName,
417     d3dx9_animation_controller_AdvanceTime,
418     d3dx9_animation_controller_Reset,
419     d3dx9_animation_controller_GetTime,
420     d3dx9_animation_controller_SetTrackAnimationSet,
421     d3dx9_animation_controller_GetTrackAnimationSet,
422     d3dx9_animation_controller_SetTrackPriority,
423     d3dx9_animation_controller_SetTrackSpeed,
424     d3dx9_animation_controller_SetTrackWeight,
425     d3dx9_animation_controller_SetTrackPosition,
426     d3dx9_animation_controller_SetTrackEnable,
427     d3dx9_animation_controller_SetTrackDesc,
428     d3dx9_animation_controller_GetTrackDesc,
429     d3dx9_animation_controller_SetPriorityBlend,
430     d3dx9_animation_controller_GetPriorityBlend,
431     d3dx9_animation_controller_KeyTrackSpeed,
432     d3dx9_animation_controller_KeyTrackWeight,
433     d3dx9_animation_controller_KeyTrackPosition,
434     d3dx9_animation_controller_KeyTrackEnable,
435     d3dx9_animation_controller_KeyTrackBlend,
436     d3dx9_animation_controller_UnkeyEvent,
437     d3dx9_animation_controller_UnkeyAllTrackEvents,
438     d3dx9_animation_controller_UnkeyAllPriorityBlends,
439     d3dx9_animation_controller_GetCurrentTrackEvent,
440     d3dx9_animation_controller_GetCurrentPriorityBlend,
441     d3dx9_animation_controller_GetUpcomingTrackEvent,
442     d3dx9_animation_controller_GetUpcomingPriorityBlend,
443     d3dx9_animation_controller_ValidateEvent,
444     d3dx9_animation_controller_GetEventDesc,
445     d3dx9_animation_controller_CloneAnimationController
446 };
447 
448 HRESULT WINAPI D3DXCreateAnimationController(UINT max_outputs, UINT max_sets,
449         UINT max_tracks, UINT max_events, ID3DXAnimationController **controller)
450 {
451     struct d3dx9_animation_controller *object;
452 
453     TRACE("max_outputs %u, max_sets %u, max_tracks %u, max_events %u, controller %p.\n",
454             max_outputs, max_sets, max_tracks, max_events, controller);
455 
456     if (!max_outputs || !max_sets || !max_tracks || !max_events || !controller)
457         return D3D_OK;
458 
459     object = HeapAlloc(GetProcessHeap(), 0, sizeof(*object));
460     if (!object)
461         return E_OUTOFMEMORY;
462 
463     object->ID3DXAnimationController_iface.lpVtbl = &d3dx9_animation_controller_vtbl;
464     object->ref = 1;
465     object->max_outputs = max_outputs;
466     object->max_sets    = max_sets;
467     object->max_tracks  = max_tracks;
468     object->max_events  = max_events;
469 
470     *controller = &object->ID3DXAnimationController_iface;
471 
472     return D3D_OK;
473 }
474 
475 struct d3dx9_keyframed_animation_set
476 {
477     ID3DXKeyframedAnimationSet ID3DXKeyframedAnimationSet_iface;
478     LONG ref;
479 
480     const char *name;
481     double ticks_per_second;
482     D3DXPLAYBACK_TYPE playback_type;
483     unsigned int animation_count;
484     unsigned int callback_key_count;
485     const D3DXKEY_CALLBACK *callback_keys;
486 };
487 
488 static inline struct d3dx9_keyframed_animation_set *impl_from_ID3DXKeyframedAnimationSet(ID3DXKeyframedAnimationSet *iface)
489 {
490     return CONTAINING_RECORD(iface, struct d3dx9_keyframed_animation_set, ID3DXKeyframedAnimationSet_iface);
491 }
492 
493 static HRESULT WINAPI d3dx9_keyframed_animation_QueryInterface(ID3DXKeyframedAnimationSet *iface,
494         REFIID riid, void **obj)
495 {
496     TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), obj);
497 
498     if (IsEqualGUID(riid, &IID_IUnknown)
499             || IsEqualGUID(riid, &IID_ID3DXAnimationSet)
500             || IsEqualGUID(riid, &IID_ID3DXKeyframedAnimationSet))
501     {
502         iface->lpVtbl->AddRef(iface);
503         *obj = iface;
504         return D3D_OK;
505     }
506 
507     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
508     *obj = NULL;
509     return E_NOINTERFACE;
510 }
511 
512 static ULONG WINAPI d3dx9_keyframed_animation_AddRef(ID3DXKeyframedAnimationSet *iface)
513 {
514     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
515     ULONG refcount = InterlockedIncrement(&set->ref);
516 
517     TRACE("%p increasing refcount to %u.\n", set, refcount);
518 
519     return refcount;
520 }
521 
522 static ULONG WINAPI d3dx9_keyframed_animation_Release(ID3DXKeyframedAnimationSet *iface)
523 {
524     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
525     ULONG refcount = InterlockedDecrement(&set->ref);
526 
527     TRACE("%p decreasing refcount to %u.\n", set, refcount);
528 
529     if (!refcount)
530     {
531         heap_free((char *)set->name);
532         heap_free(set);
533     }
534 
535     return refcount;
536 }
537 
538 static const char * WINAPI d3dx9_keyframed_animation_GetName(ID3DXKeyframedAnimationSet *iface)
539 {
540     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
541 
542     TRACE("set %p.\n", set);
543     return set->name;
544 }
545 
546 static double WINAPI d3dx9_keyframed_animation_GetPeriod(ID3DXKeyframedAnimationSet *iface)
547 {
548     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
549 
550     FIXME("set %p stub.\n", set);
551     return 0.0;
552 }
553 
554 static double WINAPI d3dx9_keyframed_animation_GetPeriodicPosition(ID3DXKeyframedAnimationSet *iface, double position)
555 {
556     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
557 
558     FIXME("set %p, position %.16e stub.\n", set, position);
559     return 0.0;
560 }
561 
562 static UINT WINAPI d3dx9_keyframed_animation_GetNumAnimations(ID3DXKeyframedAnimationSet *iface)
563 {
564     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
565 
566     FIXME("set %p stub.\n", set);
567     return 0;
568 }
569 
570 static HRESULT WINAPI d3dx9_keyframed_animation_GetAnimationNameByIndex(ID3DXKeyframedAnimationSet *iface,
571         UINT index, const char **name)
572 {
573     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
574 
575     FIXME("set %p, index %u, name %p stub.\n", set, index, name);
576     return E_NOTIMPL;
577 }
578 
579 static HRESULT WINAPI d3dx9_keyframed_animation_GetAnimationIndexByName(ID3DXKeyframedAnimationSet *iface,
580         const char *name, UINT *index)
581 {
582     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
583 
584     FIXME("set %p, name %s, index %p stub.\n", set, debugstr_a(name), index);
585     return E_NOTIMPL;
586 }
587 
588 static HRESULT WINAPI d3dx9_keyframed_animation_GetSRT(ID3DXKeyframedAnimationSet *iface, double periodic_position,
589         UINT animation, D3DXVECTOR3 *scale, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation)
590 {
591     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
592 
593     FIXME("set %p, periodic_position %.16e, animation %u, scale %p, rotation %p, translation %p stub.\n",
594             set, periodic_position, animation, scale, rotation, translation);
595     return E_NOTIMPL;
596 }
597 
598 static HRESULT WINAPI d3dx9_keyframed_animation_GetCallback(ID3DXKeyframedAnimationSet *iface, double position,
599         DWORD flags, double *callback_position, void **callback_data)
600 {
601     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
602 
603     FIXME("set %p, position %.16e, flags %#x, callback_position %p, callback_data %p stub.\n",
604             set, position, flags, callback_position, callback_data);
605     return E_NOTIMPL;
606 }
607 
608 static D3DXPLAYBACK_TYPE WINAPI d3dx9_keyframed_animation_GetPlaybackType(ID3DXKeyframedAnimationSet *iface)
609 {
610     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
611 
612     TRACE("set %p.\n", set);
613     return set->playback_type;
614 }
615 
616 static double WINAPI d3dx9_keyframed_animation_GetSourceTicksPerSecond(ID3DXKeyframedAnimationSet *iface)
617 {
618     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
619 
620     TRACE("set %p.\n", set);
621     return set->ticks_per_second;
622 }
623 
624 static UINT WINAPI d3dx9_keyframed_animation_GetNumScaleKeys(ID3DXKeyframedAnimationSet *iface, UINT keys)
625 {
626     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
627 
628     FIXME("set %p, keys %u stub.\n", set, keys);
629     return 0;
630 }
631 
632 static HRESULT WINAPI d3dx9_keyframed_animation_GetScaleKeys(ID3DXKeyframedAnimationSet *iface, UINT animation,
633         D3DXKEY_VECTOR3 *scale_keys)
634 {
635     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
636 
637     FIXME("set %p, animation %u, scale_keys %p stub.\n", set, animation, scale_keys);
638     return E_NOTIMPL;
639 }
640 
641 static HRESULT WINAPI d3dx9_keyframed_animation_GetScaleKey(ID3DXKeyframedAnimationSet *iface, UINT animation,
642         UINT key, D3DXKEY_VECTOR3 *scale_key)
643 {
644     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
645 
646     FIXME("set %p, animation %u, key %u, scale_key %p stub.\n", set, animation, key, scale_key);
647     return E_NOTIMPL;
648 }
649 
650 static HRESULT WINAPI d3dx9_keyframed_animation_SetScaleKey(ID3DXKeyframedAnimationSet *iface, UINT animation,
651         UINT key, D3DXKEY_VECTOR3 *scale_key)
652 {
653     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
654 
655     FIXME("set %p, animation %u, key %u, scale_key %p stub.\n", set, animation, key, scale_key);
656     return E_NOTIMPL;
657 }
658 
659 static UINT WINAPI d3dx9_keyframed_animation_GetNumRotationKeys(ID3DXKeyframedAnimationSet *iface, UINT animation)
660 {
661     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
662 
663     FIXME("set %p, animation %u stub.\n", set, animation);
664     return E_NOTIMPL;
665 }
666 
667 static HRESULT WINAPI d3dx9_keyframed_animation_GetRotationKeys(ID3DXKeyframedAnimationSet *iface,
668         UINT animation, D3DXKEY_QUATERNION *rotation_keys)
669 {
670     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
671 
672     FIXME("set %p, animation %u, rotation_keys %p stub.\n", set, animation, rotation_keys);
673     return E_NOTIMPL;
674 }
675 
676 static HRESULT WINAPI d3dx9_keyframed_animation_GetRotationKey(ID3DXKeyframedAnimationSet *iface,
677         UINT animation, UINT key, D3DXKEY_QUATERNION *rotation_key)
678 {
679     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
680 
681     FIXME("set %p, animation %u, key %u, rotation_key %p stub.\n", set, animation, key, rotation_key);
682     return E_NOTIMPL;
683 }
684 
685 static HRESULT WINAPI d3dx9_keyframed_animation_SetRotationKey(ID3DXKeyframedAnimationSet *iface,
686         UINT animation, UINT key, D3DXKEY_QUATERNION *rotation_key)
687 {
688     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
689 
690     FIXME("set %p, animation %u, key %u, rotation_key %p stub.\n", set, animation, key, rotation_key);
691     return E_NOTIMPL;
692 }
693 
694 static UINT WINAPI d3dx9_keyframed_animation_GetNumTranslationKeys(ID3DXKeyframedAnimationSet *iface, UINT animation)
695 {
696     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
697 
698     FIXME("set %p, animation %u stub.\n", set, animation);
699     return E_NOTIMPL;
700 }
701 
702 static HRESULT WINAPI d3dx9_keyframed_animation_GetTranslationKeys(ID3DXKeyframedAnimationSet *iface,
703         UINT animation, D3DXKEY_VECTOR3 *translation_keys)
704 {
705     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
706 
707     FIXME("set %p, animation %u, translation_keys %p stub.\n", set, animation, translation_keys);
708     return E_NOTIMPL;
709 }
710 
711 static HRESULT WINAPI d3dx9_keyframed_animation_GetTranslationKey(ID3DXKeyframedAnimationSet *iface,
712         UINT animation, UINT key, D3DXKEY_VECTOR3 *translation_key)
713 {
714     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
715 
716     FIXME("set %p, animation %u, key %u, translation_key %p stub.\n", set, animation, key, translation_key);
717     return E_NOTIMPL;
718 }
719 
720 static HRESULT WINAPI d3dx9_keyframed_animation_SetTranslationKey(ID3DXKeyframedAnimationSet *iface,
721         UINT animation, UINT key, D3DXKEY_VECTOR3 *translation_key)
722 {
723     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
724 
725     FIXME("set %p, animation %u, key %u, translation_key %p stub.\n", set, animation, key, translation_key);
726     return E_NOTIMPL;
727 }
728 
729 static UINT WINAPI d3dx9_keyframed_animation_GetNumCallbackKeys(ID3DXKeyframedAnimationSet *iface)
730 {
731     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
732 
733     FIXME("set %p stub.\n", set);
734     return E_NOTIMPL;
735 }
736 
737 static HRESULT WINAPI d3dx9_keyframed_animation_GetCallbackKeys(ID3DXKeyframedAnimationSet *iface,
738         D3DXKEY_CALLBACK *callback_keys)
739 {
740     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
741 
742     FIXME("set %p, callback_keys %p stub.\n", set, callback_keys);
743     return E_NOTIMPL;
744 }
745 
746 static HRESULT WINAPI d3dx9_keyframed_animation_GetCallbackKey(ID3DXKeyframedAnimationSet *iface,
747         UINT key, D3DXKEY_CALLBACK *callback_key)
748 {
749     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
750 
751     FIXME("set %p, key %u, callback_key %p stub.\n", set, key, callback_key);
752     return E_NOTIMPL;
753 }
754 
755 static HRESULT WINAPI d3dx9_keyframed_animation_SetCallbackKey(ID3DXKeyframedAnimationSet *iface,
756         UINT key, D3DXKEY_CALLBACK *callback_key)
757 {
758     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
759 
760     FIXME("set %p, key %u, callback_key %p stub.\n", set, key, callback_key);
761     return E_NOTIMPL;
762 }
763 
764 static HRESULT WINAPI d3dx9_keyframed_animation_UnregisterScaleKey(ID3DXKeyframedAnimationSet *iface,
765         UINT animation, UINT key)
766 {
767     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
768 
769     FIXME("set %p, animation %u, key %u stub.\n", set, animation, key);
770     return E_NOTIMPL;
771 }
772 
773 static HRESULT WINAPI d3dx9_keyframed_animation_UnregisterRotationKey(ID3DXKeyframedAnimationSet *iface,
774         UINT animation, UINT key)
775 {
776     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
777 
778     FIXME("set %p, animation %u, key %u stub.\n", set, animation, key);
779     return E_NOTIMPL;
780 }
781 
782 static HRESULT WINAPI d3dx9_keyframed_animation_UnregisterTranslationKey(ID3DXKeyframedAnimationSet *iface,
783         UINT animation, UINT key)
784 {
785     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
786 
787     FIXME("set %p, animation %u, key %u stub.\n", set, animation, key);
788     return E_NOTIMPL;
789 }
790 
791 static HRESULT WINAPI d3dx9_keyframed_animation_RegisterAnimationSRTKeys(ID3DXKeyframedAnimationSet *iface,
792         const char *name, UINT scale_keys_count, UINT rotation_keys_count, UINT translation_keys_count,
793         const D3DXKEY_VECTOR3 *scale_keys, const D3DXKEY_QUATERNION *rotation_keys,
794         const D3DXKEY_VECTOR3 *translation_keys, DWORD *animation_index)
795 {
796     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
797 
798     FIXME("set %p, name %s, scale_keys_count %u, rotation_keys_count %u, translation_keys_count %u, "
799             "scale_keys %p, rotation_keys %p, translation_keys %p, animation_index %p stub.\n",
800             set, debugstr_a(name), scale_keys_count, rotation_keys_count, translation_keys_count,
801             scale_keys, rotation_keys, translation_keys, animation_index);
802     return E_NOTIMPL;
803 }
804 
805 static HRESULT WINAPI d3dx9_keyframed_animation_Compress(ID3DXKeyframedAnimationSet *iface,
806         DWORD flags, float lossiness, D3DXFRAME *hierarchy, ID3DXBuffer **compressed_data)
807 {
808     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
809 
810     FIXME("set %p, flags %#x, lossiness %.8e, hierarchy %p, compressed_data %p stub.\n",
811             set, flags, lossiness, hierarchy, compressed_data);
812     return E_NOTIMPL;
813 }
814 
815 static HRESULT WINAPI d3dx9_keyframed_animation_UnregisterAnimation(ID3DXKeyframedAnimationSet *iface, UINT index)
816 {
817     struct d3dx9_keyframed_animation_set *set = impl_from_ID3DXKeyframedAnimationSet(iface);
818 
819     FIXME("set %p, index %u stub.\n", set, index);
820     return E_NOTIMPL;
821 }
822 
823 static const struct ID3DXKeyframedAnimationSetVtbl d3dx9_keyframed_animation_vtbl =
824 {
825     d3dx9_keyframed_animation_QueryInterface,
826     d3dx9_keyframed_animation_AddRef,
827     d3dx9_keyframed_animation_Release,
828     d3dx9_keyframed_animation_GetName,
829     d3dx9_keyframed_animation_GetPeriod,
830     d3dx9_keyframed_animation_GetPeriodicPosition,
831     d3dx9_keyframed_animation_GetNumAnimations,
832     d3dx9_keyframed_animation_GetAnimationNameByIndex,
833     d3dx9_keyframed_animation_GetAnimationIndexByName,
834     d3dx9_keyframed_animation_GetSRT,
835     d3dx9_keyframed_animation_GetCallback,
836     d3dx9_keyframed_animation_GetPlaybackType,
837     d3dx9_keyframed_animation_GetSourceTicksPerSecond,
838     d3dx9_keyframed_animation_GetNumScaleKeys,
839     d3dx9_keyframed_animation_GetScaleKeys,
840     d3dx9_keyframed_animation_GetScaleKey,
841     d3dx9_keyframed_animation_SetScaleKey,
842     d3dx9_keyframed_animation_GetNumRotationKeys,
843     d3dx9_keyframed_animation_GetRotationKeys,
844     d3dx9_keyframed_animation_GetRotationKey,
845     d3dx9_keyframed_animation_SetRotationKey,
846     d3dx9_keyframed_animation_GetNumTranslationKeys,
847     d3dx9_keyframed_animation_GetTranslationKeys,
848     d3dx9_keyframed_animation_GetTranslationKey,
849     d3dx9_keyframed_animation_SetTranslationKey,
850     d3dx9_keyframed_animation_GetNumCallbackKeys,
851     d3dx9_keyframed_animation_GetCallbackKeys,
852     d3dx9_keyframed_animation_GetCallbackKey,
853     d3dx9_keyframed_animation_SetCallbackKey,
854     d3dx9_keyframed_animation_UnregisterScaleKey,
855     d3dx9_keyframed_animation_UnregisterRotationKey,
856     d3dx9_keyframed_animation_UnregisterTranslationKey,
857     d3dx9_keyframed_animation_RegisterAnimationSRTKeys,
858     d3dx9_keyframed_animation_Compress,
859     d3dx9_keyframed_animation_UnregisterAnimation
860 };
861 
862 HRESULT WINAPI D3DXCreateKeyframedAnimationSet(const char *name, double ticks_per_second,
863         D3DXPLAYBACK_TYPE playback_type, UINT animation_count, UINT callback_key_count,
864         const D3DXKEY_CALLBACK *callback_keys, ID3DXKeyframedAnimationSet **animation_set)
865 {
866     struct d3dx9_keyframed_animation_set *object;
867     char *string;
868 
869     TRACE("name %s, ticks_per_second %.16e, playback_type %u, animation_count %u, "
870             "callback_key_count %u, callback_keys %p, animation_set %p.\n",
871             debugstr_a(name), ticks_per_second, playback_type, animation_count,
872             callback_key_count, callback_keys, animation_set);
873 
874     if (!animation_count)
875         return D3DERR_INVALIDCALL;
876 
877     if (!(object = heap_alloc(sizeof(*object))))
878         return E_OUTOFMEMORY;
879 
880     object->ID3DXKeyframedAnimationSet_iface.lpVtbl = &d3dx9_keyframed_animation_vtbl;
881     object->ref = 1;
882     if (!(string = heap_alloc(strlen(name) + 1)))
883     {
884         heap_free(object);
885         return E_OUTOFMEMORY;
886     }
887     strcpy(string, name);
888     object->name = string;
889     object->ticks_per_second = ticks_per_second;
890     object->playback_type = playback_type;
891     object->animation_count = animation_count;
892     object->callback_key_count = callback_key_count;
893     object->callback_keys = callback_keys;
894 
895     *animation_set = &object->ID3DXKeyframedAnimationSet_iface;
896 
897     return D3D_OK;
898 }
899