[PATCH 1/8] d3drm: Change signature of d3drm_device_create.

Aaryaman Vasishta jem456.vasishta at gmail.com
Thu Aug 6 16:47:51 CDT 2015


Supersedes patch 113449.

This is to help keep things generic in terms of passing the device object for initialization from different versions.
---
 dlls/d3drm/d3drm.c         | 126 +++++++++++++++++++++++++++++++++++++++------
 dlls/d3drm/d3drm_private.h |   7 ++-
 dlls/d3drm/device.c        |  25 ++++++---
 3 files changed, 136 insertions(+), 22 deletions(-)

diff --git a/dlls/d3drm/d3drm.c b/dlls/d3drm/d3drm.c
index 4a920fb..b061c11 100644
--- a/dlls/d3drm/d3drm.c
+++ b/dlls/d3drm/d3drm.c
@@ -231,37 +231,69 @@ static HRESULT WINAPI d3drm1_CreateMaterial(IDirect3DRM *iface,
 static HRESULT WINAPI d3drm1_CreateDevice(IDirect3DRM *iface,
         DWORD width, DWORD height, IDirect3DRMDevice **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_CreateDeviceFromSurface(IDirect3DRM *iface, GUID *guid,
         IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, guid %s, ddraw %p, backbuffer %p, device %p partial stub.\n",
             iface, debugstr_guid(guid), ddraw, backbuffer, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_CreateDeviceFromD3D(IDirect3DRM *iface,
         IDirect3D *d3d, IDirect3DDevice *d3d_device, IDirect3DRMDevice **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n",
             iface, d3d, d3d_device, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_CreateDeviceFromClipper(IDirect3DRM *iface,
         IDirectDrawClipper *clipper, GUID *guid, int width, int height,
         IDirect3DRMDevice **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
             iface, clipper, debugstr_guid(guid), width, height, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm1_CreateTextureFromSurface(IDirect3DRM *iface,
@@ -583,37 +615,69 @@ static HRESULT WINAPI d3drm2_CreateMaterial(IDirect3DRM2 *iface,
 static HRESULT WINAPI d3drm2_CreateDevice(IDirect3DRM2 *iface,
         DWORD width, DWORD height, IDirect3DRMDevice2 **device)
 {
-    FIXME("iface %p, width %u, height %u, device %p.\n", iface, width, height, device);
+    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))
+        return hr;
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
+    *device = IDirect3DRMDevice2_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_CreateDeviceFromSurface(IDirect3DRM2 *iface, GUID *guid,
         IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, IDirect3DRMDevice2 **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, guid %s, ddraw %p, backbuffer %p, device %p partial stub.\n",
             iface, debugstr_guid(guid), ddraw, backbuffer, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice2_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_CreateDeviceFromD3D(IDirect3DRM2 *iface,
         IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device, IDirect3DRMDevice2 **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n",
             iface, d3d, d3d_device, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice2_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_CreateDeviceFromClipper(IDirect3DRM2 *iface,
         IDirectDrawClipper *clipper, GUID *guid, int width, int height,
         IDirect3DRMDevice2 **device)
 {
-    FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p partial stub.\n",
+    struct d3drm_device *object;
+    HRESULT hr;
+    FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
             iface, clipper, debugstr_guid(guid), width, height, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice2, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice2_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm2_CreateTextureFromSurface(IDirect3DRM2 *iface,
@@ -957,37 +1021,69 @@ static HRESULT WINAPI d3drm3_CreateMaterial(IDirect3DRM3 *iface,
 static HRESULT WINAPI d3drm3_CreateDevice(IDirect3DRM3 *iface,
         DWORD width, DWORD height, IDirect3DRMDevice3 **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, width %u, height %u, device %p partial stub!\n", iface, width, height, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice3_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_CreateDeviceFromSurface(IDirect3DRM3 *iface, GUID *guid,
         IDirectDraw *ddraw, IDirectDrawSurface *backbuffer, DWORD flags, IDirect3DRMDevice3 **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, guid %s, ddraw %p, backbuffer %p, flags %#x, device %p partial stub.\n",
             iface, debugstr_guid(guid), ddraw, backbuffer, flags, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice3_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_CreateDeviceFromD3D(IDirect3DRM3 *iface,
         IDirect3D2 *d3d, IDirect3DDevice2 *d3d_device, IDirect3DRMDevice3 **device)
 {
+    struct d3drm_device *object;
+    HRESULT hr;
     FIXME("iface %p, d3d %p, d3d_device %p, device %p partial stub.\n",
             iface, d3d, d3d_device, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice3_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_CreateDeviceFromClipper(IDirect3DRM3 *iface,
         IDirectDrawClipper *clipper, GUID *guid, int width, int height,
         IDirect3DRMDevice3 **device)
 {
-    FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p partial stub.\n",
+    struct d3drm_device *object;
+    HRESULT hr;
+    FIXME("iface %p, clipper %p, guid %s, width %d, height %d, device %p.\n",
             iface, clipper, debugstr_guid(guid), width, height, device);
 
-    return Direct3DRMDevice_create(&IID_IDirect3DRMDevice3, (IUnknown **)device);
+    hr = d3drm_device_create(&object);
+    if (FAILED(hr))
+        return hr;
+
+    *device = IDirect3DRMDevice3_from_impl(object);
+
+    return D3DRM_OK;
 }
 
 static HRESULT WINAPI d3drm3_CreateShadow(IDirect3DRM3 *iface, IUnknown *object, IDirect3DRMLight *light,
diff --git a/dlls/d3drm/d3drm_private.h b/dlls/d3drm/d3drm_private.h
index 80da952..9538de0 100644
--- a/dlls/d3drm/d3drm_private.h
+++ b/dlls/d3drm/d3drm_private.h
@@ -24,7 +24,12 @@
 #include "d3drm.h"
 #include "dxfile.h"
 
-HRESULT Direct3DRMDevice_create(REFIID riid, IUnknown** ppObj) DECLSPEC_HIDDEN;
+struct d3drm_device;
+
+HRESULT d3drm_device_create(struct d3drm_device **out) 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;
diff --git a/dlls/d3drm/device.c b/dlls/d3drm/device.c
index 9c0fe4a..ddb9873 100644
--- a/dlls/d3drm/device.c
+++ b/dlls/d3drm/device.c
@@ -60,6 +60,21 @@ static inline struct d3drm_device *impl_from_IDirect3DRMDevice3(IDirect3DRMDevic
     return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMDevice3_iface);
 }
 
+IDirect3DRMDevice *IDirect3DRMDevice_from_impl(struct d3drm_device *device)
+{
+    return &device->IDirect3DRMDevice_iface;
+}
+
+IDirect3DRMDevice2 *IDirect3DRMDevice2_from_impl(struct d3drm_device *device)
+{
+    return &device->IDirect3DRMDevice2_iface;
+}
+
+IDirect3DRMDevice3 *IDirect3DRMDevice3_from_impl(struct d3drm_device *device)
+{
+    return &device->IDirect3DRMDevice3_iface;
+}
+
 static inline struct d3drm_device *impl_from_IDirect3DRMWinDevice(IDirect3DRMWinDevice *iface)
 {
     return CONTAINING_RECORD(iface, struct d3drm_device, IDirect3DRMWinDevice_iface);
@@ -1381,12 +1396,11 @@ static const struct IDirect3DRMWinDeviceVtbl d3drm_device_win_vtbl =
     d3drm_device_win_HandleActivate,
 };
 
-HRESULT Direct3DRMDevice_create(REFIID riid, IUnknown **out)
+HRESULT d3drm_device_create(struct d3drm_device **out)
 {
     struct d3drm_device *object;
-    HRESULT hr;
 
-    TRACE("riid %s, out %p.\n", debugstr_guid(riid), out);
+    TRACE("out %p.\n", out);
 
     if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
         return E_OUTOFMEMORY;
@@ -1397,8 +1411,7 @@ HRESULT Direct3DRMDevice_create(REFIID riid, IUnknown **out)
     object->IDirect3DRMWinDevice_iface.lpVtbl = &d3drm_device_win_vtbl;
     object->ref = 1;
 
-    hr = IDirect3DRMDevice_QueryInterface(&object->IDirect3DRMDevice3_iface, riid, (void **)out);
-    IDirect3DRMDevice3_Release(&object->IDirect3DRMDevice3_iface);
+    *out = object;
 
-    return hr;
+    return D3DRM_OK;
 }
-- 
2.3.2 (Apple Git-55)




More information about the wine-patches mailing list