frame.c 115 KB
Newer Older
1 2 3
/*
 * Implementation of IDirect3DRMFrame Interface
 *
4
 * Copyright 2011, 2012 André Hentschel
5
 * Copyright 2012 Christian Costa
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "d3drm_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(d3drm);

26 27 28 29 30 31
static const struct d3drm_matrix identity =
{
    1.0f, 0.0f, 0.0f, 0.0f,
    0.0f, 1.0f, 0.0f, 0.0f,
    0.0f, 0.0f, 1.0f, 0.0f,
    0.0f, 0.0f, 0.0f, 1.0f,
32 33
};

34 35
struct d3drm_frame_array
{
36 37 38
    IDirect3DRMFrameArray IDirect3DRMFrameArray_iface;
    LONG ref;
    ULONG size;
39
    IDirect3DRMFrame **frames;
40
};
41

42 43
struct d3drm_visual_array
{
44 45 46
    IDirect3DRMVisualArray IDirect3DRMVisualArray_iface;
    LONG ref;
    ULONG size;
47
    IDirect3DRMVisual **visuals;
48
};
49

50 51
struct d3drm_light_array
{
52 53 54
    IDirect3DRMLightArray IDirect3DRMLightArray_iface;
    LONG ref;
    ULONG size;
55
    IDirect3DRMLight **lights;
56
};
57

58 59 60 61 62
static inline struct d3drm_frame *impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface)
{
    return CONTAINING_RECORD(iface, struct d3drm_frame, IDirect3DRMFrame_iface);
}

63
static inline struct d3drm_frame *impl_from_IDirect3DRMFrame2(IDirect3DRMFrame2 *iface)
64
{
65
    return CONTAINING_RECORD(iface, struct d3drm_frame, IDirect3DRMFrame2_iface);
66 67
}

68
static inline struct d3drm_frame *impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
69
{
70
    return CONTAINING_RECORD(iface, struct d3drm_frame, IDirect3DRMFrame3_iface);
71 72
}

73
static inline struct d3drm_frame_array *impl_from_IDirect3DRMFrameArray(IDirect3DRMFrameArray *iface)
74
{
75
    return CONTAINING_RECORD(iface, struct d3drm_frame_array, IDirect3DRMFrameArray_iface);
76 77
}

78
static inline struct d3drm_visual_array *impl_from_IDirect3DRMVisualArray(IDirect3DRMVisualArray *iface)
79
{
80
    return CONTAINING_RECORD(iface, struct d3drm_visual_array, IDirect3DRMVisualArray_iface);
81 82
}

83
static inline struct d3drm_light_array *impl_from_IDirect3DRMLightArray(IDirect3DRMLightArray *iface)
84
{
85
    return CONTAINING_RECORD(iface, struct d3drm_light_array, IDirect3DRMLightArray_iface);
86 87
}

88 89 90 91 92 93 94 95 96 97
static inline struct d3drm_animation *impl_from_IDirect3DRMAnimation(IDirect3DRMAnimation *iface)
{
    return CONTAINING_RECORD(iface, struct d3drm_animation, IDirect3DRMAnimation_iface);
}

static inline struct d3drm_animation *impl_from_IDirect3DRMAnimation2(IDirect3DRMAnimation2 *iface)
{
    return CONTAINING_RECORD(iface, struct d3drm_animation, IDirect3DRMAnimation2_iface);
}

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
static void d3drm_matrix_multiply_affine(struct d3drm_matrix *dst,
        const struct d3drm_matrix *src1, const struct d3drm_matrix *src2)
{
    struct d3drm_matrix tmp;

    tmp._11 = src1->_11 * src2->_11 + src1->_12 * src2->_21 + src1->_13 * src2->_31;
    tmp._12 = src1->_11 * src2->_12 + src1->_12 * src2->_22 + src1->_13 * src2->_32;
    tmp._13 = src1->_11 * src2->_13 + src1->_12 * src2->_23 + src1->_13 * src2->_33;
    tmp._14 = 0.0f;

    tmp._21 = src1->_21 * src2->_11 + src1->_22 * src2->_21 + src1->_23 * src2->_31;
    tmp._22 = src1->_21 * src2->_12 + src1->_22 * src2->_22 + src1->_23 * src2->_32;
    tmp._23 = src1->_21 * src2->_13 + src1->_22 * src2->_23 + src1->_23 * src2->_33;
    tmp._24 = 0.0f;

    tmp._31 = src1->_31 * src2->_11 + src1->_32 * src2->_21 + src1->_33 * src2->_31;
    tmp._32 = src1->_31 * src2->_12 + src1->_32 * src2->_22 + src1->_33 * src2->_32;
    tmp._33 = src1->_31 * src2->_13 + src1->_32 * src2->_23 + src1->_33 * src2->_33;
    tmp._34 = 0.0f;

    tmp._41 = src1->_41 * src2->_11 + src1->_42 * src2->_21 + src1->_43 * src2->_31 + src2->_41;
    tmp._42 = src1->_41 * src2->_12 + src1->_42 * src2->_22 + src1->_43 * src2->_32 + src2->_42;
    tmp._43 = src1->_41 * src2->_13 + src1->_42 * src2->_23 + src1->_43 * src2->_33 + src2->_43;
    tmp._44 = 1.0f;

    *dst = tmp;
}

126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
static void d3drm_matrix_set_rotation(struct d3drm_matrix *matrix, D3DVECTOR *axis, float theta)
{
    float sin_theta, cos_theta, vers_theta;

    D3DRMVectorNormalize(axis);
    sin_theta = sinf(theta);
    cos_theta = cosf(theta);
    vers_theta = 1.0f - cos_theta;

    matrix->_11 = vers_theta * axis->u1.x * axis->u1.x + cos_theta;
    matrix->_21 = vers_theta * axis->u1.x * axis->u2.y - sin_theta * axis->u3.z;
    matrix->_31 = vers_theta * axis->u1.x * axis->u3.z + sin_theta * axis->u2.y;
    matrix->_41 = 0.0f;

    matrix->_12 = vers_theta * axis->u2.y * axis->u1.x + sin_theta * axis->u3.z;
    matrix->_22 = vers_theta * axis->u2.y * axis->u2.y + cos_theta;
    matrix->_32 = vers_theta * axis->u2.y * axis->u3.z - sin_theta * axis->u1.x;
    matrix->_42 = 0.0f;

    matrix->_13 = vers_theta * axis->u3.z * axis->u1.x - sin_theta * axis->u2.y;
    matrix->_23 = vers_theta * axis->u3.z * axis->u2.y + sin_theta * axis->u1.x;
    matrix->_33 = vers_theta * axis->u3.z * axis->u3.z + cos_theta;
    matrix->_43 = 0.0f;

    matrix->_14 = 0.0f;
    matrix->_24 = 0.0f;
    matrix->_34 = 0.0f;
    matrix->_44 = 1.0f;
}

156 157 158 159 160 161 162 163 164 165 166
static void d3drm_vector_transform_affine(D3DVECTOR *dst, const D3DVECTOR *v, const struct d3drm_matrix *m)
{
    D3DVECTOR tmp;

    tmp.u1.x = v->u1.x * m->_11 + v->u2.y * m->_21 + v->u3.z * m->_31 + m->_41;
    tmp.u2.y = v->u1.x * m->_12 + v->u2.y * m->_22 + v->u3.z * m->_32 + m->_42;
    tmp.u3.z = v->u1.x * m->_13 + v->u2.y * m->_23 + v->u3.z * m->_33 + m->_43;

    *dst = tmp;
}

167
static HRESULT WINAPI d3drm_frame_array_QueryInterface(IDirect3DRMFrameArray *iface, REFIID riid, void **out)
168
{
169
    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
170

171 172
    if (IsEqualGUID(riid, &IID_IDirect3DRMFrameArray)
            || IsEqualGUID(riid, &IID_IUnknown))
173
    {
174 175 176
        IDirect3DRMFrameArray_AddRef(iface);
        *out = iface;
        return S_OK;
177 178
    }

179 180 181 182
    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));

    *out = NULL;
    return E_NOINTERFACE;
183 184
}

185
static ULONG WINAPI d3drm_frame_array_AddRef(IDirect3DRMFrameArray *iface)
186
{
187 188
    struct d3drm_frame_array *array = impl_from_IDirect3DRMFrameArray(iface);
    ULONG refcount = InterlockedIncrement(&array->ref);
189

190
    TRACE("%p increasing refcount to %u.\n", iface, refcount);
191

192
    return refcount;
193 194
}

195
static ULONG WINAPI d3drm_frame_array_Release(IDirect3DRMFrameArray *iface)
196
{
197 198
    struct d3drm_frame_array *array = impl_from_IDirect3DRMFrameArray(iface);
    ULONG refcount = InterlockedDecrement(&array->ref);
199
    ULONG i;
200

201
    TRACE("%p decreasing refcount to %u.\n", iface, refcount);
202

203
    if (!refcount)
204
    {
205 206 207 208
        for (i = 0; i < array->size; ++i)
        {
            IDirect3DRMFrame_Release(array->frames[i]);
        }
209 210
        heap_free(array->frames);
        heap_free(array);
211
    }
212

213
    return refcount;
214 215
}

216
static DWORD WINAPI d3drm_frame_array_GetSize(IDirect3DRMFrameArray *iface)
217
{
218
    struct d3drm_frame_array *array = impl_from_IDirect3DRMFrameArray(iface);
219

220
    TRACE("iface %p.\n", iface);
221

222
    return array->size;
223 224
}

225
static HRESULT WINAPI d3drm_frame_array_GetElement(IDirect3DRMFrameArray *iface,
226
        DWORD index, IDirect3DRMFrame **frame)
227
{
228
    struct d3drm_frame_array *array = impl_from_IDirect3DRMFrameArray(iface);
229

230
    TRACE("iface %p, index %u, frame %p.\n", iface, index, frame);
231

232 233
    if (!frame)
        return D3DRMERR_BADVALUE;
234

235 236 237
    if (index >= array->size)
    {
        *frame = NULL;
238
        return D3DRMERR_BADVALUE;
239
    }
240

241 242
    IDirect3DRMFrame_AddRef(array->frames[index]);
    *frame = array->frames[index];
243 244

    return D3DRM_OK;
245 246
}

247
static const struct IDirect3DRMFrameArrayVtbl d3drm_frame_array_vtbl =
248
{
249 250 251 252 253
    d3drm_frame_array_QueryInterface,
    d3drm_frame_array_AddRef,
    d3drm_frame_array_Release,
    d3drm_frame_array_GetSize,
    d3drm_frame_array_GetElement,
254
};
255

256
static struct d3drm_frame_array *d3drm_frame_array_create(unsigned int frame_count, IDirect3DRMFrame3 **frames)
257
{
258
    struct d3drm_frame_array *array;
259
    unsigned int i;
260

261
    if (!(array = heap_alloc_zero(sizeof(*array))))
262
        return NULL;
263

264 265
    array->IDirect3DRMFrameArray_iface.lpVtbl = &d3drm_frame_array_vtbl;
    array->ref = 1;
266 267 268 269
    array->size = frame_count;

    if (frame_count)
    {
270
        if (!(array->frames = heap_calloc(frame_count, sizeof(*array->frames))))
271
        {
272
            heap_free(array);
273 274 275 276 277 278 279 280
            return NULL;
        }

        for (i = 0; i < frame_count; ++i)
        {
            IDirect3DRMFrame3_QueryInterface(frames[i], &IID_IDirect3DRMFrame, (void **)&array->frames[i]);
        }
    }
281

282
    return array;
283 284
}

285
static HRESULT WINAPI d3drm_visual_array_QueryInterface(IDirect3DRMVisualArray *iface, REFIID riid, void **out)
286
{
287
    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
288

289 290
    if (IsEqualGUID(riid, &IID_IDirect3DRMVisualArray)
            || IsEqualGUID(riid, &IID_IUnknown))
291 292
    {
        IDirect3DRMVisualArray_AddRef(iface);
293
        *out = iface;
294 295
        return S_OK;
    }
296

297
    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
298

299
    *out = NULL;
300
    return E_NOINTERFACE;
301 302
}

303
static ULONG WINAPI d3drm_visual_array_AddRef(IDirect3DRMVisualArray *iface)
304
{
305 306
    struct d3drm_visual_array *array = impl_from_IDirect3DRMVisualArray(iface);
    ULONG refcount = InterlockedIncrement(&array->ref);
307

308
    TRACE("%p increasing refcount to %u.\n", iface, refcount);
309

310
    return refcount;
311 312
}

313
static ULONG WINAPI d3drm_visual_array_Release(IDirect3DRMVisualArray *iface)
314
{
315 316
    struct d3drm_visual_array *array = impl_from_IDirect3DRMVisualArray(iface);
    ULONG refcount = InterlockedDecrement(&array->ref);
317
    ULONG i;
318

319
    TRACE("%p decreasing refcount to %u.\n", iface, refcount);
320

321
    if (!refcount)
322
    {
323 324 325 326
        for (i = 0; i < array->size; ++i)
        {
            IDirect3DRMVisual_Release(array->visuals[i]);
        }
327 328
        heap_free(array->visuals);
        heap_free(array);
329
    }
330

331
    return refcount;
332 333
}

334
static DWORD WINAPI d3drm_visual_array_GetSize(IDirect3DRMVisualArray *iface)
335
{
336
    struct d3drm_visual_array *array = impl_from_IDirect3DRMVisualArray(iface);
337

338
    TRACE("iface %p.\n", iface);
339

340
    return array->size;
341 342
}

343
static HRESULT WINAPI d3drm_visual_array_GetElement(IDirect3DRMVisualArray *iface,
344
        DWORD index, IDirect3DRMVisual **visual)
345
{
346
    struct d3drm_visual_array *array = impl_from_IDirect3DRMVisualArray(iface);
347

348
    TRACE("iface %p, index %u, visual %p.\n", iface, index, visual);
349

350 351
    if (!visual)
        return D3DRMERR_BADVALUE;
352

353 354 355
    if (index >= array->size)
    {
        *visual = NULL;
356
        return D3DRMERR_BADVALUE;
357
    }
358

359 360
    IDirect3DRMVisual_AddRef(array->visuals[index]);
    *visual = array->visuals[index];
361 362

    return D3DRM_OK;
363 364
}

365
static const struct IDirect3DRMVisualArrayVtbl d3drm_visual_array_vtbl =
366
{
367 368 369 370 371
    d3drm_visual_array_QueryInterface,
    d3drm_visual_array_AddRef,
    d3drm_visual_array_Release,
    d3drm_visual_array_GetSize,
    d3drm_visual_array_GetElement,
372
};
373

374
static struct d3drm_visual_array *d3drm_visual_array_create(unsigned int visual_count, IDirect3DRMVisual **visuals)
375
{
376
    struct d3drm_visual_array *array;
377
    unsigned int i;
378

379
    if (!(array = heap_alloc_zero(sizeof(*array))))
380
        return NULL;
381

382 383
    array->IDirect3DRMVisualArray_iface.lpVtbl = &d3drm_visual_array_vtbl;
    array->ref = 1;
384 385 386 387
    array->size = visual_count;

    if (visual_count)
    {
388
        if (!(array->visuals = heap_calloc(visual_count, sizeof(*array->visuals))))
389
        {
390
            heap_free(array);
391 392 393 394 395 396 397 398 399
            return NULL;
        }

        for (i = 0; i < visual_count; ++i)
        {
            array->visuals[i] = visuals[i];
            IDirect3DRMVisual_AddRef(array->visuals[i]);
        }
    }
400

401
    return array;
402 403
}

404
static HRESULT WINAPI d3drm_light_array_QueryInterface(IDirect3DRMLightArray *iface, REFIID riid, void **out)
405
{
406
    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
407

408 409
    if (IsEqualGUID(riid, &IID_IDirect3DRMLightArray)
            || IsEqualGUID(riid, &IID_IUnknown))
410
    {
411 412 413
        IDirect3DRMLightArray_AddRef(iface);
        *out = iface;
        return S_OK;
414 415
    }

416 417 418 419
    WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));

    *out = NULL;
    return E_NOINTERFACE;
420 421
}

422
static ULONG WINAPI d3drm_light_array_AddRef(IDirect3DRMLightArray *iface)
423
{
424 425
    struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
    ULONG refcount = InterlockedIncrement(&array->ref);
426

427
    TRACE("%p increasing refcount to %u.\n", iface, refcount);
428

429
    return refcount;
430 431
}

432
static ULONG WINAPI d3drm_light_array_Release(IDirect3DRMLightArray *iface)
433
{
434 435
    struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
    ULONG refcount = InterlockedDecrement(&array->ref);
436
    ULONG i;
437

438
    TRACE("%p decreasing refcount to %u.\n", iface, refcount);
439

440
    if (!refcount)
441
    {
442 443 444 445
        for (i = 0; i < array->size; ++i)
        {
            IDirect3DRMLight_Release(array->lights[i]);
        }
446 447
        heap_free(array->lights);
        heap_free(array);
448 449
    }

450
    return refcount;
451 452
}

453
static DWORD WINAPI d3drm_light_array_GetSize(IDirect3DRMLightArray *iface)
454
{
455
    struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
456

457
    TRACE("iface %p.\n", iface);
458

459
    return array->size;
460 461
}

462
static HRESULT WINAPI d3drm_light_array_GetElement(IDirect3DRMLightArray *iface,
463
        DWORD index, IDirect3DRMLight **light)
464
{
465
    struct d3drm_light_array *array = impl_from_IDirect3DRMLightArray(iface);
466

467
    TRACE("iface %p, index %u, light %p.\n", iface, index, light);
468

469 470 471
    if (!light)
        return D3DRMERR_BADVALUE;

472 473 474
    if (index >= array->size)
    {
        *light = NULL;
475
        return D3DRMERR_BADVALUE;
476
    }
477

478 479
    IDirect3DRMLight_AddRef(array->lights[index]);
    *light = array->lights[index];
480 481

    return D3DRM_OK;
482 483
}

484
static const struct IDirect3DRMLightArrayVtbl d3drm_light_array_vtbl =
485
{
486 487 488 489 490
    d3drm_light_array_QueryInterface,
    d3drm_light_array_AddRef,
    d3drm_light_array_Release,
    d3drm_light_array_GetSize,
    d3drm_light_array_GetElement,
491
};
492

493
static struct d3drm_light_array *d3drm_light_array_create(unsigned int light_count, IDirect3DRMLight **lights)
494
{
495
    struct d3drm_light_array *array;
496
    unsigned int i;
497

498
    if (!(array = heap_alloc_zero(sizeof(*array))))
499
        return NULL;
500

501 502
    array->IDirect3DRMLightArray_iface.lpVtbl = &d3drm_light_array_vtbl;
    array->ref = 1;
503 504 505 506
    array->size = light_count;

    if (light_count)
    {
507
        if (!(array->lights = heap_calloc(light_count, sizeof(*array->lights))))
508
        {
509
            heap_free(array);
510 511 512 513 514 515 516 517 518
            return NULL;
        }

        for (i = 0; i < light_count; ++i)
        {
            array->lights[i] = lights[i];
            IDirect3DRMLight_AddRef(array->lights[i]);
        }
    }
519

520
    return array;
521 522
}

523
static HRESULT WINAPI d3drm_frame3_QueryInterface(IDirect3DRMFrame3 *iface, REFIID riid, void **out)
524
{
525 526 527 528
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);

    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);

529
    if (IsEqualGUID(riid, &IID_IDirect3DRMFrame)
530 531 532
            || IsEqualGUID(riid, &IID_IDirect3DRMObject)
            || IsEqualGUID(riid, &IID_IDirect3DRMVisual)
            || IsEqualGUID(riid, &IID_IUnknown))
533 534 535 536
    {
        *out = &frame->IDirect3DRMFrame_iface;
    }
    else if (IsEqualGUID(riid, &IID_IDirect3DRMFrame2))
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
    {
        *out = &frame->IDirect3DRMFrame2_iface;
    }
    else if (IsEqualGUID(riid, &IID_IDirect3DRMFrame3))
    {
        *out = &frame->IDirect3DRMFrame3_iface;
    }
    else
    {
        *out = NULL;
        WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
        return CLASS_E_CLASSNOTAVAILABLE;
    }

    IUnknown_AddRef((IUnknown *)*out);
    return S_OK;
553 554
}

555 556 557 558 559 560 561 562 563
static HRESULT WINAPI d3drm_frame2_QueryInterface(IDirect3DRMFrame2 *iface, REFIID riid, void **out)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);

    return d3drm_frame3_QueryInterface(&frame->IDirect3DRMFrame3_iface, riid, out);
}

564 565 566 567 568 569 570 571 572
static HRESULT WINAPI d3drm_frame1_QueryInterface(IDirect3DRMFrame *iface, REFIID riid, void **out)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);

    return d3drm_frame3_QueryInterface(&frame->IDirect3DRMFrame3_iface, riid, out);
}

573
static ULONG WINAPI d3drm_frame3_AddRef(IDirect3DRMFrame3 *iface)
574
{
575
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
576
    ULONG refcount = InterlockedIncrement(&frame->ref);
577

578
    TRACE("%p increasing refcount to %u.\n", iface, refcount);
579

580
    return refcount;
581 582
}

583 584 585 586 587 588 589 590 591
static ULONG WINAPI d3drm_frame2_AddRef(IDirect3DRMFrame2 *iface)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_frame3_AddRef(&frame->IDirect3DRMFrame3_iface);
}

592 593 594 595 596 597 598 599 600
static ULONG WINAPI d3drm_frame1_AddRef(IDirect3DRMFrame *iface)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_frame3_AddRef(&frame->IDirect3DRMFrame3_iface);
}

601
static ULONG WINAPI d3drm_frame3_Release(IDirect3DRMFrame3 *iface)
602
{
603
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
604 605
    ULONG refcount = InterlockedDecrement(&frame->ref);
    ULONG i;
606

607
    TRACE("%p decreasing refcount to %u.\n", iface, refcount);
608

609 610
    if (!refcount)
    {
611
        d3drm_object_cleanup((IDirect3DRMObject *)&frame->IDirect3DRMFrame_iface, &frame->obj);
612 613 614 615
        for (i = 0; i < frame->nb_children; ++i)
        {
            IDirect3DRMFrame3_Release(frame->children[i]);
        }
616
        heap_free(frame->children);
617 618 619 620
        for (i = 0; i < frame->nb_visuals; ++i)
        {
            IDirect3DRMVisual_Release(frame->visuals[i]);
        }
621
        heap_free(frame->visuals);
622 623 624 625
        for (i = 0; i < frame->nb_lights; ++i)
        {
            IDirect3DRMLight_Release(frame->lights[i]);
        }
626
        heap_free(frame->lights);
627
        IDirect3DRM_Release(frame->d3drm);
628
        heap_free(frame);
629 630 631
    }

    return refcount;
632 633
}

634 635 636 637 638 639 640 641 642
static ULONG WINAPI d3drm_frame2_Release(IDirect3DRMFrame2 *iface)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_frame3_Release(&frame->IDirect3DRMFrame3_iface);
}

643 644 645 646 647 648 649 650 651
static ULONG WINAPI d3drm_frame1_Release(IDirect3DRMFrame *iface)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_frame3_Release(&frame->IDirect3DRMFrame3_iface);
}

652
static HRESULT WINAPI d3drm_frame3_Clone(IDirect3DRMFrame3 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
653
        IUnknown *outer, REFIID iid, void **out)
654
{
Henri Verbeet's avatar
Henri Verbeet committed
655
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);
656 657 658 659

    return E_NOTIMPL;
}

660 661 662 663 664 665 666 667
static HRESULT WINAPI d3drm_frame2_Clone(IDirect3DRMFrame2 *iface,
        IUnknown *outer, REFIID iid, void **out)
{
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);

    return E_NOTIMPL;
}

668 669 670 671 672 673 674 675
static HRESULT WINAPI d3drm_frame1_Clone(IDirect3DRMFrame *iface,
        IUnknown *outer, REFIID iid, void **out)
{
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);

    return E_NOTIMPL;
}

676
static HRESULT WINAPI d3drm_frame3_AddDestroyCallback(IDirect3DRMFrame3 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
677
        D3DRMOBJECTCALLBACK cb, void *ctx)
678
{
679
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
680

681 682 683
    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return d3drm_object_add_destroy_callback(&frame->obj, cb, ctx);
684 685
}

686 687 688
static HRESULT WINAPI d3drm_frame2_AddDestroyCallback(IDirect3DRMFrame2 *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
689
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
690

691 692 693
    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return IDirect3DRMFrame3_AddDestroyCallback(&frame->IDirect3DRMFrame3_iface, cb, ctx);
694 695
}

696 697 698
static HRESULT WINAPI d3drm_frame1_AddDestroyCallback(IDirect3DRMFrame *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
699
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
700

701 702 703
    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return IDirect3DRMFrame3_AddDestroyCallback(&frame->IDirect3DRMFrame3_iface, cb, ctx);
704 705
}

706
static HRESULT WINAPI d3drm_frame3_DeleteDestroyCallback(IDirect3DRMFrame3 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
707
        D3DRMOBJECTCALLBACK cb, void *ctx)
708
{
709
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
710

711 712 713
    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return d3drm_object_delete_destroy_callback(&frame->obj, cb, ctx);
714 715
}

716 717 718
static HRESULT WINAPI d3drm_frame2_DeleteDestroyCallback(IDirect3DRMFrame2 *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
719
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
720

721 722 723
    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return IDirect3DRMFrame3_DeleteDestroyCallback(&frame->IDirect3DRMFrame3_iface, cb, ctx);
724 725
}

726 727 728
static HRESULT WINAPI d3drm_frame1_DeleteDestroyCallback(IDirect3DRMFrame *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
729
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
730

731 732 733
    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return IDirect3DRMFrame3_DeleteDestroyCallback(&frame->IDirect3DRMFrame3_iface, cb, ctx);
734 735
}

736
static HRESULT WINAPI d3drm_frame3_SetAppData(IDirect3DRMFrame3 *iface, DWORD data)
737
{
738
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
739

740 741 742 743 744
    TRACE("iface %p, data %#x.\n", iface, data);

    frame->obj.appdata = data;

    return D3DRM_OK;
745 746
}

747 748
static HRESULT WINAPI d3drm_frame2_SetAppData(IDirect3DRMFrame2 *iface, DWORD data)
{
749
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
750

751 752 753
    TRACE("iface %p, data %#x.\n", iface, data);

    return d3drm_frame3_SetAppData(&frame->IDirect3DRMFrame3_iface, data);
754 755
}

756 757
static HRESULT WINAPI d3drm_frame1_SetAppData(IDirect3DRMFrame *iface, DWORD data)
{
758
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
759

760 761 762
    TRACE("iface %p, data %#x.\n", iface, data);

    return d3drm_frame3_SetAppData(&frame->IDirect3DRMFrame3_iface, data);
763 764
}

765
static DWORD WINAPI d3drm_frame3_GetAppData(IDirect3DRMFrame3 *iface)
766
{
767
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
768

769 770 771
    TRACE("iface %p.\n", iface);

    return frame->obj.appdata;
772 773
}

774 775
static DWORD WINAPI d3drm_frame2_GetAppData(IDirect3DRMFrame2 *iface)
{
776
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
777

778 779 780
    TRACE("iface %p.\n", iface);

    return d3drm_frame3_GetAppData(&frame->IDirect3DRMFrame3_iface);
781 782
}

783 784
static DWORD WINAPI d3drm_frame1_GetAppData(IDirect3DRMFrame *iface)
{
785 786 787
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p.\n", iface);
788

789
    return d3drm_frame3_GetAppData(&frame->IDirect3DRMFrame3_iface);
790 791
}

792
static HRESULT WINAPI d3drm_frame3_SetName(IDirect3DRMFrame3 *iface, const char *name)
793
{
794
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
795

796 797 798
    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_object_set_name(&frame->obj, name);
799 800
}

801 802
static HRESULT WINAPI d3drm_frame2_SetName(IDirect3DRMFrame2 *iface, const char *name)
{
803
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
804

805 806 807
    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_frame3_SetName(&frame->IDirect3DRMFrame3_iface, name);
808 809
}

810 811
static HRESULT WINAPI d3drm_frame1_SetName(IDirect3DRMFrame *iface, const char *name)
{
812
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
813

814 815 816
    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_frame3_SetName(&frame->IDirect3DRMFrame3_iface, name);
817 818
}

819
static HRESULT WINAPI d3drm_frame3_GetName(IDirect3DRMFrame3 *iface, DWORD *size, char *name)
820
{
821
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
822

823 824 825
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_object_get_name(&frame->obj, size, name);
826 827
}

828 829
static HRESULT WINAPI d3drm_frame2_GetName(IDirect3DRMFrame2 *iface, DWORD *size, char *name)
{
830
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
831

832 833 834
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_frame3_GetName(&frame->IDirect3DRMFrame3_iface, size, name);
835 836
}

837 838
static HRESULT WINAPI d3drm_frame1_GetName(IDirect3DRMFrame *iface, DWORD *size, char *name)
{
839
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
840

841 842 843
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_frame3_GetName(&frame->IDirect3DRMFrame3_iface, size, name);
844 845
}

846
static HRESULT WINAPI d3drm_frame3_GetClassName(IDirect3DRMFrame3 *iface, DWORD *size, char *name)
847
{
848
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
849

850
    TRACE("iface %p, size %p, name %p.\n", iface, size, name);
851

852
    return d3drm_object_get_class_name(&frame->obj, size, name);
853 854
}

855 856 857 858 859 860 861 862 863
static HRESULT WINAPI d3drm_frame2_GetClassName(IDirect3DRMFrame2 *iface, DWORD *size, char *name)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_frame3_GetClassName(&frame->IDirect3DRMFrame3_iface, size, name);
}

864 865 866 867 868 869 870 871 872
static HRESULT WINAPI d3drm_frame1_GetClassName(IDirect3DRMFrame *iface, DWORD *size, char *name)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_frame3_GetClassName(&frame->IDirect3DRMFrame3_iface, size, name);
}

873
static HRESULT WINAPI d3drm_frame3_AddChild(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 *child)
874
{
875
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
876
    struct d3drm_frame *child_obj = unsafe_impl_from_IDirect3DRMFrame3(child);
877

878
    TRACE("iface %p, child %p.\n", iface, child);
879

880
    if (!child_obj)
881 882
        return D3DRMERR_BADOBJECT;

883 884 885 886 887 888 889
    if (child_obj->parent)
    {
        IDirect3DRMFrame3* parent = &child_obj->parent->IDirect3DRMFrame3_iface;

        if (parent == iface)
        {
            /* Passed frame is already a child so return success */
