Add BaseTexture class support, call from d3d9.

This commit is contained in:
Jason Edmeades 2004-12-07 14:29:12 +00:00 committed by Alexandre Julliard
parent 0e6c60076f
commit 819b0e1190
7 changed files with 254 additions and 31 deletions

View File

@ -1,7 +1,7 @@
/*
* IDirect3DBaseTexture9 implementation
*
* Copyright 2002-2003 Jason Edmeades
* Copyright 2002-2004 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
@ -43,15 +43,17 @@ HRESULT WINAPI IDirect3DBaseTexture9Impl_QueryInterface(LPDIRECT3DBASETEXTURE9 i
ULONG WINAPI IDirect3DBaseTexture9Impl_AddRef(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
TRACE("(%p) : AddRef from %ld\n", This, This->ref);
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG WINAPI IDirect3DBaseTexture9Impl_Release(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
ULONG ref = --This->ref;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
if (ref == 0)
if (ref == 0) {
IWineD3DBaseTexture_Release(This->wineD3DBaseTexture);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
@ -63,41 +65,38 @@ HRESULT WINAPI IDirect3DBaseTexture9Impl_GetDevice(LPDIRECT3DBASETEXTURE9 iface,
HRESULT WINAPI IDirect3DBaseTexture9Impl_SetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
return IWineD3DBaseTexture_SetPrivateData(This->wineD3DBaseTexture, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IDirect3DBaseTexture9Impl_GetPrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
return IWineD3DBaseTexture_GetPrivateData(This->wineD3DBaseTexture, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IDirect3DBaseTexture9Impl_FreePrivateData(LPDIRECT3DBASETEXTURE9 iface, REFGUID refguid) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
return IWineD3DBaseTexture_FreePrivateData(This->wineD3DBaseTexture, refguid);
}
DWORD WINAPI IDirect3DBaseTexture9Impl_SetPriority(LPDIRECT3DBASETEXTURE9 iface, DWORD PriorityNew) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
return IDirect3DResource9Impl_SetPriority((LPDIRECT3DRESOURCE9) This, PriorityNew);
return IWineD3DBaseTexture_SetPriority(This->wineD3DBaseTexture, PriorityNew);
}
DWORD WINAPI IDirect3DBaseTexture9Impl_GetPriority(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
return IDirect3DResource9Impl_GetPriority((LPDIRECT3DRESOURCE9) This);
return IWineD3DBaseTexture_GetPriority(This->wineD3DBaseTexture);
}
void WINAPI IDirect3DBaseTexture9Impl_PreLoad(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
FIXME("(%p) : stub\n", This);
IWineD3DBaseTexture_PreLoad(This->wineD3DBaseTexture);
return ;
}
D3DRESOURCETYPE WINAPI IDirect3DBaseTexture9Impl_GetType(LPDIRECT3DBASETEXTURE9 iface) {
IDirect3DBaseTexture9Impl *This = (IDirect3DBaseTexture9Impl *)iface;
return IDirect3DResource9Impl_GetType((LPDIRECT3DRESOURCE9) This);
return IWineD3DBaseTexture_GetType(This->wineD3DBaseTexture);
}
/* IDirect3DBaseTexture9 Interface follow: */

View File

@ -540,7 +540,6 @@ struct IDirect3DResource9Impl
/* IDirect3DResource9 fields */
IWineD3DResource *wineD3DResource;
IDirect3DDevice9 *device;
};
/* IUnknown: */
@ -578,7 +577,6 @@ struct IDirect3DSurface9Impl
DWORD ref;
/* IDirect3DResource9 fields */
IDirect3DDevice9Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DSurface9 fields */
@ -724,13 +722,7 @@ struct IDirect3DBaseTexture9Impl
DWORD ref;
/* IDirect3DResource9 fields */
IDirect3DDevice9Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture9 fields */
BOOL Dirty;
D3DFORMAT format;
UINT levels;
IWineD3DBaseTexture *wineD3DBaseTexture;
};
/* IUnknown: */
@ -776,7 +768,6 @@ struct IDirect3DCubeTexture9Impl
DWORD ref;
/* IDirect3DResource9 fields */
IDirect3DDevice9Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture9 fields */
@ -840,7 +831,6 @@ struct IDirect3DTexture9Impl
DWORD ref;
/* IDirect3DResource9 fields */
IDirect3DDevice9Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture9 fields */
@ -905,7 +895,6 @@ struct IDirect3DVolumeTexture9Impl
DWORD ref;
/* IDirect3DResource9 fields */
IDirect3DDevice9Impl *Device;
D3DRESOURCETYPE ResourceType;
/* IDirect3DBaseTexture9 fields */

View File

