[v2 resend 4/6] d3d9: make use of wined3d_texture_map in d3d9_surface_LockRect

Riccardo Bortolato rikyz619 at gmail.com
Mon Oct 12 05:44:10 CDT 2015


Also store wined3d_texture and sub_resource_idx in d3d9_surface.

Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
---
 dlls/d3d9/d3d9_private.h |  4 +++-
 dlls/d3d9/device.c       |  2 +-
 dlls/d3d9/surface.c      | 11 +++++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index ea0d3e6..dc9ae1c 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -214,6 +214,8 @@ struct d3d9_surface
 {
     IDirect3DSurface9 IDirect3DSurface9_iface;
     struct d3d9_resource resource;
+    struct wined3d_texture *wined3d_texture;
+    unsigned int sub_resource_idx;
     struct wined3d_surface *wined3d_surface;
     struct list rtv_entry;
     struct wined3d_rendertarget_view *wined3d_rtv;
@@ -224,7 +226,7 @@ struct d3d9_surface
 };
 
 struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN;
-void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
+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) DECLSPEC_HIDDEN;
 struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
 
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 5df36f3..f49664e 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3545,7 +3545,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
     if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
         return E_OUTOFMEMORY;
 
-    surface_init(d3d_surface, wined3d_texture_get_parent(wined3d_texture), surface, parent_ops);
+    surface_init(d3d_surface, wined3d_texture, sub_resource_idx, surface, parent_ops);
     *parent = d3d_surface;
     TRACE("Created surface %p.\n", d3d_surface);
 
diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c
index 7dc6e70..ec5b420 100644
--- a/dlls/d3d9/surface.c
+++ b/dlls/d3d9/surface.c
@@ -251,7 +251,8 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface,
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect ? &box : NULL, flags);
+    hr = wined3d_texture_map(surface->wined3d_texture, surface->sub_resource_idx,
+            &map_desc, rect ? &box : NULL, flags);
     wined3d_mutex_unlock();
 
     if (SUCCEEDED(hr))
@@ -356,7 +357,7 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
     surface_wined3d_object_destroyed,
 };
 
-void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
+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;
@@ -367,9 +368,11 @@ void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
     surface->resource.refcount = 0;
     surface->wined3d_surface = wined3d_surface;
     list_init(&surface->rtv_entry);
-    surface->container = container_parent;
+    surface->container = wined3d_texture_get_parent(wined3d_texture);
+    surface->wined3d_texture = wined3d_texture;
+    surface->sub_resource_idx = sub_resource_idx;
 
-    if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent,
+    if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
             &IID_IDirect3DBaseTexture9, (void **)&texture)))
     {
         surface->texture = unsafe_impl_from_IDirect3DBaseTexture9(texture);
-- 
1.9.1




More information about the wine-patches mailing list