Commit 9603125e authored by Aaryaman Vasishta's avatar Aaryaman Vasishta Committed by Alexandre Julliard

d3drm: Implement IDirect3DRM::CreateDeviceFromD3D.

parent e29a0cf4
...@@ -279,13 +279,25 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface, ...@@ -279,13 +279,25 @@ static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface,
{ {
struct d3drm_device *object; struct d3drm_device *object;
HRESULT hr; HRESULT hr;
FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n", TRACE("iface %p, d3d %p, d3d_device %p, device %p.\n",
iface, d3d, d3d_device, device); iface, d3d, d3d_device, device);
if (!device)
return D3DRMERR_BADVALUE;
*device = NULL;
if (!d3d || !d3d_device)
return D3DRMERR_BADVALUE;
hr = d3drm_device_create(&object); hr = d3drm_device_create(&object);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
hr = d3drm_device_set_ddraw_device_d3d(object, iface, d3d, d3d_device);
if (FAILED(hr))
{
d3drm_device_destroy(object);
return hr;
}
*device = IDirect3DRMDevice_from_impl(object); *device = IDirect3DRMDevice_from_impl(object);
return D3DRM_OK; return D3DRM_OK;
......
...@@ -50,6 +50,8 @@ HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, I ...@@ -50,6 +50,8 @@ HRESULT d3drm_device_create_surfaces_from_clipper(struct d3drm_device *object, I
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, IDirect3DRM *d3drm, IDirectDraw *ddraw, IDirectDrawSurface *surface,
BOOL create_z_surface) DECLSPEC_HIDDEN; 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 struct d3drm_file_header
{ {
WORD major; WORD major;
......
...@@ -241,6 +241,16 @@ HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirect3DRM ...@@ -241,6 +241,16 @@ HRESULT d3drm_device_init(struct d3drm_device *device, UINT version, IDirect3DRM
return hr; return hr;
} }
HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, IDirect3DRM *d3drm, IDirect3D *d3d, IDirect3DDevice *d3d_device)
{
device->d3drm = d3drm;
IDirect3DRM_AddRef(d3drm);
device->device = d3d_device;
IDirect3DDevice_AddRef(d3d_device);
return IDirect3D_QueryInterface(d3d, &IID_IDirectDraw, (void **)&device->ddraw);
}
static HRESULT WINAPI d3drm_device1_QueryInterface(IDirect3DRMDevice *iface, REFIID riid, void **out) static HRESULT WINAPI d3drm_device1_QueryInterface(IDirect3DRMDevice *iface, REFIID riid, void **out)
{ {
struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface); struct d3drm_device *device = impl_from_IDirect3DRMDevice(iface);
......
...@@ -3117,7 +3117,7 @@ static void test_create_device_from_d3d1(void) ...@@ -3117,7 +3117,7 @@ static void test_create_device_from_d3d1(void)
IDirectDraw *ddraw1 = NULL; IDirectDraw *ddraw1 = NULL;
IDirect3D *d3d1 = NULL; IDirect3D *d3d1 = NULL;
IDirect3DRM *d3drm1 = NULL; IDirect3DRM *d3drm1 = NULL;
IDirect3DRMDevice *device1 = NULL; IDirect3DRMDevice *device1 = (IDirect3DRMDevice *)0xdeadbeef;
IDirect3DDevice *d3ddevice1 = NULL, *d3drm_d3ddevice1 = NULL; IDirect3DDevice *d3ddevice1 = NULL, *d3drm_d3ddevice1 = NULL;
IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL; IDirectDrawSurface *surface = NULL, *ds = NULL, *d3drm_ds = NULL;
DWORD expected_flags; DWORD expected_flags;
...@@ -3152,13 +3152,20 @@ static void test_create_device_from_d3d1(void) ...@@ -3152,13 +3152,20 @@ static void test_create_device_from_d3d1(void)
ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr); ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x).\n", hr);
ref1 = get_refcount((IUnknown *)d3drm1); ref1 = get_refcount((IUnknown *)d3drm1);
hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, NULL, d3ddevice1, &device1);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
ok(device1 == NULL, "Expected device returned == NULL, got %p.\n", device1);
hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, NULL, &device1);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, NULL);
ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, &device1); hr = IDirect3DRM_CreateDeviceFromD3D(d3drm1, d3d1, d3ddevice1, &device1);
ok(hr == DD_OK, "Failed to create IDirect3DRMDevice interface (hr = %x)\n", hr); ok(hr == DD_OK, "Failed to create IDirect3DRMDevice interface (hr = %x)\n", hr);
ref2 = get_refcount((IUnknown *)d3drm1); ref2 = get_refcount((IUnknown *)d3drm1);
todo_wine ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2); ok(ref2 > ref1, "expected ref2 > ref1, got ref1 = %u , ref2 = %u.\n", ref1, ref2);
device_ref2 = get_refcount((IUnknown *)d3ddevice1); device_ref2 = get_refcount((IUnknown *)d3ddevice1);
todo_wine ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2); ok(device_ref2 > device_ref1, "Expected device_ref2 > device_ref1, got device_ref1 = %u, device_ref2 = %u.\n", device_ref1, device_ref2);
hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST, hr = IDirectDraw_EnumSurfaces(ddraw1, DDENUMSURFACES_ALL | DDENUMSURFACES_DOESEXIST,
NULL, &surface, surface_callback); NULL, &surface, surface_callback);
...@@ -3166,9 +3173,7 @@ static void test_create_device_from_d3d1(void) ...@@ -3166,9 +3173,7 @@ static void test_create_device_from_d3d1(void)
ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface); ok(surface == NULL, "No primary surface should have enumerated (%p).\n", surface);
hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1); hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3drm_d3ddevice1);
todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr); ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
if (FAILED(hr))
goto cleanup;
ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode deivce created == %p, got %p.\n", d3ddevice1, d3drm_d3ddevice1); ok(d3ddevice1 == d3drm_d3ddevice1, "Expected Immediate Mode deivce created == %p, got %p.\n", d3ddevice1, d3drm_d3ddevice1);
/* Check properties of render target and depth surfaces */ /* Check properties of render target and depth surfaces */
...@@ -3203,13 +3208,8 @@ static void test_create_device_from_d3d1(void) ...@@ -3203,13 +3208,8 @@ static void test_create_device_from_d3d1(void)
IDirectDrawSurface_Release(d3drm_ds); IDirectDrawSurface_Release(d3drm_ds);
IDirectDrawSurface_Release(ds); IDirectDrawSurface_Release(ds);
ds = NULL;
IDirectDrawSurface_Release(surface); IDirectDrawSurface_Release(surface);
IDirect3DDevice_Release(d3drm_d3ddevice1); IDirect3DDevice_Release(d3drm_d3ddevice1);
cleanup:
if (ds)
IDirectDrawSurface_Release(ds);
IDirect3DRMDevice_Release(device1); IDirect3DRMDevice_Release(device1);
ref2 = get_refcount((IUnknown *)d3drm1); ref2 = get_refcount((IUnknown *)d3drm1);
ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2); ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
......
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