890
            return D3DRM_OK;
891 892 893 894 895 896 897
        }
        else
        {
            /* Remove parent and continue */
            IDirect3DRMFrame3_DeleteChild(parent, child);
        }
    }
898

899 900 901
    if (!d3drm_array_reserve((void **)&frame->children, &frame->children_size,
            frame->nb_children + 1, sizeof(*frame->children)))
        return E_OUTOFMEMORY;
902

903
    frame->children[frame->nb_children++] = child;
904
    IDirect3DRMFrame3_AddRef(child);
905
    child_obj->parent = frame;
906 907

    return D3DRM_OK;
908 909
}

910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927
static HRESULT WINAPI d3drm_frame2_AddChild(IDirect3DRMFrame2 *iface, IDirect3DRMFrame *child)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
    IDirect3DRMFrame3 *child3;
    HRESULT hr;

    TRACE("iface %p, child %p.\n", iface, child);

    if (!child)
        return D3DRMERR_BADOBJECT;
    hr = IDirect3DRMFrame_QueryInterface(child, &IID_IDirect3DRMFrame3, (void **)&child3);
    if (hr != S_OK)
        return D3DRMERR_BADOBJECT;
    IDirect3DRMFrame_Release(child);

    return d3drm_frame3_AddChild(&frame->IDirect3DRMFrame3_iface, child3);
}

928 929 930 931 932 933 934 935 936 937 938 939 940
static HRESULT WINAPI d3drm_frame1_AddChild(IDirect3DRMFrame *iface, IDirect3DRMFrame *child)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
    struct d3drm_frame *child_frame = unsafe_impl_from_IDirect3DRMFrame(child);

    TRACE("iface %p, child %p.\n", iface, child);

    if (!child_frame)
        return D3DRMERR_BADOBJECT;

    return d3drm_frame3_AddChild(&frame->IDirect3DRMFrame3_iface, &child_frame->IDirect3DRMFrame3_iface);
}

941
static HRESULT WINAPI d3drm_frame3_AddLight(IDirect3DRMFrame3 *iface, IDirect3DRMLight *light)
942
{
943
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
944
    ULONG i;
945

946
    TRACE("iface %p, light %p.\n", iface, light);
947

948 949 950 951
    if (!light)
        return D3DRMERR_BADOBJECT;

    /* Check if already existing and return gracefully without increasing ref count */
952 953
    for (i = 0; i < frame->nb_lights; i++)
        if (frame->lights[i] == light)
954 955
            return D3DRM_OK;

956 957 958
    if (!d3drm_array_reserve((void **)&frame->lights, &frame->lights_size,
            frame->nb_lights + 1, sizeof(*frame->lights)))
        return E_OUTOFMEMORY;
959

960
    frame->lights[frame->nb_lights++] = light;
961 962 963
    IDirect3DRMLight_AddRef(light);

    return D3DRM_OK;
964 965
}

966 967 968 969 970 971 972 973 974
static HRESULT WINAPI d3drm_frame2_AddLight(IDirect3DRMFrame2 *iface, IDirect3DRMLight *light)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, light %p.\n", iface, light);

    return d3drm_frame3_AddLight(&frame->IDirect3DRMFrame3_iface, light);
}

975 976 977 978 979 980 981 982 983
static HRESULT WINAPI d3drm_frame1_AddLight(IDirect3DRMFrame *iface, IDirect3DRMLight *light)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, light %p.\n", iface, light);

    return d3drm_frame3_AddLight(&frame->IDirect3DRMFrame3_iface, light);
}

984
static HRESULT WINAPI d3drm_frame3_AddMoveCallback(IDirect3DRMFrame3 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
985
        D3DRMFRAME3MOVECALLBACK cb, void *ctx, DWORD flags)
986
{
Henri Verbeet's avatar
Henri Verbeet committed
987
    FIXME("iface %p, cb %p, ctx %p flags %#x stub!\n", iface, cb, ctx, flags);
988 989 990 991

    return E_NOTIMPL;
}

992 993 994 995 996 997 998 999
static HRESULT WINAPI d3drm_frame2_AddMoveCallback(IDirect3DRMFrame2 *iface,
        D3DRMFRAMEMOVECALLBACK cb, void *ctx)
{
    FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);

    return E_NOTIMPL;
}

1000 1001 1002 1003 1004 1005 1006 1007
static HRESULT WINAPI d3drm_frame1_AddMoveCallback(IDirect3DRMFrame *iface,
        D3DRMFRAMEMOVECALLBACK cb, void *ctx)
{
    FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);

    return E_NOTIMPL;
}

1008 1009
static HRESULT WINAPI d3drm_frame3_AddTransform(IDirect3DRMFrame3 *iface,
        D3DRMCOMBINETYPE type, D3DRMMATRIX4D matrix)
1010
{
1011
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1012
    const struct d3drm_matrix *m = d3drm_matrix(matrix);
1013

1014
    TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);
1015

1016 1017 1018
    if (m->_14 != 0.0f || m->_24 != 0.0f || m->_34 != 0.0f || m->_44 != 1.0f)
        return D3DRMERR_BADVALUE;