@ -59,9 +59,9 @@ ULONG WINAPI IDirect3DResource9Impl_Release(LPDIRECT3DRESOURCE9 iface) {
/* IDirect3DResource9 Interface follow: */
HRESULT WINAPI IDirect3DResource9Impl_GetDevice(LPDIRECT3DRESOURCE9 iface, IDirect3DDevice9** ppDevice) {
IDirect3DResource9Impl *This = (IDirect3DResource9Impl *)iface;
TRACE("(%p) : returning %p\n", This, This->device);
*ppDevice = (LPDIRECT3DDEVICE9) This->device;
IDirect3DDevice9Impl_AddRef(*ppDevice);
IWineD3DDevice *myDevice = NULL;
IWineD3DResource_GetDevice(This->wineD3DResource, &myDevice);
IWineD3DDevice_GetParent(myDevice, (IUnknown **)ppDevice);
return D3D_OK;
}

View File

@ -8,6 +8,7 @@ EXTRAINCL = @X_CFLAGS@
EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ @OPENGL_LIBS@
C_SRCS = \
basetexture.c \
device.c \
directx.c \
indexbuffer.c \

157
dlls/wined3d/basetexture.c Normal file
View File

@ -0,0 +1,157 @@
/*
* IWineD3DBaseTexture Implementation
*
* Copyright 2002-2004 Jason Edmeades
* Raphael Junqueira
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
/* *******************************************
IWineD3DBaseTexture IUnknown parts follow
******************************************* */
HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
WARN("(%p)->(%s,%p) should not be called\n",This,debugstr_guid(riid),ppobj);
return E_NOINTERFACE;
}
ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
IUnknown_AddRef(This->resource.parent);
return InterlockedIncrement(&This->resource.ref);
}
ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
ULONG ref;
TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
IWineD3DDevice_Release(This->resource.wineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
} else {
IUnknown_Release(This->resource.parent); /* Released the reference to the d3dx object */
}
return ref;
}
/* ****************************************************
IWineD3DBaseTexture IWineD3DResource parts follow
**************************************************** */
HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResource_GetDevice((IWineD3DResource *)iface, ppDevice);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResource_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResource_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid) {
return IWineD3DResource_FreePrivateData((IWineD3DResource *)iface, refguid);
}
DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew) {
return IWineD3DResource_SetPriority((IWineD3DResource *)iface, PriorityNew);
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface) {
return IWineD3DResource_GetPriority((IWineD3DResource *)iface);
}
void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface) {
return IWineD3DResource_PreLoad((IWineD3DResource *)iface);
}
D3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface) {
return IWineD3DResource_GetType((IWineD3DResource *)iface);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent) {
return IWineD3DResource_GetParent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
IWineD3DBaseTexture IWineD3DBaseTexture parts follow
****************************************************** */
DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return 0;
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
return This->baseTexture.levels;
}
HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, D3DTEXTUREFILTERTYPE FilterType) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return D3D_OK;
}
D3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return D3DTEXF_NONE;
}
void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
return ;
}
IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
{
IWineD3DBaseTextureImpl_QueryInterface,
IWineD3DBaseTextureImpl_AddRef,
IWineD3DBaseTextureImpl_Release,
IWineD3DBaseTextureImpl_GetParent,
IWineD3DBaseTextureImpl_GetDevice,
IWineD3DBaseTextureImpl_SetPrivateData,
IWineD3DBaseTextureImpl_GetPrivateData,
IWineD3DBaseTextureImpl_FreePrivateData,
IWineD3DBaseTextureImpl_SetPriority,
IWineD3DBaseTextureImpl_GetPriority,
IWineD3DBaseTextureImpl_PreLoad,
IWineD3DBaseTextureImpl_GetType,
IWineD3DBaseTextureImpl_SetLOD,
IWineD3DBaseTextureImpl_GetLOD,
IWineD3DBaseTextureImpl_GetLevelCount,
IWineD3DBaseTextureImpl_SetAutoGenFilterType,
IWineD3DBaseTextureImpl_GetAutoGenFilterType,
IWineD3DBaseTextureImpl_GenerateMipSubLevels
};

View File

@ -268,6 +268,26 @@ typedef struct IWineD3DIndexBufferImpl
extern IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl;
/*****************************************************************************
* IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
*/
typedef struct IWineD3DBaseTextureClass
{
UINT levels;
} IWineD3DBaseTextureClass;
typedef struct IWineD3DBaseTextureImpl
{
/* IUnknown & WineD3DResource Information */
IWineD3DIndexBufferVtbl *lpVtbl;
IWineD3DResourceClass resource;
IWineD3DBaseTextureClass baseTexture;
} IWineD3DBaseTextureImpl;
extern IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl;
/*****************************************************************************
* IWineD3DStateBlock implementation structure
*/

View File

