wined3d: Fix SetContainer.

Add/Release references to the container.
Change the type of the container from IUnknown to IWineD3DBase.
This commit is contained in:
H. Verbeet 2006-02-06 11:30:48 +01:00 committed by Alexandre Julliard
parent bcfa7dcf7d
commit e43cfb1a68
5 changed files with 38 additions and 16 deletions

View File

@ -725,7 +725,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Wid
/** Create and initialise the surface resource **/
D3DCREATERESOURCEOBJECTINSTANCE(object,Surface,D3DRTYPE_SURFACE, Size)
object->container = (IUnknown*) This;
IWineD3DSurface_SetContainer((IWineD3DSurface *)object, (IWineD3DBase *)This);
object->currentDesc.Width = Width;
object->currentDesc.Height = Height;
@ -888,7 +888,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Wid
return hr;
}
IWineD3DSurface_SetContainer(object->surfaces[i], (IUnknown *)object);
IWineD3DSurface_SetContainer(object->surfaces[i], (IWineD3DBase *)object);
TRACE("Created surface level %d @ %p\n", i, object->surfaces[i]);
/* calculate the next mipmap level */
tmpW = max(1, tmpW >> 1);
@ -958,7 +958,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
(IWineD3DVolume **)&object->volumes[i], pSharedHandle);
/* Set it's container to this object */
IWineD3DVolume_SetContainer(object->volumes[i], (IUnknown *)object);
IWineD3DVolume_SetContainer(object->volumes[i], (IWineD3DBase *)object);
/* calcualte the next mipmap level */
tmpW = max(1, tmpW >> 1);
@ -1076,7 +1076,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT
*ppCubeTexture = NULL;
return hr;
}
IWineD3DSurface_SetContainer(object->surfaces[j][i], (IUnknown *)object);
IWineD3DSurface_SetContainer(object->surfaces[j][i], (IWineD3DBase *)object);
TRACE("Created surface level %d @ %p,\n", i, object->surfaces[j][i]);
}
tmpW = max(1, tmpW >> 1);
@ -1402,7 +1402,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevice* ifac
&object->frontBuffer,
NULL /* pShared (always null)*/);
if (object->frontBuffer != NULL)
IWineD3DSurface_SetContainer(object->frontBuffer, (IUnknown *)object);
IWineD3DSurface_SetContainer(object->frontBuffer, (IWineD3DBase *)object);
TRACE("calling rendertarget CB\n");
hr = D3DCB_CreateRenderTarget((IUnknown *) This->parent,
object->presentParms.BackBufferWidth,
@ -1414,7 +1414,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevice* ifac
&object->backBuffer,
NULL /* pShared (always null)*/);
if (object->backBuffer != NULL)
IWineD3DSurface_SetContainer(object->backBuffer, (IUnknown *)object);
IWineD3DSurface_SetContainer(object->backBuffer, (IWineD3DBase *)object);
/* Under directX swapchains share the depth stencil, so only create one depth-stencil */
if (pPresentationParameters->EnableAutoDepthStencil) {
@ -1430,7 +1430,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevice* ifac
&This->depthStencilBuffer,
NULL /* pShared (always null)*/ );
if (This->depthStencilBuffer != NULL)
IWineD3DSurface_SetContainer(This->depthStencilBuffer, (IUnknown *)iface);
IWineD3DSurface_SetContainer(This->depthStencilBuffer, (IWineD3DBase *)iface);
}
/** TODO: A check on width, height and multisample types

View File

@ -1334,10 +1334,21 @@ extern HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, C
return D3D_OK;
}
HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IUnknown *container) {
HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("This %p, container %p\n", This, container);
if (container) {
IWineD3DBase_AddRef(container);
}
if (This->container) {
IWineD3DBase_Release(This->container);
}
TRACE("Setting container to %p from %p\n", container, This->container);
This->container = container;
return D3D_OK;
}

View File

@ -233,11 +233,22 @@ HRESULT WINAPI IWineD3DVolumeImpl_AddDirtyBox(IWineD3DVolume *iface, CONST D3DBO
return D3D_OK;
}
HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IUnknown* container){
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWineD3DBase* container) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
This->container = container;
return D3D_OK;
TRACE("This %p, container %p\n", This, container);
if (container) {
IWineD3DBase_AddRef(container);
}
if (This->container) {
IWineD3DBase_Release(This->container);
}
TRACE("Setting container to %p from %p\n", container, This->container);
This->container = container;
return D3D_OK;
}
HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, GLenum gl_level) {

View File

@ -747,7 +747,7 @@ typedef struct IWineD3DVolumeImpl
/* WineD3DVolume Information */
D3DVOLUME_DESC currentDesc;
IUnknown *container;
IWineD3DBase *container;
UINT bytesPerPixel;
BOOL lockable;
@ -799,7 +799,7 @@ struct IWineD3DSurfaceImpl
IWineD3DResourceClass resource;
/* IWineD3DSurface fields */
IUnknown *container;
IWineD3DBase *container;
WINED3DSURFACET_DESC currentDesc;
UINT textureName;

View File

@ -1054,7 +1054,7 @@ DECLARE_INTERFACE_(IWineD3DSurface,IWineD3DResource)
STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pRect) PURE;
STDMETHOD(LoadTexture)(THIS) PURE;
STDMETHOD(SaveSnapshot)(THIS_ const char *filename) PURE;
STDMETHOD(SetContainer)(THIS_ IUnknown *container) PURE;
STDMETHOD(SetContainer)(THIS_ IWineD3DBase *container) PURE;
STDMETHOD(SetPBufferState)(THIS_ BOOL inPBuffer, BOOL inTexture) PURE;
STDMETHOD_(void,SetGlTextureDesc)(THIS_ UINT textureName, int target) PURE;
STDMETHOD_(void,GetGlDesc)(THIS_ glDescriptor **glDescription) PURE;
@ -1128,7 +1128,7 @@ DECLARE_INTERFACE_(IWineD3DVolume,IWineD3DResource)
STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE;
STDMETHOD(CleanDirtyBox)(THIS) PURE;
STDMETHOD(LoadTexture)(THIS_ UINT gl_level) PURE;
STDMETHOD(SetContainer)(THIS_ IUnknown *container) PURE;
STDMETHOD(SetContainer)(THIS_ IWineD3DBase *container) PURE;
};
#undef INTERFACE