1019 1020 1021
    switch (type)
    {
        case D3DRMCOMBINE_REPLACE:
1022
            frame->transform = *m;
1023 1024 1025
            break;

        case D3DRMCOMBINE_BEFORE:
1026
            d3drm_matrix_multiply_affine(&frame->transform, m, &frame->transform);
1027 1028 1029
            break;

        case D3DRMCOMBINE_AFTER:
1030
            d3drm_matrix_multiply_affine(&frame->transform, &frame->transform, m);
1031 1032 1033
            break;

        default:
1034
            FIXME("Unhandled type %#x.\n", type);
1035 1036 1037 1038
            return D3DRMERR_BADVALUE;
    }

    return S_OK;
1039 1040
}

1041 1042 1043 1044 1045 1046 1047 1048 1049 1050
static HRESULT WINAPI d3drm_frame2_AddTransform(IDirect3DRMFrame2 *iface,
        D3DRMCOMBINETYPE type, D3DRMMATRIX4D matrix)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);

    return d3drm_frame3_AddTransform(&frame->IDirect3DRMFrame3_iface, type, matrix);
}

1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
static HRESULT WINAPI d3drm_frame1_AddTransform(IDirect3DRMFrame *iface,
        D3DRMCOMBINETYPE type, D3DRMMATRIX4D matrix)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);

    return d3drm_frame3_AddTransform(&frame->IDirect3DRMFrame3_iface, type, matrix);
}

1061 1062
static HRESULT WINAPI d3drm_frame3_AddTranslation(IDirect3DRMFrame3 *iface,
        D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
1063
{
1064
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1065

1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094
    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);

    switch (type)
    {
        case D3DRMCOMBINE_REPLACE:
            frame->transform = identity;
            frame->transform._41 = x;
            frame->transform._42 = y;
            frame->transform._43 = z;
            break;

        case D3DRMCOMBINE_BEFORE:
            frame->transform._41 += x * frame->transform._11 + y * frame->transform._21 + z * frame->transform._31;
            frame->transform._42 += x * frame->transform._12 + y * frame->transform._22 + z * frame->transform._32;
            frame->transform._43 += x * frame->transform._13 + y * frame->transform._23 + z * frame->transform._33;
            break;

        case D3DRMCOMBINE_AFTER:
            frame->transform._41 += x;
            frame->transform._42 += y;
            frame->transform._43 += z;
            break;

        default:
            FIXME("Unhandled type %#x.\n", type);
            return D3DRMERR_BADVALUE;
    }

    return D3DRM_OK;
1095 1096
}

1097 1098 1099
static HRESULT WINAPI d3drm_frame2_AddTranslation(IDirect3DRMFrame2 *iface,
        D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
1100
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
1101

1102 1103 1104
    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);

    return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
1105 1106
}

1107 1108 1109
static HRESULT WINAPI d3drm_frame1_AddTranslation(IDirect3DRMFrame *iface,
        D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
1110
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
1111

1112 1113 1114
    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z);

    return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z);
1115 1116
}

1117 1118
static HRESULT WINAPI d3drm_frame3_AddScale(IDirect3DRMFrame3 *iface,
        D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
1119
{
1120
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1121

1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165
    TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);

    switch (type)
    {
        case D3DRMCOMBINE_REPLACE:
            frame->transform = identity;
            frame->transform._11 = sx;
            frame->transform._22 = sy;
            frame->transform._33 = sz;
            break;

        case D3DRMCOMBINE_BEFORE:
            frame->transform._11 *= sx;
            frame->transform._12 *= sx;
            frame->transform._13 *= sx;
            frame->transform._21 *= sy;
            frame->transform._22 *= sy;
            frame->transform._23 *= sy;
            frame->transform._31 *= sz;
            frame->transform._32 *= sz;
            frame->transform._33 *= sz;
            break;

        case D3DRMCOMBINE_AFTER:
            frame->transform._11 *= sx;
            frame->transform._12 *= sy;
            frame->transform._13 *= sz;
            frame->transform._21 *= sx;
            frame->transform._22 *= sy;
            frame->transform._23 *= sz;
            frame->transform._31 *= sx;
            frame->transform._32 *= sy;
            frame->transform._33 *= sz;
            frame->transform._41 *= sx;
            frame->transform._42 *= sy;
            frame->transform._43 *= sz;
            break;

        default:
            FIXME("Unhandled type %#x.\n", type);
            return D3DRMERR_BADVALUE;
    }

    return D3DRM_OK;
1166 1167
}

1168 1169 1170
static HRESULT WINAPI d3drm_frame2_AddScale(IDirect3DRMFrame2 *iface,
        D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
{
1171
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
1172

1173 1174 1175
    TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);

    return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz);
1176 1177
}

1178 1179 1180
static HRESULT WINAPI d3drm_frame1_AddScale(IDirect3DRMFrame *iface,
        D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz)
{
1181
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
1182

1183 1184 1185
    TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz);

    return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz);
1186 1187
}

1188 1189
static HRESULT WINAPI d3drm_frame3_AddRotation(IDirect3DRMFrame3 *iface,
        D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
1190
{
1191 1192 1193
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
    struct d3drm_matrix m;
    D3DVECTOR axis;
1194

1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222
    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);

    axis.u1.x = x;
    axis.u2.y = y;
    axis.u3.z = z;

    switch (type)
    {
        case D3DRMCOMBINE_REPLACE:
            d3drm_matrix_set_rotation(&frame->transform, &axis, theta);
            break;

        case D3DRMCOMBINE_BEFORE:
            d3drm_matrix_set_rotation(&m, &axis, theta);
            d3drm_matrix_multiply_affine(&frame->transform, &m, &frame->transform);
            break;

        case D3DRMCOMBINE_AFTER:
            d3drm_matrix_set_rotation(&m, &axis, theta);
            d3drm_matrix_multiply_affine(&frame->transform, &frame->transform, &m);
            break;

        default:
            FIXME("Unhandled type %#x.\n", type);
            return D3DRMERR_BADVALUE;
    }

    return D3DRM_OK;
1223 1224
}

1225 1226 1227
static HRESULT WINAPI d3drm_frame2_AddRotation(IDirect3DRMFrame2 *iface,
        D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
1228
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
1229

1230 1231 1232
    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);

    return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta);
1233 1234
}

1235 1236 1237
static HRESULT WINAPI d3drm_frame1_AddRotation(IDirect3DRMFrame *iface,
        D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
1238
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
1239

1240 1241 1242
    TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta);

    return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta);
1243 1244
}

1245
static HRESULT WINAPI d3drm_frame3_AddVisual(IDirect3DRMFrame3 *iface, IUnknown *visual)
1246
{
1247
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1248
    ULONG i;
1249

Henri Verbeet's avatar
Henri Verbeet committed
1250
    TRACE("iface %p, visual %p.\n", iface, visual);
1251

Henri Verbeet's avatar
Henri Verbeet committed
1252
    if (!visual)
1253 1254 1255
        return D3DRMERR_BADOBJECT;

    /* Check if already existing and return gracefully without increasing ref count */
1256 1257
    for (i = 0; i < frame->nb_visuals; i++)
        if (frame->visuals[i] == (IDirect3DRMVisual *)visual)
1258 1259
            return D3DRM_OK;

1260 1261 1262
    if (!d3drm_array_reserve((void **)&frame->visuals, &frame->visuals_size,
            frame->nb_visuals + 1, sizeof(*frame->visuals)))
        return E_OUTOFMEMORY;
1263

1264
    frame->visuals[frame->nb_visuals++] = (IDirect3DRMVisual *)visual;
Henri Verbeet's avatar
Henri Verbeet committed
1265
    IDirect3DRMVisual_AddRef(visual);
1266 1267

    return D3DRM_OK;
1268 1269
}

1270 1271 1272 1273 1274 1275 1276 1277 1278
static HRESULT WINAPI d3drm_frame2_AddVisual(IDirect3DRMFrame2 *iface, IDirect3DRMVisual *visual)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, visual %p.\n", iface, visual);

    return d3drm_frame3_AddVisual(&frame->IDirect3DRMFrame3_iface, (IUnknown *)visual);
}

1279 1280 1281 1282 1283 1284 1285 1286 1287
static HRESULT WINAPI d3drm_frame1_AddVisual(IDirect3DRMFrame *iface, IDirect3DRMVisual *visual)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, visual %p.\n", iface, visual);

    return d3drm_frame3_AddVisual(&frame->IDirect3DRMFrame3_iface, (IUnknown *)visual);
}

1288
static HRESULT WINAPI d3drm_frame3_GetChildren(IDirect3DRMFrame3 *iface, IDirect3DRMFrameArray **children)
1289
{
1290
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1291
    struct d3drm_frame_array *array;
1292

1293
    TRACE("iface %p, children %p.\n", iface, children);
1294

1295 1296 1297
    if (!children)
        return D3DRMERR_BADVALUE;

1298
    if (!(array = d3drm_frame_array_create(frame->nb_children, frame->children)))
1299
        return E_OUTOFMEMORY;
1300

1301 1302
    *children = &array->IDirect3DRMFrameArray_iface;

1303
    return D3DRM_OK;
1304 1305
}

1306 1307 1308 1309 1310 1311 1312 1313 1314
static HRESULT WINAPI d3drm_frame2_GetChildren(IDirect3DRMFrame2 *iface, IDirect3DRMFrameArray **children)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, children %p.\n", iface, children);

    return d3drm_frame3_GetChildren(&frame->IDirect3DRMFrame3_iface, children);
}

1315 1316 1317 1318 1319 1320 1321 1322 1323
static HRESULT WINAPI d3drm_frame1_GetChildren(IDirect3DRMFrame *iface, IDirect3DRMFrameArray **children)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, children %p.\n", iface, children);

    return d3drm_frame3_GetChildren(&frame->IDirect3DRMFrame3_iface, children);
}

1324
static D3DCOLOR WINAPI d3drm_frame3_GetColor(IDirect3DRMFrame3 *iface)
1325
{
1326
    FIXME("iface %p stub!\n", iface);
1327 1328 1329 1330

    return 0;
}

1331 1332 1333 1334 1335 1336 1337
static D3DCOLOR WINAPI d3drm_frame2_GetColor(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return 0;
}

1338 1339 1340 1341 1342 1343 1344
static D3DCOLOR WINAPI d3drm_frame1_GetColor(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return 0;
}

1345
static HRESULT WINAPI d3drm_frame3_GetLights(IDirect3DRMFrame3 *iface, IDirect3DRMLightArray **lights)
1346
{
1347
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1348
    struct d3drm_light_array *array;
1349

1350
    TRACE("iface %p, lights %p.\n", iface, lights);
1351

1352 1353 1354
    if (!lights)
        return D3DRMERR_BADVALUE;

1355
    if (!(array = d3drm_light_array_create(frame->nb_lights, frame->lights)))
1356
        return E_OUTOFMEMORY;
1357

1358 1359
    *lights = &array->IDirect3DRMLightArray_iface;

1360
    return D3DRM_OK;
1361 1362
}

1363 1364 1365 1366 1367 1368 1369 1370 1371
static HRESULT WINAPI d3drm_frame2_GetLights(IDirect3DRMFrame2 *iface, IDirect3DRMLightArray **lights)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, lights %p.\n", iface, lights);

    return d3drm_frame3_GetLights(&frame->IDirect3DRMFrame3_iface, lights);
}

1372 1373 1374 1375 1376 1377 1378 1379 1380
static HRESULT WINAPI d3drm_frame1_GetLights(IDirect3DRMFrame *iface, IDirect3DRMLightArray **lights)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, lights %p.\n", iface, lights);

    return d3drm_frame3_GetLights(&frame->IDirect3DRMFrame3_iface, lights);
}

1381
static D3DRMMATERIALMODE WINAPI d3drm_frame3_GetMaterialMode(IDirect3DRMFrame3 *iface)
1382
{
1383
    FIXME("iface %p stub!\n", iface);
1384 1385 1386 1387

    return D3DRMMATERIAL_FROMPARENT;
}

1388 1389 1390 1391 1392 1393 1394
static D3DRMMATERIALMODE WINAPI d3drm_frame2_GetMaterialMode(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMMATERIAL_FROMPARENT;
}

1395 1396 1397 1398 1399 1400 1401
static D3DRMMATERIALMODE WINAPI d3drm_frame1_GetMaterialMode(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMMATERIAL_FROMPARENT;
}

1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
static HRESULT WINAPI d3drm_frame3_GetParent(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 **parent)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);

    TRACE("iface %p, parent %p.\n", iface, parent);

    if (!parent)
        return D3DRMERR_BADVALUE;

    if (frame->parent)
    {
        *parent = &frame->parent->IDirect3DRMFrame3_iface;
        IDirect3DRMFrame_AddRef(*parent);
    }
    else
    {
        *parent = NULL;
    }

    return D3DRM_OK;
}

static HRESULT WINAPI d3drm_frame2_GetParent(IDirect3DRMFrame2 *iface, IDirect3DRMFrame **parent)
1425
{
1426
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
1427

1428
    TRACE("iface %p, parent %p.\n", iface, parent);
1429

1430
    if (!parent)
1431 1432
        return D3DRMERR_BADVALUE;

1433
    if (frame->parent)
1434
    {
1435
        *parent = &frame->parent->IDirect3DRMFrame_iface;
1436
        IDirect3DRMFrame_AddRef(*parent);
1437 1438 1439
    }
    else
    {
1440
        *parent = NULL;
1441 1442 1443
    }

    return D3DRM_OK;
1444 1445
}

1446 1447 1448 1449 1450 1451 1452 1453 1454
static HRESULT WINAPI d3drm_frame1_GetParent(IDirect3DRMFrame *iface, IDirect3DRMFrame **parent)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, parent %p.\n", iface, parent);

    return d3drm_frame2_GetParent(&frame->IDirect3DRMFrame2_iface, parent);
}

1455 1456
static HRESULT WINAPI d3drm_frame3_GetPosition(IDirect3DRMFrame3 *iface,
        IDirect3DRMFrame3 *reference, D3DVECTOR *position)
1457
{
1458
    FIXME("iface %p, reference %p, position %p stub!\n", iface, reference, position);
1459 1460 1461 1462

    return E_NOTIMPL;
}

1463 1464 1465 1466 1467 1468 1469 1470
static HRESULT WINAPI d3drm_frame2_GetPosition(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *position)
{
    FIXME("iface %p, reference %p, position %p stub!\n", iface, reference, position);

    return E_NOTIMPL;
}

1471 1472 1473 1474 1475 1476 1477 1478 1479
static HRESULT WINAPI d3drm_frame1_GetPosition(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *position)
{
    FIXME("iface %p, reference %p, position %p stub!\n", iface, reference, position);

    return E_NOTIMPL;
}


1480 1481
static HRESULT WINAPI d3drm_frame3_GetRotation(IDirect3DRMFrame3 *iface,
        IDirect3DRMFrame3 *reference, D3DVECTOR *axis, D3DVALUE *theta)
1482
{
1483
    FIXME("iface %p, reference %p, axis %p, theta %p stub!\n", iface, reference, axis, theta);
1484 1485 1486 1487

    return E_NOTIMPL;
}

1488 1489 1490 1491 1492 1493 1494 1495
static HRESULT WINAPI d3drm_frame2_GetRotation(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *axis, D3DVALUE *theta)
{
    FIXME("iface %p, reference %p, axis %p, theta %p stub!\n", iface, reference, axis, theta);

    return E_NOTIMPL;
}

1496 1497 1498 1499 1500 1501 1502 1503
static HRESULT WINAPI d3drm_frame1_GetRotation(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *axis, D3DVALUE *theta)
{
    FIXME("iface %p, reference %p, axis %p, theta %p stub!\n", iface, reference, axis, theta);

    return E_NOTIMPL;
}

1504
static HRESULT WINAPI d3drm_frame3_GetScene(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 **scene)
1505
{
1506
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1507

1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519
    TRACE("iface %p, scene %p.\n", iface, scene);

    if (!scene)
        return D3DRMERR_BADVALUE;

    while (frame->parent)
        frame = frame->parent;

    *scene = &frame->IDirect3DRMFrame3_iface;
    IDirect3DRMFrame3_AddRef(*scene);

    return D3DRM_OK;
1520 1521
}

1522 1523
static HRESULT WINAPI d3drm_frame2_GetScene(IDirect3DRMFrame2 *iface, IDirect3DRMFrame **scene)
{
1524 1525 1526
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
    IDirect3DRMFrame3 *frame3;
    HRESULT hr;
1527

1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543
    TRACE("iface %p, scene %p.\n", iface, scene);

    if (!scene)
        return D3DRMERR_BADVALUE;

    hr = IDirect3DRMFrame3_GetScene(&frame->IDirect3DRMFrame3_iface, &frame3);
    if (FAILED(hr) || !frame3)
    {
        *scene = NULL;
        return hr;
    }

    hr = IDirect3DRMFrame3_QueryInterface(frame3, &IID_IDirect3DRMFrame, (void **)scene);
    IDirect3DRMFrame3_Release(frame3);

    return hr;
1544 1545
}

1546 1547
static HRESULT WINAPI d3drm_frame1_GetScene(IDirect3DRMFrame *iface, IDirect3DRMFrame **scene)
{
1548
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
1549

1550 1551 1552
    TRACE("iface %p, scene %p.\n", iface, scene);

    return d3drm_frame2_GetScene(&frame->IDirect3DRMFrame2_iface, scene);
1553 1554
}

1555
static D3DRMSORTMODE WINAPI d3drm_frame3_GetSortMode(IDirect3DRMFrame3 *iface)
1556
{
1557
    FIXME("iface %p stub!\n", iface);
1558 1559 1560 1561

    return D3DRMSORT_FROMPARENT;
}

1562 1563 1564 1565 1566 1567 1568
static D3DRMSORTMODE WINAPI d3drm_frame2_GetSortMode(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMSORT_FROMPARENT;
}

1569 1570 1571 1572 1573 1574 1575
static D3DRMSORTMODE WINAPI d3drm_frame1_GetSortMode(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMSORT_FROMPARENT;
}

