From e6feb9b03112b43b853bc12c33cea01d71b8c20a Mon Sep 17 00:00:00 2001 From: Aaryaman Vasishta Date: Mon, 20 Jun 2016 00:58:08 +0530 Subject: [PATCH] d3drm: Fix frame object creation method. Signed-off-by: Aaryaman Vasishta Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/d3drm/d3drm.c | 32 +++++++++++++++++++++++++++++--- dlls/d3drm/d3drm_private.h | 23 ++++++++++++++++++++++- dlls/d3drm/frame.c | 38 +++++++++----------------------------- 3 files changed, 60 insertions(+), 33 deletions(-) diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c index 14fed3a92c3..4f1f84038e8 100644 --- a/dlls/d3drm/d3drm.c +++ b/dlls/d3drm/d3drm.c @@ -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) diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index 817accfda03..42112bf8461 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -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; diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 395b9ac828e..e58dd0514c0 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -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; }