Henri Verbeet : wined3d: Get rid of IWineD3DVolumeTexture::Map().

Alexandre Julliard julliard at winehq.org
Tue Mar 15 11:33:55 CDT 2011


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Mon Mar 14 21:02:57 2011 +0100

wined3d: Get rid of IWineD3DVolumeTexture::Map().

---

 dlls/d3d10core/texture.c     |   22 +++++++++++-----------
 dlls/d3d8/volumetexture.c    |   16 +++++++++++-----
 dlls/d3d9/volumetexture.c    |   18 +++++++++++-------
 dlls/wined3d/volume.c        |    5 +++++
 dlls/wined3d/volumetexture.c |   20 --------------------
 dlls/wined3d/wined3d.spec    |    2 ++
 include/wine/wined3d.idl     |    8 ++------
 7 files changed, 42 insertions(+), 49 deletions(-)

diff --git a/dlls/d3d10core/texture.c b/dlls/d3d10core/texture.c
index 920b64f..8379605 100644
--- a/dlls/d3d10core/texture.c
+++ b/dlls/d3d10core/texture.c
@@ -346,32 +346,32 @@ static UINT STDMETHODCALLTYPE d3d10_texture3d_GetEvictionPriority(ID3D10Texture3
     return 0;
 }
 
-static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UINT sub_resource,
+static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UINT sub_resource_idx,
         D3D10_MAP map_type, UINT map_flags, D3D10_MAPPED_TEXTURE3D *mapped_texture)
 {
     struct d3d10_texture3d *texture = (struct d3d10_texture3d *)iface;
+    struct wined3d_resource *sub_resource;
     WINED3DLOCKED_BOX wined3d_map_desc;
     HRESULT hr;
 
-    TRACE("iface %p, sub_resource %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
-            iface, sub_resource, map_type, map_flags, mapped_texture);
+    TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n",
+            iface, sub_resource_idx, map_type, map_flags, mapped_texture);
 
     if (map_type != D3D10_MAP_READ_WRITE)
         FIXME("Ignoring map_type %#x.\n", map_type);
     if (map_flags)
         FIXME("Ignoring map_flags %#x.\n", map_flags);
 
-    hr = IWineD3DVolumeTexture_Map(texture->wined3d_texture, sub_resource, &wined3d_map_desc, NULL, 0);
-    if (FAILED(hr))
+    if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wined3d_texture, sub_resource_idx)))
+        hr = E_INVALIDARG;
+    else if (SUCCEEDED(hr = IWineD3DVolume_Map(wined3d_volume_from_resource(sub_resource),
+            &wined3d_map_desc, NULL, 0)))
     {
-        WARN("Failed to map texture, hr %#x.\n", hr);
-        return hr;
+        mapped_texture->pData = wined3d_map_desc.pBits;
+        mapped_texture->RowPitch = wined3d_map_desc.RowPitch;
+        mapped_texture->DepthPitch = wined3d_map_desc.SlicePitch;
     }
 
-    mapped_texture->pData = wined3d_map_desc.pBits;
-    mapped_texture->RowPitch = wined3d_map_desc.RowPitch;
-    mapped_texture->DepthPitch = wined3d_map_desc.SlicePitch;
-
     return hr;
 }
 
diff --git a/dlls/d3d8/volumetexture.c b/dlls/d3d8/volumetexture.c
index 429f112..873822b 100644
--- a/dlls/d3d8/volumetexture.c
+++ b/dlls/d3d8/volumetexture.c
@@ -277,16 +277,22 @@ static HRESULT WINAPI IDirect3DVolumeTexture8Impl_GetVolumeLevel(IDirect3DVolume
     return D3D_OK;
 }
 
-static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(LPDIRECT3DVOLUMETEXTURE8 iface, UINT Level, D3DLOCKED_BOX *pLockedVolume, CONST D3DBOX *pBox, DWORD Flags) {
-    IDirect3DVolumeTexture8Impl *This = (IDirect3DVolumeTexture8Impl *)iface;
+static HRESULT WINAPI IDirect3DVolumeTexture8Impl_LockBox(IDirect3DVolumeTexture8 *iface,
+        UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
+{
+    IDirect3DVolumeTexture8Impl *texture = (IDirect3DVolumeTexture8Impl *)iface;
+    struct wined3d_resource *sub_resource;
     HRESULT hr;
 
     TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
-            iface, Level, pLockedVolume, pBox, Flags);
+            iface, level, locked_box, box, flags);
 
     wined3d_mutex_lock();
-    hr = IWineD3DVolumeTexture_Map(This->wineD3DVolumeTexture, Level,
-            (WINED3DLOCKED_BOX *)pLockedVolume, (const WINED3DBOX *)pBox, Flags);
+    if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wineD3DVolumeTexture, level)))
+        hr = D3DERR_INVALIDCALL;
+    else
+        hr = IDirect3DVolume8_LockBox((IDirect3DVolume8 *)wined3d_resource_get_parent(sub_resource),
+                locked_box, box, flags);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/d3d9/volumetexture.c b/dlls/d3d9/volumetexture.c
index e97d1a4..b4b5503 100644
--- a/dlls/d3d9/volumetexture.c
+++ b/dlls/d3d9/volumetexture.c
@@ -339,18 +339,22 @@ static HRESULT WINAPI IDirect3DVolumeTexture9Impl_GetVolumeLevel(IDirect3DVolume
     return D3D_OK;
 }
 
-static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(LPDIRECT3DVOLUMETEXTURE9 iface, UINT Level, D3DLOCKED_BOX* pLockedVolume, CONST D3DBOX* pBox, DWORD Flags) {
-    IDirect3DVolumeTexture9Impl *This = (IDirect3DVolumeTexture9Impl *)iface;
+static HRESULT WINAPI IDirect3DVolumeTexture9Impl_LockBox(IDirect3DVolumeTexture9 *iface,
+        UINT level, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags)
+{
+    IDirect3DVolumeTexture9Impl *texture = (IDirect3DVolumeTexture9Impl *)iface;
+    struct wined3d_resource *sub_resource;
     HRESULT hr;
 
     TRACE("iface %p, level %u, locked_box %p, box %p, flags %#x.\n",
-            iface, Level, pLockedVolume, pBox, Flags);
+            iface, level, locked_box, box, flags);
 
     wined3d_mutex_lock();
-
-    hr = IWineD3DVolumeTexture_Map(This->wineD3DVolumeTexture, Level,
-            (WINED3DLOCKED_BOX *)pLockedVolume, (const WINED3DBOX *)pBox, Flags);
-
+    if (!(sub_resource = IWineD3DVolumeTexture_GetSubResource(texture->wineD3DVolumeTexture, level)))
+        hr = D3DERR_INVALIDCALL;
+    else
+        hr = IDirect3DVolume9_LockBox((IDirect3DVolume9 *)wined3d_resource_get_parent(sub_resource),
+                locked_box, box, flags);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index d05a9f2..3f7090c 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -277,6 +277,11 @@ static HRESULT WINAPI IWineD3DVolumeImpl_Map(IWineD3DVolume *iface,
     return WINED3D_OK;
 }
 
+IWineD3DVolume * CDECL wined3d_volume_from_resource(struct wined3d_resource *resource)
+{
+    return (IWineD3DVolume *)volume_from_resource(resource);
+}
+
 static HRESULT WINAPI IWineD3DVolumeImpl_Unmap(IWineD3DVolume *iface)
 {
     IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
diff --git a/dlls/wined3d/volumetexture.c b/dlls/wined3d/volumetexture.c
index e53d4f5..643141f 100644
--- a/dlls/wined3d/volumetexture.c
+++ b/dlls/wined3d/volumetexture.c
@@ -273,25 +273,6 @@ static struct wined3d_resource * WINAPI IWineD3DVolumeTextureImpl_GetSubResource
     return basetexture_get_sub_resource(texture, sub_resource_idx);
 }
 
-static HRESULT WINAPI IWineD3DVolumeTextureImpl_Map(IWineD3DVolumeTexture *iface,
-        UINT sub_resource_idx, WINED3DLOCKED_BOX *locked_box, const WINED3DBOX *box, DWORD flags)
-{
-    IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
-    struct wined3d_resource *sub_resource;
-
-    TRACE("iface %p, sub_resource_idx %u, locked_box %p, box %p, flags %#x.\n",
-            iface, sub_resource_idx, locked_box, box, flags);
-
-    if (!(sub_resource = basetexture_get_sub_resource(texture, sub_resource_idx)))
-    {
-        WARN("Failed to get sub-resource.\n");
-        return WINED3DERR_INVALIDCALL;
-    }
-
-    return IWineD3DVolume_Map((IWineD3DVolume *)volume_from_resource(sub_resource),
-            locked_box, box, flags);
-}
-
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_Unmap(IWineD3DVolumeTexture *iface, UINT sub_resource_idx)
 {
     IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *)iface;
@@ -352,7 +333,6 @@ static const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
     IWineD3DVolumeTextureImpl_IsCondNP2,
     IWineD3DVolumeTextureImpl_GetSubResource,
     /* volume texture */
-    IWineD3DVolumeTextureImpl_Map,
     IWineD3DVolumeTextureImpl_Unmap,
     IWineD3DVolumeTextureImpl_AddDirtyBox
 };
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 558fd82..f8e2121 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -69,3 +69,5 @@
 @ cdecl wined3d_vertex_declaration_decref(ptr)
 @ cdecl wined3d_vertex_declaration_get_parent(ptr)
 @ cdecl wined3d_vertex_declaration_incref(ptr)
+
+@ cdecl wined3d_volume_from_resource(ptr)
diff --git a/include/wine/wined3d.idl b/include/wine/wined3d.idl
index 7827080..d7c8b97 100644
--- a/include/wine/wined3d.idl
+++ b/include/wine/wined3d.idl
@@ -2395,12 +2395,6 @@ interface IWineD3DCubeTexture : IWineD3DBaseTexture
 ]
 interface IWineD3DVolumeTexture : IWineD3DBaseTexture
 {
-    HRESULT Map(
-        [in] UINT sub_resource_idx,
-        [out] WINED3DLOCKED_BOX *locked_box,
-        [in] const WINED3DBOX *box,
-        [in] DWORD flags
-    );
     HRESULT Unmap(
         [in] UINT sub_resource_idx
     );
@@ -3200,3 +3194,5 @@ ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
 ULONG __cdecl wined3d_vertex_declaration_decref(struct wined3d_vertex_declaration *declaration);
 void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex_declaration *declaration);
 ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
+
+IWineD3DVolume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);




More information about the wine-cvs mailing list