1576
static HRESULT WINAPI d3drm_frame3_GetTexture(IDirect3DRMFrame3 *iface, IDirect3DRMTexture3 **texture)
1577
{
1578
    FIXME("iface %p, texture %p stub!\n", iface, texture);
1579 1580 1581 1582

    return E_NOTIMPL;
}

1583 1584 1585 1586 1587 1588 1589
static HRESULT WINAPI d3drm_frame2_GetTexture(IDirect3DRMFrame2 *iface, IDirect3DRMTexture **texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

1590 1591 1592 1593 1594 1595 1596
static HRESULT WINAPI d3drm_frame1_GetTexture(IDirect3DRMFrame *iface, IDirect3DRMTexture **texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

1597 1598
static HRESULT WINAPI d3drm_frame3_GetTransform(IDirect3DRMFrame3 *iface,
        IDirect3DRMFrame3 *reference, D3DRMMATRIX4D matrix)
1599
{
1600
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1601
    struct d3drm_matrix *m = d3drm_matrix(matrix);
1602

1603
    TRACE("iface %p, reference %p, matrix %p.\n", iface, reference, matrix);
1604

1605
    if (reference)
1606
        FIXME("Ignoring reference frame %p.\n", reference);
1607

1608
    *m = frame->transform;
1609 1610

    return D3DRM_OK;
1611 1612
}

1613 1614 1615
static HRESULT WINAPI d3drm_frame2_GetTransform(IDirect3DRMFrame2 *iface, D3DRMMATRIX4D matrix)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
1616
    struct d3drm_matrix *m = d3drm_matrix(matrix);
1617 1618 1619

    TRACE("iface %p, matrix %p.\n", iface, matrix);

1620
    *m = frame->transform;
1621 1622 1623 1624

    return D3DRM_OK;
}

1625 1626 1627 1628 1629 1630 1631 1632 1633
static HRESULT WINAPI d3drm_frame1_GetTransform(IDirect3DRMFrame *iface, D3DRMMATRIX4D matrix)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, matrix %p.\n", iface, matrix);

    return d3drm_frame2_GetTransform(&frame->IDirect3DRMFrame2_iface, matrix);
}

1634 1635
static HRESULT WINAPI d3drm_frame3_GetVelocity(IDirect3DRMFrame3 *iface,
        IDirect3DRMFrame3 *reference, D3DVECTOR *velocity, BOOL with_rotation)
1636
{
1637 1638
    FIXME("iface %p, reference %p, velocity %p, with_rotation %#x stub!\n",
            iface, reference, velocity, with_rotation);
1639 1640 1641 1642

    return E_NOTIMPL;
}

1643 1644 1645 1646 1647 1648 1649 1650 1651
static HRESULT WINAPI d3drm_frame2_GetVelocity(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *velocity, BOOL with_rotation)
{
    FIXME("iface %p, reference %p, velocity %p, with_rotation %#x stub!\n",
            iface, reference, velocity, with_rotation);

    return E_NOTIMPL;
}

1652 1653 1654 1655 1656 1657 1658 1659 1660
static HRESULT WINAPI d3drm_frame1_GetVelocity(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *velocity, BOOL with_rotation)
{
    FIXME("iface %p, reference %p, velocity %p, with_rotation %#x stub!\n",
            iface, reference, velocity, with_rotation);

    return E_NOTIMPL;
}

1661
static HRESULT WINAPI d3drm_frame3_GetOrientation(IDirect3DRMFrame3 *iface,
1662
        IDirect3DRMFrame3 *reference, D3DVECTOR *dir, D3DVECTOR *up)
1663
{
1664
    FIXME("iface %p, reference %p, dir %p, up %p stub!\n", iface, reference, dir, up);
1665 1666 1667 1668

    return E_NOTIMPL;
}

1669 1670 1671 1672 1673 1674 1675 1676
static HRESULT WINAPI d3drm_frame2_GetOrientation(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *dir, D3DVECTOR *up)
{
    FIXME("iface %p, reference %p, dir %p, up %p stub!\n", iface, reference, dir, up);

    return E_NOTIMPL;
}

1677 1678 1679 1680 1681 1682 1683 1684
static HRESULT WINAPI d3drm_frame1_GetOrientation(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVECTOR *dir, D3DVECTOR *up)
{
    FIXME("iface %p, reference %p, dir %p, up %p stub!\n", iface, reference, dir, up);

    return E_NOTIMPL;
}

1685
static HRESULT WINAPI d3drm_frame3_GetVisuals(IDirect3DRMFrame3 *iface, DWORD *count, IUnknown **visuals)
1686
{
Henri Verbeet's avatar
Henri Verbeet committed
1687
    FIXME("iface %p, count %p, visuals %p stub!\n", iface, count, visuals);
1688 1689 1690 1691

    return E_NOTIMPL;
}

1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
static HRESULT WINAPI d3drm_frame2_GetVisuals(IDirect3DRMFrame2 *iface, IDirect3DRMVisualArray **visuals)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
    struct d3drm_visual_array *array;

    TRACE("iface %p, visuals %p.\n", iface, visuals);

    if (!visuals)
        return D3DRMERR_BADVALUE;

    if (!(array = d3drm_visual_array_create(frame->nb_visuals, frame->visuals)))
        return E_OUTOFMEMORY;

    *visuals = &array->IDirect3DRMVisualArray_iface;

    return D3DRM_OK;
}

1710 1711 1712 1713 1714 1715 1716 1717 1718
static HRESULT WINAPI d3drm_frame1_GetVisuals(IDirect3DRMFrame *iface, IDirect3DRMVisualArray **visuals)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, visuals %p.\n", iface, visuals);

    return d3drm_frame2_GetVisuals(&frame->IDirect3DRMFrame2_iface, visuals);
}

1719 1720 1721 1722 1723 1724 1725
static HRESULT WINAPI d3drm_frame2_GetTextureTopology(IDirect3DRMFrame2 *iface, BOOL *wrap_u, BOOL *wrap_v)
{
    FIXME("iface %p, wrap_u %p, wrap_v %p stub!\n", iface, wrap_u, wrap_v);

    return E_NOTIMPL;
}

1726 1727 1728 1729 1730 1731 1732
static HRESULT WINAPI d3drm_frame1_GetTextureTopology(IDirect3DRMFrame *iface, BOOL *wrap_u, BOOL *wrap_v)
{
    FIXME("iface %p, wrap_u %p, wrap_v %p stub!\n", iface, wrap_u, wrap_v);

    return E_NOTIMPL;
}

1733
static HRESULT WINAPI d3drm_frame3_InverseTransform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
1734
{
1735
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
1736 1737 1738 1739

    return E_NOTIMPL;
}

1740 1741 1742 1743 1744 1745 1746
static HRESULT WINAPI d3drm_frame2_InverseTransform(IDirect3DRMFrame2 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);

    return E_NOTIMPL;
}

1747 1748 1749 1750 1751 1752 1753
static HRESULT WINAPI d3drm_frame1_InverseTransform(IDirect3DRMFrame *iface, D3DVECTOR *d, D3DVECTOR *s)
{
    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);

    return E_NOTIMPL;
}

1754
static HRESULT WINAPI d3drm_frame3_Load(IDirect3DRMFrame3 *iface, void *filename,
Henri Verbeet's avatar
Henri Verbeet committed
1755
        void *name, D3DRMLOADOPTIONS flags, D3DRMLOADTEXTURE3CALLBACK cb, void *ctx)
1756
{
Henri Verbeet's avatar
Henri Verbeet committed
1757 1758
    FIXME("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p stub!\n",
            iface, filename, name, flags, cb, ctx);
1759 1760 1761 1762

    return E_NOTIMPL;
}

1763 1764 1765 1766 1767 1768 1769 1770 1771
static HRESULT WINAPI d3drm_frame2_Load(IDirect3DRMFrame2 *iface, void *filename,
        void *name, D3DRMLOADOPTIONS flags, D3DRMLOADTEXTURECALLBACK cb, void *ctx)
{
    FIXME("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p stub!\n",
            iface, filename, name, flags, cb, ctx);

    return E_NOTIMPL;
}

1772 1773 1774 1775 1776 1777 1778 1779 1780
static HRESULT WINAPI d3drm_frame1_Load(IDirect3DRMFrame *iface, void *filename,
        void *name, D3DRMLOADOPTIONS flags, D3DRMLOADTEXTURECALLBACK cb, void *ctx)
{
    FIXME("iface %p, filename %p, name %p, flags %#x, cb %p, ctx %p stub!\n",
            iface, filename, name, flags, cb, ctx);

    return E_NOTIMPL;
}

1781
static HRESULT WINAPI d3drm_frame3_LookAt(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 *target,
1782
        IDirect3DRMFrame3 *reference, D3DRMFRAMECONSTRAINT constraint)
1783
{
1784
    FIXME("iface %p, target %p, reference %p, constraint %#x stub!\n", iface, target, reference, constraint);
1785 1786 1787 1788

    return E_NOTIMPL;
}

1789 1790 1791 1792 1793 1794 1795 1796
static HRESULT WINAPI d3drm_frame2_LookAt(IDirect3DRMFrame2 *iface, IDirect3DRMFrame *target,
        IDirect3DRMFrame *reference, D3DRMFRAMECONSTRAINT constraint)
{
    FIXME("iface %p, target %p, reference %p, constraint %#x stub!\n", iface, target, reference, constraint);

    return E_NOTIMPL;
}

1797 1798 1799 1800 1801 1802 1803 1804
static HRESULT WINAPI d3drm_frame1_LookAt(IDirect3DRMFrame *iface, IDirect3DRMFrame *target,
        IDirect3DRMFrame *reference, D3DRMFRAMECONSTRAINT constraint)
{
    FIXME("iface %p, target %p, reference %p, constraint %#x stub!\n", iface, target, reference, constraint);

    return E_NOTIMPL;
}

1805
static HRESULT WINAPI d3drm_frame3_Move(IDirect3DRMFrame3 *iface, D3DVALUE delta)
1806
{
1807
    FIXME("iface %p, delta %.8e stub!\n", iface, delta);
1808 1809 1810 1811

    return E_NOTIMPL;
}

1812 1813 1814 1815 1816 1817 1818
static HRESULT WINAPI d3drm_frame2_Move(IDirect3DRMFrame2 *iface, D3DVALUE delta)
{
    FIXME("iface %p, delta %.8e stub!\n", iface, delta);

    return E_NOTIMPL;
}

1819 1820 1821 1822 1823 1824 1825
static HRESULT WINAPI d3drm_frame1_Move(IDirect3DRMFrame *iface, D3DVALUE delta)
{
    FIXME("iface %p, delta %.8e stub!\n", iface, delta);

    return E_NOTIMPL;
}

1826
static HRESULT WINAPI d3drm_frame3_DeleteChild(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 *child)
1827
{
1828 1829
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
    struct d3drm_frame *child_impl = unsafe_impl_from_IDirect3DRMFrame3(child);
1830
    ULONG i;
1831

1832
    TRACE("iface %p, child %p.\n", iface, child);
1833

1834
    if (!child_impl)
1835 1836 1837
        return D3DRMERR_BADOBJECT;

    /* Check if child exists */
1838 1839 1840
    for (i = 0; i < frame->nb_children; ++i)
    {
        if (frame->children[i] == child)
1841
            break;
1842
    }
1843

1844
    if (i == frame->nb_children)
1845 1846
        return D3DRMERR_BADVALUE;

1847 1848 1849 1850
    memmove(frame->children + i, frame->children + i + 1, sizeof(*frame->children) * (frame->nb_children - 1 - i));
    IDirect3DRMFrame3_Release(child);
    child_impl->parent = NULL;
    --frame->nb_children;
1851 1852

    return D3DRM_OK;
1853 1854
}

1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
static HRESULT WINAPI d3drm_frame2_DeleteChild(IDirect3DRMFrame2 *iface, IDirect3DRMFrame *child)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
    IDirect3DRMFrame3 *child3;
    HRESULT hr;

    TRACE("iface %p, child %p.\n", iface, child);

    if (!child)
        return D3DRMERR_BADOBJECT;
    if (FAILED(hr = IDirect3DRMFrame_QueryInterface(child, &IID_IDirect3DRMFrame3, (void **)&child3)))
        return D3DRMERR_BADOBJECT;
    IDirect3DRMFrame_Release(child);

    return d3drm_frame3_DeleteChild(&frame->IDirect3DRMFrame3_iface, child3);
}

1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
static HRESULT WINAPI d3drm_frame1_DeleteChild(IDirect3DRMFrame *iface, IDirect3DRMFrame *child)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
    struct d3drm_frame *child_frame = unsafe_impl_from_IDirect3DRMFrame(child);

    TRACE("iface %p, child %p.\n", iface, child);

    if (!child_frame)
        return D3DRMERR_BADOBJECT;

    return d3drm_frame3_DeleteChild(&frame->IDirect3DRMFrame3_iface, &child_frame->IDirect3DRMFrame3_iface);
}

1885
static HRESULT WINAPI d3drm_frame3_DeleteLight(IDirect3DRMFrame3 *iface, IDirect3DRMLight *light)
1886
{
1887
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1888 1889
    ULONG i;

1890
    TRACE("iface %p, light %p.\n", iface, light);
1891

1892 1893
    if (!light)
        return D3DRMERR_BADOBJECT;
1894

1895
    /* Check if visual exists */
1896 1897 1898
    for (i = 0; i < frame->nb_lights; ++i)
    {
        if (frame->lights[i] == light)
1899
            break;
1900
    }
1901

1902
    if (i == frame->nb_lights)
1903 1904
        return D3DRMERR_BADVALUE;

1905
    memmove(frame->lights + i, frame->lights + i + 1, sizeof(*frame->lights) * (frame->nb_lights - 1 - i));
1906
    IDirect3DRMLight_Release(light);
1907
    --frame->nb_lights;
1908 1909

    return D3DRM_OK;
1910 1911
}

1912 1913 1914 1915 1916 1917 1918 1919 1920
static HRESULT WINAPI d3drm_frame2_DeleteLight(IDirect3DRMFrame2 *iface, IDirect3DRMLight *light)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, light %p.\n", iface, light);

    return d3drm_frame3_DeleteLight(&frame->IDirect3DRMFrame3_iface, light);
}

1921 1922 1923 1924 1925 1926 1927 1928 1929
static HRESULT WINAPI d3drm_frame1_DeleteLight(IDirect3DRMFrame *iface, IDirect3DRMLight *light)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, light %p.\n", iface, light);

    return d3drm_frame3_DeleteLight(&frame->IDirect3DRMFrame3_iface, light);
}

1930
static HRESULT WINAPI d3drm_frame3_DeleteMoveCallback(IDirect3DRMFrame3 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
1931
        D3DRMFRAME3MOVECALLBACK cb, void *ctx)
1932
{
Henri Verbeet's avatar
Henri Verbeet committed
1933
    FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);
1934 1935 1936 1937

    return E_NOTIMPL;
}

1938 1939 1940 1941 1942 1943 1944 1945
static HRESULT WINAPI d3drm_frame2_DeleteMoveCallback(IDirect3DRMFrame2 *iface,
        D3DRMFRAMEMOVECALLBACK cb, void *ctx)
{
    FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);

    return E_NOTIMPL;
}

1946 1947 1948 1949 1950 1951 1952 1953
static HRESULT WINAPI d3drm_frame1_DeleteMoveCallback(IDirect3DRMFrame *iface,
        D3DRMFRAMEMOVECALLBACK cb, void *ctx)
{
    FIXME("iface %p, cb %p, ctx %p stub!\n", iface, cb, ctx);

    return E_NOTIMPL;
}

1954
static HRESULT WINAPI d3drm_frame3_DeleteVisual(IDirect3DRMFrame3 *iface, IUnknown *visual)
1955
{
1956
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
1957 1958
    ULONG i;

Henri Verbeet's avatar
Henri Verbeet committed
1959
    TRACE("iface %p, visual %p.\n", iface, visual);
1960

Henri Verbeet's avatar
Henri Verbeet committed
1961
    if (!visual)
1962
        return D3DRMERR_BADOBJECT;
1963

1964
    /* Check if visual exists */
1965 1966 1967
    for (i = 0; i < frame->nb_visuals; ++i)
    {
        if (frame->visuals[i] == (IDirect3DRMVisual *)visual)
1968
            break;
1969
    }
1970

1971
    if (i == frame->nb_visuals)
1972 1973
        return D3DRMERR_BADVALUE;

1974
    memmove(frame->visuals + i, frame->visuals + i + 1, sizeof(*frame->visuals) * (frame->nb_visuals - 1 - i));
Henri Verbeet's avatar
Henri Verbeet committed
1975
    IDirect3DRMVisual_Release(visual);
1976
    --frame->nb_visuals;
1977 1978

    return D3DRM_OK;
1979 1980
}

1981 1982 1983 1984 1985 1986 1987 1988 1989
static HRESULT WINAPI d3drm_frame2_DeleteVisual(IDirect3DRMFrame2 *iface, IDirect3DRMVisual *visual)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, visual %p.\n", iface, visual);

    return d3drm_frame3_DeleteVisual(&frame->IDirect3DRMFrame3_iface, (IUnknown *)visual);
}

1990 1991 1992 1993 1994 1995 1996 1997 1998
static HRESULT WINAPI d3drm_frame1_DeleteVisual(IDirect3DRMFrame *iface, IDirect3DRMVisual *visual)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, visual %p.\n", iface, visual);

    return d3drm_frame3_DeleteVisual(&frame->IDirect3DRMFrame3_iface, (IUnknown *)visual);
}

1999
static D3DCOLOR WINAPI d3drm_frame3_GetSceneBackground(IDirect3DRMFrame3 *iface)
2000
{
2001
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
2002

2003
    TRACE("iface %p.\n", iface);
2004

2005
    return frame->scenebackground;
2006 2007
}

2008 2009 2010 2011 2012 2013 2014 2015 2016
static D3DCOLOR WINAPI d3drm_frame2_GetSceneBackground(IDirect3DRMFrame2 *iface)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_frame3_GetSceneBackground(&frame->IDirect3DRMFrame3_iface);
}

