[D3D8 - 2] split of patch1: COM fixes
Raphaël Junqueira
fenix at club-internet.fr
Sat Jan 11 07:55:42 CST 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
this is the first patch of [D3D8 - 1] split
Changelog:
- Resend of last Jason texture work
- mipmapping
- copyrect#1
- copyrect#2
- begin of more COM compliant behavior:
- AddRef/Release where needed
- use IUnknown* instead void*
- fix many GetDevice using AddRef
- fix IDirect3DSurface8Impl_GetContainer using QueryInterface
Raphael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+ICJep7NA3AmQTU4RAp2MAJ9WTkn6UuzYijzx6VxVMAJFGwEV2QCfclHD
Pi3TiiJXhB22rD4LW9s/IPA=
=0leG
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: dlls/d3d8/basetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/basetexture.c,v
retrieving revision 1.2
diff -u -r1.2 basetexture.c
--- dlls/d3d8/basetexture.c 17 Dec 2002 01:15:16 -0000 1.2
+++ dlls/d3d8/basetexture.c 10 Jan 2003 23:42:11 -0000
@@ -65,6 +65,11 @@
ICOM_THIS(IDirect3DBaseTexture8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
+ /**
+ * Note Calling this method will increase the internal reference count
+ * on the IDirect3DDevice8 interface.
+ */
+ IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DBaseTexture8Impl_SetPrivateData(LPDIRECT3DBASETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
Index: dlls/d3d8/cubetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/cubetexture.c,v
retrieving revision 1.2
diff -u -r1.2 cubetexture.c
--- dlls/d3d8/cubetexture.c 17 Dec 2002 01:15:16 -0000 1.2
+++ dlls/d3d8/cubetexture.c 10 Jan 2003 23:42:20 -0000
@@ -75,6 +75,11 @@
ICOM_THIS(IDirect3DCubeTexture8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
+ /**
+ * Note Calling this method will increase the internal reference count
+ * on the IDirect3DDevice8 interface.
+ */
+ IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DCubeTexture8Impl_SetPrivateData(LPDIRECT3DCUBETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
Index: dlls/d3d8/d3d8_private.h
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/d3d8_private.h,v
retrieving revision 1.10
diff -u -r1.10 d3d8_private.h
--- dlls/d3d8/d3d8_private.h 2 Jan 2003 17:59:02 -0000 1.10
+++ dlls/d3d8/d3d8_private.h 10 Jan 2003 23:43:28 -0000
@@ -530,7 +563,7 @@
IDirect3DDevice8Impl *Device;
D3DRESOURCETYPE ResourceType;
- void *Container;
+ IUnknown *Container;
D3DSURFACE_DESC myDesc;
BYTE *allocatedMemory;
Index: dlls/d3d8/device.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/device.c,v
retrieving revision 1.23
diff -u -r1.23 device.c
--- dlls/d3d8/device.c 9 Jan 2003 06:02:39 -0000 1.23
+++ dlls/d3d8/device.c 10 Jan 2003 23:43:33 -0000
@@ -28,6 +28,7 @@
#include "wingdi.h"
#include "wine/debug.h"
+#include "config.h"
#include "d3d8_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
@@ -1124,7 +1168,7 @@
TRACE("(%p) : W(%d) H(%d), Lvl(%d) Usage(%ld), Fmt(%d), Pool(%d)\n", This, Width, Height, Levels, Usage, Format, Pool);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DTexture8Impl));
object->lpVtbl = &Direct3DTexture8_Vtbl;
- object->Device = This;
+ object->Device = This; /* FIXME: AddRef(This) */
object->ResourceType = D3DRTYPE_TEXTURE;
object->ref = 1;
object->width = Width;
@@ -1153,12 +1197,12 @@
for (i=0; i<object->levels; i++)
{
IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpH, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[i]);
- object->surfaces[i]->Container = object;
+ object->surfaces[i]->Container = (IUnknown*) object; /* FIXME: AddRef(object) */
object->surfaces[i]->myDesc.Usage = Usage;
object->surfaces[i]->myDesc.Pool = Pool ;
TRACE("Created surface level %d @ %p, memory at %p\n", i, object->surfaces[i], object->surfaces[i]->allocatedMemory);
- tmpW = max(1,tmpW / 2);
+ tmpW = max(1, tmpW / 2);
tmpH = max(1, tmpH / 2);
}
@@ -1220,7 +1264,7 @@
object->volumes[i] = (IDirect3DVolume8Impl *) volume;
volume->lpVtbl = &Direct3DVolume8_Vtbl;
- volume->Device = This;
+ volume->Device = This; /* FIXME: AddRef(This) */
volume->ResourceType = D3DRTYPE_VOLUME;
volume->Container = object;
volume->ref = 1;
@@ -1259,7 +1303,7 @@
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DCubeTexture8Impl));
object->lpVtbl = &Direct3DCubeTexture8_Vtbl;
object->ref = 1;
- object->Device = This;
+ object->Device = This; /* FIXME: AddRef(This) */
object->ResourceType = D3DRTYPE_CUBETEXTURE;
object->edgeLength = EdgeLength;
@@ -1286,7 +1330,7 @@
/* Create the 6 faces */
for (j=0;j<6;j++) {
IDirect3DDevice8Impl_CreateImageSurface(iface, tmpW, tmpW, Format, (LPDIRECT3DSURFACE8*) &object->surfaces[j][i]);
- object->surfaces[j][i]->Container = object;
+ object->surfaces[j][i]->Container = (IUnknown*) object;
object->surfaces[j][i]->myDesc.Usage = Usage;
object->surfaces[j][i]->myDesc.Pool = Pool ;
@@ -1371,7 +1415,7 @@
object->lpVtbl = &Direct3DSurface8_Vtbl;
object->Device = This;
object->ResourceType = D3DRTYPE_SURFACE;
- object->Container = This;
+ object->Container = (IUnknown*) This;
object->ref = 1;
object->myDesc.Width = Width;
@@ -1390,7 +1434,9 @@
HRESULT WINAPI IDirect3DDevice8Impl_CopyRects(LPDIRECT3DDEVICE8 iface, IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,
IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) {
- HRESULT rc = D3D_OK;
+ HRESULT rc = D3D_OK;
+ IDirect3DBaseTexture8* texture = NULL;
+
IDirect3DSurface8Impl *src = (IDirect3DSurface8Impl*) pSourceSurface;
IDirect3DSurface8Impl *dst = (IDirect3DSurface8Impl*) pDestinationSurface;
@@ -1404,14 +1450,13 @@
if (src->myDesc.Format != dst->myDesc.Format && (dst->myDesc.Format != D3DFMT_UNKNOWN)) {
TRACE("Formats do not match %x / %x\n", src->myDesc.Format, dst->myDesc.Format);
rc = D3DERR_INVALIDCALL;
- } else if (dst->myDesc.Format == D3DFMT_UNKNOWN) {
- void *texture = NULL;
+ } else if (dst->myDesc.Format == D3DFMT_UNKNOWN) {
TRACE("Converting dest to same format as source, since dest was unknown\n");
dst->myDesc.Format = src->myDesc.Format;
/* Convert container as well */
- IDirect3DSurface8Impl_GetContainer((LPDIRECT3DSURFACE8) dst, NULL, &texture); /* FIXME: Which refid? */
+ IDirect3DSurface8Impl_GetContainer((LPDIRECT3DSURFACE8) dst, &IID_IDirect3DBaseTexture8, (void**) &texture); /* FIXME: Which refid? */
if (texture != NULL) {
switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) texture)) {
@@ -1428,6 +1473,8 @@
FIXME("Unhandled texture type\n");
}
+ /** Releasing texture after GetContainer */
+ IDirect3DBaseTexture8_Release(texture);
}
}
@@ -1469,6 +1516,40 @@
}
}
}
+
+ /* Set dirty */
+ if (rc == D3D_OK) {
+ IDirect3DSurface8Impl_GetContainer((LPDIRECT3DSURFACE8) dst, &IID_IDirect3DBaseTexture8, (void**) &texture); /* FIXME: Which refid? */
+ if (texture != NULL) {
+
+ switch (IDirect3DBaseTexture8Impl_GetType((LPDIRECT3DBASETEXTURE8) texture)) {
+ case D3DRTYPE_TEXTURE:
+ {
+ IDirect3DTexture8Impl *pTexture = (IDirect3DTexture8Impl *)texture;
+ pTexture->Dirty = TRUE;
+ }
+ break;
+ case D3DRTYPE_VOLUMETEXTURE:
+ {
+ IDirect3DVolumeTexture8Impl *pTexture = (IDirect3DVolumeTexture8Impl *)texture;
+ pTexture->Dirty = TRUE;
+ }
+ break;
+ case D3DRTYPE_CUBETEXTURE:
+ {
+ IDirect3DCubeTexture8Impl *pTexture = (IDirect3DCubeTexture8Impl *)texture;
+ pTexture->Dirty = TRUE;
+ }
+ break;
+ default:
+ FIXME("Unhandled texture type\n");
+ }
+
+ /** Releasing texture after GetContainer */
+ IDirect3DBaseTexture8_Release(texture);
+ }
+ }
+
return D3D_OK;
}
HRESULT WINAPI IDirect3DDevice8Impl_UpdateTexture(LPDIRECT3DDEVICE8 iface, IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) {
Index: dlls/d3d8/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/directx.c,v
retrieving revision 1.11
diff -u -r1.11 directx.c
--- dlls/d3d8/directx.c 7 Jan 2003 20:36:30 -0000 1.11
+++ dlls/d3d8/directx.c 10 Jan 2003 23:43:50 -0000
@@ -409,6 +421,8 @@
object->lpVtbl = &Direct3DDevice8_Vtbl;
object->ref = 1;
object->direct3d8 = This;
+ /** The device AddRef the direct3d8 Interface else crash in propers clients codes */
+ IDirect3D8_AddRef((LPDIRECT3D8) object->direct3d8);
object->UpdateStateBlock = &object->StateBlock;
/* Save the creation parameters */
Index: dlls/d3d8/resource.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/resource.c,v
retrieving revision 1.1
diff -u -r1.1 resource.c
--- dlls/d3d8/resource.c 27 Sep 2002 22:46:17 -0000 1.1
+++ dlls/d3d8/resource.c 10 Jan 2003 23:44:07 -0000
@@ -34,7 +34,7 @@
ICOM_THIS(IDirect3DResource8Impl,iface);
if (IsEqualGUID(riid, &IID_IUnknown)
- || IsEqualGUID(riid, &IID_IClassFactory)) {
+ || IsEqualGUID(riid, &IID_IDirect3DResource8)) {
IDirect3DResource8Impl_AddRef(iface);
*ppobj = This;
return D3D_OK;
Index: dlls/d3d8/surface.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/surface.c,v
retrieving revision 1.4
diff -u -r1.4 surface.c
--- dlls/d3d8/surface.c 8 Jan 2003 21:09:27 -0000 1.4
+++ dlls/d3d8/surface.c 10 Jan 2003 23:44:21 -0000
@@ -66,18 +66,18 @@
ICOM_THIS(IDirect3DSurface8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
-
- /* Note Calling this method will increase the internal reference count
- on the IDirect3DDevice8 interface. */
+ /**
+ * Note Calling this method will increase the internal reference count
+ * on the IDirect3DDevice8 interface.
+ */
IDirect3DDevice8Impl_AddRef(*ppDevice);
-
return D3D_OK;
}
-HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) {
+HRESULT WINAPI IDirect3DSurface8Impl_SetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
}
-HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid,void* pData,DWORD* pSizeOfData) {
+HRESULT WINAPI IDirect3DSurface8Impl_GetPrivateData(LPDIRECT3DSURFACE8 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
}
@@ -85,15 +85,25 @@
ICOM_THIS(IDirect3DSurface8Impl,iface);
FIXME("(%p) : stub\n", This); return D3D_OK;
}
-HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid,void** ppContainer) {
+HRESULT WINAPI IDirect3DSurface8Impl_GetContainer(LPDIRECT3DSURFACE8 iface, REFIID riid, void** ppContainer) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
-
- /* If the surface is created using CreateImageSurface, CreateRenderTarget,
- or CreateDepthStencilSurface, the surface is considered stand alone. In this case,
- GetContainer will return the Direct3D device used to create the surface. */
+ HRESULT res;
+ /*
TRACE("(%p) : returning %p\n", This, This->Container);
*ppContainer = This->Container;
return D3D_OK;
+ */
+ res = IUnknown_QueryInterface(This->Container, riid, ppContainer);
+ if (E_NOINTERFACE == res) {
+ /**
+ * If the surface is created using CreateImageSurface, CreateRenderTarget,
+ * or CreateDepthStencilSurface, the surface is considered stand alone. In this case,
+ * GetContainer will return the Direct3D device used to create the surface.
+ */
+ res = IUnknown_QueryInterface(This->Container, &IID_IDirect3DDevice8, ppContainer);
+ }
+ TRACE("(%p) : returning %p\n", This, *ppContainer);
+ return res;
}
HRESULT WINAPI IDirect3DSurface8Impl_GetDesc(LPDIRECT3DSURFACE8 iface, D3DSURFACE_DESC *pDesc) {
ICOM_THIS(IDirect3DSurface8Impl,iface);
@@ -121,7 +131,7 @@
ICOM_THIS(IDirect3DSurface8Impl,iface);
TRACE("(%p) : stub\n", This);
if (This->Container) {
- IDirect3DBaseTexture8 *cont = This->Container;
+ IDirect3DBaseTexture8 *cont = (IDirect3DBaseTexture8*) This->Container;
/* Now setup the texture appropraitly */
int containerType = IDirect3DBaseTexture8Impl_GetType(cont);
Index: dlls/d3d8/texture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/texture.c,v
retrieving revision 1.3
diff -u -r1.3 texture.c
--- dlls/d3d8/texture.c 18 Dec 2002 05:05:41 -0000 1.3
+++ dlls/d3d8/texture.c 10 Jan 2003 23:44:35 -0000
@@ -74,7 +74,12 @@
HRESULT WINAPI IDirect3DTexture8Impl_GetDevice(LPDIRECT3DTEXTURE8 iface, IDirect3DDevice8** ppDevice) {
ICOM_THIS(IDirect3DTexture8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
- *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
+ *ppDevice = (LPDIRECT3DDEVICE8) This->Device;
+ /**
+ * Note Calling this method will increase the internal reference count
+ * on the IDirect3DDevice8 interface.
+ */
+ IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DTexture8Impl_SetPrivateData(LPDIRECT3DTEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
Index: dlls/d3d8/volumetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/d3d8/volumetexture.c,v
retrieving revision 1.3
diff -u -r1.3 volumetexture.c
--- dlls/d3d8/volumetexture.c 18 Dec 2002 05:05:41 -0000 1.3
+++ dlls/d3d8/volumetexture.c 10 Jan 2003 23:44:54 -0000
@@ -77,6 +77,11 @@
ICOM_THIS(IDirect3DVolumeTexture8Impl,iface);
TRACE("(%p) : returning %p\n", This, This->Device);
*ppDevice = (LPDIRECT3DDEVICE8) This->Device;
+ /**
+ * Note Calling this method will increase the internal reference count
+ * on the IDirect3DDevice8 interface.
+ */
+ IDirect3DDevice8Impl_AddRef(*ppDevice);
return D3D_OK;
}
HRESULT WINAPI IDirect3DVolumeTexture8Impl_SetPrivateData(LPDIRECT3DVOLUMETEXTURE8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
More information about the wine-patches
mailing list