@ -85,6 +85,7 @@ typedef struct IWineD3DDevice IWineD3DDevice;
typedef struct IWineD3DResource IWineD3DResource;
typedef struct IWineD3DVertexBuffer IWineD3DVertexBuffer;
typedef struct IWineD3DIndexBuffer IWineD3DIndexBuffer;
typedef struct IWineD3DBaseTexture IWineD3DBaseTexture;
typedef struct IWineD3DStateBlock IWineD3DStateBlock;
/*****************************************************************************
@ -253,7 +254,7 @@ DECLARE_INTERFACE_(IWineD3DResource,IUnknown)
* WineD3DVertexBuffer interface
*/
#define INTERFACE IWineD3DVertexBuffer
DECLARE_INTERFACE_(IWineD3DVertexBuffer,IDirect3DResource8)
DECLARE_INTERFACE_(IWineD3DVertexBuffer,IWineD3DResource)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
@ -301,7 +302,7 @@ DECLARE_INTERFACE_(IWineD3DVertexBuffer,IDirect3DResource8)
* WineD3DIndexBuffer interface
*/
#define INTERFACE IWineD3DIndexBuffer
DECLARE_INTERFACE_(IWineD3DIndexBuffer,IDirect3DResource8)
DECLARE_INTERFACE_(IWineD3DIndexBuffer,IWineD3DResource)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
@ -345,6 +346,62 @@ DECLARE_INTERFACE_(IWineD3DIndexBuffer,IDirect3DResource8)
#define IWineD3DIndexBuffer_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
#endif
/*****************************************************************************
* IWineD3DBaseTexture interface
* Note at d3d8 this does NOT extend Resource, but at d3d9 it does
* since most functions are common anyway, it makes sense to extend it
*/
#define INTERFACE IWineD3DBaseTexture
DECLARE_INTERFACE_(IWineD3DBaseTexture,IWineD3DResource)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID riid, void** ppvObject) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IWineD3DResource methods ***/
STDMETHOD(GetParent)(THIS_ IUnknown **pParent) PURE;
STDMETHOD(GetDevice)(THIS_ IWineD3DDevice ** ppDevice) PURE;
STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags) PURE;
STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid, void * pData, DWORD * pSizeOfData) PURE;
STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE;
STDMETHOD_(DWORD,SetPriority)(THIS_ DWORD PriorityNew) PURE;
STDMETHOD_(DWORD,GetPriority)(THIS) PURE;
STDMETHOD_(void,PreLoad)(THIS) PURE;
STDMETHOD_(D3DRESOURCETYPE,GetType)(THIS) PURE;
/*** IWineD3DBaseTexture methods ***/
STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE;
STDMETHOD_(DWORD, GetLOD)(THIS) PURE;
STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE;
STDMETHOD(SetAutoGenFilterType)(THIS_ D3DTEXTUREFILTERTYPE FilterType) PURE;
STDMETHOD_(D3DTEXTUREFILTERTYPE, GetAutoGenFilterType)(THIS) PURE;
STDMETHOD_(void, GenerateMipSubLevels)(THIS) PURE;
};
#undef INTERFACE
#if !defined(__cplusplus) || defined(CINTERFACE)
/*** IUnknown methods ***/
#define IWineD3DBaseTexture_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IWineD3DBaseTexture_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IWineD3DBaseTexture_Release(p) (p)->lpVtbl->Release(p)
/*** IWineD3DBaseTexture methods: IDirect3DResource9 ***/
#define IWineD3DBaseTexture_GetParent(p,a) (p)->lpVtbl->GetParent(p,a)
#define IWineD3DBaseTexture_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a)
#define IWineD3DBaseTexture_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d)
#define IWineD3DBaseTexture_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c)
#define IWineD3DBaseTexture_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a)
#define IWineD3DBaseTexture_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a)
#define IWineD3DBaseTexture_GetPriority(p) (p)->lpVtbl->GetPriority(p)
#define IWineD3DBaseTexture_PreLoad(p) (p)->lpVtbl->PreLoad(p)
#define IWineD3DBaseTexture_GetType(p) (p)->lpVtbl->GetType(p)
/*** IWineD3DBaseTexture methods ***/
#define IWineD3DBaseTexture_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a)
#define IWineD3DBaseTexture_GetLOD(p) (p)->lpVtbl->GetLOD(p)
#define IWineD3DBaseTexture_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p)
#define IWineD3DBaseTexture_SetAutoGenFilterType(p,a) (p)->lpVtbl->SetAutoGenFilterType(p,a)
#define IWineD3DBaseTexture_GetAutoGenFilterType(p) (p)->lpVtbl->GetAutoGenFilterType(p)
#define IWineD3DBaseTexture_GenerateMipSubLevels(p) (p)->lpVtbl->GenerateMipSubLevels(p)
#endif
/*****************************************************************************
* WineD3DStateBlock interface
*/