2008-07-28 01:04:16 +02:00
|
|
|
/*
|
|
|
|
*IDirect3DSwapChain9 implementation
|
|
|
|
*
|
|
|
|
*Copyright 2002-2003 Jason Edmeades
|
|
|
|
*Copyright 2002-2003 Raphael Junqueira
|
|
|
|
*Copyright 2005 Oliver Stieber
|
2008-10-18 19:21:20 +02:00
|
|
|
*Copyright 2007-2008 Stefan Dösinger for CodeWeavers
|
2008-07-28 01:04:16 +02:00
|
|
|
*
|
|
|
|
*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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|
|
|
|
|
|
|
/* IDirect3DSwapChain IUnknown parts follow: */
|
2009-12-21 23:17:25 +01:00
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, void **object)
|
2008-07-28 01:04:16 +02:00
|
|
|
{
|
2009-12-21 23:17:25 +01:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IWineD3DSwapChain)
|
|
|
|
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|
|
|
|
|| IsEqualGUID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*object = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
|
|
|
|
|
|
|
*object = NULL;
|
|
|
|
return E_NOINTERFACE;
|
2008-07-28 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) {
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
DWORD refCount = InterlockedIncrement(&This->ref);
|
|
|
|
TRACE("(%p) : AddRef increasing from %d\n", This, refCount - 1);
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) {
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
DWORD refCount;
|
|
|
|
refCount = InterlockedDecrement(&This->ref);
|
|
|
|
TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
|
|
|
|
if (refCount == 0) {
|
2009-09-16 08:37:15 +02:00
|
|
|
IWineD3DSwapChain_Destroy(iface);
|
2008-07-28 01:04:16 +02:00
|
|
|
}
|
|
|
|
return refCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent){
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
*ppParent = This->parent;
|
|
|
|
IUnknown_AddRef(*ppParent);
|
|
|
|
TRACE("(%p) returning %p\n", This , *ppParent);
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *pDestSurface) {
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
POINT start;
|
|
|
|
|
|
|
|
TRACE("(%p) : iface(%p) pDestSurface(%p)\n", This, iface, pDestSurface);
|
|
|
|
|
|
|
|
start.x = 0;
|
|
|
|
start.y = 0;
|
|
|
|
|
|
|
|
if (This->presentParms.Windowed) {
|
|
|
|
MapWindowPoints(This->win_handle, NULL, &start, 1);
|
|
|
|
}
|
|
|
|
|
2010-04-26 21:33:00 +02:00
|
|
|
IWineD3DSurface_BltFast(pDestSurface, start.x, start.y, (IWineD3DSurface *)This->front_buffer, NULL, 0);
|
2008-07-28 01:04:16 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) {
|
|
|
|
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
|
|
|
|
if (iBackBuffer > This->presentParms.BackBufferCount - 1) {
|
|
|
|
TRACE("Back buffer count out of range\n");
|
2008-10-10 13:44:43 +02:00
|
|
|
/* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
|
|
|
|
* here in wined3d to avoid problems in other libs
|
|
|
|
*/
|
2008-07-28 01:04:16 +02:00
|
|
|
*ppBackBuffer = NULL;
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2008-10-10 13:44:43 +02:00
|
|
|
/* Return invalid if there is no backbuffer array, otherwise it will crash when ddraw is
|
|
|
|
* used (there This->backBuffer is always NULL). We need this because this function has
|
2008-08-31 12:20:28 +02:00
|
|
|
* to be called from IWineD3DStateBlockImpl_InitStartupStateBlock to get the default
|
|
|
|
* scissorrect dimensions. */
|
2010-04-26 21:33:01 +02:00
|
|
|
if (!This->back_buffers)
|
|
|
|
{
|
2008-08-31 12:20:28 +02:00
|
|
|
*ppBackBuffer = NULL;
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2010-04-26 21:33:01 +02:00
|
|
|
*ppBackBuffer = (IWineD3DSurface *)This->back_buffers[iBackBuffer];
|
2008-07-28 01:04:16 +02:00
|
|
|
TRACE("(%p) : BackBuf %d Type %d returning %p\n", This, iBackBuffer, Type, *ppBackBuffer);
|
|
|
|
|
|
|
|
/* Note inc ref on returned surface */
|
|
|
|
if(*ppBackBuffer) IWineD3DSurface_AddRef(*ppBackBuffer);
|
|
|
|
return WINED3D_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
|
2008-12-01 15:32:14 +01:00
|
|
|
static BOOL warned;
|
2010-07-18 09:26:51 +02:00
|
|
|
/* No OpenGL equivalent */
|
2008-12-01 15:32:14 +01:00
|
|
|
if (!warned)
|
|
|
|
{
|
2009-12-21 23:17:26 +01:00
|
|
|
FIXME("iface %p, raster_status %p stub!\n", iface, pRasterStatus);
|
2008-12-01 15:32:14 +01:00
|
|
|
warned = TRUE;
|
2008-07-28 01:04:16 +02:00
|
|
|
}
|
2010-07-18 09:26:51 +02:00
|
|
|
/* Obtaining the raster status is a widely implemented but optional feature.
|
|
|
|
* When this method returns OK then the application Starcraft 2 expects that
|
|
|
|
* the pRasterStatus->InVBlank value differs over time. To prevent Starcraft 2
|
|
|
|
* from running in an infinite loop at startup this method returns INVALIDCALL.
|
|
|
|
*/
|
|
|
|
return WINED3DERR_INVALIDCALL;
|
2008-07-28 01:04:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p): Calling GetAdapterDisplayMode\n", This, pMode);
|
2009-12-09 20:32:08 +01:00
|
|
|
hr = IWineD3D_GetAdapterDisplayMode(This->device->wined3d, This->device->adapter->ordinal, pMode);
|
2008-07-28 01:04:16 +02:00
|
|
|
|
|
|
|
TRACE("(%p) : returning w(%d) h(%d) rr(%d) fmt(%u,%s)\n", This, pMode->Width, pMode->Height, pMode->RefreshRate,
|
|
|
|
pMode->Format, debug_d3dformat(pMode->Format));
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-04-20 22:38:39 +02:00
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice **device)
|
|
|
|
{
|
2008-07-28 01:04:16 +02:00
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
|
2010-04-20 22:38:39 +02:00
|
|
|
*device = (IWineD3DDevice *)This->device;
|
|
|
|
IWineD3DDevice_AddRef(*device);
|
2008-07-28 01:04:16 +02:00
|
|
|
|
2010-04-20 22:38:39 +02:00
|
|
|
TRACE("(%p) : returning %p\n", This, *device);
|
2008-07-28 01:04:16 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) {
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
*pPresentationParameters = This->presentParms;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp){
|
|
|
|
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
HDC hDC;
|
|
|
|
TRACE("(%p) : pRamp@%p flags(%d)\n", This, pRamp, Flags);
|
2010-03-15 21:07:30 +01:00
|
|
|
hDC = GetDC(This->device_window);
|
2008-07-28 01:04:16 +02:00
|
|
|
SetDeviceGammaRamp(hDC, (LPVOID)pRamp);
|
2010-03-15 21:07:30 +01:00
|
|
|
ReleaseDC(This->device_window, hDC);
|
2008-07-28 01:04:16 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp){
|
|
|
|
|
|
|
|
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
|
|
|
|
HDC hDC;
|
|
|
|
TRACE("(%p) : pRamp@%p\n", This, pRamp);
|
2010-03-15 21:07:30 +01:00
|
|
|
hDC = GetDC(This->device_window);
|
2008-07-28 01:04:16 +02:00
|
|
|
GetDeviceGammaRamp(hDC, pRamp);
|
2010-03-15 21:07:30 +01:00
|
|
|
ReleaseDC(This->device_window, hDC);
|
2008-07-28 01:04:16 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
|
|
|
|
}
|