Henri Verbeet : d3d9: Add a separate function for texture initialization.
Alexandre Julliard
julliard at winehq.org
Thu Sep 17 13:53:20 CDT 2009
Module: wine
Branch: master
Commit: 75f005ebf97816548dfc4c67f1f08f2b0f0bb798
URL: http://source.winehq.org/git/wine.git/?a=commit;h=75f005ebf97816548dfc4c67f1f08f2b0f0bb798
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Thu Sep 17 12:35:29 2009 +0200
d3d9: Add a separate function for texture initialization.
---
dlls/d3d9/d3d9_private.h | 6 ++--
dlls/d3d9/device.c | 32 ++++++++++++++++++++++++++++
dlls/d3d9/texture.c | 51 +++++++++++++++------------------------------
3 files changed, 52 insertions(+), 37 deletions(-)
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index e373af8..e80d1a2 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -197,9 +197,6 @@ extern HRESULT WINAPI IDirect3DDevice9Impl_CreateAdditionalSwapChain(IDirect3DDe
extern HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(IDirect3DDevice9Ex *iface,
UINT iSwapChain, IDirect3DSwapChain9 **pSwapChain) DECLSPEC_HIDDEN;
extern UINT WINAPI IDirect3DDevice9Impl_GetNumberOfSwapChains(IDirect3DDevice9Ex *iface) DECLSPEC_HIDDEN;
-extern HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *iface,
- UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
- IDirect3DTexture9 **ppTexture, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
extern HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(IDirect3DDevice9Ex *iface,
UINT Length, DWORD Usage, DWORD FVF, D3DPOOL Pool,
IDirect3DVertexBuffer9 **ppVertexBuffer, HANDLE *pSharedHandle) DECLSPEC_HIDDEN;
@@ -441,6 +438,9 @@ typedef struct IDirect3DTexture9Impl
LPDIRECT3DDEVICE9EX parentDevice;
} IDirect3DTexture9Impl;
+HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *device,
+ UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
+
/* ----------------------- */
/* IDirect3DVolumeTexture9 */
/* ----------------------- */
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 06cfcee..7ddc0d6 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -644,6 +644,38 @@ static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface,
wined3d_mutex_unlock();
}
+static HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(IDirect3DDevice9Ex *iface,
+ UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format,
+ D3DPOOL pool, IDirect3DTexture9 **texture, HANDLE *shared_handle)
+{
+ IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
+ IDirect3DTexture9Impl *object;
+ HRESULT hr;
+
+ TRACE("iface %p, width %u, height %u, levels %u, usage %#x, format %#x, pool %#x, texture %p, shared_handle %p.\n",
+ iface, width, height, levels, usage, format, pool, texture, shared_handle);
+
+ object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
+ if (!object)
+ {
+ ERR("Failed to allocate texture memory.\n");
+ return D3DERR_OUTOFVIDEOMEMORY;
+ }
+
+ hr = texture_init(object, This, width, height, levels, usage, format, pool);
+ if (FAILED(hr))
+ {
+ WARN("Failed to initialize texture, hr %#x.\n", hr);
+ HeapFree(GetProcessHeap(), 0, object);
+ return hr;
+ }
+
+ TRACE("Created texture %p.\n", object);
+ *texture = (IDirect3DTexture9 *)object;
+
+ return D3D_OK;
+}
+
static HRESULT WINAPI IDirect3DDevice9Impl_CreateVolumeTexture(IDirect3DDevice9Ex *iface,
UINT width, UINT height, UINT depth, UINT levels, DWORD usage, D3DFORMAT format,
D3DPOOL pool, IDirect3DVolumeTexture9 **texture, HANDLE *shared_handle)
diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c
index ea1cde8..c3a3232 100644
--- a/dlls/d3d9/texture.c
+++ b/dlls/d3d9/texture.c
@@ -350,43 +350,26 @@ static const IDirect3DTexture9Vtbl Direct3DTexture9_Vtbl =
IDirect3DTexture9Impl_AddDirtyRect
};
+HRESULT texture_init(IDirect3DTexture9Impl *texture, IDirect3DDevice9Impl *device,
+ UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
+{
+ HRESULT hr;
-/* IDirect3DDevice9 IDirect3DTexture9 Methods follow: */
-HRESULT WINAPI IDirect3DDevice9Impl_CreateTexture(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height, UINT Levels, DWORD Usage,
- D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
- IDirect3DTexture9Impl *object;
- IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
- HRESULT hrc = D3D_OK;
-
- TRACE("(%p) : W(%d) H(%d), Lvl(%d) d(%d), Fmt(%#x), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
-
- /* Allocate the storage for the device */
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture9Impl));
-
- if (NULL == object) {
- ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
- return D3DERR_OUTOFVIDEOMEMORY;
- }
-
- object->lpVtbl = &Direct3DTexture9_Vtbl;
- object->ref = 1;
+ texture->lpVtbl = &Direct3DTexture9_Vtbl;
+ texture->ref = 1;
wined3d_mutex_lock();
- hrc = IWineD3DDevice_CreateTexture(This->WineD3DDevice, Width, Height, Levels, Usage & WINED3DUSAGE_MASK,
- wined3dformat_from_d3dformat(Format), Pool, &object->wineD3DTexture, (IUnknown *)object);
+ hr = IWineD3DDevice_CreateTexture(device->WineD3DDevice, width, height, levels, usage & WINED3DUSAGE_MASK,
+ wined3dformat_from_d3dformat(format), pool, &texture->wineD3DTexture, (IUnknown *)texture);
wined3d_mutex_unlock();
-
- if (FAILED(hrc))
+ if (FAILED(hr))
{
- /* free up object */
- WARN("(%p) call to IWineD3DDevice_CreateTexture failed\n", This);
- HeapFree(GetProcessHeap(), 0, object);
- } else {
- IDirect3DDevice9Ex_AddRef(iface);
- object->parentDevice = iface;
- *ppTexture= (LPDIRECT3DTEXTURE9) object;
- TRACE("(%p) Created Texture %p, %p\n", This, object, object->wineD3DTexture);
- }
-
- return hrc;
+ WARN("Failed to create wined3d texture, hr %#x.\n", hr);
+ return hr;
+ }
+
+ texture->parentDevice = (IDirect3DDevice9Ex *)device;
+ IDirect3DDevice9Ex_AddRef(texture->parentDevice);
+
+ return D3D_OK;
}
More information about the wine-cvs
mailing list