2017 2018 2019 2020 2021 2022 2023 2024 2025
static D3DCOLOR WINAPI d3drm_frame1_GetSceneBackground(IDirect3DRMFrame *iface)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_frame3_GetSceneBackground(&frame->IDirect3DRMFrame3_iface);
}

2026
static HRESULT WINAPI d3drm_frame3_GetSceneBackgroundDepth(IDirect3DRMFrame3 *iface,
2027
        IDirectDrawSurface **surface)
2028
{
2029
    FIXME("iface %p, surface %p stub!\n", iface, surface);
2030 2031 2032 2033

    return E_NOTIMPL;
}

2034 2035 2036 2037 2038 2039 2040 2041
static HRESULT WINAPI d3drm_frame2_GetSceneBackgroundDepth(IDirect3DRMFrame2 *iface,
        IDirectDrawSurface **surface)
{
    FIXME("iface %p, surface %p stub!\n", iface, surface);

    return E_NOTIMPL;
}

2042 2043 2044 2045 2046 2047 2048 2049
static HRESULT WINAPI d3drm_frame1_GetSceneBackgroundDepth(IDirect3DRMFrame *iface,
        IDirectDrawSurface **surface)
{
    FIXME("iface %p, surface %p stub!\n", iface, surface);

    return E_NOTIMPL;
}

2050
static D3DCOLOR WINAPI d3drm_frame3_GetSceneFogColor(IDirect3DRMFrame3 *iface)
2051
{
2052
    FIXME("iface %p stub!\n", iface);
2053 2054 2055 2056

    return 0;
}

2057 2058 2059 2060 2061 2062 2063
static D3DCOLOR WINAPI d3drm_frame2_GetSceneFogColor(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return 0;
}

2064 2065 2066 2067 2068 2069 2070
static D3DCOLOR WINAPI d3drm_frame1_GetSceneFogColor(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return 0;
}

2071
static BOOL WINAPI d3drm_frame3_GetSceneFogEnable(IDirect3DRMFrame3 *iface)
2072
{
2073
    FIXME("iface %p stub!\n", iface);
2074 2075 2076 2077

    return FALSE;
}

2078 2079 2080 2081 2082 2083 2084
static BOOL WINAPI d3drm_frame2_GetSceneFogEnable(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return FALSE;
}

2085 2086 2087 2088 2089 2090 2091
static BOOL WINAPI d3drm_frame1_GetSceneFogEnable(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return FALSE;
}

2092
static D3DRMFOGMODE WINAPI d3drm_frame3_GetSceneFogMode(IDirect3DRMFrame3 *iface)
2093
{
2094
    FIXME("iface %p stub!\n", iface);
2095 2096 2097 2098

    return D3DRMFOG_LINEAR;
}

2099 2100 2101 2102 2103 2104 2105
static D3DRMFOGMODE WINAPI d3drm_frame2_GetSceneFogMode(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMFOG_LINEAR;
}

2106 2107 2108 2109 2110 2111 2112
static D3DRMFOGMODE WINAPI d3drm_frame1_GetSceneFogMode(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMFOG_LINEAR;
}

2113 2114
static HRESULT WINAPI d3drm_frame3_GetSceneFogParams(IDirect3DRMFrame3 *iface,
        D3DVALUE *start, D3DVALUE *end, D3DVALUE *density)
2115
{
2116
    FIXME("iface %p, start %p, end %p, density %p stub!\n", iface, start, end, density);
2117 2118 2119 2120

    return E_NOTIMPL;
}

2121 2122 2123 2124 2125 2126 2127 2128
static HRESULT WINAPI d3drm_frame2_GetSceneFogParams(IDirect3DRMFrame2 *iface,
        D3DVALUE *start, D3DVALUE *end, D3DVALUE *density)
{
    FIXME("iface %p, start %p, end %p, density %p stub!\n", iface, start, end, density);

    return E_NOTIMPL;
}

2129 2130 2131 2132 2133 2134 2135 2136
static HRESULT WINAPI d3drm_frame1_GetSceneFogParams(IDirect3DRMFrame *iface,
        D3DVALUE *start, D3DVALUE *end, D3DVALUE *density)
{
    FIXME("iface %p, start %p, end %p, density %p stub!\n", iface, start, end, density);

    return E_NOTIMPL;
}

2137
static HRESULT WINAPI d3drm_frame3_SetSceneBackground(IDirect3DRMFrame3 *iface, D3DCOLOR color)
2138
{
2139
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
2140

2141
    TRACE("iface %p, color 0x%08x.\n", iface, color);
2142

2143
    frame->scenebackground = color;
2144 2145

    return D3DRM_OK;
2146 2147
}

2148 2149 2150 2151 2152 2153 2154 2155 2156
static HRESULT WINAPI d3drm_frame2_SetSceneBackground(IDirect3DRMFrame2 *iface, D3DCOLOR color)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, color 0x%08x.\n", iface, color);

    return d3drm_frame3_SetSceneBackground(&frame->IDirect3DRMFrame3_iface, color);
}

2157 2158 2159 2160 2161 2162 2163 2164 2165
static HRESULT WINAPI d3drm_frame1_SetSceneBackground(IDirect3DRMFrame *iface, D3DCOLOR color)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, color 0x%08x.\n", iface, color);

    return d3drm_frame3_SetSceneBackground(&frame->IDirect3DRMFrame3_iface, color);
}

2166 2167
static HRESULT WINAPI d3drm_frame3_SetSceneBackgroundRGB(IDirect3DRMFrame3 *iface,
        D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2168
{
2169
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
2170

2171
    TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);
2172

2173
    d3drm_set_color(&frame->scenebackground, red, green, blue, 1.0f);
2174 2175

    return D3DRM_OK;
2176 2177
}

2178 2179 2180 2181 2182 2183 2184 2185 2186 2187
static HRESULT WINAPI d3drm_frame2_SetSceneBackgroundRGB(IDirect3DRMFrame2 *iface,
        D3DVALUE red, D3DVALUE green, D3DVALUE blue)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);

    TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);

    return d3drm_frame3_SetSceneBackgroundRGB(&frame->IDirect3DRMFrame3_iface, red, green, blue);
}

2188 2189 2190 2191 2192 2193 2194 2195 2196 2197
static HRESULT WINAPI d3drm_frame1_SetSceneBackgroundRGB(IDirect3DRMFrame *iface,
        D3DVALUE red, D3DVALUE green, D3DVALUE blue)
{
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);

    TRACE("iface %p, red %.8e, green %.8e, blue %.8e.\n", iface, red, green, blue);

    return d3drm_frame3_SetSceneBackgroundRGB(&frame->IDirect3DRMFrame3_iface, red, green, blue);
}

2198
static HRESULT WINAPI d3drm_frame3_SetSceneBackgroundDepth(IDirect3DRMFrame3 *iface,
2199
        IDirectDrawSurface *surface)
2200
{
2201
    FIXME("iface %p, surface %p stub!\n", iface, surface);
2202 2203 2204 2205

    return E_NOTIMPL;
}

2206 2207 2208 2209 2210 2211 2212 2213
static HRESULT WINAPI d3drm_frame2_SetSceneBackgroundDepth(IDirect3DRMFrame2 *iface,
        IDirectDrawSurface *surface)
{
    FIXME("iface %p, surface %p stub!\n", iface, surface);

    return E_NOTIMPL;
}

2214 2215 2216 2217 2218 2219 2220 2221
static HRESULT WINAPI d3drm_frame1_SetSceneBackgroundDepth(IDirect3DRMFrame *iface,
        IDirectDrawSurface *surface)
{
    FIXME("iface %p, surface %p stub!\n", iface, surface);

    return E_NOTIMPL;
}

