diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c index 7fcb0ba208f..d0145d977d8 100644 --- a/dlls/d3drm/d3drm.c +++ b/dlls/d3drm/d3drm.c @@ -273,10 +273,10 @@ static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface, { struct d3drm_device *object; HRESULT hr; + FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device); - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, iface))) return hr; *device = IDirect3DRMDevice_from_impl(object); @@ -287,7 +287,6 @@ static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface, static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *guid, IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice **device) { - struct d3drm *d3drm = impl_from_IDirect3DRM(iface); struct d3drm_device *object; HRESULT hr; @@ -301,12 +300,10 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *g if (!backbuffer || !ddraw) return D3DRMERR_BADDEVICE; - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, iface))) return hr; - hr = d3drm_device_init(object, 1, &d3drm->IDirect3DRM_iface, ddraw, backbuffer, TRUE); - if (SUCCEEDED(hr)) + if (SUCCEEDED(hr = d3drm_device_init(object, 1, ddraw, backbuffer, TRUE))) *device = IDirect3DRMDevice_from_impl(object); else d3drm_device_destroy(object); @@ -328,12 +325,10 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface, if (!d3d || !d3d_device) return D3DRMERR_BADVALUE; - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, iface))) return hr; - hr = d3drm_device_set_ddraw_device_d3d(object, iface, d3d, d3d_device); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_set_ddraw_device_d3d(object, d3d, d3d_device))) { d3drm_device_destroy(object); return hr; @@ -366,8 +361,7 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromClipper(IDirect3DRM *iface, if (FAILED(hr)) return hr; - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, iface))) { IDirectDraw_Release(ddraw); return hr; @@ -381,7 +375,7 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromClipper(IDirect3DRM *iface, return hr; } - hr = d3drm_device_init(object, 1, iface, ddraw, render_target, TRUE); + hr = d3drm_device_init(object, 1, ddraw, render_target, TRUE); IDirectDraw_Release(ddraw); IDirectDrawSurface_Release(render_target); if (FAILED(hr)) @@ -756,12 +750,13 @@ static HRESULT WINAPI d3drm2_CreateMaterial(IDirect3DRM2 *iface, static HRESULT WINAPI d3drm2_CreateDevice(IDirect3DRM2 *iface, DWORD width, DWORD height, IDirect3DRMDevice2 **device) { + struct d3drm *d3drm = impl_from_IDirect3DRM2(iface); struct d3drm_device *object; HRESULT hr; + FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device); - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface))) return hr; *device = IDirect3DRMDevice2_from_impl(object); @@ -1305,12 +1300,13 @@ static HRESULT WINAPI d3drm3_CreateMaterial(IDirect3DRM3 *iface, static HRESULT WINAPI d3drm3_CreateDevice(IDirect3DRM3 *iface, DWORD width, DWORD height, IDirect3DRMDevice3 **device) { + struct d3drm *d3drm = impl_from_IDirect3DRM3(iface); struct d3drm_device *object; HRESULT hr; + FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device); - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface))) return hr; *device = IDirect3DRMDevice3_from_impl(object); @@ -1336,14 +1332,12 @@ static HRESULT WINAPI d3drm3_CreateDeviceFromSurface(IDirect3DRM3 *iface, GUID * if (!backbuffer || !ddraw) return D3DRMERR_BADDEVICE; - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface))) return hr; use_z_surface = !(flags & D3DRMDEVICE_NOZBUFFER); - hr = d3drm_device_init(object, 3, &d3drm->IDirect3DRM_iface, ddraw, backbuffer, use_z_surface); - if (SUCCEEDED(hr)) + if (SUCCEEDED(hr = d3drm_device_init(object, 3, ddraw, backbuffer, use_z_surface))) *device = IDirect3DRMDevice3_from_impl(object); else d3drm_device_destroy(object); @@ -1414,8 +1408,7 @@ static HRESULT WINAPI d3drm3_CreateDeviceFromClipper(IDirect3DRM3 *iface, if (FAILED(hr)) return hr; - hr = d3drm_device_create(&object); - if (FAILED(hr)) + if (FAILED(hr = d3drm_device_create(&object, &d3drm->IDirect3DRM_iface))) { IDirectDraw_Release(ddraw); return hr; @@ -1429,7 +1422,7 @@ static HRESULT WINAPI d3drm3_CreateDeviceFromClipper(IDirect3DRM3 *iface, return hr; } - hr = d3drm_device_init(object, 3, &d3drm->IDirect3DRM_iface, ddraw, render_target, TRUE); + hr = d3drm_device_init(object, 3, ddraw, render_target, TRUE); IDirectDraw_Release(ddraw); IDirectDrawSurface_Release(render_target); if (FAILED(hr)) diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h index 651eaec35c1..1a2aff11692 100644 --- a/dlls/d3drm/d3drm_private.h +++ b/dlls/d3drm/d3drm_private.h @@ -81,12 +81,20 @@ struct d3drm_viewport D3DRMPROJECTIONTYPE projection; }; +HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; +HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, + IDirectDrawClipper *clipper, int width, int height, IDirectDrawSurface **surface) DECLSPEC_HIDDEN; +void d3drm_device_destroy(struct d3drm_device *device) DECLSPEC_HIDDEN; +HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw, + IDirectDrawSurface *surface, BOOL create_z_surface) DECLSPEC_HIDDEN; +HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, + IDirect3D *d3d, IDirect3DDevice *d3d_device) DECLSPEC_HIDDEN; + 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; void d3drm_object_cleanup(IDirect3DRMObject *iface, struct d3drm_object *object) DECLSPEC_HIDDEN; -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; HRESULT d3drm_viewport_create(struct d3drm_viewport **viewport, IDirect3DRM *d3drm) DECLSPEC_HIDDEN; @@ -102,16 +110,6 @@ HRESULT Direct3DRMMaterial_create(IDirect3DRMMaterial2** ret_iface) DECLSPEC_HID HRESULT load_mesh_data(IDirect3DRMMeshBuilder3 *iface, IDirectXFileData *data, D3DRMLOADTEXTURECALLBACK load_texture_proc, void *arg) DECLSPEC_HIDDEN; -void d3drm_device_destroy(struct d3drm_device *device) DECLSPEC_HIDDEN; - -HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, IDirectDraw *ddraw, IDirectDrawClipper *clipper, int width, int height, - IDirectDrawSurface **surface) DECLSPEC_HIDDEN; - -HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirect3DRM *d3drm, IDirectDraw *ddraw, IDirectDrawSurface *surface, - BOOL create_z_surface) DECLSPEC_HIDDEN; - -HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3DRM *d3drm, IDirect3D *d3d, IDirect3DDevice *d3d_device) DECLSPEC_HIDDEN; - struct d3drm_file_header { WORD major; diff --git a/dlls/d3drm/device.c b/dlls/d3drm/device.c index 2efd6afc065..ba61c29bb96 100644 --- a/dlls/d3drm/device.c +++ b/dlls/d3drm/device.c @@ -159,7 +159,7 @@ HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, I return D3DRM_OK; } -HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirect3DRM *d3drm, IDirectDraw *ddraw, IDirectDrawSurface *surface, +HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirectDraw *ddraw, IDirectDrawSurface *surface, BOOL create_z_surface) { DDSCAPS caps = { DDSCAPS_ZBUFFER }; @@ -172,8 +172,7 @@ HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirect3DRM device->ddraw = ddraw; IDirectDraw_AddRef(ddraw); - device->d3drm = d3drm; - IDirect3DRM_AddRef(d3drm); + IDirect3DRM_AddRef(device->d3drm); device->render_target = surface; IDirectDrawSurface_AddRef(surface); @@ -243,7 +242,7 @@ HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirect3DRM return hr; } -HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3DRM *d3drm, IDirect3D *d3d, IDirect3DDevice *d3d_device) +HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D *d3d, IDirect3DDevice *d3d_device) { IDirectDrawSurface *surface; IDirect3DDevice2 *d3d_device2; @@ -272,8 +271,7 @@ HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3D device->width = desc.dwWidth; device->height = desc.dwHeight; - device->d3drm = d3drm; - IDirect3DRM_AddRef(d3drm); + IDirect3DRM_AddRef(device->d3drm); device->device = d3d_device; IDirect3DDevice_AddRef(d3d_device); @@ -1605,11 +1603,11 @@ static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl = d3drm_device_win_HandleActivate, }; -HRESULT d3drm_device_create(struct d3drm_device **out) +HRESULT d3drm_device_create(struct d3drm_device **device, IDirect3DRM *d3drm) { struct d3drm_device *object; - TRACE("out %p.\n", out); + TRACE("device %p, d3drm %p.\n", device, d3drm); if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; @@ -1618,9 +1616,10 @@ HRESULT d3drm_device_create(struct d3drm_device **out) object->IDirect3DRMDevice2_iface.lpVtbl = &d3drm_device2_vtbl; object->IDirect3DRMDevice3_iface.lpVtbl = &d3drm_device3_vtbl; object->IDirect3DRMWinDevice_iface.lpVtbl = &d3drm_device_win_vtbl; + object->d3drm = d3drm; object->ref = 1; - *out = object; + *device = object; return D3DRM_OK; }