Henri Verbeet : d3d8: Add a separate function for cube texture initialization.
Alexandre Julliard
julliard at winehq.org
Thu Sep 17 13:53:07 CDT 2009
Module: wine
Branch: master
Commit: b5b58e423d32666581f69046c74bb19902c35c2b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b5b58e423d32666581f69046c74bb19902c35c2b
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Sep 17 12:35:24 2009 +0200
d3d8: Add a separate function for cube texture initialization.
---
dlls/d3d8/cubetexture.c | 27 +++++++++++++++++++++++++--
dlls/d3d8/d3d8_private.h | 8 +++-----
dlls/d3d8/device.c | 45 +++++++++++++++++----------------------------
3 files changed, 45 insertions(+), 35 deletions(-)
diff --git a/dlls/d3d8/cubetexture.c b/dlls/d3d8/cubetexture.c
index 4377693..97454d0 100644
--- a/dlls/d3d8/cubetexture.c
+++ b/dlls/d3d8/cubetexture.c
@@ -286,8 +286,7 @@ static HRESULT WINAPI IDirect3DCubeTexture8Impl_AddDirtyRect(LPDIRECT3DCUBETEXTU
return hr;
}
-
-const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
+static const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
{
/* IUnknown */
IDirect3DCubeTexture8Impl_QueryInterface,
@@ -313,3 +312,27 @@ const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl =
IDirect3DCubeTexture8Impl_UnlockRect,
IDirect3DCubeTexture8Impl_AddDirtyRect
};
+
+HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
+ UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
+{
+ HRESULT hr;
+
+ texture->lpVtbl = &Direct3DCubeTexture8_Vtbl;
+ texture->ref = 1;
+
+ wined3d_mutex_lock();
+ hr = IWineD3DDevice_CreateCubeTexture(device->WineD3DDevice, edge_length, levels, usage & WINED3DUSAGE_MASK,
+ wined3dformat_from_d3dformat(format), pool, &texture->wineD3DCubeTexture, (IUnknown *)texture);
+ wined3d_mutex_unlock();
+ if (FAILED(hr))
+ {
+ WARN("Failed to create wined3d cube texture, hr %#x.\n", hr);
+ return hr;
+ }
+
+ texture->parentDevice = (IDirect3DDevice8 *)device;
+ IDirect3DDevice8_AddRef(texture->parentDevice);
+
+ return D3D_OK;
+}
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index f1c7ded..5d1587e 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -390,11 +390,6 @@ struct IDirect3DBaseTexture8Impl
/* --------------------- */
/*****************************************************************************
- * Predeclare the interface implementation structures
- */
-extern const IDirect3DCubeTexture8Vtbl Direct3DCubeTexture8_Vtbl DECLSPEC_HIDDEN;
-
-/*****************************************************************************
* IDirect3DCubeTexture8 implementation structure
*/
struct IDirect3DCubeTexture8Impl
@@ -410,6 +405,9 @@ struct IDirect3DCubeTexture8Impl
LPDIRECT3DDEVICE8 parentDevice;
};
+HRESULT cubetexture_init(IDirect3DCubeTexture8Impl *texture, IDirect3DDevice8Impl *device,
+ UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
+
/* ----------------- */
/* IDirect3DTexture8 */
/* ----------------- */
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 8e63108..f7c56db 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -726,45 +726,34 @@ static HRESULT WINAPI IDirect3DDevice8Impl_CreateVolumeTexture(IDirect3DDevice8
return D3D_OK;
}
-static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT EdgeLength,
- UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DCubeTexture8 **ppCubeTexture)
+static HRESULT WINAPI IDirect3DDevice8Impl_CreateCubeTexture(IDirect3DDevice8 *iface, UINT edge_length,
+ UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool, IDirect3DCubeTexture8 **texture)
{
- IDirect3DCubeTexture8Impl *object;
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
- HRESULT hr = D3D_OK;
+ IDirect3DCubeTexture8Impl *object;
+ HRESULT hr;
- TRACE("(%p) : ELen(%d) Lvl(%d) Usage(%d) fmt(%u), Pool(%d)\n" , This, EdgeLength, Levels, Usage, Format, Pool);
+ TRACE("iface %p, edge_length %u, levels %u, usage %#x, format %#x, pool %#x, texture %p.\n",
+ iface, edge_length, levels, usage, format, pool, texture);
- /* Allocate the storage for the device */
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
-
- if (NULL == object) {
- FIXME("(%p) allocation of CubeTexture failed\n", This);
- *ppCubeTexture = NULL;
+ if (!object)
+ {
+ ERR("Failed to allocate cube texture memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
}
- object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
- object->ref = 1;
-
- wined3d_mutex_lock();
- hr = IWineD3DDevice_CreateCubeTexture(This->WineD3DDevice, EdgeLength, Levels, Usage & WINED3DUSAGE_MASK,
- wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DCubeTexture, (IUnknown *)object);
- wined3d_mutex_unlock();
-
- if (hr != D3D_OK){
-
- /* free up object */
- FIXME("(%p) call to IWineD3DDevice_CreateCubeTexture failed\n", This);
+ hr = cubetexture_init(object, This, edge_length, levels, usage, format, pool);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize cube texture, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
- *ppCubeTexture = NULL;
- } else {
- IUnknown_AddRef(iface);
- object->parentDevice = iface;
- *ppCubeTexture = (LPDIRECT3DCUBETEXTURE8) object;
+ return hr;
}
- TRACE("(%p) returning %p\n",This, *ppCubeTexture);
+ TRACE("Created cube texture %p.\n", object);
+ *texture = (IDirect3DCubeTexture8 *)object;
+
return hr;
}
More information about the wine-cvs
mailing list