2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237
static HRESULT WINAPI d3drm_frame3_SetSceneBackgroundImage(IDirect3DRMFrame3 *iface,
        IDirect3DRMTexture3 *texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_frame2_SetSceneBackgroundImage(IDirect3DRMFrame2 *iface,
        IDirect3DRMTexture *texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

2238 2239 2240 2241 2242 2243 2244 2245
static HRESULT WINAPI d3drm_frame1_SetSceneBackgroundImage(IDirect3DRMFrame *iface,
        IDirect3DRMTexture *texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

2246 2247 2248 2249 2250 2251 2252 2253
static HRESULT WINAPI d3drm_frame3_SetSceneFogEnable(IDirect3DRMFrame3 *iface, BOOL enable)
{
    FIXME("iface %p, enable %#x stub!\n", iface, enable);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_frame2_SetSceneFogEnable(IDirect3DRMFrame2 *iface, BOOL enable)
2254
{
2255
    FIXME("iface %p, enable %#x stub!\n", iface, enable);
2256 2257 2258 2259

    return E_NOTIMPL;
}

2260 2261 2262 2263 2264 2265 2266
static HRESULT WINAPI d3drm_frame1_SetSceneFogEnable(IDirect3DRMFrame *iface, BOOL enable)
{
    FIXME("iface %p, enable %#x stub!\n", iface, enable);

    return E_NOTIMPL;
}

2267
static HRESULT WINAPI d3drm_frame3_SetSceneFogColor(IDirect3DRMFrame3 *iface, D3DCOLOR color)
2268
{
2269
    FIXME("iface %p, color 0x%08x stub!\n", iface, color);
2270 2271 2272 2273

    return E_NOTIMPL;
}

2274
static HRESULT WINAPI d3drm_frame2_SetSceneFogColor(IDirect3DRMFrame2 *iface, D3DCOLOR color)
2275
{
2276
    FIXME("iface %p, color 0x%08x stub!\n", iface, color);
2277 2278 2279 2280

    return E_NOTIMPL;
}

2281 2282 2283 2284 2285 2286 2287
static HRESULT WINAPI d3drm_frame1_SetSceneFogColor(IDirect3DRMFrame *iface, D3DCOLOR color)
{
    FIXME("iface %p, color 0x%08x stub!\n", iface, color);

    return E_NOTIMPL;
}

2288
static HRESULT WINAPI d3drm_frame3_SetSceneFogMode(IDirect3DRMFrame3 *iface, D3DRMFOGMODE mode)
2289
{
2290
    FIXME("iface %p, mode %#x stub!\n", iface, mode);
2291 2292 2293 2294

    return E_NOTIMPL;
}

2295 2296 2297 2298 2299 2300 2301
static HRESULT WINAPI d3drm_frame2_SetSceneFogMode(IDirect3DRMFrame2 *iface, D3DRMFOGMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2302 2303 2304 2305 2306 2307 2308
static HRESULT WINAPI d3drm_frame1_SetSceneFogMode(IDirect3DRMFrame *iface, D3DRMFOGMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2309 2310
static HRESULT WINAPI d3drm_frame3_SetSceneFogParams(IDirect3DRMFrame3 *iface,
        D3DVALUE start, D3DVALUE end, D3DVALUE density)
2311
{
2312
    FIXME("iface %p, start %.8e, end %.8e, density %.8e stub!\n", iface, start, end, density);
2313 2314 2315 2316

    return E_NOTIMPL;
}

2317 2318 2319 2320 2321 2322 2323 2324
static HRESULT WINAPI d3drm_frame2_SetSceneFogParams(IDirect3DRMFrame2 *iface,
        D3DVALUE start, D3DVALUE end, D3DVALUE density)
{
    FIXME("iface %p, start %.8e, end %.8e, density %.8e stub!\n", iface, start, end, density);

    return E_NOTIMPL;
}

2325 2326 2327 2328 2329 2330 2331 2332
static HRESULT WINAPI d3drm_frame1_SetSceneFogParams(IDirect3DRMFrame *iface,
        D3DVALUE start, D3DVALUE end, D3DVALUE density)
{
    FIXME("iface %p, start %.8e, end %.8e, density %.8e stub!\n", iface, start, end, density);

    return E_NOTIMPL;
}

2333
static HRESULT WINAPI d3drm_frame3_SetColor(IDirect3DRMFrame3 *iface, D3DCOLOR color)
2334
{
2335
    FIXME("iface %p, color 0x%08x stub!\n", iface, color);
2336 2337 2338 2339

    return E_NOTIMPL;
}

2340 2341 2342 2343 2344 2345 2346
static HRESULT WINAPI d3drm_frame2_SetColor(IDirect3DRMFrame2 *iface, D3DCOLOR color)
{
    FIXME("iface %p, color 0x%08x stub!\n", iface, color);

    return E_NOTIMPL;
}

2347 2348 2349 2350 2351 2352 2353
static HRESULT WINAPI d3drm_frame1_SetColor(IDirect3DRMFrame *iface, D3DCOLOR color)
{
    FIXME("iface %p, color 0x%08x stub!\n", iface, color);

    return E_NOTIMPL;
}

2354 2355
static HRESULT WINAPI d3drm_frame3_SetColorRGB(IDirect3DRMFrame3 *iface,
        D3DVALUE red, D3DVALUE green, D3DVALUE blue)
2356
{
2357
    FIXME("iface %p, red %.8e, green %.8e, blue %.8e stub!\n", iface, red, green, blue);
2358 2359 2360 2361

    return E_NOTIMPL;
}

2362 2363 2364 2365 2366 2367 2368 2369
static HRESULT WINAPI d3drm_frame2_SetColorRGB(IDirect3DRMFrame2 *iface,
        D3DVALUE red, D3DVALUE green, D3DVALUE blue)
{
    FIXME("iface %p, red %.8e, green %.8e, blue %.8e stub!\n", iface, red, green, blue);

    return E_NOTIMPL;
}

2370 2371 2372 2373 2374 2375 2376 2377
static HRESULT WINAPI d3drm_frame1_SetColorRGB(IDirect3DRMFrame *iface,
        D3DVALUE red, D3DVALUE green, D3DVALUE blue)
{
    FIXME("iface %p, red %.8e, green %.8e, blue %.8e stub!\n", iface, red, green, blue);

    return E_NOTIMPL;
}

2378
static D3DRMZBUFFERMODE WINAPI d3drm_frame3_GetZbufferMode(IDirect3DRMFrame3 *iface)
2379
{
2380
    FIXME("iface %p stub!\n", iface);
2381 2382 2383 2384

    return D3DRMZBUFFER_FROMPARENT;
}

2385 2386 2387 2388 2389 2390 2391
static D3DRMZBUFFERMODE WINAPI d3drm_frame2_GetZbufferMode(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMZBUFFER_FROMPARENT;
}

2392 2393 2394 2395 2396 2397 2398
static D3DRMZBUFFERMODE WINAPI d3drm_frame1_GetZbufferMode(IDirect3DRMFrame *iface)
{
    FIXME("iface %p stub!\n", iface);

    return D3DRMZBUFFER_FROMPARENT;
}

2399
static HRESULT WINAPI d3drm_frame3_SetMaterialMode(IDirect3DRMFrame3 *iface, D3DRMMATERIALMODE mode)
2400
{
2401
    FIXME("iface %p, mode %#x stub!\n", iface, mode);
2402 2403 2404 2405

    return E_NOTIMPL;
}

2406 2407 2408 2409 2410 2411 2412
static HRESULT WINAPI d3drm_frame2_SetMaterialMode(IDirect3DRMFrame2 *iface, D3DRMMATERIALMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2413 2414 2415 2416 2417 2418 2419
static HRESULT WINAPI d3drm_frame1_SetMaterialMode(IDirect3DRMFrame *iface, D3DRMMATERIALMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2420
static HRESULT WINAPI d3drm_frame3_SetOrientation(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 *reference,
2421
        D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz)
2422
{
2423 2424
    FIXME("iface %p, reference %p, dx %.8e, dy %.8e, dz %.8e, ux %.8e, uy %.8e, uz %.8e stub!\n",
            iface, reference, dx, dy, dz, ux, uy, uz);
2425 2426 2427 2428

    return E_NOTIMPL;
}

2429 2430 2431 2432 2433 2434 2435 2436 2437
static HRESULT WINAPI d3drm_frame2_SetOrientation(IDirect3DRMFrame2 *iface, IDirect3DRMFrame *reference,
        D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz)
{
    FIXME("iface %p, reference %p, dx %.8e, dy %.8e, dz %.8e, ux %.8e, uy %.8e, uz %.8e stub!\n",
            iface, reference, dx, dy, dz, ux, uy, uz);

    return E_NOTIMPL;
}

2438 2439 2440 2441 2442 2443 2444 2445 2446
static HRESULT WINAPI d3drm_frame1_SetOrientation(IDirect3DRMFrame *iface, IDirect3DRMFrame *reference,
        D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz)
{
    FIXME("iface %p, reference %p, dx %.8e, dy %.8e, dz %.8e, ux %.8e, uy %.8e, uz %.8e stub!\n",
            iface, reference, dx, dy, dz, ux, uy, uz);

    return E_NOTIMPL;
}

2447
static HRESULT WINAPI d3drm_frame3_SetPosition(IDirect3DRMFrame3 *iface,
2448
        IDirect3DRMFrame3 *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z)
2449
{
2450
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e stub!\n", iface, reference, x, y, z);
2451 2452 2453 2454

    return E_NOTIMPL;
}

2455 2456 2457 2458 2459 2460 2461 2462
static HRESULT WINAPI d3drm_frame2_SetPosition(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e stub!\n", iface, reference, x, y, z);

    return E_NOTIMPL;
}

2463 2464 2465 2466 2467 2468 2469 2470
static HRESULT WINAPI d3drm_frame1_SetPosition(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e stub!\n", iface, reference, x, y, z);

    return E_NOTIMPL;
}

2471
static HRESULT WINAPI d3drm_frame3_SetRotation(IDirect3DRMFrame3 *iface,
2472
        IDirect3DRMFrame3 *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
2473
{
2474 2475
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n",
            iface, reference, x, y, z, theta);
2476 2477 2478 2479

    return E_NOTIMPL;
}

2480 2481 2482 2483 2484 2485 2486 2487 2488
static HRESULT WINAPI d3drm_frame2_SetRotation(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n",
            iface, reference, x, y, z, theta);

    return E_NOTIMPL;
}

2489 2490 2491 2492 2493 2494 2495 2496 2497
static HRESULT WINAPI d3drm_frame1_SetRotation(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta)
{
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n",
            iface, reference, x, y, z, theta);

    return E_NOTIMPL;
}

2498
static HRESULT WINAPI d3drm_frame3_SetSortMode(IDirect3DRMFrame3 *iface, D3DRMSORTMODE mode)
2499
{
2500
    FIXME("iface %p, mode %#x stub!\n", iface, mode);
2501 2502 2503 2504

    return E_NOTIMPL;
}

2505 2506 2507 2508 2509 2510 2511
static HRESULT WINAPI d3drm_frame2_SetSortMode(IDirect3DRMFrame2 *iface, D3DRMSORTMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2512 2513 2514 2515 2516 2517 2518
static HRESULT WINAPI d3drm_frame1_SetSortMode(IDirect3DRMFrame *iface, D3DRMSORTMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2519
static HRESULT WINAPI d3drm_frame3_SetTexture(IDirect3DRMFrame3 *iface, IDirect3DRMTexture3 *texture)
2520
{
2521
    FIXME("iface %p, texture %p stub!\n", iface, texture);
2522 2523 2524 2525

    return E_NOTIMPL;
}

2526 2527 2528 2529 2530 2531 2532
static HRESULT WINAPI d3drm_frame2_SetTexture(IDirect3DRMFrame2 *iface, IDirect3DRMTexture *texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

2533 2534 2535 2536 2537 2538 2539
static HRESULT WINAPI d3drm_frame1_SetTexture(IDirect3DRMFrame *iface, IDirect3DRMTexture *texture)
{
    FIXME("iface %p, texture %p stub!\n", iface, texture);

    return E_NOTIMPL;
}

2540 2541 2542 2543 2544 2545 2546
static HRESULT WINAPI d3drm_frame2_SetTextureTopology(IDirect3DRMFrame2 *iface, BOOL wrap_u, BOOL wrap_v)
{
    FIXME("iface %p, wrap_u %#x, wrap_v %#x stub!\n", iface, wrap_u, wrap_v);

    return E_NOTIMPL;
}

2547 2548 2549 2550 2551 2552 2553
static HRESULT WINAPI d3drm_frame1_SetTextureTopology(IDirect3DRMFrame *iface, BOOL wrap_u, BOOL wrap_v)
{
    FIXME("iface %p, wrap_u %#x, wrap_v %#x stub!\n", iface, wrap_u, wrap_v);

    return E_NOTIMPL;
}

2554
static HRESULT WINAPI d3drm_frame3_SetVelocity(IDirect3DRMFrame3 *iface,
2555
        IDirect3DRMFrame3 *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation)
2556
{
2557 2558
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e, with_rotation %#x.\n",
            iface, reference, x, y, z, with_rotation);
2559 2560 2561 2562

    return E_NOTIMPL;
}

2563 2564 2565 2566 2567 2568 2569 2570 2571
static HRESULT WINAPI d3drm_frame2_SetVelocity(IDirect3DRMFrame2 *iface,
        IDirect3DRMFrame *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation)
{
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e, with_rotation %#x stub!\n",
            iface, reference, x, y, z, with_rotation);

    return E_NOTIMPL;
}

2572 2573 2574 2575 2576 2577 2578 2579 2580
static HRESULT WINAPI d3drm_frame1_SetVelocity(IDirect3DRMFrame *iface,
        IDirect3DRMFrame *reference, D3DVALUE x, D3DVALUE y, D3DVALUE z, BOOL with_rotation)
{
    FIXME("iface %p, reference %p, x %.8e, y %.8e, z %.8e, with_rotation %#x stub!\n",
            iface, reference, x, y, z, with_rotation);

    return E_NOTIMPL;
}

2581
static HRESULT WINAPI d3drm_frame3_SetZbufferMode(IDirect3DRMFrame3 *iface, D3DRMZBUFFERMODE mode)
2582
{
2583
    FIXME("iface %p, mode %#x stub!\n", iface, mode);
2584 2585 2586 2587

    return E_NOTIMPL;
}

2588 2589 2590 2591 2592 2593 2594
static HRESULT WINAPI d3drm_frame2_SetZbufferMode(IDirect3DRMFrame2 *iface, D3DRMZBUFFERMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2595 2596 2597 2598 2599 2600 2601
static HRESULT WINAPI d3drm_frame1_SetZbufferMode(IDirect3DRMFrame *iface, D3DRMZBUFFERMODE mode)
{
    FIXME("iface %p, mode %#x stub!\n", iface, mode);

    return E_NOTIMPL;
}

2602
static HRESULT WINAPI d3drm_frame3_Transform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
2603
{
2604
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
2605

2606 2607 2608 2609 2610 2611 2612 2613 2614
    TRACE("iface %p, d %p, s %p.\n", iface, d, s);

    d3drm_vector_transform_affine(d, s, &frame->transform);
    while ((frame = frame->parent))
    {
        d3drm_vector_transform_affine(d, d, &frame->transform);
    }

    return D3DRM_OK;
2615 2616
}

2617 2618
static HRESULT WINAPI d3drm_frame2_Transform(IDirect3DRMFrame2 *iface, D3DVECTOR *d, D3DVECTOR *s)
{
2619
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
2620

2621 2622 2623
    TRACE("iface %p, d %p, s %p.\n", iface, d, s);

    return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
2624 2625
}

2626 2627
static HRESULT WINAPI d3drm_frame1_Transform(IDirect3DRMFrame *iface, D3DVECTOR *d, D3DVECTOR *s)
{
2628
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
2629

2630 2631 2632
    TRACE("iface %p, d %p, s %p.\n", iface, d, s);

    return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s);
2633 2634
}

2635 2636 2637 2638 2639 2640 2641 2642
static HRESULT WINAPI d3drm_frame2_AddMoveCallback2(IDirect3DRMFrame2 *iface,
        D3DRMFRAMEMOVECALLBACK cb, void *ctx, DWORD flags)
{
    FIXME("iface %p, cb %p, ctx %p, flags %#x stub!\n", iface, cb, ctx, flags);

    return E_NOTIMPL;
}

2643
static HRESULT WINAPI d3drm_frame3_GetBox(IDirect3DRMFrame3 *iface, D3DRMBOX *box)
2644
{
2645
    FIXME("iface %p, box %p stub!\n", iface, box);
2646 2647 2648 2649

    return E_NOTIMPL;
}

2650 2651 2652 2653 2654 2655 2656
static HRESULT WINAPI d3drm_frame2_GetBox(IDirect3DRMFrame2 *iface, D3DRMBOX *box)
{
    FIXME("iface %p, box %p stub!\n", iface, box);

    return E_NOTIMPL;
}

2657
static BOOL WINAPI d3drm_frame3_GetBoxEnable(IDirect3DRMFrame3 *iface)
2658
{
2659
    FIXME("iface %p stub!\n", iface);
2660

2661
    return FALSE;
2662 2663
}

2664 2665 2666 2667 2668 2669 2670
static BOOL WINAPI d3drm_frame2_GetBoxEnable(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return FALSE;
}

2671
static HRESULT WINAPI d3drm_frame3_GetAxes(IDirect3DRMFrame3 *iface, D3DVECTOR *dir, D3DVECTOR *up)
2672
{
2673
    FIXME("iface %p, dir %p, up %p stub!\n", iface, dir, up);
2674 2675 2676 2677

    return E_NOTIMPL;
}

2678 2679 2680 2681 2682 2683 2684
static HRESULT WINAPI d3drm_frame2_GetAxes(IDirect3DRMFrame2 *iface, D3DVECTOR *dir, D3DVECTOR *up)
{
    FIXME("iface %p, dir %p, up %p stub!\n", iface, dir, up);

    return E_NOTIMPL;
}

2685
static HRESULT WINAPI d3drm_frame3_GetMaterial(IDirect3DRMFrame3 *iface, IDirect3DRMMaterial2 **material)
2686
{
2687
    FIXME("iface %p, material %p stub!\n", iface, material);
2688 2689 2690 2691

    return E_NOTIMPL;
}

2692 2693 2694 2695 2696 2697 2698
static HRESULT WINAPI d3drm_frame2_GetMaterial(IDirect3DRMFrame2 *iface, IDirect3DRMMaterial **material)
{
    FIXME("iface %p, material %p stub!\n", iface, material);

    return E_NOTIMPL;
}

2699
static BOOL WINAPI d3drm_frame3_GetInheritAxes(IDirect3DRMFrame3 *iface)
2700
{
2701
    FIXME("iface %p stub!\n", iface);
2702

2703
    return FALSE;
2704 2705
}

2706 2707 2708 2709 2710 2711 2712
static BOOL WINAPI d3drm_frame2_GetInheritAxes(IDirect3DRMFrame2 *iface)
{
    FIXME("iface %p stub!\n", iface);

    return FALSE;
}

2713
static HRESULT WINAPI d3drm_frame3_GetHierarchyBox(IDirect3DRMFrame3 *iface, D3DRMBOX *box)
2714
{
2715
    FIXME("iface %p, box %p stub!\n", iface, box);
2716 2717 2718 2719

    return E_NOTIMPL;
}

2720 2721 2722 2723 2724 2725 2726
static HRESULT WINAPI d3drm_frame2_GetHierarchyBox(IDirect3DRMFrame2 *iface, D3DRMBOX *box)
{
    FIXME("iface %p, box %p stub!\n", iface, box);

    return E_NOTIMPL;
}

2727
static HRESULT WINAPI d3drm_frame3_SetBox(IDirect3DRMFrame3 *iface, D3DRMBOX *box)
2728
{
2729
    FIXME("iface %p, box %p stub!\n", iface, box);
2730 2731 2732 2733

    return E_NOTIMPL;
}

2734
static HRESULT WINAPI d3drm_frame3_SetBoxEnable(IDirect3DRMFrame3 *iface, BOOL enable)
2735
{
2736
    FIXME("iface %p, enable %#x stub!\n", iface, enable);
2737 2738 2739 2740

    return E_NOTIMPL;
}

2741 2742
static HRESULT WINAPI d3drm_frame3_SetAxes(IDirect3DRMFrame3 *iface,
        D3DVALUE dx, D3DVALUE dy, D3DVALUE dz, D3DVALUE ux, D3DVALUE uy, D3DVALUE uz)
2743
{
2744 2745
    FIXME("iface %p, dx %.8e, dy %.8e, dz %.8e, ux %.8e, uy %.8e, uz %.8e stub!\n",
            iface, dx, dy, dz, ux, uy, uz);
2746 2747 2748 2749

    return E_NOTIMPL;
}

2750
static HRESULT WINAPI d3drm_frame3_SetInheritAxes(IDirect3DRMFrame3 *iface, BOOL inherit)
2751
{
2752
    FIXME("iface %p, inherit %#x stub!\n", iface, inherit);
2753 2754 2755 2756

    return E_NOTIMPL;
}

2757
static HRESULT WINAPI d3drm_frame3_SetMaterial(IDirect3DRMFrame3 *iface, IDirect3DRMMaterial2 *material)
2758
{
2759
    FIXME("iface %p, material %p stub!\n", iface, material);
2760 2761 2762 2763

    return E_NOTIMPL;
}

2764
static HRESULT WINAPI d3drm_frame3_SetQuaternion(IDirect3DRMFrame3 *iface,
2765
        IDirect3DRMFrame3 *reference, D3DRMQUATERNION *q)
2766
{
2767
    FIXME("iface %p, reference %p, q %p stub!\n", iface, reference, q);
2768 2769 2770 2771

    return E_NOTIMPL;
}

2772 2773
static HRESULT WINAPI d3drm_frame3_RayPick(IDirect3DRMFrame3 *iface, IDirect3DRMFrame3 *reference,
        D3DRMRAY *ray, DWORD flags, IDirect3DRMPicked2Array **visuals)
2774
{
2775 2776
    FIXME("iface %p, reference %p, ray %p, flags %#x, visuals %p stub!\n",
            iface, reference, ray, flags, visuals);
2777 2778 2779 2780

    return E_NOTIMPL;
}

2781
static HRESULT WINAPI d3drm_frame3_Save(IDirect3DRMFrame3 *iface,
Henri Verbeet's avatar
Henri Verbeet committed
2782
        const char *filename, D3DRMXOFFORMAT format, D3DRMSAVEOPTIONS flags)
2783
{
Henri Verbeet's avatar
Henri Verbeet committed
2784 2785
    FIXME("iface %p, filename %s, format %#x, flags %#x stub!\n",
            iface, debugstr_a(filename), format, flags);
2786 2787 2788 2789

    return E_NOTIMPL;
}

2790
static HRESULT WINAPI d3drm_frame3_TransformVectors(IDirect3DRMFrame3 *iface,
2791
        IDirect3DRMFrame3 *reference, DWORD num, D3DVECTOR *dst, D3DVECTOR *src)
2792
{
2793
    FIXME("iface %p, reference %p, num %u, dst %p, src %p stub!\n", iface, reference, num, dst, src);
2794 2795 2796 2797

    return E_NOTIMPL;
}

2798
static HRESULT WINAPI d3drm_frame3_InverseTransformVectors(IDirect3DRMFrame3 *iface,
2799
        IDirect3DRMFrame3 *reference, DWORD num, D3DVECTOR *dst, D3DVECTOR *src)
2800
{
2801
    FIXME("iface %p, reference %p, num %u, dst %p, src %p stub!\n", iface, reference, num, dst, src);
2802 2803 2804 2805

    return E_NOTIMPL;
}

2806
static HRESULT WINAPI d3drm_frame3_SetTraversalOptions(IDirect3DRMFrame3 *iface, DWORD options)
2807
{
2808 2809
    static const DWORD supported_options = D3DRMFRAME_RENDERENABLE | D3DRMFRAME_PICKENABLE;
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
2810

2811 2812 2813 2814 2815 2816 2817 2818
    TRACE("iface %p, options %#x.\n", iface, options);

    if (options & ~supported_options)
        return D3DRMERR_BADVALUE;

    frame->traversal_options = options;

    return D3DRM_OK;
2819 2820
}

2821
static HRESULT WINAPI d3drm_frame3_GetTraversalOptions(IDirect3DRMFrame3 *iface, DWORD *options)
2822
{
2823
    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
2824

2825 2826 2827 2828 2829 2830 2831 2832
    TRACE("iface %p, options %p.\n", iface, options);

    if (!options)
        return D3DRMERR_BADVALUE;

    *options = frame->traversal_options;

    return D3DRM_OK;
2833 2834
}

2835
static HRESULT WINAPI d3drm_frame3_SetSceneFogMethod(IDirect3DRMFrame3 *iface, DWORD flags)
2836
{
2837
    FIXME("iface %p, flags %#x stub!\n", iface, flags);
2838 2839 2840 2841

    return E_NOTIMPL;
}

2842
static HRESULT WINAPI d3drm_frame3_GetSceneFogMethod(IDirect3DRMFrame3 *iface, DWORD *fog_mode)
2843
{
2844
    FIXME("iface %p, fog_mode %p stub!\n", iface, fog_mode);
2845 2846 2847 2848

    return E_NOTIMPL;
}

2849
static HRESULT WINAPI d3drm_frame3_SetMaterialOverride(IDirect3DRMFrame3 *iface,
2850
        D3DRMMATERIALOVERRIDE *override)
2851
{
2852
    FIXME("iface %p, override %p stub!\n", iface, override);
2853 2854 2855 2856

    return E_NOTIMPL;
}

2857
static HRESULT WINAPI d3drm_frame3_GetMaterialOverride(IDirect3DRMFrame3 *iface,
2858
        D3DRMMATERIALOVERRIDE *override)
2859
{
2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955
    FIXME("iface %p, override %p stub!\n", iface, override);

    return E_NOTIMPL;
}

static const struct IDirect3DRMFrame3Vtbl d3drm_frame3_vtbl =
{
    d3drm_frame3_QueryInterface,
    d3drm_frame3_AddRef,
    d3drm_frame3_Release,
    d3drm_frame3_Clone,
    d3drm_frame3_AddDestroyCallback,
    d3drm_frame3_DeleteDestroyCallback,
    d3drm_frame3_SetAppData,
    d3drm_frame3_GetAppData,
    d3drm_frame3_SetName,
    d3drm_frame3_GetName,
    d3drm_frame3_GetClassName,
    d3drm_frame3_AddChild,
    d3drm_frame3_AddLight,
    d3drm_frame3_AddMoveCallback,
    d3drm_frame3_AddTransform,
    d3drm_frame3_AddTranslation,
    d3drm_frame3_AddScale,
    d3drm_frame3_AddRotation,
    d3drm_frame3_AddVisual,
    d3drm_frame3_GetChildren,
    d3drm_frame3_GetColor,
    d3drm_frame3_GetLights,
    d3drm_frame3_GetMaterialMode,
    d3drm_frame3_GetParent,
    d3drm_frame3_GetPosition,
    d3drm_frame3_GetRotation,
    d3drm_frame3_GetScene,
    d3drm_frame3_GetSortMode,
    d3drm_frame3_GetTexture,
    d3drm_frame3_GetTransform,
    d3drm_frame3_GetVelocity,
    d3drm_frame3_GetOrientation,
    d3drm_frame3_GetVisuals,
    d3drm_frame3_InverseTransform,
    d3drm_frame3_Load,
    d3drm_frame3_LookAt,
    d3drm_frame3_Move,
    d3drm_frame3_DeleteChild,
    d3drm_frame3_DeleteLight,
    d3drm_frame3_DeleteMoveCallback,
    d3drm_frame3_DeleteVisual,
    d3drm_frame3_GetSceneBackground,
    d3drm_frame3_GetSceneBackgroundDepth,
    d3drm_frame3_GetSceneFogColor,
    d3drm_frame3_GetSceneFogEnable,
    d3drm_frame3_GetSceneFogMode,
    d3drm_frame3_GetSceneFogParams,
    d3drm_frame3_SetSceneBackground,
    d3drm_frame3_SetSceneBackgroundRGB,
    d3drm_frame3_SetSceneBackgroundDepth,
    d3drm_frame3_SetSceneBackgroundImage,
    d3drm_frame3_SetSceneFogEnable,
    d3drm_frame3_SetSceneFogColor,
    d3drm_frame3_SetSceneFogMode,
    d3drm_frame3_SetSceneFogParams,
    d3drm_frame3_SetColor,
    d3drm_frame3_SetColorRGB,
    d3drm_frame3_GetZbufferMode,
    d3drm_frame3_SetMaterialMode,
    d3drm_frame3_SetOrientation,
    d3drm_frame3_SetPosition,
    d3drm_frame3_SetRotation,
    d3drm_frame3_SetSortMode,
    d3drm_frame3_SetTexture,
    d3drm_frame3_SetVelocity,
    d3drm_frame3_SetZbufferMode,
    d3drm_frame3_Transform,
    d3drm_frame3_GetBox,
    d3drm_frame3_GetBoxEnable,
    d3drm_frame3_GetAxes,
    d3drm_frame3_GetMaterial,
    d3drm_frame3_GetInheritAxes,
    d3drm_frame3_GetHierarchyBox,
    d3drm_frame3_SetBox,
    d3drm_frame3_SetBoxEnable,
    d3drm_frame3_SetAxes,
    d3drm_frame3_SetInheritAxes,
    d3drm_frame3_SetMaterial,
    d3drm_frame3_SetQuaternion,
    d3drm_frame3_RayPick,
    d3drm_frame3_Save,
    d3drm_frame3_TransformVectors,
    d3drm_frame3_InverseTransformVectors,
    d3drm_frame3_SetTraversalOptions,
    d3drm_frame3_GetTraversalOptions,
    d3drm_frame3_SetSceneFogMethod,
    d3drm_frame3_GetSceneFogMethod,
    d3drm_frame3_SetMaterialOverride,
    d3drm_frame3_GetMaterialOverride,
2956
};
2957

2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037
static const struct IDirect3DRMFrame2Vtbl d3drm_frame2_vtbl =
{
    d3drm_frame2_QueryInterface,
    d3drm_frame2_AddRef,
    d3drm_frame2_Release,
    d3drm_frame2_Clone,
    d3drm_frame2_AddDestroyCallback,
    d3drm_frame2_DeleteDestroyCallback,
    d3drm_frame2_SetAppData,
    d3drm_frame2_GetAppData,
    d3drm_frame2_SetName,
    d3drm_frame2_GetName,
    d3drm_frame2_GetClassName,
    d3drm_frame2_AddChild,
    d3drm_frame2_AddLight,
    d3drm_frame2_AddMoveCallback,
    d3drm_frame2_AddTransform,
    d3drm_frame2_AddTranslation,
    d3drm_frame2_AddScale,
    d3drm_frame2_AddRotation,
    d3drm_frame2_AddVisual,
    d3drm_frame2_GetChildren,
    d3drm_frame2_GetColor,
    d3drm_frame2_GetLights,
    d3drm_frame2_GetMaterialMode,
    d3drm_frame2_GetParent,
    d3drm_frame2_GetPosition,
    d3drm_frame2_GetRotation,
    d3drm_frame2_GetScene,
    d3drm_frame2_GetSortMode,
    d3drm_frame2_GetTexture,
    d3drm_frame2_GetTransform,
    d3drm_frame2_GetVelocity,
    d3drm_frame2_GetOrientation,
    d3drm_frame2_GetVisuals,
    d3drm_frame2_GetTextureTopology,
    d3drm_frame2_InverseTransform,
    d3drm_frame2_Load,
    d3drm_frame2_LookAt,
    d3drm_frame2_Move,
    d3drm_frame2_DeleteChild,
    d3drm_frame2_DeleteLight,
    d3drm_frame2_DeleteMoveCallback,
    d3drm_frame2_DeleteVisual,
    d3drm_frame2_GetSceneBackground,
    d3drm_frame2_GetSceneBackgroundDepth,
    d3drm_frame2_GetSceneFogColor,
    d3drm_frame2_GetSceneFogEnable,
    d3drm_frame2_GetSceneFogMode,
    d3drm_frame2_GetSceneFogParams,
    d3drm_frame2_SetSceneBackground,
    d3drm_frame2_SetSceneBackgroundRGB,
    d3drm_frame2_SetSceneBackgroundDepth,
    d3drm_frame2_SetSceneBackgroundImage,
    d3drm_frame2_SetSceneFogEnable,
    d3drm_frame2_SetSceneFogColor,
    d3drm_frame2_SetSceneFogMode,
    d3drm_frame2_SetSceneFogParams,
    d3drm_frame2_SetColor,
    d3drm_frame2_SetColorRGB,
    d3drm_frame2_GetZbufferMode,
    d3drm_frame2_SetMaterialMode,
    d3drm_frame2_SetOrientation,
    d3drm_frame2_SetPosition,
    d3drm_frame2_SetRotation,
    d3drm_frame2_SetSortMode,
    d3drm_frame2_SetTexture,
    d3drm_frame2_SetTextureTopology,
    d3drm_frame2_SetVelocity,
    d3drm_frame2_SetZbufferMode,
    d3drm_frame2_Transform,
    d3drm_frame2_AddMoveCallback2,
    d3drm_frame2_GetBox,
    d3drm_frame2_GetBoxEnable,
    d3drm_frame2_GetAxes,
    d3drm_frame2_GetMaterial,
    d3drm_frame2_GetInheritAxes,
    d3drm_frame2_GetHierarchyBox,
};

3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110
static const struct IDirect3DRMFrameVtbl d3drm_frame1_vtbl =
{
    d3drm_frame1_QueryInterface,
    d3drm_frame1_AddRef,
    d3drm_frame1_Release,
    d3drm_frame1_Clone,
    d3drm_frame1_AddDestroyCallback,
    d3drm_frame1_DeleteDestroyCallback,
    d3drm_frame1_SetAppData,
    d3drm_frame1_GetAppData,
    d3drm_frame1_SetName,
    d3drm_frame1_GetName,
    d3drm_frame1_GetClassName,
    d3drm_frame1_AddChild,
    d3drm_frame1_AddLight,
    d3drm_frame1_AddMoveCallback,
    d3drm_frame1_AddTransform,
    d3drm_frame1_AddTranslation,
    d3drm_frame1_AddScale,
    d3drm_frame1_AddRotation,
    d3drm_frame1_AddVisual,
    d3drm_frame1_GetChildren,
    d3drm_frame1_GetColor,
    d3drm_frame1_GetLights,
    d3drm_frame1_GetMaterialMode,
    d3drm_frame1_GetParent,
    d3drm_frame1_GetPosition,
    d3drm_frame1_GetRotation,
    d3drm_frame1_GetScene,
    d3drm_frame1_GetSortMode,
    d3drm_frame1_GetTexture,
    d3drm_frame1_GetTransform,
    d3drm_frame1_GetVelocity,
    d3drm_frame1_GetOrientation,
    d3drm_frame1_GetVisuals,
    d3drm_frame1_GetTextureTopology,
    d3drm_frame1_InverseTransform,
    d3drm_frame1_Load,
    d3drm_frame1_LookAt,
    d3drm_frame1_Move,
    d3drm_frame1_DeleteChild,
    d3drm_frame1_DeleteLight,
    d3drm_frame1_DeleteMoveCallback,
    d3drm_frame1_DeleteVisual,
    d3drm_frame1_GetSceneBackground,
    d3drm_frame1_GetSceneBackgroundDepth,
    d3drm_frame1_GetSceneFogColor,
    d3drm_frame1_GetSceneFogEnable,
    d3drm_frame1_GetSceneFogMode,
    d3drm_frame1_GetSceneFogParams,
    d3drm_frame1_SetSceneBackground,
    d3drm_frame1_SetSceneBackgroundRGB,
    d3drm_frame1_SetSceneBackgroundDepth,
    d3drm_frame1_SetSceneBackgroundImage,
    d3drm_frame1_SetSceneFogEnable,
    d3drm_frame1_SetSceneFogColor,
    d3drm_frame1_SetSceneFogMode,
    d3drm_frame1_SetSceneFogParams,
    d3drm_frame1_SetColor,
    d3drm_frame1_SetColorRGB,
    d3drm_frame1_GetZbufferMode,
    d3drm_frame1_SetMaterialMode,
    d3drm_frame1_SetOrientation,
    d3drm_frame1_SetPosition,
    d3drm_frame1_SetRotation,
    d3drm_frame1_SetSortMode,
    d3drm_frame1_SetTexture,
    d3drm_frame1_SetTextureTopology,
    d3drm_frame1_SetVelocity,
    d3drm_frame1_SetZbufferMode,
    d3drm_frame1_Transform,
};

3111
struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame3(IDirect3DRMFrame3 *iface)
3112 3113 3114
{
    if (!iface)
        return NULL;
3115
    assert(iface->lpVtbl == &d3drm_frame3_vtbl);
3116 3117 3118 3119

    return impl_from_IDirect3DRMFrame3(iface);
}

3120
struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMFrame *iface)
3121 3122 3123 3124 3125 3126 3127 3128
{
    if (!iface)
        return NULL;
    assert(iface->lpVtbl == &d3drm_frame1_vtbl);

    return impl_from_IDirect3DRMFrame(iface);
}

3129
HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm)
3130
{
3131
    static const char classname[] = "Frame";
3132
    struct d3drm_frame *object;
3133
    HRESULT hr = D3DRM_OK;
3134

3135
    TRACE("frame %p, parent_frame %p, d3drm %p.\n", frame, parent_frame, d3drm);
3136

3137
    if (!(object = heap_alloc_zero(sizeof(*object))))
3138 3139
        return E_OUTOFMEMORY;

3140
    object->IDirect3DRMFrame_iface.lpVtbl = &d3drm_frame1_vtbl;
3141 3142
    object->IDirect3DRMFrame2_iface.lpVtbl = &d3drm_frame2_vtbl;
    object->IDirect3DRMFrame3_iface.lpVtbl = &d3drm_frame3_vtbl;
3143
    object->d3drm = d3drm;
3144
    object->ref = 1;
3145
    d3drm_set_color(&object->scenebackground, 0.0f, 0.0f, 0.0f, 1.0f);
3146
    object->traversal_options = D3DRMFRAME_RENDERENABLE | D3DRMFRAME_PICKENABLE;
3147

3148 3149
    d3drm_object_init(&object->obj, classname);

3150
    object->transform = identity;
3151

3152
    if (parent_frame)
3153
    {
3154 3155
        IDirect3DRMFrame3 *p;

3156
        if (FAILED(hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&p)))
3157
        {
3158
            heap_free(object);
3159
            return hr;
3160
        }
3161
        IDirect3DRMFrame_Release(parent_frame);
3162
        IDirect3DRMFrame3_AddChild(p, &object->IDirect3DRMFrame3_iface);
3163
    }
3164

3165 3166
    IDirect3DRM_AddRef(object->d3drm);

3167 3168
    *frame = object;

3169
    return hr;
3170
}
3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234

static HRESULT WINAPI d3drm_animation2_QueryInterface(IDirect3DRMAnimation2 *iface, REFIID riid, void **out)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);

    if (IsEqualGUID(riid, &IID_IDirect3DRMAnimation)
            || IsEqualGUID(riid, &IID_IDirect3DRMObject)
            || IsEqualGUID(riid, &IID_IUnknown))
    {
        *out = &animation->IDirect3DRMAnimation_iface;
    }
    else if (IsEqualGUID(riid, &IID_IDirect3DRMAnimation2))
    {
        *out = &animation->IDirect3DRMAnimation2_iface;
    }
    else
    {
        *out = NULL;
        WARN("%s not implemented, returning CLASS_E_CLASSNOTAVAILABLE.\n", debugstr_guid(riid));
        return CLASS_E_CLASSNOTAVAILABLE;
    }

    IUnknown_AddRef((IUnknown *)*out);
    return S_OK;
}

static HRESULT WINAPI d3drm_animation1_QueryInterface(IDirect3DRMAnimation *iface, REFIID riid, void **out)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);

    return IDirect3DRMAnimation2_QueryInterface(&animation->IDirect3DRMAnimation2_iface, riid, out);
}

static ULONG WINAPI d3drm_animation2_AddRef(IDirect3DRMAnimation2 *iface)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
    ULONG refcount = InterlockedIncrement(&animation->ref);

    TRACE("%p increasing refcount to %u.\n", iface, refcount);

    return refcount;
}

static ULONG WINAPI d3drm_animation1_AddRef(IDirect3DRMAnimation *iface)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
    return IDirect3DRMAnimation2_AddRef(&animation->IDirect3DRMAnimation2_iface);
}

static ULONG WINAPI d3drm_animation2_Release(IDirect3DRMAnimation2 *iface)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
    ULONG refcount = InterlockedDecrement(&animation->ref);

    TRACE("%p decreasing refcount to %u.\n", iface, refcount);

    if (!refcount)
    {
        d3drm_object_cleanup((IDirect3DRMObject *)&animation->IDirect3DRMAnimation_iface, &animation->obj);
        IDirect3DRM_Release(animation->d3drm);
3235 3236 3237 3238
        heap_free(animation->rotate.keys);
        heap_free(animation->scale.keys);
        heap_free(animation->position.keys);
        heap_free(animation);
3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396
    }

    return refcount;
}

static ULONG WINAPI d3drm_animation1_Release(IDirect3DRMAnimation *iface)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    return IDirect3DRMAnimation2_Release(&animation->IDirect3DRMAnimation2_iface);
}

static HRESULT WINAPI d3drm_animation2_Clone(IDirect3DRMAnimation2 *iface, IUnknown *outer, REFIID iid, void **out)
{
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_animation1_Clone(IDirect3DRMAnimation *iface, IUnknown *outer, REFIID iid, void **out)
{
    FIXME("iface %p, outer %p, iid %s, out %p stub!\n", iface, outer, debugstr_guid(iid), out);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_animation2_AddDestroyCallback(IDirect3DRMAnimation2 *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return d3drm_object_add_destroy_callback(&animation->obj, cb, ctx);
}

static HRESULT WINAPI d3drm_animation1_AddDestroyCallback(IDirect3DRMAnimation *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return IDirect3DRMAnimation2_AddDestroyCallback(&animation->IDirect3DRMAnimation2_iface, cb, ctx);
}

static HRESULT WINAPI d3drm_animation2_DeleteDestroyCallback(IDirect3DRMAnimation2 *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return d3drm_object_delete_destroy_callback(&animation->obj, cb, ctx);
}

static HRESULT WINAPI d3drm_animation1_DeleteDestroyCallback(IDirect3DRMAnimation *iface,
        D3DRMOBJECTCALLBACK cb, void *ctx)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, cb %p, ctx %p.\n", iface, cb, ctx);

    return IDirect3DRMAnimation2_DeleteDestroyCallback(&animation->IDirect3DRMAnimation2_iface, cb, ctx);
}

static HRESULT WINAPI d3drm_animation2_SetAppData(IDirect3DRMAnimation2 *iface, DWORD data)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, data %#x.\n", iface, data);

    animation->obj.appdata = data;

    return D3DRM_OK;
}

static HRESULT WINAPI d3drm_animation1_SetAppData(IDirect3DRMAnimation *iface, DWORD data)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, data %#x.\n", iface, data);

    return d3drm_animation2_SetAppData(&animation->IDirect3DRMAnimation2_iface, data);
}

static DWORD WINAPI d3drm_animation2_GetAppData(IDirect3DRMAnimation2 *iface)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p.\n", iface);

    return animation->obj.appdata;
}

static DWORD WINAPI d3drm_animation1_GetAppData(IDirect3DRMAnimation *iface)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p.\n", iface);

    return d3drm_animation2_GetAppData(&animation->IDirect3DRMAnimation2_iface);
}

static HRESULT WINAPI d3drm_animation2_SetName(IDirect3DRMAnimation2 *iface, const char *name)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_object_set_name(&animation->obj, name);
}

static HRESULT WINAPI d3drm_animation1_SetName(IDirect3DRMAnimation *iface, const char *name)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, name %s.\n", iface, debugstr_a(name));

    return d3drm_animation2_SetName(&animation->IDirect3DRMAnimation2_iface, name);
}

static HRESULT WINAPI d3drm_animation2_GetName(IDirect3DRMAnimation2 *iface, DWORD *size, char *name)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_object_get_name(&animation->obj, size, name);
}

static HRESULT WINAPI d3drm_animation1_GetName(IDirect3DRMAnimation *iface, DWORD *size, char *name)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_animation2_GetName(&animation->IDirect3DRMAnimation2_iface, size, name);
}

static HRESULT WINAPI d3drm_animation2_GetClassName(IDirect3DRMAnimation2 *iface, DWORD *size, char *name)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);

    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_object_get_class_name(&animation->obj, size, name);
}

static HRESULT WINAPI d3drm_animation1_GetClassName(IDirect3DRMAnimation *iface, DWORD *size, char *name)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, size %p, name %p.\n", iface, size, name);

    return d3drm_animation2_GetClassName(&animation->IDirect3DRMAnimation2_iface, size, name);
}

3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421
static HRESULT WINAPI d3drm_animation2_SetOptions(IDirect3DRMAnimation2 *iface, D3DRMANIMATIONOPTIONS options)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
    static const DWORD supported_options = D3DRMANIMATION_OPEN | D3DRMANIMATION_CLOSED | D3DRMANIMATION_LINEARPOSITION
        | D3DRMANIMATION_SPLINEPOSITION | D3DRMANIMATION_SCALEANDROTATION | D3DRMANIMATION_POSITION;

    TRACE("iface %p, options %#x.\n", iface, options);

    if (!(options & supported_options))
        return D3DRMERR_BADVALUE;

    if ((options & (D3DRMANIMATION_OPEN | D3DRMANIMATION_CLOSED)) == (D3DRMANIMATION_OPEN | D3DRMANIMATION_CLOSED) ||
            (options & (D3DRMANIMATION_LINEARPOSITION | D3DRMANIMATION_SPLINEPOSITION)) ==
            (D3DRMANIMATION_LINEARPOSITION | D3DRMANIMATION_SPLINEPOSITION) ||
            (options & (D3DRMANIMATION_SCALEANDROTATION | D3DRMANIMATION_POSITION)) ==
            (D3DRMANIMATION_SCALEANDROTATION | D3DRMANIMATION_POSITION))
    {
        return D3DRMERR_BADVALUE;
    }

    animation->options = options;

    return D3DRM_OK;
}

