[PATCH 1/3] d3drm: Store reference to render target in IDirect3DRM*::CreateDeviceFromD3D. (v2)

Aaryaman Vasishta jem456.vasishta at gmail.com
Wed Aug 10 10:37:02 CDT 2016


v2: Avoid todo_wine.

Signed-off-by: Aaryaman Vasishta <jem456.vasishta at gmail.com>
---
 dlls/d3drm/device.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/dlls/d3drm/device.c b/dlls/d3drm/device.c
index a8d646b..57fd7c0 100644
--- a/dlls/d3drm/device.c
+++ b/dlls/d3drm/device.c
@@ -213,7 +213,7 @@ static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, ID
 {
     IDirectDraw *ddraw;
     IDirectDrawSurface *surface;
-    IDirect3DDevice2 *d3d_device2;
+    IDirect3DDevice2 *d3d_device2 = NULL;
     DDSURFACEDESC desc;
     HRESULT hr;
 
@@ -223,9 +223,6 @@ static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, ID
     IDirect3DRM_AddRef(device->d3drm);
     IDirect3DDevice_AddRef(d3d_device);
 
-    if (device->ddraw)
-        return D3DRMERR_BADOBJECT;
-
     /* Fetch render target and get width/height from there */
     if (FAILED(hr = IDirect3DDevice_QueryInterface(d3d_device, &IID_IDirectDrawSurface, (void **)&surface)))
     {
@@ -237,16 +234,26 @@ static HRESULT d3drm_device_set_ddraw_device_d3d(struct d3drm_device *device, ID
             return hr;
     }
 
+    if (device->ddraw)
+    {
+        if (d3d_device2)
+            IDirectDrawSurface_Release(surface);
+        return D3DRMERR_BADOBJECT;
+    }
+
     desc.dwSize = sizeof(desc);
     hr = IDirectDrawSurface_GetSurfaceDesc(surface, &desc);
-    IDirectDrawSurface_Release(surface);
     if (FAILED(hr))
+    {
+        IDirectDrawSurface_Release(surface);
         return hr;
+    }
 
     device->ddraw = ddraw;
     device->width = desc.dwWidth;
     device->height = desc.dwHeight;
     device->device = d3d_device;
+    device->render_target = surface;
 
     return hr;
 }
-- 
2.3.2 (Apple Git-55)




More information about the wine-patches mailing list