Henri Verbeet : wined3d: Set the surface container in surface_init().

Alexandre Julliard julliard at winehq.org
Fri Nov 15 13:14:29 CST 2013


Module: wine
Branch: master
Commit: 42f6ca821ce4bbdd474f29703673a3bb47a73428
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=42f6ca821ce4bbdd474f29703673a3bb47a73428

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Fri Nov 15 08:24:33 2013 +0100

wined3d: Set the surface container in surface_init().

---

 dlls/ddraw/surface.c           |   15 +++------------
 dlls/wined3d/surface.c         |   24 +++++++++++++-----------
 dlls/wined3d/texture.c         |    6 ++----
 dlls/wined3d/wined3d_private.h |    2 +-
 4 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 60f7dad..958abd7 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -484,8 +484,7 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface)
                 surface, surface->ref7, surface->ref4, surface->ref3, surface->ref2, surface->ref1);
     }
 
-    if (surface->wined3d_texture
-            && !(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
+    if (surface->wined3d_texture)
         wined3d_texture_decref(surface->wined3d_texture);
     if (surface->wined3d_surface)
         wined3d_surface_decref(surface->wined3d_surface);
@@ -508,11 +507,7 @@ ULONG ddraw_surface_release_iface(struct ddraw_surface *This)
             wined3d_mutex_unlock();
             return iface_count;
         }
-        /* If it's a texture, destroy the wined3d texture. */
-        if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
-            wined3d_texture_decref(This->wined3d_texture);
-        else
-            ddraw_surface_cleanup(This);
+        ddraw_surface_cleanup(This);
         wined3d_mutex_unlock();
 
         if (release_iface)
@@ -5579,12 +5574,8 @@ static const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops =
 
 static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *parent)
 {
-    struct ddraw_texture *texture = parent;
-
-    TRACE("texture %p.\n", texture);
+    TRACE("parent %p.\n", parent);
 
-    if (texture->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
-        ddraw_surface_cleanup(texture->root);
     HeapFree(GetProcessHeap(), 0, parent);
 }
 
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 3c45780..e30d6b4 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -6766,9 +6766,10 @@ cpu:
     return surface_cpu_blt(dst_surface, &dst_rect, src_surface, &src_rect, flags, fx, filter);
 }
 
-static HRESULT surface_init(struct wined3d_surface *surface, const struct wined3d_resource_desc *desc,
-        struct wined3d_device *device, DWORD flags)
+static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_texture *container,
+        const struct wined3d_resource_desc *desc, DWORD flags)
 {
+    struct wined3d_device *device = container->resource.device;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format);
     UINT multisample_quality = desc->multisample_quality;
@@ -6830,9 +6831,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, const struct wined3
         return hr;
     }
 
-    /* "Standalone" surface. */
-    surface_set_container(surface, NULL);
-
+    surface_set_container(surface, container);
     list_init(&surface->overlays);
 
     /* Flags */
@@ -6866,6 +6865,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, const struct wined3
     if (FAILED(hr))
     {
         ERR("Private setup failed, returning %#x\n", hr);
+        surface_set_container(surface, NULL);
         surface_cleanup(surface);
         return hr;
     }
@@ -6883,34 +6883,36 @@ static HRESULT surface_init(struct wined3d_surface *surface, const struct wined3
     return hr;
 }
 
-HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, void *container_parent,
+HRESULT CDECL wined3d_surface_create(struct wined3d_texture *container,
         const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_surface **surface)
 {
+    struct wined3d_device_parent *device_parent = container->resource.device->device_parent;
     const struct wined3d_parent_ops *parent_ops;
     struct wined3d_surface *object;
     void *parent;
     HRESULT hr;
 
-    TRACE("device %p, container_parent %p, width %u, height %u, format %s, usage %s (%#x), "
+    TRACE("container %p, width %u, height %u, format %s, usage %s (%#x), "
             "pool %s, multisample_type %#x, multisample_quality %u, flags %#x, surface %p.\n",
-            device, container_parent, desc->width, desc->height, debug_d3dformat(desc->format),
+            container, desc->width, desc->height, debug_d3dformat(desc->format),
             debug_d3dusage(desc->usage), desc->usage, debug_d3dpool(desc->pool),
             desc->multisample_type, desc->multisample_quality, flags, surface);
 
     if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
         return E_OUTOFMEMORY;
 
-    if (FAILED(hr = surface_init(object, desc, device, flags)))
+    if (FAILED(hr = surface_init(object, container, desc, flags)))
     {
         WARN("Failed to initialize surface, returning %#x.\n", hr);
         HeapFree(GetProcessHeap(), 0, object);
         return hr;
     }
 
-    if (FAILED(hr = device->device_parent->ops->surface_created(device->device_parent,
-            container_parent, object, &parent, &parent_ops)))
+    if (FAILED(hr = device_parent->ops->surface_created(device_parent,
+            wined3d_texture_get_parent(container), object, &parent, &parent_ops)))
     {
         WARN("Failed to create surface parent, hr %#x.\n", hr);
+        surface_set_container(object, NULL);
         wined3d_surface_decref(object);
         return hr;
     }
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index da48100..a6a9dbf 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -860,14 +860,13 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi
             UINT idx = j * texture->level_count + i;
             struct wined3d_surface *surface;
 
-            if (FAILED(hr = wined3d_surface_create(device, parent, &surface_desc, surface_flags, &surface)))
+            if (FAILED(hr = wined3d_surface_create(texture, &surface_desc, surface_flags, &surface)))
             {
                 WARN("Failed to create surface, hr %#x.\n", hr);
                 wined3d_texture_cleanup(texture);
                 return hr;
             }
 
-            surface_set_container(surface, texture);
             surface_set_texture_target(surface, cube_targets[j], i);
             texture->sub_resources[idx] = &surface->resource;
             TRACE("Created surface level %u @ %p.\n", i, surface);
@@ -1015,14 +1014,13 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
     {
         struct wined3d_surface *surface;
 
-        if (FAILED(hr = wined3d_surface_create(device, parent, &surface_desc, surface_flags, &surface)))
+        if (FAILED(hr = wined3d_surface_create(texture, &surface_desc, surface_flags, &surface)))
         {
             WARN("Failed to create surface, hr %#x.\n", hr);
             wined3d_texture_cleanup(texture);
             return hr;
         }
 
-        surface_set_container(surface, texture);
         surface_set_texture_target(surface, texture->target, i);
         texture->sub_resources[i] = &surface->resource;
         TRACE("Created surface level %u @ %p.\n", i, surface);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8a11f30..3c39ee1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2273,7 +2273,7 @@ void surface_update_draw_binding(struct wined3d_surface *surface) DECLSPEC_HIDDE
 HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,
         struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
 void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
-HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, void *container_parent,
+HRESULT CDECL wined3d_surface_create(struct wined3d_texture *container,
         const struct wined3d_resource_desc *desc, DWORD flags, struct wined3d_surface **surface) DECLSPEC_HIDDEN;
 
 void get_drawable_size_swapchain(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list