Commit c40501db authored by Markus Amsler's avatar Markus Amsler Committed by Alexandre Julliard

Revert "d3d: Remove AddRef from IWineD3DDevice_GetSwapChain.".

This reverts commit f84f687e.
parent 0bff261c
......@@ -219,6 +219,7 @@ HRESULT WINAPI IDirect3DDevice9Impl_GetSwapChain(LPDIRECT3DDEVICE9 iface, UINT
hrc = IWineD3DDevice_GetSwapChain(This->WineD3DDevice, iSwapChain, &swapchain);
if (hrc == D3D_OK && NULL != swapchain) {
IWineD3DSwapChain_GetParent(swapchain, (IUnknown **)pSwapChain);
IWineD3DSwapChain_Release(swapchain);
} else {
*pSwapChain = NULL;
}
......
......@@ -1614,6 +1614,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateAdditionalSwapChain(IWineD3DDevic
/* TODO: don't use Impl structures outside of create functions! (a context manager will replace the ->glCtx) */
/* and create a new context with the implicit swapchains context as the shared context */
object->glCtx = glXCreateContext(object->display, object->visInfo, ((IWineD3DSwapChainImpl *)implSwapChain)->glCtx, GL_TRUE);
IWineD3DSwapChain_Release(implSwapChain);
}
}
......@@ -1931,6 +1932,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetSwapChain(IWineD3DDevice *iface, U
if(iSwapChain < This->NumberOfSwapChains) {
*pSwapChain = This->swapchains[iSwapChain];
IWineD3DSwapChain_AddRef(*pSwapChain);
TRACE("(%p) returning %p\n", This, *pSwapChain);
return WINED3D_OK;
} else {
......@@ -5849,6 +5851,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetBackBuffer(IWineD3DDevice *iface, UI
hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapChain);
if (hr == WINED3D_OK) {
hr = IWineD3DSwapChain_GetBackBuffer(swapChain, BackBuffer, Type, ppBackBuffer);
IWineD3DSwapChain_Release(swapChain);
} else {
*ppBackBuffer = NULL;
}
......@@ -5870,6 +5873,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDisplayMode(IWineD3DDevice *iface, U
hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, (IWineD3DSwapChain **)&swapChain);
if (hr == WINED3D_OK) {
hr = IWineD3DSwapChain_GetDisplayMode(swapChain, pMode);
IWineD3DSwapChain_Release(swapChain);
} else {
FIXME("(%p) Error getting display mode\n", This);
}
......@@ -6024,6 +6028,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Present(IWineD3DDevice *iface,
IWineD3DDeviceImpl_GetSwapChain(iface, i , (IWineD3DSwapChain **)&swapChain);
TRACE("presentinng chain %d, %p\n", i, swapChain);
IWineD3DSwapChain_Present(swapChain, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion, 0);
IWineD3DSwapChain_Release(swapChain);
}
return WINED3D_OK;
......@@ -6492,6 +6497,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *if
hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, (IWineD3DSwapChain **)&swapChain);
if(hr == WINED3D_OK) {
hr = IWineD3DSwapChain_GetFrontBufferData(swapChain, pDestSurface);
IWineD3DSwapChain_Release(swapChain);
}
return hr;
}
......@@ -6600,6 +6606,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface
hr = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, (IWineD3DSwapChain **)&swapChain);
if(hr == WINED3D_OK){
hr = IWineD3DSwapChain_GetRasterStatus(swapChain, pRasterStatus);
IWineD3DSwapChain_Release(swapChain);
}else{
FIXME("(%p) IWineD3DSwapChain_GetRasterStatus returned in error\n", This);
}
......@@ -6905,6 +6912,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetFrontBackBuffers(IWineD3DDevice *ifa
return hr;
}
/* Make sure to release the swapchain */
IWineD3DSwapChain_Release((IWineD3DSwapChain *) Swapchain);
if(FrontImpl && !(FrontImpl->resource.usage & WINED3DUSAGE_RENDERTARGET) ) {
ERR("Trying to set a front buffer which doesn't have WINED3DUSAGE_RENDERTARGET usage\n");
return WINED3DERR_INVALIDCALL;
......@@ -7431,12 +7441,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ActiveRender(IWineD3DDevice* iface,
IWineD3DDevice_GetSwapChain(iface, 0, &implicitSwapchain);
IWineD3DSurface_GetContainer(RenderSurface, &IID_IWineD3DSwapChain, (void**) &renderSurfaceSwapchain);
IWineD3DSurface_GetContainer(This->renderTarget, &IID_IWineD3DSwapChain, (void **)&currentSwapchain);
if (currentSwapchain == NULL) {
if (currentSwapchain == NULL)
IWineD3DDevice_GetSwapChain(iface, 0, &currentSwapchain);
/* GetContainer currently AddRefs, but GetSwapChain doesn't.
* Like this the release code for both is the same. */
IWineD3DDevice_AddRef(currentSwapchain);
}
currentSwapchainImpl = (IWineD3DSwapChainImpl*) currentSwapchain;
implicitSwapchainImpl = (IWineD3DSwapChainImpl*) implicitSwapchain;
......@@ -7588,6 +7594,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ActiveRender(IWineD3DDevice* iface,
}
if (cfgs != NULL) XFree(cfgs);
if (implicitSwapchain != NULL) IWineD3DSwapChain_Release(implicitSwapchain);
if (currentSwapchain != NULL) IWineD3DSwapChain_Release(currentSwapchain);
if (renderSurfaceSwapchain != NULL) IWineD3DSwapChain_Release(renderSurfaceSwapchain);
LEAVE_GL();
......@@ -7742,6 +7749,7 @@ static void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice * iface, UINT
if ((hrc = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain)) == WINED3D_OK) {
IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, (WINED3DGAMMARAMP *)pRamp);
IWineD3DSwapChain_Release(swapchain);
}
return;
}
......@@ -7754,6 +7762,7 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i
if ((hrc = IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain)) == WINED3D_OK) {
hrc =IWineD3DSwapChain_GetGammaRamp(swapchain, pRamp);
IWineD3DSwapChain_Release(swapchain);
}
return;
}
......
......@@ -2156,6 +2156,7 @@ void drawPrimitive(IWineD3DDevice *iface,
IWineD3DDevice_GetSwapChain(iface, i, (IWineD3DSwapChain **) &swapchain);
if(swapchain) {
if(swapchain->backBuffer) ((IWineD3DSurfaceImpl *) swapchain->backBuffer[0])->Flags |= SFLAG_GLDIRTY;
IWineD3DSwapChain_Release( (IWineD3DSwapChain *) swapchain);
}
}
......
......@@ -750,6 +750,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
notInContext = TRUE;
/* TODO: check the contexts, to see if were shared with the current context */
}
IWineD3DSwapChain_Release((IWineD3DSwapChain *)implSwapChain);
}
if (swapchain != NULL) IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapchain);
if (targetSwapChain != NULL) IWineD3DSwapChain_Release((IWineD3DSwapChain *)targetSwapChain);
......@@ -1237,6 +1238,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
} else {
FIXME("unsupported unlocking to Rendering surface surf@%p usage(%s)\n", This, debug_d3dusage(This->resource.usage));
}
IWineD3DSwapChain_Release((IWineD3DSwapChain *)implSwapChain);
} else if (WINED3DUSAGE_DEPTHSTENCIL & This->resource.usage) { /* stencil surfaces */
......@@ -2702,6 +2704,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
TRACE("Calling GetSwapChain with mydevice = %p\n", myDevice);
IWineD3DDevice_GetSwapChain((IWineD3DDevice *)myDevice, 0, (IWineD3DSwapChain **)&implSwapChain);
IWineD3DSwapChain_Release( (IWineD3DSwapChain *) implSwapChain );
if(implSwapChain->backBuffer && This == (IWineD3DSurfaceImpl*) implSwapChain->backBuffer[0]) {
glDrawBuffer(GL_BACK);
checkGLcall("glDrawBuffer(GL_BACK)");
......
......@@ -294,6 +294,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
glXDestroyContext(oldDisplay, oldContext); /* Should this happen on an active context? seems a bad idea */
LEAVE_GL();
}
IWineD3DSwapChain_Release((IWineD3DSwapChain *)swapChainImpl);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment