Commit e6feb9b0 authored by Aaryaman Vasishta's avatar Aaryaman Vasishta Committed by Alexandre Julliard

d3drm: Fix frame object creation method.

parent e6f11af2
......@@ -150,9 +150,17 @@ static HRESULT WINAPI d3drm1_CreateObject(IDirect3DRM *iface,
static HRESULT WINAPI d3drm1_CreateFrame(IDirect3DRM *iface,
IDirect3DRMFrame *parent_frame, IDirect3DRMFrame **frame)
{
struct d3drm_frame *object;
HRESULT hr;
TRACE("iface %p, parent_frame %p, frame %p.\n", iface, parent_frame, frame);
return Direct3DRMFrame_create(&IID_IDirect3DRMFrame, (IUnknown *)parent_frame, (IUnknown **)frame);
if (FAILED(hr = d3drm_frame_create(&object, (IUnknown *)parent_frame, iface)))
return hr;
*frame = &object->IDirect3DRMFrame_iface;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm1_CreateMesh(IDirect3DRM *iface, IDirect3DRMMesh **mesh)
......@@ -624,9 +632,18 @@ static HRESULT WINAPI d3drm2_CreateObject(IDirect3DRM2 *iface,
static HRESULT WINAPI d3drm2_CreateFrame(IDirect3DRM2 *iface,
IDirect3DRMFrame *parent_frame, IDirect3DRMFrame2 **frame)
{
struct d3drm *d3drm = impl_from_IDirect3DRM2(iface);
struct d3drm_frame *object;
HRESULT hr;
TRACE("iface %p, parent_frame %p, frame %p.\n", iface, parent_frame, frame);
return Direct3DRMFrame_create(&IID_IDirect3DRMFrame2, (IUnknown*)parent_frame, (IUnknown**)frame);
if (FAILED(hr = d3drm_frame_create(&object, (IUnknown *)parent_frame, &d3drm->IDirect3DRM_iface)))
return hr;
*frame = &object->IDirect3DRMFrame2_iface;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm2_CreateMesh(IDirect3DRM2 *iface, IDirect3DRMMesh **mesh)
......@@ -1126,9 +1143,18 @@ static HRESULT WINAPI d3drm3_CreateObject(IDirect3DRM3 *iface,
static HRESULT WINAPI d3drm3_CreateFrame(IDirect3DRM3 *iface,
IDirect3DRMFrame3 *parent, IDirect3DRMFrame3 **frame)
{
struct d3drm *d3drm = impl_from_IDirect3DRM3(iface);
struct d3drm_frame *object;
HRESULT hr;
TRACE("iface %p, parent %p, frame %p.\n", iface, parent, frame);
return Direct3DRMFrame_create(&IID_IDirect3DRMFrame3, (IUnknown *)parent, (IUnknown **)frame);
if (FAILED(hr = d3drm_frame_create(&object, (IUnknown *)parent, &d3drm->IDirect3DRM_iface)))
return hr;
*frame = &object->IDirect3DRMFrame3_iface;
return D3DRM_OK;
}
static HRESULT WINAPI d3drm3_CreateMesh(IDirect3DRM3 *iface, IDirect3DRMMesh **mesh)
......
......@@ -44,6 +44,27 @@ struct d3drm_texture
D3DRMIMAGE *image;
};
struct d3drm_frame
{
IDirect3DRMFrame IDirect3DRMFrame_iface;
IDirect3DRMFrame2 IDirect3DRMFrame2_iface;
IDirect3DRMFrame3 IDirect3DRMFrame3_iface;
IDirect3DRM *d3drm;
LONG ref;
struct d3drm_frame *parent;
ULONG nb_children;
ULONG children_capacity;
IDirect3DRMFrame3 **children;
ULONG nb_visuals;
ULONG visuals_capacity;
IDirect3DRMVisual **visuals;
ULONG nb_lights;
ULONG lights_capacity;
IDirect3DRMLight **lights;
D3DRMMATRIX4D transform;
D3DCOLOR scenebackground;
};
void d3drm_object_init(struct d3drm_object *object) DECLSPEC_HIDDEN;
HRESULT d3drm_object_add_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
HRESULT d3drm_object_delete_destroy_callback(struct d3drm_object *object, D3DRMOBJECTCALLBACK cb, void *ctx) DECLSPEC_HIDDEN;
......@@ -51,11 +72,11 @@ void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object)
HRESULT d3drm_device_create(struct d3drm_device **out) DECLSPEC_HIDDEN;
HRESULT d3drm_texture_create(struct d3drm_texture **texture, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm) DECLSPEC_HIDDEN;
IDirect3DRMDevice *IDirect3DRMDevice_from_impl(struct d3drm_device *device) DECLSPEC_HIDDEN;
IDirect3DRMDevice2 *IDirect3DRMDevice2_from_impl(struct d3drm_device *device) DECLSPEC_HIDDEN;
IDirect3DRMDevice3 *IDirect3DRMDevice3_from_impl(struct d3drm_device *device) DECLSPEC_HIDDEN;
HRESULT Direct3DRMFace_create(REFIID riid, IUnknown** ret_iface) DECLSPEC_HIDDEN;
HRESULT Direct3DRMFrame_create(REFIID riid, IUnknown* parent_frame, IUnknown** ret_iface) DECLSPEC_HIDDEN;
HRESULT Direct3DRMLight_create(IUnknown** ppObj) DECLSPEC_HIDDEN;
HRESULT Direct3DRMMesh_create(IDirect3DRMMesh** obj) DECLSPEC_HIDDEN;
HRESULT Direct3DRMMeshBuilder_create(REFIID riid, IUnknown** ppObj) DECLSPEC_HIDDEN;
......
......@@ -38,26 +38,6 @@ static D3DRMMATRIX4D identity = {
{ 0.0f, 0.0f, 0.0f, 1.0f }
};
struct d3drm_frame
{
IDirect3DRMFrame IDirect3DRMFrame_iface;
IDirect3DRMFrame2 IDirect3DRMFrame2_iface;
IDirect3DRMFrame3 IDirect3DRMFrame3_iface;
LONG ref;
struct d3drm_frame *parent;
ULONG nb_children;
ULONG children_capacity;
IDirect3DRMFrame3** children;
ULONG nb_visuals;
ULONG visuals_capacity;
IDirect3DRMVisual** visuals;
ULONG nb_lights;
ULONG lights_capacity;
IDirect3DRMLight** lights;
D3DRMMATRIX4D transform;
D3DCOLOR scenebackground;
};
struct d3drm_frame_array
{
IDirect3DRMFrameArray IDirect3DRMFrameArray_iface;
......@@ -2926,12 +2906,12 @@ static inline struct d3drm_frame *unsafe_impl_from_IDirect3DRMFrame(IDirect3DRMF
return impl_from_IDirect3DRMFrame(iface);
}
HRESULT Direct3DRMFrame_create(REFIID riid, IUnknown *parent, IUnknown **out)
HRESULT d3drm_frame_create(struct d3drm_frame **frame, IUnknown *parent_frame, IDirect3DRM *d3drm)
{
struct d3drm_frame *object;
HRESULT hr;
HRESULT hr = D3DRM_OK;
TRACE("riid %s, parent %p, out %p.\n", debugstr_guid(riid), parent, out);
TRACE("frame %p, parent_frame %p, d3drm %p.\n", frame, parent_frame, d3drm);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
......@@ -2939,26 +2919,26 @@ HRESULT Direct3DRMFrame_create(REFIID riid, IUnknown *parent, IUnknown **out)
object->IDirect3DRMFrame_iface.lpVtbl = &d3drm_frame1_vtbl;
object->IDirect3DRMFrame2_iface.lpVtbl = &d3drm_frame2_vtbl;
object->IDirect3DRMFrame3_iface.lpVtbl = &d3drm_frame3_vtbl;
object->d3drm = d3drm;
object->ref = 1;
object->scenebackground = RGBA_MAKE(0, 0, 0, 0xff);
memcpy(object->transform, identity, sizeof(D3DRMMATRIX4D));
if (parent)
if (parent_frame)
{
IDirect3DRMFrame3 *p;
hr = IDirect3DRMFrame_QueryInterface(parent, &IID_IDirect3DRMFrame3, (void**)&p);
if (hr != S_OK)
if (FAILED(hr = IDirect3DRMFrame_QueryInterface(parent_frame, &IID_IDirect3DRMFrame3, (void **)&p)))
{
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
IDirect3DRMFrame_Release(parent);
IDirect3DRMFrame_Release(parent_frame);
IDirect3DRMFrame3_AddChild(p, &object->IDirect3DRMFrame3_iface);
}
hr = IDirect3DRMFrame3_QueryInterface(&object->IDirect3DRMFrame3_iface, riid, (void **)out);
IDirect3DRMFrame3_Release(&object->IDirect3DRMFrame3_iface);
*frame = object;
return hr;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment