[PATCH 5/5] d3d9: Get rid of IDirect3DSurface9Impl.

Henri Verbeet hverbeet at codeweavers.com
Wed May 30 09:15:00 CDT 2012


---
 dlls/d3d9/d3d9_private.h |   30 ++----
 dlls/d3d9/device.c       |   49 +++++-----
 dlls/d3d9/surface.c      |  251 ++++++++++++++++++++++-----------------------
 dlls/d3d9/swapchain.c    |    4 +-
 dlls/d3d9/texture.c      |   12 +-
 5 files changed, 164 insertions(+), 182 deletions(-)

diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 9cf1ba1..93760ee 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -187,33 +187,21 @@ struct d3d9_swapchain
 HRESULT d3d9_swapchain_create(struct d3d9_device *device, D3DPRESENT_PARAMETERS *present_parameters,
         struct d3d9_swapchain **swapchain) DECLSPEC_HIDDEN;
 
-/* ----------------- */
-/* IDirect3DSurface9 */
-/* ----------------- */
-
-/*****************************************************************************
- * IDirect3DSurface9 implementation structure
- */
-typedef struct IDirect3DSurface9Impl
+struct d3d9_surface
 {
     IDirect3DSurface9 IDirect3DSurface9_iface;
-    LONG ref;
+    LONG refcount;
     struct wined3d_surface *wined3d_surface;
-    IDirect3DDevice9Ex *parentDevice;
-
-    /* The surface container */
-    IUnknown                    *container;
-
-    /* If set forward refcounting to this object */
-    IUnknown                    *forwardReference;
-
-    BOOL                        getdc_supported;
-} IDirect3DSurface9Impl;
+    IDirect3DDevice9Ex *parent_device;
+    IUnknown *container;
+    IUnknown *forwardReference;
+    BOOL getdc_supported;
+};
 
-HRESULT surface_init(IDirect3DSurface9Impl *surface, struct d3d9_device *device,
+HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device,
         UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
         DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
-IDirect3DSurface9Impl *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
+struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
 
 /* ---------------------- */
 /* IDirect3DVertexBuffer9 */
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 9982724..1c86729 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -391,7 +391,7 @@ static HRESULT WINAPI d3d9_device_SetCursorProperties(IDirect3DDevice9Ex *iface,
         UINT hotspot_x, UINT hotspot_y, IDirect3DSurface9 *bitmap)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *bitmap_impl = unsafe_impl_from_IDirect3DSurface9(bitmap);
+    struct d3d9_surface *bitmap_impl = unsafe_impl_from_IDirect3DSurface9(bitmap);
     HRESULT hr;
 
     TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
@@ -501,7 +501,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
     wined3d_resource_get_desc(resource, &desc);
     if (desc.pool == WINED3D_POOL_DEFAULT)
     {
-        IDirect3DSurface9Impl *surface;
+        struct d3d9_surface *surface;
 
         if (desc.resource_type != WINED3D_RTYPE_SURFACE)
         {
@@ -510,7 +510,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
         }
 
         surface = wined3d_resource_get_parent(resource);
-        if (surface->ref)
+        if (surface->refcount)
         {
             WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
             return D3DERR_INVALIDCALL;
@@ -589,7 +589,7 @@ static HRESULT WINAPI d3d9_device_GetBackBuffer(IDirect3DDevice9Ex *iface, UINT
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
     struct wined3d_surface *wined3d_surface = NULL;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     HRESULT hr;
 
     TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
@@ -706,7 +706,7 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface,
     if (set_mem)
     {
         struct wined3d_resource *resource;
-        IDirect3DSurface9Impl *surface;
+        struct d3d9_surface *surface;
 
         resource = wined3d_texture_get_sub_resource(object->wined3d_texture, 0);
         surface = wined3d_resource_get_parent(resource);
@@ -865,7 +865,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
         D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, IDirect3DSurface9 **surface,
         UINT usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
 {
-    IDirect3DSurface9Impl *object;
+    struct d3d9_surface *object;
     HRESULT hr;
 
     TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p.\n"
@@ -873,8 +873,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
             device, width, height, format, lockable, discard, level, surface, usage, pool,
             multisample_type, multisample_quality);
 
-    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
-    if (!object)
+    if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
     {
         FIXME("Failed to allocate surface memory.\n");
         return D3DERR_OUTOFVIDEOMEMORY;
@@ -943,8 +942,8 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
         IDirect3DSurface9 *dst_surface, const POINT *dst_point)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
-    IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
+    struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
+    struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
     HRESULT hr;
 
     TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
@@ -981,8 +980,8 @@ static HRESULT WINAPI d3d9_device_UpdateTexture(IDirect3DDevice9Ex *iface,
 static HRESULT WINAPI d3d9_device_GetRenderTargetData(IDirect3DDevice9Ex *iface,
         IDirect3DSurface9 *render_target, IDirect3DSurface9 *dst_surface)
 {
-    IDirect3DSurface9Impl *rt_impl = unsafe_impl_from_IDirect3DSurface9(render_target);
-    IDirect3DSurface9Impl *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
+    struct d3d9_surface *rt_impl = unsafe_impl_from_IDirect3DSurface9(render_target);
+    struct d3d9_surface *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
     HRESULT hr;
 
     TRACE("iface %p, render_target %p, dst_surface %p.\n", iface, render_target, dst_surface);
@@ -998,7 +997,7 @@ static HRESULT WINAPI d3d9_device_GetFrontBufferData(IDirect3DDevice9Ex *iface,
         UINT swapchain, IDirect3DSurface9 *dst_surface)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
+    struct d3d9_surface *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
     HRESULT hr;
 
     TRACE("iface %p, swapchain %u, dst_surface %p.\n", iface, swapchain, dst_surface);
@@ -1014,8 +1013,8 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex *iface, IDirect
         const RECT *src_rect, IDirect3DSurface9 *dst_surface, const RECT *dst_rect, D3DTEXTUREFILTERTYPE filter)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
-    IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
+    struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
+    struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
     HRESULT hr = D3DERR_INVALIDCALL;
     struct wined3d_resource_desc src_desc, dst_desc;
     struct wined3d_resource *wined3d_resource;
@@ -1085,7 +1084,7 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface,
         ((color >> 24) & 0xff) / 255.0f,
     };
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
+    struct d3d9_surface *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
     struct wined3d_resource *wined3d_resource;
     struct wined3d_resource_desc desc;
     HRESULT hr;
@@ -1141,7 +1140,7 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex
 static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
+    struct d3d9_surface *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
     HRESULT hr;
 
     TRACE("iface %p, idx %u, surface %p.\n", iface, idx, surface);
@@ -1164,7 +1163,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
     struct wined3d_surface *wined3d_surface;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     HRESULT hr;
 
     TRACE("iface %p, idx %u, surface %p.\n", iface, idx, surface);
@@ -1201,7 +1200,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO
 static HRESULT WINAPI d3d9_device_SetDepthStencilSurface(IDirect3DDevice9Ex *iface, IDirect3DSurface9 *depth_stencil)
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
-    IDirect3DSurface9Impl *ds_impl = unsafe_impl_from_IDirect3DSurface9(depth_stencil);
+    struct d3d9_surface *ds_impl = unsafe_impl_from_IDirect3DSurface9(depth_stencil);
     HRESULT hr;
 
     TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
@@ -1217,7 +1216,7 @@ static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *ifa
 {
     struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
     struct wined3d_surface *wined3d_surface;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     HRESULT hr;
 
     TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
@@ -3095,7 +3094,7 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
         enum wined3d_pool pool, UINT level, enum wined3d_cubemap_face face, struct wined3d_surface **surface)
 {
     struct d3d9_device *device = device_from_device_parent(device_parent);
-    IDirect3DSurface9Impl *d3d_surface;
+    struct d3d9_surface *d3d_surface;
     BOOL lockable = TRUE;
     HRESULT hr;
 
@@ -3119,8 +3118,8 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
     wined3d_surface_incref(*surface);
 
     d3d_surface->container = container_parent;
-    IDirect3DDevice9Ex_Release(d3d_surface->parentDevice);
-    d3d_surface->parentDevice = NULL;
+    IDirect3DDevice9Ex_Release(d3d_surface->parent_device);
+    d3d_surface->parent_device = NULL;
 
     IDirect3DSurface9_Release(&d3d_surface->IDirect3DSurface9_iface);
     d3d_surface->forwardReference = container_parent;
@@ -3134,7 +3133,7 @@ static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_par
         struct wined3d_surface **surface)
 {
     struct d3d9_device *device = device_from_device_parent(device_parent);
-    IDirect3DSurface9Impl *d3d_surface;
+    struct d3d9_surface *d3d_surface;
     HRESULT hr;
 
     TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
@@ -3166,7 +3165,7 @@ static HRESULT CDECL device_parent_create_depth_stencil(struct wined3d_device_pa
         DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface)
 {
     struct d3d9_device *device = device_from_device_parent(device_parent);
-    IDirect3DSurface9Impl *d3d_surface;
+    struct d3d9_surface *d3d_surface;
     HRESULT hr;
 
     TRACE("device_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index ecdd5b5..7213a32 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -24,106 +24,102 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
 
-static inline IDirect3DSurface9Impl *impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
+static inline struct d3d9_surface *impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
 {
-    return CONTAINING_RECORD(iface, IDirect3DSurface9Impl, IDirect3DSurface9_iface);
+    return CONTAINING_RECORD(iface, struct d3d9_surface, IDirect3DSurface9_iface);
 }
 
-/* IDirect3DSurface9 IUnknown parts follow: */
-static HRESULT WINAPI IDirect3DSurface9Impl_QueryInterface(IDirect3DSurface9 *iface, REFIID riid,
-        void **ppobj)
+static HRESULT WINAPI d3d9_surface_QueryInterface(IDirect3DSurface9 *iface, REFIID riid, void **out)
 {
-    TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
+    TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
 
     if (IsEqualGUID(riid, &IID_IDirect3DSurface9)
             || IsEqualGUID(riid, &IID_IDirect3DResource9)
             || IsEqualGUID(riid, &IID_IUnknown))
     {
         IDirect3DSurface9_AddRef(iface);
-        *ppobj = iface;
+        *out = iface;
         return S_OK;
     }
 
     WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
 
-    *ppobj = NULL;
+    *out = NULL;
     return E_NOINTERFACE;
 }
 
-static ULONG WINAPI IDirect3DSurface9Impl_AddRef(IDirect3DSurface9 *iface)
+static ULONG WINAPI d3d9_surface_AddRef(IDirect3DSurface9 *iface)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
+    ULONG refcount;
 
     TRACE("iface %p.\n", iface);
 
-    if (This->forwardReference) {
-        /* Forward refcounting */
-        TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
-        return IUnknown_AddRef(This->forwardReference);
-    } else {
-        /* No container, handle our own refcounting */
-        ULONG ref = InterlockedIncrement(&This->ref);
-
-        TRACE("%p increasing refcount to %u.\n", iface, ref);
+    if (surface->forwardReference)
+    {
+        TRACE("Forwarding to %p.\n", surface->forwardReference);
+        return IUnknown_AddRef(surface->forwardReference);
+    }
 
-        if (ref == 1)
-        {
-            if (This->parentDevice) IDirect3DDevice9Ex_AddRef(This->parentDevice);
-            wined3d_mutex_lock();
-            wined3d_surface_incref(This->wined3d_surface);
-            wined3d_mutex_unlock();
-        }
+    refcount = InterlockedIncrement(&surface->refcount);
+    TRACE("%p increasing refcount to %u.\n", iface, refcount);
 
-        return ref;
+    if (refcount == 1)
+    {
+        if (surface->parent_device)
+            IDirect3DDevice9Ex_AddRef(surface->parent_device);
+        wined3d_mutex_lock();
+        wined3d_surface_incref(surface->wined3d_surface);
+        wined3d_mutex_unlock();
     }
 
+    return refcount;
 }
 
-static ULONG WINAPI IDirect3DSurface9Impl_Release(IDirect3DSurface9 *iface)
+static ULONG WINAPI d3d9_surface_Release(IDirect3DSurface9 *iface)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
+    ULONG refcount;
 
     TRACE("iface %p.\n", iface);
 
-    if (This->forwardReference) {
-        /* Forward to the containerParent */
-        TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference);
-        return IUnknown_Release(This->forwardReference);
-    } else {
-        /* No container, handle our own refcounting */
-        ULONG ref = InterlockedDecrement(&This->ref);
-
-        TRACE("%p decreasing refcount to %u.\n", iface, ref);
+    if (surface->forwardReference)
+    {
+        TRACE("Forwarding to %p.\n", surface->forwardReference);
+        return IUnknown_Release(surface->forwardReference);
+    }
 
-        if (ref == 0) {
-            IDirect3DDevice9Ex *parentDevice = This->parentDevice;
+    refcount = InterlockedDecrement(&surface->refcount);
+    TRACE("%p decreasing refcount to %u.\n", iface, refcount);
 
-            wined3d_mutex_lock();
-            wined3d_surface_decref(This->wined3d_surface);
-            wined3d_mutex_unlock();
+    if (!refcount)
+    {
+        IDirect3DDevice9Ex *parent_device = surface->parent_device;
 
-            /* Release the device last, as it may cause the device to be destroyed. */
-            if (parentDevice) IDirect3DDevice9Ex_Release(parentDevice);
-        }
+        wined3d_mutex_lock();
+        wined3d_surface_decref(surface->wined3d_surface);
+        wined3d_mutex_unlock();
 
-        return ref;
+        /* Release the device last, as it may cause the device to be destroyed. */
+        if (parent_device)
+            IDirect3DDevice9Ex_Release(parent_device);
     }
+
+    return refcount;
 }
 
-/* IDirect3DSurface9 IDirect3DResource9 Interface follow: */
-static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(IDirect3DSurface9 *iface,
-        IDirect3DDevice9 **device)
+static HRESULT WINAPI d3d9_surface_GetDevice(IDirect3DSurface9 *iface, IDirect3DDevice9 **device)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
 
     TRACE("iface %p, device %p.\n", iface, device);
 
-    if (This->forwardReference)
+    if (surface->forwardReference)
     {
         IDirect3DResource9 *resource;
         HRESULT hr;
 
-        hr = IUnknown_QueryInterface(This->forwardReference, &IID_IDirect3DResource9, (void **)&resource);
+        hr = IUnknown_QueryInterface(surface->forwardReference, &IID_IDirect3DResource9, (void **)&resource);
         if (SUCCEEDED(hr))
         {
             hr = IDirect3DResource9_GetDevice(resource, device);
@@ -135,7 +131,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(IDirect3DSurface9 *iface,
         return hr;
     }
 
-    *device = (IDirect3DDevice9 *)This->parentDevice;
+    *device = (IDirect3DDevice9 *)surface->parent_device;
     IDirect3DDevice9_AddRef(*device);
 
     TRACE("Returning device %p.\n", *device);
@@ -143,10 +139,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDevice(IDirect3DSurface9 *iface,
     return D3D_OK;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(IDirect3DSurface9 *iface, REFGUID guid,
+static HRESULT WINAPI d3d9_surface_SetPrivateData(IDirect3DSurface9 *iface, REFGUID guid,
         const void *data, DWORD data_size, DWORD flags)
 {
-    IDirect3DSurface9Impl *surface = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     struct wined3d_resource *resource;
     HRESULT hr;
 
@@ -161,10 +157,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_SetPrivateData(IDirect3DSurface9 *if
     return hr;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(IDirect3DSurface9 *iface, REFGUID guid,
+static HRESULT WINAPI d3d9_surface_GetPrivateData(IDirect3DSurface9 *iface, REFGUID guid,
         void *data, DWORD *data_size)
 {
-    IDirect3DSurface9Impl *surface = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     struct wined3d_resource *resource;
     HRESULT hr;
 
@@ -179,9 +175,9 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetPrivateData(IDirect3DSurface9 *if
     return hr;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(IDirect3DSurface9 *iface, REFGUID guid)
+static HRESULT WINAPI d3d9_surface_FreePrivateData(IDirect3DSurface9 *iface, REFGUID guid)
 {
-    IDirect3DSurface9Impl *surface = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     struct wined3d_resource *resource;
     HRESULT hr;
 
@@ -195,80 +191,79 @@ static HRESULT WINAPI IDirect3DSurface9Impl_FreePrivateData(IDirect3DSurface9 *i
     return hr;
 }
 
-static DWORD WINAPI IDirect3DSurface9Impl_SetPriority(IDirect3DSurface9 *iface, DWORD PriorityNew)
+static DWORD WINAPI d3d9_surface_SetPriority(IDirect3DSurface9 *iface, DWORD priority)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
-    HRESULT hr;
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
+    DWORD ret;
 
-    TRACE("iface %p, priority %u.\n", iface, PriorityNew);
+    TRACE("iface %p, priority %u.\n", iface, priority);
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_set_priority(This->wined3d_surface, PriorityNew);
+    ret = wined3d_surface_set_priority(surface->wined3d_surface, priority);
     wined3d_mutex_unlock();
 
-    return hr;
+    return ret;
 }
 
-static DWORD WINAPI IDirect3DSurface9Impl_GetPriority(IDirect3DSurface9 *iface)
+static DWORD WINAPI d3d9_surface_GetPriority(IDirect3DSurface9 *iface)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
-    HRESULT hr;
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
+    DWORD ret;
 
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_get_priority(This->wined3d_surface);
+    ret = wined3d_surface_get_priority(surface->wined3d_surface);
     wined3d_mutex_unlock();
 
-    return hr;
+    return ret;
 }
 
-static void WINAPI IDirect3DSurface9Impl_PreLoad(IDirect3DSurface9 *iface)
+static void WINAPI d3d9_surface_PreLoad(IDirect3DSurface9 *iface)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
 
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    wined3d_surface_preload(This->wined3d_surface);
+    wined3d_surface_preload(surface->wined3d_surface);
     wined3d_mutex_unlock();
 }
 
-static D3DRESOURCETYPE WINAPI IDirect3DSurface9Impl_GetType(IDirect3DSurface9 *iface)
+static D3DRESOURCETYPE WINAPI d3d9_surface_GetType(IDirect3DSurface9 *iface)
 {
     TRACE("iface %p.\n", iface);
 
     return D3DRTYPE_SURFACE;
 }
 
-/* IDirect3DSurface9 Interface follow: */
-static HRESULT WINAPI IDirect3DSurface9Impl_GetContainer(IDirect3DSurface9 *iface, REFIID riid,
-        void **ppContainer)
+static HRESULT WINAPI d3d9_surface_GetContainer(IDirect3DSurface9 *iface, REFIID riid, void **container)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
-    HRESULT res;
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
+    HRESULT hr;
 
-    TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), ppContainer);
+    TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), container);
 
-    if (!This->container) return E_NOINTERFACE;
+    if (!surface->container)
+        return E_NOINTERFACE;
 
-    res = IUnknown_QueryInterface(This->container, riid, ppContainer);
+    hr = IUnknown_QueryInterface(surface->container, riid, container);
 
-    TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer);
+    TRACE("Returning %p.\n", *container);
 
-    return res;
+    return hr;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_DESC *desc)
+static HRESULT WINAPI d3d9_surface_GetDesc(IDirect3DSurface9 *iface, D3DSURFACE_DESC *desc)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     struct wined3d_resource_desc wined3d_desc;
     struct wined3d_resource *wined3d_resource;
 
     TRACE("iface %p, desc %p.\n", iface, desc);
 
     wined3d_mutex_lock();
-    wined3d_resource = wined3d_surface_get_resource(This->wined3d_surface);
+    wined3d_resource = wined3d_surface_get_resource(surface->wined3d_surface);
     wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
     wined3d_mutex_unlock();
 
@@ -284,10 +279,10 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDesc(IDirect3DSurface9 *iface, D3
     return D3D_OK;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(IDirect3DSurface9 *iface,
+static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface,
         D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     struct wined3d_map_desc map_desc;
     HRESULT hr;
 
@@ -295,7 +290,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(IDirect3DSurface9 *iface,
             iface, locked_rect, wine_dbgstr_rect(rect), flags);
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_map(This->wined3d_surface, &map_desc, rect, flags);
+    hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect, flags);
     wined3d_mutex_unlock();
 
     locked_rect->Pitch = map_desc.row_pitch;
@@ -304,15 +299,15 @@ static HRESULT WINAPI IDirect3DSurface9Impl_LockRect(IDirect3DSurface9 *iface,
     return hr;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(IDirect3DSurface9 *iface)
+static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     HRESULT hr;
 
     TRACE("iface %p.\n", iface);
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_unmap(This->wined3d_surface);
+    hr = wined3d_surface_unmap(surface->wined3d_surface);
     wined3d_mutex_unlock();
 
     switch(hr)
@@ -322,14 +317,14 @@ static HRESULT WINAPI IDirect3DSurface9Impl_UnlockRect(IDirect3DSurface9 *iface)
     }
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(IDirect3DSurface9 *iface, HDC* phdc)
+static HRESULT WINAPI d3d9_surface_GetDC(IDirect3DSurface9 *iface, HDC *dc)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     HRESULT hr;
 
-    TRACE("iface %p, hdc %p.\n", iface, phdc);
+    TRACE("iface %p, dc %p.\n", iface, dc);
 
-    if(!This->getdc_supported)
+    if (!surface->getdc_supported)
     {
         WARN("Surface does not support GetDC, returning D3DERR_INVALIDCALL\n");
         /* Don't touch the DC */
@@ -337,21 +332,21 @@ static HRESULT WINAPI IDirect3DSurface9Impl_GetDC(IDirect3DSurface9 *iface, HDC*
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_getdc(This->wined3d_surface, phdc);
+    hr = wined3d_surface_getdc(surface->wined3d_surface, dc);
     wined3d_mutex_unlock();
 
     return hr;
 }
 
-static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(IDirect3DSurface9 *iface, HDC hdc)
+static HRESULT WINAPI d3d9_surface_ReleaseDC(IDirect3DSurface9 *iface, HDC dc)
 {
-    IDirect3DSurface9Impl *This = impl_from_IDirect3DSurface9(iface);
+    struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface);
     HRESULT hr;
 
-    TRACE("iface %p, hdc %p.\n", iface, hdc);
+    TRACE("iface %p, dc %p.\n", iface, dc);
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_releasedc(This->wined3d_surface, hdc);
+    hr = wined3d_surface_releasedc(surface->wined3d_surface, dc);
     wined3d_mutex_unlock();
 
     switch (hr)
@@ -361,28 +356,28 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(IDirect3DSurface9 *iface,
     }
 }
 
-static const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
+static const struct IDirect3DSurface9Vtbl d3d9_surface_vtbl =
 {
     /* IUnknown */
-    IDirect3DSurface9Impl_QueryInterface,
-    IDirect3DSurface9Impl_AddRef,
-    IDirect3DSurface9Impl_Release,
+    d3d9_surface_QueryInterface,
+    d3d9_surface_AddRef,
+    d3d9_surface_Release,
     /* IDirect3DResource9 */
-    IDirect3DSurface9Impl_GetDevice,
-    IDirect3DSurface9Impl_SetPrivateData,
-    IDirect3DSurface9Impl_GetPrivateData,
-    IDirect3DSurface9Impl_FreePrivateData,
-    IDirect3DSurface9Impl_SetPriority,
-    IDirect3DSurface9Impl_GetPriority,
-    IDirect3DSurface9Impl_PreLoad,
-    IDirect3DSurface9Impl_GetType,
+    d3d9_surface_GetDevice,
+    d3d9_surface_SetPrivateData,
+    d3d9_surface_GetPrivateData,
+    d3d9_surface_FreePrivateData,
+    d3d9_surface_SetPriority,
+    d3d9_surface_GetPriority,
+    d3d9_surface_PreLoad,
+    d3d9_surface_GetType,
     /* IDirect3DSurface9 */
-    IDirect3DSurface9Impl_GetContainer,
-    IDirect3DSurface9Impl_GetDesc,
-    IDirect3DSurface9Impl_LockRect,
-    IDirect3DSurface9Impl_UnlockRect,
-    IDirect3DSurface9Impl_GetDC,
-    IDirect3DSurface9Impl_ReleaseDC
+    d3d9_surface_GetContainer,
+    d3d9_surface_GetDesc,
+    d3d9_surface_LockRect,
+    d3d9_surface_UnlockRect,
+    d3d9_surface_GetDC,
+    d3d9_surface_ReleaseDC,
 };
 
 static void STDMETHODCALLTYPE surface_wined3d_object_destroyed(void *parent)
@@ -395,15 +390,15 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
     surface_wined3d_object_destroyed,
 };
 
-HRESULT surface_init(IDirect3DSurface9Impl *surface, struct d3d9_device *device,
+HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device,
         UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
         DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
 {
     DWORD flags = 0;
     HRESULT hr;
 
-    surface->IDirect3DSurface9_iface.lpVtbl = &Direct3DSurface9_Vtbl;
-    surface->ref = 1;
+    surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
+    surface->refcount = 1;
 
     switch (format)
     {
@@ -444,17 +439,17 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, struct d3d9_device *device,
         return hr;
     }
 
-    surface->parentDevice = &device->IDirect3DDevice9Ex_iface;
-    IDirect3DDevice9Ex_AddRef(surface->parentDevice);
+    surface->parent_device = &device->IDirect3DDevice9Ex_iface;
+    IDirect3DDevice9Ex_AddRef(surface->parent_device);
 
     return D3D_OK;
 }
 
-IDirect3DSurface9Impl *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
+struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
 {
     if (!iface)
         return NULL;
-    assert(iface->lpVtbl == &Direct3DSurface9_Vtbl);
+    assert(iface->lpVtbl == &d3d9_surface_vtbl);
 
     return impl_from_IDirect3DSurface9(iface);
 }
diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c
index 50db85a..b70067d 100644
--- a/dlls/d3d9/swapchain.c
+++ b/dlls/d3d9/swapchain.c
@@ -113,7 +113,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_swapchain_Present(IDirect3DSwapChai
 static HRESULT WINAPI d3d9_swapchain_GetFrontBufferData(IDirect3DSwapChain9 *iface, IDirect3DSurface9 *surface)
 {
     struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9(iface);
-    IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(surface);
+    struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(surface);
     HRESULT hr;
 
     TRACE("iface %p, surface %p.\n", iface, surface);
@@ -130,7 +130,7 @@ static HRESULT WINAPI d3d9_swapchain_GetBackBuffer(IDirect3DSwapChain9 *iface,
 {
     struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9(iface);
     struct wined3d_surface *wined3d_surface = NULL;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     HRESULT hr;
 
     TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index da7a572..87395c0 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -326,7 +326,7 @@ static HRESULT WINAPI d3d9_texture_2d_GetSurfaceLevel(IDirect3DTexture9 *iface,
 {
     struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
     struct wined3d_resource *sub_resource;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
 
     TRACE("iface %p, level %u, surface %p.\n", iface, level, surface);
 
@@ -350,7 +350,7 @@ static HRESULT WINAPI d3d9_texture_2d_LockRect(IDirect3DTexture9 *iface,
 {
     struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
     struct wined3d_resource *sub_resource;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     HRESULT hr;
 
     TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
@@ -373,7 +373,7 @@ static HRESULT WINAPI d3d9_texture_2d_UnlockRect(IDirect3DTexture9 *iface, UINT
 {
     struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
     struct wined3d_resource *sub_resource;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     HRESULT hr;
 
     TRACE("iface %p, level %u.\n", iface, level);
@@ -748,7 +748,7 @@ static HRESULT WINAPI d3d9_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture9
 {
     struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
     struct wined3d_resource *sub_resource;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     UINT sub_resource_idx;
     DWORD level_count;
 
@@ -783,7 +783,7 @@ static HRESULT WINAPI d3d9_texture_cube_LockRect(IDirect3DCubeTexture9 *iface,
 {
     struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
     struct wined3d_resource *sub_resource;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     UINT sub_resource_idx;
     HRESULT hr;
 
@@ -809,7 +809,7 @@ static HRESULT WINAPI d3d9_texture_cube_UnlockRect(IDirect3DCubeTexture9 *iface,
 {
     struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
     struct wined3d_resource *sub_resource;
-    IDirect3DSurface9Impl *surface_impl;
+    struct d3d9_surface *surface_impl;
     UINT sub_resource_idx;
     HRESULT hr;
 
-- 
1.7.3.4




More information about the wine-patches mailing list