From 7280b5d1fba875235f7daaf2c3d7d4a0c5f338d9 Mon Sep 17 00:00:00 2001
From: Aaryaman Vasishta <jem456.vasishta@gmail.com>
Date: Tue, 21 Jul 2015 16:44:29 +0530
Subject: [PATCH 4/8] d3drm: Implement IDirect3DRMDevice*::GetDirect3DDevice.
Reply-To: wine-devel <wine-devel@winehq.org>

---
 dlls/d3drm/device.c      | 10 +++++++++-
 dlls/d3drm/tests/d3drm.c | 26 ++++++++------------------
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/dlls/d3drm/device.c b/dlls/d3drm/device.c
index b824e41..e4a6bdc 100644
--- a/dlls/d3drm/device.c
+++ b/dlls/d3drm/device.c
@@ -1273,7 +1273,15 @@ static D3DRMTEXTUREQUALITY WINAPI d3drm_device3_GetTextureQuality(IDirect3DRMDev
 
 static HRESULT WINAPI d3drm_device3_GetDirect3DDevice(IDirect3DRMDevice3 *iface, IDirect3DDevice **d3d_device)
 {
-    FIXME("iface %p, d3d_device %p stub!\n", iface, d3d_device);
+    struct d3drm_device *device = impl_from_IDirect3DRMDevice3(iface);
+    TRACE("iface %p, d3d_device %p!\n", iface, d3d_device);
+
+    if (device->device)
+    {
+        *d3d_device = device->device;
+        IDirect3DDevice_AddRef(*d3d_device);
+        return D3DRM_OK;
+    }
 
     return E_NOTIMPL;
 }
diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c
index b427014..74943b6 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -2008,9 +2008,7 @@ static void test_create_device_from_clipper1(void)
 
     /* Fetch immediate mode device in order to access render target */
     hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
-    todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
-    if (FAILED(hr))
-        goto cleanup;
+    ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
     ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
@@ -2084,7 +2082,7 @@ static void test_create_device_from_clipper1(void)
     ref2 = get_refcount((IUnknown *)d3drm1);
     ok(ref1 == ref2, "expected ref1 == ref2, got ref1 = %u, ref2 = %u.\n", ref1, ref2);
     cref2 = get_refcount((IUnknown *)clipper);
-    todo_wine ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
+    ok(cref1 == cref2, "expected cref1 == cref2, got cref1 = %u, cref2 = %u.\n", cref1, cref2);
 
     /* Test if render target format follows the screen format */
     hr = IDirectDraw_GetDisplayMode(ddraw, &desc);
@@ -2100,9 +2098,7 @@ static void test_create_device_from_clipper1(void)
     ok(hr == D3DRM_OK, "Cannot create IDirect3DRMDevice interface (hr = %x).\n", hr);
 
     hr = IDirect3DRMDevice_GetDirect3DDevice(device1, &d3ddevice1);
-    todo_wine ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
-    if (FAILED(hr))
-        goto cleanup;
+    ok(hr == D3DRM_OK, "Cannot get IDirect3DDevice interface (hr = %x).\n", hr);
 
     hr = IDirect3DDevice_QueryInterface(d3ddevice1, &IID_IDirectDrawSurface, (void **)&surface);
     ok(hr == DD_OK, "Cannot get surface to the render target (hr = %x).\n", hr);
@@ -2116,20 +2112,14 @@ static void test_create_device_from_clipper1(void)
     hr = IDirectDraw2_RestoreDisplayMode(ddraw);
     ok(SUCCEEDED(hr), "RestoreDisplayMode failed, hr %#x.\n", hr);
 
-cleanup:
     if (ds)
         IDirectDrawSurface_Release(ds);
-    if (surface)
-        IDirectDrawSurface_Release(surface);
-    if (d3ddevice1)
-        IDirect3DDevice_Release(d3ddevice1);
+    IDirectDrawSurface_Release(surface);
+    IDirect3DDevice_Release(d3ddevice1);
     IDirect3DRMDevice_Release(device1);
-    if (d3drm1)
-        IDirect3DRM_Release(d3drm1);
-    if (clipper)
-        IDirectDrawClipper_Release(clipper);
-    if (ddraw)
-        IDirectDraw_Release(ddraw);
+    IDirect3DRM_Release(d3drm1);
+    IDirectDrawClipper_Release(clipper);
+    IDirectDraw_Release(ddraw);
     DestroyWindow(window);
 }
 
-- 
2.3.2 (Apple Git-55)