3422 3423
static HRESULT WINAPI d3drm_animation1_SetOptions(IDirect3DRMAnimation *iface, D3DRMANIMATIONOPTIONS options)
{
3424
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
3425

3426 3427 3428
    TRACE("iface %p, %#x.\n", iface, options);

    return d3drm_animation2_SetOptions(&animation->IDirect3DRMAnimation2_iface, options);
3429 3430
}

3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487
static SIZE_T d3drm_animation_lookup_key(const struct d3drm_animation_key *keys,
        SIZE_T count, D3DVALUE time)
{
    SIZE_T start = 0, cur = 0, end = count;

    while (start < end)
    {
        cur = start + (end - start) / 2;

        if (time == keys[cur].time)
            return cur;

        if (time < keys[cur].time)
            end = cur;
        else
            start = cur + 1;
    }

    return cur;
}

static SIZE_T d3drm_animation_get_index_min(const struct d3drm_animation_key *keys, SIZE_T count, D3DVALUE time)
{
    SIZE_T i;

    i = d3drm_animation_lookup_key(keys, count, time);
    while (i > 0 && keys[i - 1].time == time)
        --i;

    return i;
}

static SIZE_T d3drm_animation_get_index_max(const struct d3drm_animation_key *keys, SIZE_T count, D3DVALUE time)
{
    SIZE_T i;

    i = d3drm_animation_lookup_key(keys, count, time);
    while (i < count - 1 && keys[i + 1].time == time)
        ++i;

    return i;
}

static SIZE_T d3drm_animation_get_insert_position(const struct d3drm_animation_keys *keys, D3DVALUE time)
{
    if (!keys->count || time < keys->keys[0].time)
        return 0;

    if (time >= keys->keys[keys->count - 1].time)
        return keys->count;

    return d3drm_animation_get_index_max(keys->keys, keys->count, time);
}

static const struct d3drm_animation_key *d3drm_animation_get_range(const struct d3drm_animation_keys *keys,
        D3DVALUE time_min, D3DVALUE time_max, SIZE_T *count)
{
3488
    SIZE_T min;
3489 3490 3491 3492 3493 3494

    if (!keys->count || time_max < keys->keys[0].time
            || time_min > keys->keys[keys->count - 1].time)
        return NULL;

    min = d3drm_animation_get_index_min(keys->keys, keys->count, time_min);
3495 3496
    if (count)
        *count = d3drm_animation_get_index_max(&keys->keys[min], keys->count - min, time_max) - min + 1;
3497 3498 3499 3500

    return &keys->keys[min];
}

3501
static HRESULT WINAPI d3drm_animation2_AddKey(IDirect3DRMAnimation2 *iface, D3DRMANIMATIONKEY *key)
3502
{
3503 3504 3505
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
    struct d3drm_animation_keys *keys;
    SIZE_T index;
3506

3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549
    TRACE("iface %p, key %p.\n", iface, key);

    if (!key || key->dwSize != sizeof(*key))
        return E_INVALIDARG;

    switch (key->dwKeyType)
    {
        case D3DRMANIMATION_POSITIONKEY:
            keys = &animation->position;
            break;
        case D3DRMANIMATION_SCALEKEY:
            keys = &animation->scale;
            break;
        case D3DRMANIMATION_ROTATEKEY:
            keys = &animation->rotate;
            break;
        default:
            return E_INVALIDARG;
    }

    index = d3drm_animation_get_insert_position(keys, key->dvTime);

    if (!d3drm_array_reserve((void **)&keys->keys, &keys->size, keys->count + 1, sizeof(*keys->keys)))
        return E_OUTOFMEMORY;

    if (index < keys->count)
        memmove(&keys->keys[index + 1], &keys->keys[index], sizeof(*keys->keys) * (keys->count - index));
    keys->keys[index].time = key->dvTime;
    switch (key->dwKeyType)
    {
        case D3DRMANIMATION_POSITIONKEY:
            keys->keys[index].u.position = key->u.dvPositionKey;
            break;
        case D3DRMANIMATION_SCALEKEY:
            keys->keys[index].u.scale = key->u.dvScaleKey;
            break;
        case D3DRMANIMATION_ROTATEKEY:
            keys->keys[index].u.rotate = key->u.dqRotateKey;
            break;
    }
    ++keys->count;

    return D3DRM_OK;
3550 3551
}

3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593
static HRESULT WINAPI d3drm_animation2_AddRotateKey(IDirect3DRMAnimation2 *iface, D3DVALUE time, D3DRMQUATERNION *q)
{
    D3DRMANIMATIONKEY key;

    TRACE("iface %p, time %.8e, q %p.\n", iface, time, q);

    key.dwSize = sizeof(key);
    key.dwKeyType = D3DRMANIMATION_ROTATEKEY;
    key.dvTime = time;
    key.dwID = 0;
    key.u.dqRotateKey = *q;

    return d3drm_animation2_AddKey(iface, &key);
}

static HRESULT WINAPI d3drm_animation1_AddRotateKey(IDirect3DRMAnimation *iface, D3DVALUE time, D3DRMQUATERNION *q)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);

    TRACE("iface %p, time %.8e, q %p.\n", iface, time, q);

    return d3drm_animation2_AddRotateKey(&animation->IDirect3DRMAnimation2_iface, time, q);
}

static HRESULT WINAPI d3drm_animation2_AddPositionKey(IDirect3DRMAnimation2 *iface, D3DVALUE time,
        D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
    D3DRMANIMATIONKEY key;

    TRACE("iface %p, time %.8e, x %.8e, y %.8e, z %.8e.\n", iface, time, x, y, z);

    key.dwSize = sizeof(key);
    key.dwKeyType = D3DRMANIMATION_POSITIONKEY;
    key.dvTime = time;
    key.dwID = 0;
    key.u.dvPositionKey.u1.x = x;
    key.u.dvPositionKey.u2.y = y;
    key.u.dvPositionKey.u3.z = z;

    return d3drm_animation2_AddKey(iface, &key);
}

3594 3595 3596
static HRESULT WINAPI d3drm_animation1_AddPositionKey(IDirect3DRMAnimation *iface, D3DVALUE time,
        D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
3597
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
3598

3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619
    TRACE("iface %p, time %.8e, x %.8e, y %.8e, z %.8e.\n", iface, time, x, y, z);

    return d3drm_animation2_AddPositionKey(&animation->IDirect3DRMAnimation2_iface, time, x, y, z);
}

static HRESULT WINAPI d3drm_animation2_AddScaleKey(IDirect3DRMAnimation2 *iface, D3DVALUE time,
        D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
    D3DRMANIMATIONKEY key;

    TRACE("iface %p, time %.8e, x %.8e, y %.8e, z %.8e.\n", iface, time, x, y, z);

    key.dwSize = sizeof(key);
    key.dwKeyType = D3DRMANIMATION_SCALEKEY;
    key.dvTime = time;
    key.dwID = 0;
    key.u.dvScaleKey.u1.x = x;
    key.u.dvScaleKey.u2.y = y;
    key.u.dvScaleKey.u3.z = z;

    return d3drm_animation2_AddKey(iface, &key);
3620 3621 3622 3623 3624
}

static HRESULT WINAPI d3drm_animation1_AddScaleKey(IDirect3DRMAnimation *iface, D3DVALUE time,
        D3DVALUE x, D3DVALUE y, D3DVALUE z)
{
3625
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
3626

3627 3628 3629
    TRACE("iface %p, time %.8e, x %.8e, y %.8e, z %.8e.\n", iface, time, x, y, z);

    return d3drm_animation2_AddScaleKey(&animation->IDirect3DRMAnimation2_iface, time, x, y, z);
3630 3631
}

3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659
static void d3drm_animation_delete_key(struct d3drm_animation_keys *keys, const struct d3drm_animation_key *key)
{
    SIZE_T index = key - keys->keys;

    if (index < keys->count - 1)
        memmove(&keys->keys[index], &keys->keys[index + 1], sizeof(*keys->keys) * (keys->count - index - 1));
    --keys->count;
}

static HRESULT WINAPI d3drm_animation2_DeleteKey(IDirect3DRMAnimation2 *iface, D3DVALUE time)
{
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
    const struct d3drm_animation_key *key;

    TRACE("iface %p, time %.8e.\n", iface, time);

    if ((key = d3drm_animation_get_range(&animation->rotate, time, time, NULL)))
        d3drm_animation_delete_key(&animation->rotate, key);

    if ((key = d3drm_animation_get_range(&animation->position, time, time, NULL)))
        d3drm_animation_delete_key(&animation->position, key);

    if ((key = d3drm_animation_get_range(&animation->scale, time, time, NULL)))
        d3drm_animation_delete_key(&animation->scale, key);

    return D3DRM_OK;
}

3660 3661
static HRESULT WINAPI d3drm_animation1_DeleteKey(IDirect3DRMAnimation *iface, D3DVALUE time)
{
3662
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
3663

3664 3665 3666
    TRACE("iface %p, time %.8e.\n", iface, time);

    return d3drm_animation2_DeleteKey(&animation->IDirect3DRMAnimation2_iface, time);
3667 3668 3669 3670
}

static HRESULT WINAPI d3drm_animation1_SetFrame(IDirect3DRMAnimation *iface, IDirect3DRMFrame *frame)
{
3671 3672
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
    HRESULT hr = D3DRM_OK;
3673

3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685
    TRACE("iface %p, frame %p.\n", iface, frame);

    if (frame)
    {
        hr = IDirect3DRMFrame_QueryInterface(frame, &IID_IDirect3DRMFrame3, (void **)&animation->frame);
        if (SUCCEEDED(hr))
            IDirect3DRMFrame3_Release(animation->frame);
    }
    else
        animation->frame = NULL;

    return hr;
3686 3687 3688 3689 3690 3691 3692 3693 3694
}

static HRESULT WINAPI d3drm_animation1_SetTime(IDirect3DRMAnimation *iface, D3DVALUE time)
{
    FIXME("iface %p, time %.8e.\n", iface, time);

    return E_NOTIMPL;
}

3695
static D3DRMANIMATIONOPTIONS WINAPI d3drm_animation2_GetOptions(IDirect3DRMAnimation2 *iface)
3696
{
3697
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
3698

3699 3700 3701
    TRACE("iface %p.\n", iface);

    return animation->options;
3702 3703
}

3704
static D3DRMANIMATIONOPTIONS WINAPI d3drm_animation1_GetOptions(IDirect3DRMAnimation *iface)
3705
{
3706
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation(iface);
3707

3708 3709 3710
    TRACE("iface %p.\n", iface);

    return d3drm_animation2_GetOptions(&animation->IDirect3DRMAnimation2_iface);
3711 3712 3713 3714
}

static HRESULT WINAPI d3drm_animation2_SetFrame(IDirect3DRMAnimation2 *iface, IDirect3DRMFrame3 *frame)
{
3715
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
3716

3717 3718 3719 3720 3721
    TRACE("iface %p, frame %p.\n", iface, frame);

    animation->frame = frame;

    return D3DRM_OK;
3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732
}

static HRESULT WINAPI d3drm_animation2_SetTime(IDirect3DRMAnimation2 *iface, D3DVALUE time)
{
    FIXME("iface %p, time %.8e.\n", iface, time);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_animation2_GetFrame(IDirect3DRMAnimation2 *iface, IDirect3DRMFrame3 **frame)
{
3733
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
3734

3735 3736 3737 3738 3739 3740 3741 3742 3743 3744
    TRACE("iface %p, frame %p.\n", iface, frame);

    if (!frame)
        return D3DRMERR_BADVALUE;

    *frame = animation->frame;
    if (*frame)
        IDirect3DRMFrame3_AddRef(*frame);

    return D3DRM_OK;
3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763
}

static HRESULT WINAPI d3drm_animation2_DeleteKeyByID(IDirect3DRMAnimation2 *iface, DWORD id)
{
    FIXME("iface %p, id %#x.\n", iface, id);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_animation2_ModifyKey(IDirect3DRMAnimation2 *iface, D3DRMANIMATIONKEY *key)
{
    FIXME("iface %p, key %p.\n", iface, key);

    return E_NOTIMPL;
}

static HRESULT WINAPI d3drm_animation2_GetKeys(IDirect3DRMAnimation2 *iface, D3DVALUE time_min, D3DVALUE time_max,
        DWORD *key_count, D3DRMANIMATIONKEY *keys)
{
3764 3765 3766
    struct d3drm_animation *animation = impl_from_IDirect3DRMAnimation2(iface);
    const struct d3drm_animation_key *key;
    SIZE_T count, i;
3767

3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827
    TRACE("iface %p, time min %.8e, time max %.8e, key_count %p, keys %p.\n",
            iface, time_min, time_max, key_count, keys);

    if (!key_count)
        return D3DRMERR_BADVALUE;

    *key_count = 0;

    if ((key = d3drm_animation_get_range(&animation->rotate, time_min, time_max, &count)))
    {
        if (keys)
        {
            for (i = 0; i < count; ++i)
            {
                keys[i].dwSize = sizeof(*keys);
                keys[i].dwKeyType = D3DRMANIMATION_ROTATEKEY;
                keys[i].dvTime = key[i].time;
                keys[i].dwID = 0; /* FIXME */
                keys[i].u.dqRotateKey = key[i].u.rotate;
            }
            keys += count;
        }
        *key_count += count;
    }

    if ((key = d3drm_animation_get_range(&animation->position, time_min, time_max, &count)))
    {
        if (keys)
        {
            for (i = 0; i < count; ++i)
            {
                keys[i].dwSize = sizeof(*keys);
                keys[i].dwKeyType = D3DRMANIMATION_POSITIONKEY;
                keys[i].dvTime = key[i].time;
                keys[i].dwID = 0; /* FIXME */
                keys[i].u.dvPositionKey = key[i].u.position;
            }
            keys += count;
        }
        *key_count += count;
    }

    if ((key = d3drm_animation_get_range(&animation->scale, time_min, time_max, &count)))
    {
        if (keys)
        {
            for (i = 0; keys && i < count; ++i)
            {
                keys[i].dwSize = sizeof(*keys);
                keys[i].dwKeyType = D3DRMANIMATION_SCALEKEY;
                keys[i].dvTime = key[i].time;
                keys[i].dwID = 0; /* FIXME */
                keys[i].u.dvScaleKey = key[i].u.scale;
            }
            keys += count;
        }
        *key_count += count;
    }

    return *key_count ? D3DRM_OK : D3DRMERR_NOSUCHKEY;
3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888
}

static const struct IDirect3DRMAnimationVtbl d3drm_animation1_vtbl =
{
    d3drm_animation1_QueryInterface,
    d3drm_animation1_AddRef,
    d3drm_animation1_Release,
    d3drm_animation1_Clone,
    d3drm_animation1_AddDestroyCallback,
    d3drm_animation1_DeleteDestroyCallback,
    d3drm_animation1_SetAppData,
    d3drm_animation1_GetAppData,
    d3drm_animation1_SetName,
    d3drm_animation1_GetName,
    d3drm_animation1_GetClassName,
    d3drm_animation1_SetOptions,
    d3drm_animation1_AddRotateKey,
    d3drm_animation1_AddPositionKey,
    d3drm_animation1_AddScaleKey,
    d3drm_animation1_DeleteKey,
    d3drm_animation1_SetFrame,
    d3drm_animation1_SetTime,
    d3drm_animation1_GetOptions,
};

static const struct IDirect3DRMAnimation2Vtbl d3drm_animation2_vtbl =
{
    d3drm_animation2_QueryInterface,
    d3drm_animation2_AddRef,
    d3drm_animation2_Release,
    d3drm_animation2_Clone,
    d3drm_animation2_AddDestroyCallback,
    d3drm_animation2_DeleteDestroyCallback,
    d3drm_animation2_SetAppData,
    d3drm_animation2_GetAppData,
    d3drm_animation2_SetName,
    d3drm_animation2_GetName,
    d3drm_animation2_GetClassName,
    d3drm_animation2_SetOptions,
    d3drm_animation2_AddRotateKey,
    d3drm_animation2_AddPositionKey,
    d3drm_animation2_AddScaleKey,
    d3drm_animation2_DeleteKey,
    d3drm_animation2_SetFrame,
    d3drm_animation2_SetTime,
    d3drm_animation2_GetOptions,
    d3drm_animation2_GetFrame,
    d3drm_animation2_DeleteKeyByID,
    d3drm_animation2_AddKey,
    d3drm_animation2_ModifyKey,
    d3drm_animation2_GetKeys,
};

HRESULT d3drm_animation_create(struct d3drm_animation **animation, IDirect3DRM *d3drm)
{
    static const char classname[] = "Animation";
    struct d3drm_animation *object;
    HRESULT hr = D3DRM_OK;

    TRACE("animation %p, d3drm %p.\n", animation, d3drm);

3889
    if (!(object = heap_alloc_zero(sizeof(*object))))
3890 3891 3892 3893 3894 3895
        return E_OUTOFMEMORY;

    object->IDirect3DRMAnimation_iface.lpVtbl = &d3drm_animation1_vtbl;
    object->IDirect3DRMAnimation2_iface.lpVtbl = &d3drm_animation2_vtbl;
    object->d3drm = d3drm;
    object->ref = 1;
3896
    object->options = D3DRMANIMATION_CLOSED | D3DRMANIMATION_LINEARPOSITION;
3897 3898 3899 3900 3901 3902 3903 3904 3905

    d3drm_object_init(&object->obj, classname);

    IDirect3DRM_AddRef(object->d3drm);

    *animation = object;

    return hr;
}