[PATCH 03/10] d3d9: move GetDC check to actual d3d9_surface_GetDC call

Riccardo Bortolato rikyz619 at gmail.com
Mon Oct 19 12:07:31 CDT 2015


Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
---
 dlls/d3d9/d3d9_private.h |  1 -
 dlls/d3d9/surface.c      | 47 ++++++++++++++++++++++++-----------------------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 6e84faf..2f8ddf2 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -225,7 +225,6 @@ struct d3d9_surface
     IDirect3DDevice9Ex *parent_device;
     IUnknown *container;
     struct d3d9_texture *texture;
-    BOOL getdc_supported;
 };
 
 struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN;
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index 9a9c838..85b22d3 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -285,19 +285,38 @@ static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface)
 static HRESULT WINAPI d3d9_surface_GetDC(IDirect3DSurface9 *iface, HDC *dc)
 {
     struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
+    struct wined3d_resource *sub_resource;
+    struct wined3d_surface *wined3d_surface;
+    struct wined3d_resource_desc desc;
     HRESULT hr;
 
     TRACE("iface %p, dc %p.\n", iface, dc);
 
-    if (!surface->getdc_supported)
+    wined3d_mutex_lock();
+    if (!(sub_resource = wined3d_texture_get_sub_resource(surface->wined3d_texture, surface->sub_resource_idx)))
     {
-        WARN("Surface does not support GetDC, returning D3DERR_INVALIDCALL\n");
-        /* Don't touch the DC */
+        wined3d_mutex_unlock();
         return D3DERR_INVALIDCALL;
     }
+    wined3d_resource_get_desc(sub_resource, &desc);
+    switch (d3dformat_from_wined3dformat(desc.format))
+     {
+        case D3DFMT_A8R8G8B8:
+        case D3DFMT_X8R8G8B8:
+        case D3DFMT_R5G6B5:
+        case D3DFMT_X1R5G5B5:
+        case D3DFMT_A1R5G5B5:
+        case D3DFMT_R8G8B8:
+            break;
 
-    wined3d_mutex_lock();
-    hr = wined3d_surface_getdc(surface->wined3d_surface, dc);
+        default:
+            WARN("Surface does not support GetDC, returning D3DERR_INVALIDCALL\n");
+            /* Don't touch the DC */
+            wined3d_mutex_unlock();
+            return D3DERR_INVALIDCALL;
+    }
+    wined3d_surface = wined3d_surface_from_resource(sub_resource);
+    hr = wined3d_surface_getdc(wined3d_surface, dc);
     wined3d_mutex_unlock();
 
     return hr;
@@ -360,7 +379,6 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
 void surface_init(struct d3d9_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
         struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
 {
-    struct wined3d_resource_desc desc;
     IDirect3DBaseTexture9 *texture;
 
     surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
@@ -379,23 +397,6 @@ void surface_init(struct d3d9_surface *surface, struct wined3d_texture *wined3d_
         IDirect3DBaseTexture9_Release(texture);
     }
 
-    wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &desc);
-    switch (d3dformat_from_wined3dformat(desc.format))
-    {
-        case D3DFMT_A8R8G8B8:
-        case D3DFMT_X8R8G8B8:
-        case D3DFMT_R5G6B5:
-        case D3DFMT_X1R5G5B5:
-        case D3DFMT_A1R5G5B5:
-        case D3DFMT_R8G8B8:
-            surface->getdc_supported = TRUE;
-            break;
-
-        default:
-            surface->getdc_supported = FALSE;
-            break;
-    }
-
     *parent_ops = &d3d9_surface_wined3d_parent_ops;
 }
 
-- 
1.9.1




More information about the wine-patches mailing list