2006-06-09 19:36:12 +02:00
|
|
|
/* DirectDraw Surface Implementation
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997-2000 Marcus Meissner
|
|
|
|
* Copyright (c) 1998-2000 Lionel Ulmer
|
|
|
|
* Copyright (c) 2000-2001 TransGaming Technologies Inc.
|
2008-10-18 19:19:45 +02:00
|
|
|
* Copyright (c) 2006 Stefan Dösinger
|
2011-06-06 13:39:04 +02:00
|
|
|
* Copyright (c) 2011 Ričardas Barkauskas for CodeWeavers
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This file contains the (internal) driver registration functions,
|
|
|
|
* driver enumeration APIs and DirectDraw creation functions.
|
|
|
|
*
|
|
|
|
* 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 "wine/port.h"
|
|
|
|
|
|
|
|
#include "ddraw_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
|
|
|
|
2011-06-11 20:20:25 +02:00
|
|
|
static IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface);
|
|
|
|
static IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface);
|
|
|
|
|
2011-06-08 17:23:17 +02:00
|
|
|
static inline IDirectDrawSurfaceImpl *impl_from_IDirectDrawGammaControl(IDirectDrawGammaControl *iface)
|
2010-08-18 19:26:18 +02:00
|
|
|
{
|
2011-06-08 17:23:17 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawGammaControl_iface);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
2006-06-23 18:18:02 +02:00
|
|
|
* IUnknown parts follow
|
2006-06-09 19:36:12 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::QueryInterface
|
|
|
|
*
|
|
|
|
* A normal QueryInterface implementation. For QueryInterface rules
|
|
|
|
* see ddraw.c, IDirectDraw7::QueryInterface. This method
|
|
|
|
* can Query IDirectDrawSurface interfaces in all version, IDirect3DTexture
|
|
|
|
* in all versions, the IDirectDrawGammaControl interface and it can
|
|
|
|
* create an IDirect3DDevice. (Uses IDirect3D7::CreateDevice)
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* riid: The interface id queried for
|
|
|
|
* obj: Address to write the pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* S_OK on success
|
|
|
|
* E_NOINTERFACE if the requested interface wasn't found
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_QueryInterface(IDirectDrawSurface7 *iface, REFIID riid, void **obj)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), obj);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* According to COM docs, if the QueryInterface fails, obj should be set to NULL */
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if(!riid)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2011-06-06 13:39:04 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectDrawSurface7) )
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface7_AddRef(iface);
|
2009-01-21 09:56:13 +01:00
|
|
|
*obj = iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) returning IDirectDrawSurface7 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-06-06 13:39:04 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_IDirectDrawSurface4))
|
|
|
|
{
|
2011-06-28 01:34:23 +02:00
|
|
|
IDirectDrawSurface4_AddRef(&This->IDirectDrawSurface4_iface);
|
2011-06-06 13:39:04 +02:00
|
|
|
*obj = &This->IDirectDrawSurface4_iface;
|
|
|
|
TRACE("(%p) returning IDirectDrawSurface4 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-06-09 17:29:36 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_IDirectDrawSurface3))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-20 22:51:01 +02:00
|
|
|
IDirectDrawSurface3_AddRef(&This->IDirectDrawSurface3_iface);
|
2011-05-31 13:57:04 +02:00
|
|
|
*obj = &This->IDirectDrawSurface3_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) returning IDirectDrawSurface3 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-06-09 16:35:15 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_IDirectDrawSurface2))
|
|
|
|
{
|
2011-06-19 16:24:32 +02:00
|
|
|
IDirectDrawSurface2_AddRef(&This->IDirectDrawSurface2_iface);
|
2011-06-09 16:35:15 +02:00
|
|
|
*obj = &This->IDirectDrawSurface2_iface;
|
|
|
|
TRACE("(%p) returning IDirectDrawSurface2 interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2011-06-09 17:29:36 +02:00
|
|
|
else if (IsEqualGUID(riid, &IID_IDirectDrawSurface))
|
|
|
|
{
|
2011-06-20 23:15:55 +02:00
|
|
|
IDirectDrawSurface_AddRef(&This->IDirectDrawSurface_iface);
|
2011-06-09 17:29:36 +02:00
|
|
|
*obj = &This->IDirectDrawSurface_iface;
|
|
|
|
TRACE("(%p) returning IDirectDrawSurface interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
else if( IsEqualGUID(riid, &IID_IDirectDrawGammaControl) )
|
|
|
|
{
|
2011-06-28 01:53:17 +02:00
|
|
|
IDirectDrawGammaControl_AddRef(&This->IDirectDrawGammaControl_iface);
|
2011-06-08 17:23:17 +02:00
|
|
|
*obj = &This->IDirectDrawGammaControl_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE("(%p) returning IDirectDrawGammaControl interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if( IsEqualGUID(riid, &IID_D3DDEVICE_WineD3D) ||
|
2007-07-01 13:53:29 +02:00
|
|
|
IsEqualGUID(riid, &IID_IDirect3DHALDevice)||
|
|
|
|
IsEqualGUID(riid, &IID_IDirect3DRGBDevice) )
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
IDirect3DDevice7 *d3d;
|
|
|
|
|
|
|
|
/* Call into IDirect3D7 for creation */
|
2011-06-05 18:55:04 +02:00
|
|
|
IDirect3D7_CreateDevice(&This->ddraw->IDirect3D7_iface, riid, &This->IDirectDrawSurface7_iface,
|
2011-01-19 01:32:36 +01:00
|
|
|
&d3d);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-18 23:26:33 +02:00
|
|
|
if (d3d)
|
|
|
|
{
|
|
|
|
*obj = (IDirect3DDevice *)&((IDirect3DDeviceImpl *)d3d)->IDirect3DDevice_vtbl;
|
|
|
|
TRACE("(%p) Returning IDirect3DDevice interface at %p\n", This, *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-07-18 23:26:33 +02:00
|
|
|
WARN("Unable to create a IDirect3DDevice instance, returning E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
else if (IsEqualGUID( &IID_IDirect3DTexture, riid ) ||
|
|
|
|
IsEqualGUID( &IID_IDirect3DTexture2, riid ))
|
|
|
|
{
|
|
|
|
if (IsEqualGUID( &IID_IDirect3DTexture, riid ))
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
*obj = &This->IDirect3DTexture_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE(" returning Direct3DTexture interface at %p.\n", *obj);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-29 17:55:50 +02:00
|
|
|
*obj = &This->IDirect3DTexture2_iface;
|
2006-06-09 19:36:12 +02:00
|
|
|
TRACE(" returning Direct3DTexture2 interface at %p.\n", *obj);
|
|
|
|
}
|
|
|
|
IUnknown_AddRef( (IUnknown *) *obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("No interface\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_QueryInterface(IDirectDrawSurface4 *iface, REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_QueryInterface(IDirectDrawSurface3 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_QueryInterface(IDirectDrawSurface2 *iface, REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_QueryInterface(IDirectDrawSurface *iface, REFIID riid, void **object)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
|
|
|
}
|
|
|
|
|
2011-06-08 17:23:17 +02:00
|
|
|
static HRESULT WINAPI ddraw_gamma_control_QueryInterface(IDirectDrawGammaControl *iface,
|
|
|
|
REFIID riid, void **object)
|
2010-08-18 19:26:18 +02:00
|
|
|
{
|
2011-06-08 17:23:17 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawGammaControl(iface);
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
static HRESULT WINAPI d3d_texture2_QueryInterface(IDirect3DTexture2 *iface, REFIID riid, void **object)
|
|
|
|
{
|
2011-07-29 17:52:33 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture2(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_QueryInterface(IDirect3DTexture *iface, REFIID riid, void **object)
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_QueryInterface(&This->IDirectDrawSurface7_iface, riid, object);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
static void ddraw_surface_add_iface(IDirectDrawSurfaceImpl *This)
|
|
|
|
{
|
|
|
|
ULONG iface_count = InterlockedIncrement(&This->iface_count);
|
|
|
|
TRACE("%p increasing iface count to %u.\n", This, iface_count);
|
|
|
|
|
|
|
|
if (iface_count == 1)
|
|
|
|
{
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
if (This->wined3d_surface)
|
|
|
|
wined3d_surface_incref(This->wined3d_surface);
|
|
|
|
if (This->wined3d_texture)
|
|
|
|
wined3d_texture_incref(This->wined3d_texture);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::AddRef
|
|
|
|
*
|
|
|
|
* A normal addref implementation
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface7_AddRef(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref7);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
if (refcount == 1)
|
2009-09-16 08:37:15 +02:00
|
|
|
{
|
2011-06-19 12:18:22 +02:00
|
|
|
ddraw_surface_add_iface(This);
|
2009-09-16 08:37:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
return refcount;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static ULONG WINAPI ddraw_surface4_AddRef(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
2011-06-28 01:34:23 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref4);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
2011-06-28 01:34:23 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface3_AddRef(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-06-20 22:51:01 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref3);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2011-06-20 22:51:01 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static ULONG WINAPI ddraw_surface2_AddRef(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
2011-06-19 16:24:32 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref2);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
2011-06-19 16:24:32 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static ULONG WINAPI ddraw_surface1_AddRef(IDirectDrawSurface *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->ref1);
|
2011-06-09 17:29:36 +02:00
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
static ULONG WINAPI ddraw_gamma_control_AddRef(IDirectDrawGammaControl *iface)
|
|
|
|
{
|
2011-06-08 17:23:17 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawGammaControl(iface);
|
2011-06-28 01:53:17 +02:00
|
|
|
ULONG refcount = InterlockedIncrement(&This->gamma_count);
|
2011-06-08 17:23:17 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
TRACE("iface %p increasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 1)
|
|
|
|
{
|
|
|
|
ddraw_surface_add_iface(This);
|
|
|
|
}
|
2010-08-18 19:26:18 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
return refcount;
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
static ULONG WINAPI d3d_texture2_AddRef(IDirect3DTexture2 *iface)
|
|
|
|
{
|
2011-07-29 17:52:33 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture2(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-06-20 23:14:30 +02:00
|
|
|
return ddraw_surface1_AddRef(&This->IDirectDrawSurface_iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d_texture1_AddRef(IDirect3DTexture *iface)
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-06-20 23:14:30 +02:00
|
|
|
return ddraw_surface1_AddRef(&This->IDirectDrawSurface_iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
2010-07-19 18:36:20 +02:00
|
|
|
* ddraw_surface_destroy
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* A helper function for IDirectDrawSurface7::Release
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Frees the surface, regardless of its refcount.
|
2006-06-09 19:36:12 +02:00
|
|
|
* See IDirectDrawSurface7::Release for more information
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* This: Surface to free
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
void ddraw_surface_destroy(IDirectDrawSurfaceImpl *This)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("surface %p.\n", This);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
/* Check the iface count and give a warning */
|
|
|
|
if(This->iface_count > 1)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/* This can happen when a complex surface is destroyed,
|
|
|
|
* because the 2nd surface was addref()ed when the app
|
|
|
|
* called GetAttachedSurface
|
|
|
|
*/
|
2011-06-20 23:15:55 +02:00
|
|
|
WARN("(%p): Destroying surface with refcounts 7: %d 4: %d 3: %d 2: %d 1: %d\n",
|
|
|
|
This, This->ref7, This->ref4, This->ref3, This->ref2, This->ref1);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
if (This->wined3d_surface)
|
|
|
|
wined3d_surface_decref(This->wined3d_surface);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:09:24 +02:00
|
|
|
static void ddraw_surface_cleanup(IDirectDrawSurfaceImpl *surface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *surf;
|
|
|
|
IUnknown *ifaceToRelease;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
TRACE("surface %p.\n", surface);
|
|
|
|
|
2011-04-20 22:09:27 +02:00
|
|
|
if (surface->wined3d_swapchain)
|
2011-04-20 22:09:24 +02:00
|
|
|
{
|
|
|
|
IDirectDrawImpl *ddraw = surface->ddraw;
|
|
|
|
|
|
|
|
/* If it's the render target, destroy the D3D device. */
|
|
|
|
if (ddraw->d3d_initialized && surface == ddraw->d3d_target)
|
|
|
|
{
|
|
|
|
TRACE("Destroying the render target, uninitializing D3D.\n");
|
|
|
|
|
|
|
|
for (i = 0; i < ddraw->numConvertedDecls; ++i)
|
|
|
|
{
|
|
|
|
wined3d_vertex_declaration_decref(ddraw->decls[i].decl);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, ddraw->decls);
|
|
|
|
ddraw->numConvertedDecls = 0;
|
|
|
|
|
2011-05-16 23:01:22 +02:00
|
|
|
if (FAILED(wined3d_device_uninit_3d(ddraw->wined3d_device)))
|
2011-04-20 22:09:24 +02:00
|
|
|
{
|
|
|
|
ERR("Failed to uninit 3D.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Free the d3d window if one was created. */
|
|
|
|
if (ddraw->d3d_window && ddraw->d3d_window != ddraw->dest_window)
|
|
|
|
{
|
|
|
|
TRACE("Destroying the hidden render window %p.\n", ddraw->d3d_window);
|
|
|
|
DestroyWindow(ddraw->d3d_window);
|
|
|
|
ddraw->d3d_window = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ddraw->d3d_initialized = FALSE;
|
|
|
|
ddraw->d3d_target = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_uninit_gdi(ddraw->wined3d_device);
|
2011-04-20 22:09:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
surface->wined3d_swapchain = NULL;
|
|
|
|
|
|
|
|
/* Reset to the default surface implementation type. This is needed
|
|
|
|
* if applications use non render target surfaces and expect blits to
|
|
|
|
* work after destroying the render target.
|
|
|
|
*
|
|
|
|
* TODO: Recreate existing offscreen surfaces. */
|
|
|
|
ddraw->ImplType = DefaultSurfaceType;
|
|
|
|
|
|
|
|
TRACE("D3D unloaded.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The refcount test shows that the palette is detached when the surface
|
|
|
|
* is destroyed. */
|
2011-06-05 18:55:04 +02:00
|
|
|
IDirectDrawSurface7_SetPalette(&surface->IDirectDrawSurface7_iface, NULL);
|
2011-04-20 22:09:24 +02:00
|
|
|
|
|
|
|
/* Loop through all complex attached surfaces and destroy them.
|
|
|
|
*
|
|
|
|
* Yet again, only the root can have more than one complexly attached
|
|
|
|
* surface, all the others have a total of one. */
|
|
|
|
for (i = 0; i < MAX_COMPLEX_ATTACHED; ++i)
|
|
|
|
{
|
|
|
|
if (!surface->complex_array[i])
|
|
|
|
break;
|
|
|
|
|
|
|
|
surf = surface->complex_array[i];
|
|
|
|
surface->complex_array[i] = NULL;
|
|
|
|
while (surf)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *destroy = surf;
|
|
|
|
surf = surf->complex_array[0]; /* Iterate through the "tree" */
|
|
|
|
ddraw_surface_destroy(destroy); /* Destroy it */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ifaceToRelease = surface->ifaceToRelease;
|
|
|
|
|
|
|
|
/* Destroy the root surface. */
|
|
|
|
ddraw_surface_destroy(surface);
|
|
|
|
|
|
|
|
/* Reduce the ddraw refcount */
|
|
|
|
if (ifaceToRelease)
|
|
|
|
IUnknown_Release(ifaceToRelease);
|
|
|
|
}
|
|
|
|
|
2011-06-28 00:06:16 +02:00
|
|
|
ULONG ddraw_surface_release_iface(IDirectDrawSurfaceImpl *This)
|
2011-06-19 12:18:22 +02:00
|
|
|
{
|
|
|
|
ULONG iface_count = InterlockedDecrement(&This->iface_count);
|
|
|
|
TRACE("%p decreasing iface count to %u.\n", This, iface_count);
|
|
|
|
|
|
|
|
if (iface_count == 0)
|
|
|
|
{
|
|
|
|
/* Complex attached surfaces are destroyed implicitly when the root is released */
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
if(!This->is_complex_root)
|
|
|
|
{
|
|
|
|
WARN("(%p) Attempt to destroy a surface that is not a complex root\n", This);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2011-06-28 00:06:16 +02:00
|
|
|
return iface_count;
|
2011-06-19 12:18:22 +02:00
|
|
|
}
|
|
|
|
if (This->wined3d_texture) /* If it's a texture, destroy the wined3d texture. */
|
|
|
|
wined3d_texture_decref(This->wined3d_texture);
|
|
|
|
else
|
|
|
|
ddraw_surface_cleanup(This);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
}
|
|
|
|
|
2011-06-28 00:06:16 +02:00
|
|
|
return iface_count;
|
2011-06-19 12:18:22 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Release
|
|
|
|
*
|
|
|
|
* Reduces the surface's refcount by 1. If the refcount falls to 0, the
|
|
|
|
* surface is destroyed.
|
|
|
|
*
|
|
|
|
* Destroying the surface is a bit tricky. For the connection between
|
|
|
|
* WineD3DSurfaces and DirectDrawSurfaces see IDirectDraw7::CreateSurface
|
|
|
|
* It has a nice graph explaining the connection.
|
|
|
|
*
|
|
|
|
* What happens here is basically this:
|
2006-06-23 18:18:02 +02:00
|
|
|
* When a surface is destroyed, its WineD3DSurface is released,
|
2006-06-09 19:36:12 +02:00
|
|
|
* and the refcount of the DirectDraw interface is reduced by 1. If it has
|
|
|
|
* complex surfaces attached to it, then these surfaces are destroyed too,
|
2006-06-23 18:18:02 +02:00
|
|
|
* regardless of their refcount. If any surface being destroyed has another
|
|
|
|
* surface attached to it (with a "soft" attachment, not complex), then
|
2006-06-09 19:36:12 +02:00
|
|
|
* this surface is detached with DeleteAttachedSurface.
|
|
|
|
*
|
|
|
|
* When the surface is a texture, the WineD3DTexture is released.
|
|
|
|
* If the surface is the Direct3D render target, then the D3D
|
2006-06-23 18:18:02 +02:00
|
|
|
* capabilities of the WineD3DDevice are uninitialized, which causes the
|
2006-06-09 19:36:12 +02:00
|
|
|
* swapchain to be released.
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* When a complex sublevel falls to ref zero, then this is ignored.
|
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
* Returns:
|
|
|
|
* The new refcount
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface7_Release(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref7);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
if (refcount == 0)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-19 12:18:22 +02:00
|
|
|
ddraw_surface_release_iface(This);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-19 12:18:22 +02:00
|
|
|
return refcount;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static ULONG WINAPI ddraw_surface4_Release(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
2011-06-28 01:34:23 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref4);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
2011-06-28 01:34:23 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static ULONG WINAPI ddraw_surface3_Release(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-06-20 22:51:01 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref3);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2011-06-20 22:51:01 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static ULONG WINAPI ddraw_surface2_Release(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
2011-06-19 16:24:32 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref2);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
2011-06-19 16:24:32 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static ULONG WINAPI ddraw_surface1_Release(IDirectDrawSurface *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
2011-06-20 23:15:55 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->ref1);
|
2011-06-09 17:29:36 +02:00
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return refcount;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
static ULONG WINAPI ddraw_gamma_control_Release(IDirectDrawGammaControl *iface)
|
|
|
|
{
|
2011-06-08 17:23:17 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawGammaControl(iface);
|
2011-06-28 01:53:17 +02:00
|
|
|
ULONG refcount = InterlockedDecrement(&This->gamma_count);
|
2011-06-08 17:23:17 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
TRACE("iface %p decreasing refcount to %u.\n", iface, refcount);
|
|
|
|
|
|
|
|
if (refcount == 0)
|
|
|
|
{
|
|
|
|
ddraw_surface_release_iface(This);
|
|
|
|
}
|
2010-08-18 19:26:18 +02:00
|
|
|
|
2011-06-28 01:53:17 +02:00
|
|
|
return refcount;
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
static ULONG WINAPI d3d_texture2_Release(IDirect3DTexture2 *iface)
|
|
|
|
{
|
2011-07-29 17:52:33 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture2(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-06-20 23:14:30 +02:00
|
|
|
return ddraw_surface1_Release(&This->IDirectDrawSurface_iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI d3d_texture1_Release(IDirect3DTexture *iface)
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-06-20 23:14:30 +02:00
|
|
|
return ddraw_surface1_Release(&This->IDirectDrawSurface_iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetAttachedSurface
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Returns an attached surface with the requested caps. Surface attachment
|
2006-06-09 19:36:12 +02:00
|
|
|
* and complex surfaces are not clearly described by the MSDN or sdk,
|
|
|
|
* so this method is tricky and likely to contain problems.
|
2007-04-27 15:31:12 +02:00
|
|
|
* This implementation searches the complex list first, then the
|
|
|
|
* attachment chain.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* The chains are searched from This down to the last surface in the chain,
|
|
|
|
* not from the first element in the chain. The first surface found is
|
|
|
|
* returned. The MSDN says that this method fails if more than one surface
|
2007-04-27 15:31:12 +02:00
|
|
|
* matches the caps, but it is not sure if that is right. The attachment
|
|
|
|
* structure may not even allow two matching surfaces.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* The found surface is AddRef-ed before it is returned.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Caps: Pointer to a DDCAPS2 structure describing the caps asked for
|
|
|
|
* Surface: Address to store the found surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Caps or Surface is NULL
|
|
|
|
* DDERR_NOTFOUND if no surface was found
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetAttachedSurface(IDirectDrawSurface7 *iface,
|
|
|
|
DDSCAPS2 *Caps, IDirectDrawSurface7 **Surface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawSurfaceImpl *surf;
|
|
|
|
DDSCAPS2 our_caps;
|
2007-04-27 15:31:12 +02:00
|
|
|
int i;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, Caps, Surface);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(This->version < 7)
|
|
|
|
{
|
|
|
|
/* Earlier dx apps put garbage into these members, clear them */
|
2008-12-25 02:01:02 +01:00
|
|
|
our_caps.dwCaps = Caps->dwCaps;
|
2006-06-09 19:36:12 +02:00
|
|
|
our_caps.dwCaps2 = 0;
|
|
|
|
our_caps.dwCaps3 = 0;
|
|
|
|
our_caps.dwCaps4 = 0;
|
|
|
|
}
|
2008-12-25 02:01:02 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
our_caps = *Caps;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE("(%p): Looking for caps: %x,%x,%x,%x\n", This, our_caps.dwCaps, our_caps.dwCaps2, our_caps.dwCaps3, our_caps.dwCaps4); /* FIXME: Better debugging */
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-04-27 15:31:12 +02:00
|
|
|
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2007-04-27 15:31:12 +02:00
|
|
|
surf = This->complex_array[i];
|
|
|
|
if(!surf) break;
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
|
2006-06-09 19:36:12 +02:00
|
|
|
surf->surface_desc.ddsCaps.dwCaps,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps2,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps3,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
|
|
|
|
((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
|
|
|
|
|
|
|
|
/* MSDN: "This method fails if more than one surface is attached
|
|
|
|
* that matches the capabilities requested."
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* Not sure how to test this.
|
2006-06-09 19:36:12 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
TRACE("(%p): Returning surface %p\n", This, surf);
|
|
|
|
TRACE("(%p): mipmapcount=%d\n", This, surf->mipmap_level);
|
2011-06-05 18:55:04 +02:00
|
|
|
*Surface = &surf->IDirectDrawSurface7_iface;
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_AddRef(*Surface);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Next, look at the attachment chain */
|
|
|
|
surf = This;
|
|
|
|
|
|
|
|
while( (surf = surf->next_attached) )
|
|
|
|
{
|
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE("Surface: (%p) caps: %x,%x,%x,%x\n", surf,
|
2006-06-09 19:36:12 +02:00
|
|
|
surf->surface_desc.ddsCaps.dwCaps,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps2,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps3,
|
|
|
|
surf->surface_desc.ddsCaps.dwCaps4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((surf->surface_desc.ddsCaps.dwCaps & our_caps.dwCaps) == our_caps.dwCaps) &&
|
|
|
|
((surf->surface_desc.ddsCaps.dwCaps2 & our_caps.dwCaps2) == our_caps.dwCaps2)) {
|
|
|
|
|
|
|
|
TRACE("(%p): Returning surface %p\n", This, surf);
|
2011-06-05 18:55:04 +02:00
|
|
|
*Surface = &surf->IDirectDrawSurface7_iface;
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_AddRef(*Surface);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(%p) Didn't find a valid surface\n", This);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2008-04-02 23:11:43 +02:00
|
|
|
|
|
|
|
*Surface = NULL;
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetAttachedSurface(IDirectDrawSurface4 *iface,
|
|
|
|
DDSCAPS2 *caps, IDirectDrawSurface4 **attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&This->IDirectDrawSurface7_iface,
|
|
|
|
caps, &attachment7);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface4_iface;
|
2011-06-28 01:34:23 +02:00
|
|
|
ddraw_surface4_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2011-06-06 13:39:04 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetAttachedSurface(IDirectDrawSurface3 *iface,
|
|
|
|
DDSCAPS *caps, IDirectDrawSurface3 **attachment)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
IDirectDrawSurface7 *attachment7;
|
2011-06-06 12:08:56 +02:00
|
|
|
IDirectDrawSurfaceImpl *attachment_impl;
|
2010-07-19 18:36:20 +02:00
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
caps2.dwCaps = caps->dwCaps;
|
|
|
|
caps2.dwCaps2 = 0;
|
|
|
|
caps2.dwCaps3 = 0;
|
|
|
|
caps2.dwCaps4 = 0;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&This->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
&caps2, &attachment7);
|
2011-06-06 12:08:56 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
2011-06-06 12:57:55 +02:00
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
2011-06-06 12:08:56 +02:00
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface3_iface;
|
2011-06-20 22:51:01 +02:00
|
|
|
ddraw_surface3_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetAttachedSurface(IDirectDrawSurface2 *iface,
|
|
|
|
DDSCAPS *caps, IDirectDrawSurface2 **attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl;
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
caps2.dwCaps = caps->dwCaps;
|
|
|
|
caps2.dwCaps2 = 0;
|
|
|
|
caps2.dwCaps3 = 0;
|
|
|
|
caps2.dwCaps4 = 0;
|
|
|
|
|
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&This->IDirectDrawSurface7_iface,
|
|
|
|
&caps2, &attachment7);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface2_iface;
|
2011-06-19 16:24:32 +02:00
|
|
|
ddraw_surface2_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2011-06-09 16:35:15 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *iface,
|
|
|
|
DDSCAPS *caps, IDirectDrawSurface **attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurface7 *attachment7;
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl;
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p, attachment %p.\n", iface, caps, attachment);
|
|
|
|
|
|
|
|
caps2.dwCaps = caps->dwCaps;
|
|
|
|
caps2.dwCaps2 = 0;
|
|
|
|
caps2.dwCaps3 = 0;
|
|
|
|
caps2.dwCaps4 = 0;
|
|
|
|
|
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&This->IDirectDrawSurface7_iface,
|
|
|
|
&caps2, &attachment7);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
*attachment = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
attachment_impl = impl_from_IDirectDrawSurface7(attachment7);
|
|
|
|
*attachment = &attachment_impl->IDirectDrawSurface_iface;
|
2011-06-20 23:15:55 +02:00
|
|
|
ddraw_surface1_AddRef(*attachment);
|
|
|
|
ddraw_surface7_Release(attachment7);
|
2011-06-09 17:29:36 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Lock
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Locks the surface and returns a pointer to the surface's memory
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Rect: Rectangle to lock. If NULL, the whole surface is locked
|
|
|
|
* DDSD: Pointer to a DDSURFACEDESC2 which shall receive the surface's desc.
|
|
|
|
* Flags: Locking flags, e.g Read only or write only
|
|
|
|
* h: An event handle that's not used and must be NULL
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DDSD is NULL
|
|
|
|
* For more details, see IWineD3DSurface::LockRect
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Lock(IDirectDrawSurface7 *iface,
|
|
|
|
RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
WINED3DLOCKED_RECT LockedRect;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(Rect), DDSD, Flags, h);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
if(!DDSD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
/* This->surface_desc.dwWidth and dwHeight are changeable, thus lock */
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-05-03 20:58:48 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Should I check for the handle to be NULL?
|
|
|
|
*
|
|
|
|
* The DDLOCK flags and the D3DLOCK flags are equal
|
|
|
|
* for the supported values. The others are ignored by WineD3D
|
|
|
|
*/
|
|
|
|
|
2007-06-08 17:35:44 +02:00
|
|
|
if(DDSD->dwSize != sizeof(DDSURFACEDESC) &&
|
|
|
|
DDSD->dwSize != sizeof(DDSURFACEDESC2))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-26 19:52:27 +02:00
|
|
|
WARN("Invalid structure size %d, returning DDERR_INVALIDPARAMS\n", DDSD->dwSize);
|
2007-06-08 17:35:44 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2008-02-25 16:22:41 +01:00
|
|
|
/* Windows zeroes this if the rect is invalid */
|
|
|
|
DDSD->lpSurface = 0;
|
|
|
|
|
|
|
|
if (Rect)
|
|
|
|
{
|
|
|
|
if ((Rect->left < 0)
|
|
|
|
|| (Rect->top < 0)
|
|
|
|
|| (Rect->left > Rect->right)
|
|
|
|
|| (Rect->top > Rect->bottom)
|
|
|
|
|| (Rect->right > This->surface_desc.dwWidth)
|
|
|
|
|| (Rect->bottom > This->surface_desc.dwHeight))
|
|
|
|
{
|
|
|
|
WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_map(This->wined3d_surface, &LockedRect, Rect, Flags);
|
2010-10-14 13:04:02 +02:00
|
|
|
if (FAILED(hr))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-08-24 23:51:14 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
/* D3D8 and D3D9 return the general D3DERR_INVALIDCALL error, but ddraw has a more
|
|
|
|
* specific error. But since IWineD3DSurface::LockRect returns that error in this
|
|
|
|
* only occasion, keep d3d8 and d3d9 free from the return value override. There are
|
|
|
|
* many different places where d3d8/9 would have to catch the DDERR_SURFACEBUSY, it
|
|
|
|
* is much easier to do it in one place in ddraw
|
|
|
|
*/
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_SURFACEBUSY;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-06 23:40:19 +02:00
|
|
|
/* Override the memory area. The pitch should be set already. Strangely windows
|
|
|
|
* does not set the LPSURFACE flag on locked surfaces !?!.
|
|
|
|
* DDSD->dwFlags |= DDSD_LPSURFACE;
|
|
|
|
*/
|
2007-05-10 21:55:14 +02:00
|
|
|
This->surface_desc.lpSurface = LockedRect.pBits;
|
|
|
|
DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
TRACE("locked surface returning description :\n");
|
|
|
|
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Lock(IDirectDrawSurface4 *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC2 *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
|
|
|
return ddraw_surface7_Lock(&This->IDirectDrawSurface7_iface,
|
|
|
|
rect, surface_desc, flags, h);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_Lock(&This->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
rect, (DDSURFACEDESC2 *)surface_desc, flags, h);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Lock(IDirectDrawSurface2 *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
|
|
|
return ddraw_surface7_Lock(&This->IDirectDrawSurface7_iface,
|
|
|
|
rect, (DDSURFACEDESC2 *)surface_desc, flags, h);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
|
|
|
|
|
|
|
|
return ddraw_surface7_Lock(&This->IDirectDrawSurface7_iface,
|
|
|
|
rect, (DDSURFACEDESC2 *)surface_desc, flags, h);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Unlock
|
|
|
|
*
|
|
|
|
* Unlocks an locked surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Rect: Not used by this implementation
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For more details, see IWineD3DSurface::UnlockRect
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pRect)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-10 21:55:14 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(pRect));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_unmap(This->wined3d_surface);
|
2010-10-14 13:04:02 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2007-05-10 21:55:14 +02:00
|
|
|
{
|
|
|
|
This->surface_desc.lpSurface = NULL;
|
|
|
|
}
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-05-10 21:55:14 +02:00
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Unlock(IDirectDrawSurface4 *iface, RECT *pRect)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, rect %p.\n", iface, pRect);
|
|
|
|
|
|
|
|
return ddraw_surface7_Unlock(&This->IDirectDrawSurface7_iface, pRect);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Unlock(IDirectDrawSurface3 *iface, void *data)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
|
|
|
|
|
|
|
/* data might not be the LPRECT of later versions, so drop it. */
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_Unlock(&This->IDirectDrawSurface7_iface, NULL);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Unlock(IDirectDrawSurface2 *iface, void *data)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
|
|
|
|
|
|
|
/* data might not be the LPRECT of later versions, so drop it. */
|
|
|
|
return ddraw_surface7_Unlock(&This->IDirectDrawSurface7_iface, NULL);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Unlock(IDirectDrawSurface *iface, void *data)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, data %p.\n", iface, data);
|
|
|
|
|
|
|
|
/* data might not be the LPRECT of later versions, so drop it. */
|
|
|
|
return ddraw_surface7_Unlock(&This->IDirectDrawSurface7_iface, NULL);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Flip
|
|
|
|
*
|
|
|
|
* Flips a surface with the DDSCAPS_FLIP flag. The flip is relayed to
|
|
|
|
* IWineD3DSurface::Flip. Because WineD3D doesn't handle attached surfaces,
|
|
|
|
* the flip target is passed to WineD3D, even if the app didn't specify one
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DestOverride: Specifies the surface that will become the new front
|
|
|
|
* buffer. If NULL, the current back buffer is used
|
|
|
|
* Flags: some DirectDraw flags, see include/ddraw.h
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_NOTFLIPPABLE if no flip target could be found
|
|
|
|
* DDERR_INVALIDOBJECT if the surface isn't a front buffer
|
|
|
|
* For more details, see IWineD3DSurface::Flip
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Flip(IDirectDrawSurface7 *iface, IDirectDrawSurface7 *DestOverride, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *Override = unsafe_impl_from_IDirectDrawSurface7(DestOverride);
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawSurface7 *Override7;
|
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dst %p, flags %#x.\n", iface, DestOverride, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Flip has to be called from a front buffer
|
|
|
|
* What about overlay surfaces, AFAIK they can flip too?
|
|
|
|
*/
|
2008-07-24 18:38:51 +02:00
|
|
|
if( !(This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER | DDSCAPS_OVERLAY)) )
|
2008-04-02 21:26:42 +02:00
|
|
|
return DDERR_INVALIDOBJECT; /* Unchecked */
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* WineD3D doesn't keep track of attached surface, so find the target */
|
|
|
|
if(!Override)
|
|
|
|
{
|
|
|
|
DDSCAPS2 Caps;
|
|
|
|
|
|
|
|
memset(&Caps, 0, sizeof(Caps));
|
|
|
|
Caps.dwCaps |= DDSCAPS_BACKBUFFER;
|
2010-07-19 18:36:20 +02:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(iface, &Caps, &Override7);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(hr != DD_OK)
|
|
|
|
{
|
|
|
|
ERR("Can't find a flip target\n");
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_NOTFLIPPABLE; /* Unchecked */
|
|
|
|
}
|
2011-06-06 12:57:55 +02:00
|
|
|
Override = impl_from_IDirectDrawSurface7(Override7);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* For the GetAttachedSurface */
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_Release(Override7);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_flip(This->wined3d_surface, Override->wined3d_surface, Flags);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Flip(IDirectDrawSurface4 *iface, IDirectDrawSurface4 *dst, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface4(dst);
|
|
|
|
TRACE("iface %p, dst %p, flags %#x.\n", iface, dst, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_Flip(&This->IDirectDrawSurface7_iface,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Flip(IDirectDrawSurface3 *iface, IDirectDrawSurface3 *dst, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface3(dst);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dst %p, flags %#x.\n", iface, dst, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_Flip(&This->IDirectDrawSurface7_iface,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Flip(IDirectDrawSurface2 *iface, IDirectDrawSurface2 *dst, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface2(dst);
|
|
|
|
TRACE("iface %p, dst %p, flags %#x.\n", iface, dst, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_Flip(&This->IDirectDrawSurface7_iface,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, flags);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Flip(IDirectDrawSurface *iface, IDirectDrawSurface *dst, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface(dst);
|
|
|
|
TRACE("iface %p, dst %p, flags %#x.\n", iface, dst, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_Flip(&This->IDirectDrawSurface7_iface,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Blt
|
|
|
|
*
|
|
|
|
* Performs a blit on the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DestRect: Destination rectangle, can be NULL
|
|
|
|
* SrcSurface: Source surface, can be NULL
|
2008-02-13 22:11:01 +01:00
|
|
|
* SrcRect: Source rectangle, can be NULL
|
2006-06-09 19:36:12 +02:00
|
|
|
* Flags: Blt flags
|
|
|
|
* DDBltFx: Some extended blt parameters, connected to the flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* See IWineD3DSurface::Blt for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Blt(IDirectDrawSurface7 *iface, RECT *DestRect,
|
|
|
|
IDirectDrawSurface7 *SrcSurface, RECT *SrcRect, DWORD Flags, DDBLTFX *DDBltFx)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *Src = unsafe_impl_from_IDirectDrawSurface7(SrcSurface);
|
2007-04-14 22:44:55 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2010-11-02 12:02:46 +01:00
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
2010-08-19 18:57:50 +02:00
|
|
|
iface, wine_dbgstr_rect(DestRect), SrcSurface, wine_dbgstr_rect(SrcRect), Flags, DDBltFx);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-02-15 03:03:05 +01:00
|
|
|
/* Check for validity of the flags here. WineD3D Has the software-opengl selection path and would have
|
|
|
|
* to check at 2 places, and sometimes do double checks. This also saves the call to wined3d :-)
|
|
|
|
*/
|
|
|
|
if((Flags & DDBLT_KEYSRCOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYSRC)) {
|
|
|
|
WARN("Invalid source color key parameters, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((Flags & DDBLT_KEYDESTOVERRIDE) && (!DDBltFx || Flags & DDBLT_KEYDEST)) {
|
|
|
|
WARN("Invalid destination color key parameters, returning DDERR_INVALIDPARAMS\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-06-08 19:04:13 +02:00
|
|
|
|
2007-02-15 03:03:05 +01:00
|
|
|
if(Flags & DDBLT_KEYSRC && (!Src || !(Src->surface_desc.dwFlags & DDSD_CKSRCBLT))) {
|
|
|
|
WARN("DDBLT_KEYDEST blit without color key in surface, returning DDERR_INVALIDPARAMS\n");
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-02-15 03:03:05 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
/* TODO: Check if the DDBltFx contains any ddraw surface pointers. If it
|
|
|
|
* does, copy the struct, and replace the ddraw surfaces with the wined3d
|
|
|
|
* surfaces. So far no blitting operations using surfaces in the bltfx
|
|
|
|
* struct are supported anyway. */
|
|
|
|
hr = wined3d_surface_blt(This->wined3d_surface, DestRect, Src ? Src->wined3d_surface : NULL,
|
2010-10-12 13:40:01 +02:00
|
|
|
SrcRect, Flags, (WINEDDBLTFX *)DDBltFx, WINED3DTEXF_LINEAR);
|
2007-05-30 15:25:34 +02:00
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
|
|
|
|
case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Blt(IDirectDrawSurface4 *iface, RECT *dst_rect,
|
|
|
|
IDirectDrawSurface4 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *src = unsafe_impl_from_IDirectDrawSurface4(src_surface);
|
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface7_Blt(&This->IDirectDrawSurface7_iface, dst_rect,
|
|
|
|
src ? &src->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Blt(IDirectDrawSurface3 *iface, RECT *dst_rect,
|
|
|
|
IDirectDrawSurface3 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface3(src_surface);
|
2010-11-02 12:02:46 +01:00
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
2010-07-19 18:36:20 +02:00
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_Blt(&This->IDirectDrawSurface7_iface, dst_rect,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Blt(IDirectDrawSurface2 *iface, RECT *dst_rect,
|
|
|
|
IDirectDrawSurface2 *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface2(src_surface);
|
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface7_Blt(&This->IDirectDrawSurface7_iface, dst_rect,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Blt(IDirectDrawSurface *iface, RECT *dst_rect,
|
|
|
|
IDirectDrawSurface *src_surface, RECT *src_rect, DWORD flags, DDBLTFX *fx)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface(src_surface);
|
|
|
|
TRACE("iface %p, dst_rect %s, src_surface %p, src_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(dst_rect), src_surface, wine_dbgstr_rect(src_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface7_Blt(&This->IDirectDrawSurface7_iface, dst_rect,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::AddAttachedSurface
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* Attaches a surface to another surface. How the surface attachments work
|
|
|
|
* is not totally understood yet, and this method is prone to problems.
|
|
|
|
* he surface that is attached is AddRef-ed.
|
|
|
|
*
|
|
|
|
* Tests with complex surfaces suggest that the surface attachments form a
|
|
|
|
* tree, but no method to test this has been found yet.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* The attachment list consists of a first surface (first_attached) and
|
2006-06-09 19:36:12 +02:00
|
|
|
* for each surface a pointer to the next attached surface (next_attached).
|
|
|
|
* For the first surface, and a surface that has no attachments
|
|
|
|
* first_attached points to the surface itself. A surface that has
|
|
|
|
* no successors in the chain has next_attached set to NULL.
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* Newly attached surfaces are attached right after the root surface.
|
|
|
|
* If a surface is attached to a complex surface compound, it's attached to
|
|
|
|
* the surface that the app requested, not the complex root. See
|
|
|
|
* GetAttachedSurface for a description how surfaces are found.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* This is how the current implementation works, and it was coded by looking
|
|
|
|
* at the needs of the applications.
|
|
|
|
*
|
2007-04-27 15:31:12 +02:00
|
|
|
* So far only Z-Buffer attachments are tested, and they are activated in
|
|
|
|
* WineD3D. Mipmaps could be tricky to activate in WineD3D.
|
2007-05-04 18:31:14 +02:00
|
|
|
* Back buffers should work in 2D mode, but they are not tested(They can be
|
|
|
|
* attached in older iface versions). Rendering to the front buffer and
|
2007-04-27 15:31:12 +02:00
|
|
|
* switching between that and double buffering is not yet implemented in
|
|
|
|
* WineD3D, so for 3D it might have unexpected results.
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
2010-07-19 18:36:20 +02:00
|
|
|
* ddraw_surface_attach_surface is the real thing,
|
|
|
|
* ddraw_surface7_AddAttachedSurface is a wrapper around it that
|
2007-05-04 18:31:14 +02:00
|
|
|
* performs additional checks. Version 7 of this interface is much more restrictive
|
|
|
|
* than its predecessors.
|
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
* Params:
|
|
|
|
* Attach: Surface to attach to iface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_CANNOTATTACHSURFACE if the surface can't be attached for some reason
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-08-24 17:58:16 +02:00
|
|
|
static HRESULT ddraw_surface_attach_surface(IDirectDrawSurfaceImpl *This, IDirectDrawSurfaceImpl *Surf)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("surface %p, attachment %p.\n", This, Surf);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(Surf == This)
|
|
|
|
return DDERR_CANNOTATTACHSURFACE; /* unchecked */
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Check if the surface is already attached somewhere */
|
2010-08-22 23:35:39 +02:00
|
|
|
if (Surf->next_attached || Surf->first_attached != Surf)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-22 23:35:39 +02:00
|
|
|
/* TODO: Test for the structure of the manual attachment. Is it a
|
|
|
|
* chain or a list? What happens if one surface is attached to 2
|
|
|
|
* different surfaces? */
|
|
|
|
WARN("Surface %p is already attached somewhere. next_attached %p, first_attached %p.\n",
|
|
|
|
Surf, Surf->next_attached, Surf->first_attached);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-05-04 18:31:14 +02:00
|
|
|
return DDERR_SURFACEALREADYATTACHED;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This inserts the new surface at the 2nd position in the chain, right after the root surface */
|
|
|
|
Surf->next_attached = This->next_attached;
|
|
|
|
Surf->first_attached = This->first_attached;
|
|
|
|
This->next_attached = Surf;
|
|
|
|
|
2007-04-24 22:30:03 +02:00
|
|
|
/* Check if the WineD3D depth stencil needs updating */
|
|
|
|
if(This->ddraw->d3ddevice)
|
2006-10-25 12:54:15 +02:00
|
|
|
{
|
2007-04-24 22:30:03 +02:00
|
|
|
IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
|
2006-10-25 12:54:15 +02:00
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_AddAttachedSurface(IDirectDrawSurface7 *iface, IDirectDrawSurface7 *Attach)
|
2007-05-04 18:31:14 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *Surf = unsafe_impl_from_IDirectDrawSurface7(Attach);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2007-05-04 18:31:14 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, attachment %p.\n", iface, Attach);
|
|
|
|
|
2007-05-04 18:31:14 +02:00
|
|
|
/* Version 7 of this interface seems to refuse everything except z buffers, as per msdn */
|
|
|
|
if(!(Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
|
|
|
|
{
|
|
|
|
|
|
|
|
WARN("Application tries to attach a non Z buffer surface. caps %08x\n",
|
|
|
|
Surf->surface_desc.ddsCaps.dwCaps);
|
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
|
|
|
}
|
|
|
|
|
2011-06-20 23:30:12 +02:00
|
|
|
hr = ddraw_surface_attach_surface(This, Surf);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface7_AddRef(Attach);
|
|
|
|
return hr;
|
2007-05-04 18:31:14 +02:00
|
|
|
}
|
2010-07-19 18:36:20 +02:00
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_AddAttachedSurface(IDirectDrawSurface4 *iface, IDirectDrawSurface4 *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface4(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2011-06-06 13:39:04 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
2011-06-20 23:30:12 +02:00
|
|
|
hr = ddraw_surface7_AddAttachedSurface(&This->IDirectDrawSurface7_iface,
|
2011-06-06 13:39:04 +02:00
|
|
|
attachment_impl ? &attachment_impl->IDirectDrawSurface7_iface : NULL);
|
2011-06-20 23:30:12 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface4_AddRef(attachment);
|
|
|
|
ddraw_surface7_Release(&attachment_impl->IDirectDrawSurface7_iface);
|
|
|
|
return hr;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_AddAttachedSurface(IDirectDrawSurface3 *iface, IDirectDrawSurface3 *attachment)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *attach_impl = unsafe_impl_from_IDirectDrawSurface3(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2010-07-19 18:36:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
|
|
|
/* Tests suggest that
|
|
|
|
* -> offscreen plain surfaces can be attached to other offscreen plain surfaces
|
|
|
|
* -> offscreen plain surfaces can be attached to primaries
|
|
|
|
* -> primaries can be attached to offscreen plain surfaces
|
|
|
|
* -> z buffers can be attached to primaries */
|
2011-05-31 14:34:47 +02:00
|
|
|
if (This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN)
|
2010-07-19 18:36:20 +02:00
|
|
|
&& attach_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_OFFSCREENPLAIN))
|
|
|
|
{
|
|
|
|
/* Sizes have to match */
|
2011-05-31 14:34:47 +02:00
|
|
|
if (attach_impl->surface_desc.dwWidth != This->surface_desc.dwWidth
|
|
|
|
|| attach_impl->surface_desc.dwHeight != This->surface_desc.dwHeight)
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
|
|
|
WARN("Surface sizes do not match.\n");
|
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
|
|
|
}
|
|
|
|
/* OK */
|
|
|
|
}
|
2011-05-31 14:34:47 +02:00
|
|
|
else if (This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_3DDEVICE)
|
2010-07-19 18:36:20 +02:00
|
|
|
&& attach_impl->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER))
|
|
|
|
{
|
|
|
|
/* OK */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Invalid attachment combination.\n");
|
|
|
|
return DDERR_CANNOTATTACHSURFACE;
|
|
|
|
}
|
|
|
|
|
2011-06-20 23:30:12 +02:00
|
|
|
hr = ddraw_surface_attach_surface(This, attach_impl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface3_AddRef(attachment);
|
|
|
|
return hr;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_AddAttachedSurface(IDirectDrawSurface2 *iface, IDirectDrawSurface2 *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface2(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2011-06-09 16:35:15 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
2011-06-20 23:30:12 +02:00
|
|
|
hr = ddraw_surface3_AddAttachedSurface(&This->IDirectDrawSurface3_iface,
|
2011-06-09 16:35:15 +02:00
|
|
|
attachment_impl ? &attachment_impl->IDirectDrawSurface3_iface : NULL);
|
2011-06-20 23:30:12 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface2_AddRef(attachment);
|
|
|
|
ddraw_surface3_Release(&attachment_impl->IDirectDrawSurface3_iface);
|
|
|
|
return hr;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_AddAttachedSurface(IDirectDrawSurface *iface, IDirectDrawSurface *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface(attachment);
|
2011-06-20 23:30:12 +02:00
|
|
|
HRESULT hr;
|
2011-06-09 17:29:36 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, attachment %p.\n", iface, attachment);
|
|
|
|
|
2011-06-20 23:30:12 +02:00
|
|
|
hr = ddraw_surface3_AddAttachedSurface(&This->IDirectDrawSurface3_iface,
|
2011-06-09 17:29:36 +02:00
|
|
|
attachment_impl ? &attachment_impl->IDirectDrawSurface3_iface : NULL);
|
2011-06-20 23:30:12 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface1_AddRef(attachment);
|
|
|
|
ddraw_surface3_Release(&attachment_impl->IDirectDrawSurface3_iface);
|
|
|
|
return hr;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::DeleteAttachedSurface
|
|
|
|
*
|
|
|
|
* Removes a surface from the attachment chain. The surface's refcount
|
|
|
|
* is decreased by one after it has been removed
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Some flags, not used by this implementation
|
|
|
|
* Attach: Surface to detach
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_SURFACENOTATTACHED if the surface isn't attached to
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 22:46:26 +02:00
|
|
|
static HRESULT ddraw_surface_delete_attached_surface(IDirectDrawSurfaceImpl *This,
|
|
|
|
IDirectDrawSurfaceImpl *Surf)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *Prev = This;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
TRACE("surface %p, attachment %p.\n", This, Surf);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (!Surf || (Surf->first_attached != This) || (Surf == This) )
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-05-04 18:31:14 +02:00
|
|
|
return DDERR_CANNOTDETACHSURFACE;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Remove MIPMAPSUBLEVEL if this seemed to be one */
|
|
|
|
if (This->surface_desc.ddsCaps.dwCaps &
|
|
|
|
Surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
{
|
|
|
|
Surf->surface_desc.ddsCaps.dwCaps2 &= ~DDSCAPS2_MIPMAPSUBLEVEL;
|
|
|
|
/* FIXME: we should probably also subtract from dwMipMapCount of this
|
|
|
|
* and all parent surfaces */
|
|
|
|
}
|
|
|
|
|
2006-06-23 18:18:02 +02:00
|
|
|
/* Find the predecessor of the detached surface */
|
2006-06-09 19:36:12 +02:00
|
|
|
while(Prev)
|
|
|
|
{
|
|
|
|
if(Prev->next_attached == Surf) break;
|
|
|
|
Prev = Prev->next_attached;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* There must be a surface, otherwise there's a bug */
|
|
|
|
assert(Prev != NULL);
|
|
|
|
|
|
|
|
/* Unchain the surface */
|
|
|
|
Prev->next_attached = Surf->next_attached;
|
|
|
|
Surf->next_attached = NULL;
|
|
|
|
Surf->first_attached = Surf;
|
|
|
|
|
2007-04-24 22:30:03 +02:00
|
|
|
/* Check if the WineD3D depth stencil needs updating */
|
|
|
|
if(This->ddraw->d3ddevice)
|
2006-10-25 12:54:15 +02:00
|
|
|
{
|
2007-04-24 22:30:03 +02:00
|
|
|
IDirect3DDeviceImpl_UpdateDepthStencil(This->ddraw->d3ddevice);
|
2006-10-25 12:54:15 +02:00
|
|
|
}
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_DeleteAttachedSurface(IDirectDrawSurface7 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface7 *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface7(attachment);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
|
|
|
hr = ddraw_surface_delete_attached_surface(This, attachment_impl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface7_Release(attachment);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_DeleteAttachedSurface(IDirectDrawSurface4 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface4 *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface4(attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
hr = ddraw_surface_delete_attached_surface(This, attachment_impl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface4_Release(attachment);
|
|
|
|
return hr;
|
2011-06-06 13:39:04 +02:00
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_DeleteAttachedSurface(IDirectDrawSurface3 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface3 *attachment)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface3(attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
HRESULT hr;
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
hr = ddraw_surface_delete_attached_surface(This, attachment_impl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface3_Release(attachment);
|
|
|
|
return hr;
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_DeleteAttachedSurface(IDirectDrawSurface2 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface2 *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface2(attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
HRESULT hr;
|
2011-06-09 16:35:15 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
hr = ddraw_surface_delete_attached_surface(This, attachment_impl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface2_Release(attachment);
|
|
|
|
return hr;
|
2011-06-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_DeleteAttachedSurface(IDirectDrawSurface *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface *attachment)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *attachment_impl = unsafe_impl_from_IDirectDrawSurface(attachment);
|
2011-06-20 22:46:26 +02:00
|
|
|
HRESULT hr;
|
2011-06-09 17:29:36 +02:00
|
|
|
TRACE("iface %p, flags %#x, attachment %p.\n", iface, flags, attachment);
|
|
|
|
|
2011-06-20 22:46:26 +02:00
|
|
|
hr = ddraw_surface_delete_attached_surface(This, attachment_impl);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
ddraw_surface1_Release(attachment);
|
|
|
|
return hr;
|
2011-06-09 17:29:36 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::AddOverlayDirtyRect
|
|
|
|
*
|
|
|
|
* "This method is not currently implemented"
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Rect: ?
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_AddOverlayDirtyRect(IDirectDrawSurface7 *iface, RECT *Rect)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(Rect));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DDERR_UNSUPPORTED; /* unchecked */
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_AddOverlayDirtyRect(IDirectDrawSurface4 *iface, RECT *rect)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&This->IDirectDrawSurface7_iface, rect);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_AddOverlayDirtyRect(IDirectDrawSurface3 *iface, RECT *rect)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&This->IDirectDrawSurface7_iface, rect);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_AddOverlayDirtyRect(IDirectDrawSurface2 *iface, RECT *rect)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&This->IDirectDrawSurface7_iface, rect);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_AddOverlayDirtyRect(IDirectDrawSurface *iface, RECT *rect)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(rect));
|
|
|
|
|
|
|
|
return ddraw_surface7_AddOverlayDirtyRect(&This->IDirectDrawSurface7_iface, rect);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetDC
|
|
|
|
*
|
|
|
|
* Returns a GDI device context for the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* hdc: Address of a HDC variable to store the dc to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if hdc is NULL
|
|
|
|
* For details, see IWineD3DSurface::GetDC
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetDC(IDirectDrawSurface7 *iface, HDC *hdc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, hdc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!hdc)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_getdc(This->wined3d_surface, hdc);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2009-09-05 16:37:19 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
/* Some, but not all errors set *hdc to NULL. E.g. DCALREADYCREATED does not
|
|
|
|
* touch *hdc
|
|
|
|
*/
|
|
|
|
case WINED3DERR_INVALIDCALL:
|
|
|
|
if(hdc) *hdc = NULL;
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetDC(IDirectDrawSurface4 *iface, HDC *dc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetDC(&This->IDirectDrawSurface7_iface, dc);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetDC(IDirectDrawSurface3 *iface, HDC *dc)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetDC(&This->IDirectDrawSurface7_iface, dc);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetDC(IDirectDrawSurface2 *iface, HDC *dc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetDC(&This->IDirectDrawSurface7_iface, dc);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetDC(IDirectDrawSurface *iface, HDC *dc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetDC(&This->IDirectDrawSurface7_iface, dc);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::ReleaseDC
|
|
|
|
*
|
|
|
|
* Releases the DC that was constructed with GetDC
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* hdc: HDC to release
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* For more details, see IWineD3DSurface::ReleaseDC
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_ReleaseDC(IDirectDrawSurface7 *iface, HDC hdc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, hdc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_releasedc(This->wined3d_surface, hdc);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_ReleaseDC(IDirectDrawSurface4 *iface, HDC dc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
|
|
|
return ddraw_surface7_ReleaseDC(&This->IDirectDrawSurface7_iface, dc);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_ReleaseDC(IDirectDrawSurface3 *iface, HDC dc)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_ReleaseDC(&This->IDirectDrawSurface7_iface, dc);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_ReleaseDC(IDirectDrawSurface2 *iface, HDC dc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
|
|
|
return ddraw_surface7_ReleaseDC(&This->IDirectDrawSurface7_iface, dc);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_ReleaseDC(IDirectDrawSurface *iface, HDC dc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, dc %p.\n", iface, dc);
|
|
|
|
|
|
|
|
return ddraw_surface7_ReleaseDC(&This->IDirectDrawSurface7_iface, dc);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetCaps
|
|
|
|
*
|
|
|
|
* Returns the surface's caps
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Caps: Address to write the caps to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Caps is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetCaps(IDirectDrawSurface7 *iface, DDSCAPS2 *Caps)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, Caps);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Caps)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
*Caps = This->surface_desc.ddsCaps;
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetCaps(IDirectDrawSurface4 *iface, DDSCAPS2 *caps)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetCaps(&This->IDirectDrawSurface7_iface, caps);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetCaps(IDirectDrawSurface3 *iface, DDSCAPS *caps)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
hr = ddraw_surface7_GetCaps(&This->IDirectDrawSurface7_iface, &caps2);
|
2010-07-19 18:36:20 +02:00
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
caps->dwCaps = caps2.dwCaps;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetCaps(IDirectDrawSurface2 *iface, DDSCAPS *caps)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
|
|
|
hr = ddraw_surface7_GetCaps(&This->IDirectDrawSurface7_iface, &caps2);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
caps->dwCaps = caps2.dwCaps;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetCaps(IDirectDrawSurface *iface, DDSCAPS *caps)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
DDSCAPS2 caps2;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, caps %p.\n", iface, caps);
|
|
|
|
|
|
|
|
hr = ddraw_surface7_GetCaps(&This->IDirectDrawSurface7_iface, &caps2);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
caps->dwCaps = caps2.dwCaps;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetPriority
|
|
|
|
*
|
|
|
|
* Sets a texture priority for managed textures.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Priority: The new priority
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* For more details, see IWineD3DSurface::SetPriority
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetPriority(IDirectDrawSurface7 *iface, DWORD Priority)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, priority %u.\n", iface, Priority);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_priority(This->wined3d_surface, Priority);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetPriority
|
|
|
|
*
|
|
|
|
* Returns the surface's priority
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Priority: Address of a variable to write the priority to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Priority == NULL
|
|
|
|
* For more details, see IWineD3DSurface::GetPriority
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPriority(IDirectDrawSurface7 *iface, DWORD *Priority)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, priority %p.\n", iface, Priority);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Priority)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
*Priority = wined3d_surface_get_priority(This->wined3d_surface);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetPrivateData
|
|
|
|
*
|
|
|
|
* Stores some data in the surface that is intended for the application's
|
|
|
|
* use.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* tag: GUID that identifies the data
|
|
|
|
* Data: Pointer to the private data
|
|
|
|
* Size: Size of the private data
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For more details, see IWineD3DSurface::SetPrivateData
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetPrivateData(IDirectDrawSurface7 *iface,
|
|
|
|
REFGUID tag, void *Data, DWORD Size, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-21 19:50:08 +02:00
|
|
|
struct wined3d_resource *resource;
|
2007-05-11 00:09:35 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n",
|
|
|
|
iface, debugstr_guid(tag), Data, Size, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-06-21 19:50:08 +02:00
|
|
|
resource = wined3d_surface_get_resource(This->wined3d_surface);
|
|
|
|
hr = wined3d_resource_set_private_data(resource, tag, Data, Size, Flags);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-05-11 00:09:35 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetPrivateData(IDirectDrawSurface4 *iface,
|
|
|
|
REFGUID tag, void *data, DWORD size, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %u, flags %#x.\n",
|
|
|
|
iface, debugstr_guid(tag), data, size, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetPrivateData(&This->IDirectDrawSurface7_iface, tag, data, size, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetPrivateData
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Returns the private data set with IDirectDrawSurface7::SetPrivateData
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* tag: GUID of the data to return
|
|
|
|
* Data: Address where to write the data to
|
|
|
|
* Size: Size of the buffer at Data
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Data is NULL
|
|
|
|
* For more details, see IWineD3DSurface::GetPrivateData
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPrivateData(IDirectDrawSurface7 *iface, REFGUID tag, void *Data, DWORD *Size)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-21 19:50:08 +02:00
|
|
|
struct wined3d_resource *resource;
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %p.\n",
|
|
|
|
iface, debugstr_guid(tag), Data, Size);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Data)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-06-21 19:50:08 +02:00
|
|
|
resource = wined3d_surface_get_resource(This->wined3d_surface);
|
|
|
|
hr = wined3d_resource_get_private_data(resource, tag, Data, Size);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetPrivateData(IDirectDrawSurface4 *iface, REFGUID tag, void *data, DWORD *size)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, tag %s, data %p, data_size %p.\n",
|
|
|
|
iface, debugstr_guid(tag), data, size);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPrivateData(&This->IDirectDrawSurface7_iface, tag, data, size);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::FreePrivateData
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* Frees private data stored in the surface
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* tag: Tag of the data to free
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* For more details, see IWineD3DSurface::FreePrivateData
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_FreePrivateData(IDirectDrawSurface7 *iface, REFGUID tag)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-21 19:50:08 +02:00
|
|
|
struct wined3d_resource *resource;
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag));
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-06-21 19:50:08 +02:00
|
|
|
resource = wined3d_surface_get_resource(This->wined3d_surface);
|
|
|
|
hr = wined3d_resource_free_private_data(resource, tag);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_FreePrivateData(IDirectDrawSurface4 *iface, REFGUID tag)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, tag %s.\n", iface, debugstr_guid(tag));
|
|
|
|
|
|
|
|
return ddraw_surface7_FreePrivateData(&This->IDirectDrawSurface7_iface, tag);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::PageLock
|
|
|
|
*
|
|
|
|
* Prevents a sysmem surface from being paged out
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Not used, must be 0(unchecked)
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_PageLock(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* This is Windows memory management related - we don't need this */
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_PageLock(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_PageLock(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_PageLock(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_PageLock(&This->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_PageLock(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_PageLock(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::PageUnlock
|
|
|
|
*
|
|
|
|
* Allows a sysmem surface to be paged out
|
|
|
|
*
|
|
|
|
* Params:
|
2008-04-02 21:26:42 +02:00
|
|
|
* Flags: Not used, must be 0(unchecked)
|
2006-06-09 19:36:12 +02:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_PageUnlock(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_PageUnlock(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_PageUnlock(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_PageUnlock(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_PageUnlock(&This->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_PageUnlock(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_PageUnlock(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::BltBatch
|
|
|
|
*
|
|
|
|
* An unimplemented function
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_BltBatch(IDirectDrawSurface7 *iface, DDBLTBATCH *Batch, DWORD Count, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, Batch, Count, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* MSDN: "not currently implemented" */
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_BltBatch(IDirectDrawSurface4 *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_BltBatch(&This->IDirectDrawSurface7_iface, batch, count, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_BltBatch(IDirectDrawSurface3 *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_BltBatch(&This->IDirectDrawSurface7_iface, batch, count, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_BltBatch(IDirectDrawSurface2 *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_BltBatch(&This->IDirectDrawSurface7_iface, batch, count, flags);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_BltBatch(IDirectDrawSurface *iface, DDBLTBATCH *batch, DWORD count, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, batch %p, count %u, flags %#x.\n", iface, batch, count, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_BltBatch(&This->IDirectDrawSurface7_iface, batch, count, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::EnumAttachedSurfaces
|
|
|
|
*
|
|
|
|
* Enumerates all surfaces attached to this surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* context: Pointer to pass unmodified to the callback
|
|
|
|
* cb: Callback function to call for each surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if cb is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_EnumAttachedSurfaces(IDirectDrawSurface7 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK7 cb)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawSurfaceImpl *surf;
|
|
|
|
DDSURFACEDESC2 desc;
|
2007-04-27 15:31:12 +02:00
|
|
|
int i;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
/* Attached surfaces aren't handled in WineD3D */
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, cb);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!cb)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-04-27 15:31:12 +02:00
|
|
|
for(i = 0; i < MAX_COMPLEX_ATTACHED; i++)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2007-04-27 15:31:12 +02:00
|
|
|
surf = This->complex_array[i];
|
|
|
|
if(!surf) break;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
ddraw_surface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
desc = surf->surface_desc;
|
|
|
|
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
|
2011-06-05 18:55:04 +02:00
|
|
|
if (cb(&surf->IDirectDrawSurface7_iface, &desc, context) == DDENUMRET_CANCEL)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (surf = This->next_attached; surf != NULL; surf = surf->next_attached)
|
|
|
|
{
|
2011-06-05 18:55:04 +02:00
|
|
|
ddraw_surface7_AddRef(&surf->IDirectDrawSurface7_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
desc = surf->surface_desc;
|
|
|
|
/* check: != DDENUMRET_OK or == DDENUMRET_CANCEL? */
|
2011-06-05 18:55:04 +02:00
|
|
|
if (cb(&surf->IDirectDrawSurface7_iface, &desc, context) == DDENUMRET_CANCEL)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE(" end of enumeration.\n");
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
struct callback_info2
|
|
|
|
{
|
|
|
|
LPDDENUMSURFACESCALLBACK2 callback;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
struct callback_info
|
|
|
|
{
|
|
|
|
LPDDENUMSURFACESCALLBACK callback;
|
|
|
|
void *context;
|
|
|
|
};
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT CALLBACK EnumCallback2(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(surface);
|
|
|
|
const struct callback_info2 *info = context;
|
|
|
|
|
2011-06-28 01:34:23 +02:00
|
|
|
ddraw_surface4_AddRef(&This->IDirectDrawSurface4_iface);
|
|
|
|
ddraw_surface7_Release(surface);
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
return info->callback(&This->IDirectDrawSurface4_iface, surface_desc, info->context);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT CALLBACK EnumCallback(IDirectDrawSurface7 *surface, DDSURFACEDESC2 *surface_desc, void *context)
|
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *surface_impl = impl_from_IDirectDrawSurface7(surface);
|
2010-07-19 18:36:20 +02:00
|
|
|
const struct callback_info *info = context;
|
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
ddraw_surface1_AddRef(&surface_impl->IDirectDrawSurface_iface);
|
|
|
|
ddraw_surface7_Release(surface);
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
return info->callback(&surface_impl->IDirectDrawSurface_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
(DDSURFACEDESC *)surface_desc, info->context);
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_EnumAttachedSurfaces(IDirectDrawSurface4 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK2 callback)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct callback_info2 info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&This->IDirectDrawSurface7_iface,
|
|
|
|
&info, EnumCallback2);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_EnumAttachedSurfaces(IDirectDrawSurface3 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&This->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
&info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_EnumAttachedSurfaces(IDirectDrawSurface2 *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&This->IDirectDrawSurface7_iface,
|
|
|
|
&info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_EnumAttachedSurfaces(IDirectDrawSurface *iface,
|
|
|
|
void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, context %p, callback %p.\n", iface, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
|
|
|
return ddraw_surface7_EnumAttachedSurfaces(&This->IDirectDrawSurface7_iface,
|
|
|
|
&info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::EnumOverlayZOrders
|
|
|
|
*
|
|
|
|
* "Enumerates the overlay surfaces on the specified destination"
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDENUMOVERLAYZ_BACKTOFRONT or DDENUMOVERLAYZ_FRONTTOBACK
|
|
|
|
* context: context to pass back to the callback
|
|
|
|
* cb: callback function to call for each enumerated surface
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_EnumOverlayZOrders(IDirectDrawSurface7 *iface,
|
|
|
|
DWORD Flags, void *context, LPDDENUMSURFACESCALLBACK7 cb)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, flags %#x, context %p, callback %p stub!\n", iface, Flags, context, cb);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_EnumOverlayZOrders(IDirectDrawSurface4 *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK2 callback)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
struct callback_info2 info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&This->IDirectDrawSurface7_iface,
|
|
|
|
flags, &info, EnumCallback2);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_EnumOverlayZOrders(IDirectDrawSurface3 *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&This->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
flags, &info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_EnumOverlayZOrders(IDirectDrawSurface2 *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&This->IDirectDrawSurface7_iface,
|
|
|
|
flags, &info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_EnumOverlayZOrders(IDirectDrawSurface *iface,
|
|
|
|
DWORD flags, void *context, LPDDENUMSURFACESCALLBACK callback)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
struct callback_info info;
|
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, context %p, callback %p.\n", iface, flags, context, callback);
|
|
|
|
|
|
|
|
info.callback = callback;
|
|
|
|
info.context = context;
|
|
|
|
|
|
|
|
return ddraw_surface7_EnumOverlayZOrders(&This->IDirectDrawSurface7_iface,
|
|
|
|
flags, &info, EnumCallback);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetBltStatus
|
|
|
|
*
|
|
|
|
* Returns the blitting status
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDGBS_CANBLT or DDGBS_ISBLTDONE
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* See IWineD3DSurface::Blt
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetBltStatus(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-04-14 22:44:55 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_get_blt_status(This->wined3d_surface, Flags);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetBltStatus(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetBltStatus(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetBltStatus(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetBltStatus(&This->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetBltStatus(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetBltStatus(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetBltStatus(IDirectDrawSurface *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetBltStatus(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetColorKey
|
|
|
|
*
|
|
|
|
* Returns the color key assigned to the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: Some flags
|
|
|
|
* CKey: Address to store the key to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if CKey is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetColorKey(IDirectDrawSurface7 *iface, DWORD Flags, DDCOLORKEY *CKey)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, Flags, CKey);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!CKey)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2008-05-05 23:49:32 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
switch (Flags)
|
|
|
|
{
|
|
|
|
case DDCKEY_DESTBLT:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKDESTBLT))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.ddckCKDestBlt;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_DESTOVERLAY:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKDESTOVERLAY))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.u3.ddckCKDestOverlay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCBLT:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKSRCBLT))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.ddckCKSrcBlt;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCOVERLAY:
|
2008-05-05 23:49:32 +02:00
|
|
|
if (!(This->surface_desc.dwFlags & DDSD_CKSRCOVERLAY))
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_NOCOLORKEY;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
*CKey = This->surface_desc.ddckCKSrcOverlay;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetColorKey(IDirectDrawSurface4 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetColorKey(IDirectDrawSurface3 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetColorKey(IDirectDrawSurface2 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetColorKey(IDirectDrawSurface *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetFlipStatus
|
|
|
|
*
|
|
|
|
* Returns the flipping status of the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDGFS_CANFLIP of DDGFS_ISFLIPDONE
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* See IWineD3DSurface::GetFlipStatus
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetFlipStatus(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-04-14 22:44:55 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_get_flip_status(This->wined3d_surface, Flags);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetFlipStatus(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetFlipStatus(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetFlipStatus(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetFlipStatus(&This->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetFlipStatus(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetFlipStatus(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetFlipStatus(IDirectDrawSurface *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetFlipStatus(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetOverlayPosition
|
|
|
|
*
|
|
|
|
* Returns the display coordinates of a visible and active overlay surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* X
|
|
|
|
* Y
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_NOTAOVERLAYSURFACE, because it's a stub
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetOverlayPosition(IDirectDrawSurface7 *iface, LONG *X, LONG *Y)
|
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, X, Y);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_get_overlay_position(This->wined3d_surface, X, Y);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetOverlayPosition(IDirectDrawSurface4 *iface, LONG *x, LONG *y)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetOverlayPosition(IDirectDrawSurface3 *iface, LONG *x, LONG *y)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetOverlayPosition(IDirectDrawSurface2 *iface, LONG *x, LONG *y)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetOverlayPosition(IDirectDrawSurface *iface, LONG *x, LONG *y)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, x %p, y %p.\n", iface, x, y);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetPixelFormat
|
|
|
|
*
|
|
|
|
* Returns the pixel format of the Surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* PixelFormat: Pointer to a DDPIXELFORMAT structure to which the pixel
|
|
|
|
* format should be written
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if PixelFormat is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPixelFormat(IDirectDrawSurface7 *iface, DDPIXELFORMAT *PixelFormat)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
/* What is DDERR_INVALIDSURFACETYPE for here? */
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, PixelFormat);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!PixelFormat)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
DD_STRUCT_COPY_BYSIZE(PixelFormat,&This->surface_desc.u4.ddpfPixelFormat);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetPixelFormat(IDirectDrawSurface4 *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPixelFormat(&This->IDirectDrawSurface7_iface, pixel_format);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetPixelFormat(IDirectDrawSurface3 *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetPixelFormat(&This->IDirectDrawSurface7_iface, pixel_format);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetPixelFormat(IDirectDrawSurface2 *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPixelFormat(&This->IDirectDrawSurface7_iface, pixel_format);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetPixelFormat(IDirectDrawSurface *iface, DDPIXELFORMAT *pixel_format)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, pixel_format %p.\n", iface, pixel_format);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPixelFormat(&This->IDirectDrawSurface7_iface, pixel_format);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetSurfaceDesc
|
|
|
|
*
|
|
|
|
* Returns the description of this surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DDSD: Address of a DDSURFACEDESC2 structure that is to be filled with the
|
|
|
|
* surface desc
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DDSD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetSurfaceDesc(IDirectDrawSurface7 *iface, DDSURFACEDESC2 *DDSD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!DDSD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-06-08 17:22:16 +02:00
|
|
|
if (DDSD->dwSize != sizeof(DDSURFACEDESC2))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2007-06-08 17:22:16 +02:00
|
|
|
WARN("Incorrect struct size %d, returning DDERR_INVALIDPARAMS\n",DDSD->dwSize);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
DD_STRUCT_COPY_BYSIZE(DDSD,&This->surface_desc);
|
|
|
|
TRACE("Returning surface desc:\n");
|
|
|
|
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetSurfaceDesc(IDirectDrawSurface4 *iface, DDSURFACEDESC2 *DDSD)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetSurfaceDesc(&This->IDirectDrawSurface7_iface, DDSD);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetSurfaceDesc(IDirectDrawSurface3 *iface, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, surface_desc);
|
|
|
|
|
|
|
|
if (!surface_desc) return DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
if (surface_desc->dwSize != sizeof(DDSURFACEDESC))
|
|
|
|
{
|
|
|
|
WARN("Incorrect structure size %u, returning DDERR_INVALIDPARAMS.\n", surface_desc->dwSize);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-05-31 14:34:47 +02:00
|
|
|
DD_STRUCT_COPY_BYSIZE(surface_desc, (DDSURFACEDESC *)&This->surface_desc);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("Returning surface desc:\n");
|
|
|
|
if (TRACE_ON(ddraw))
|
|
|
|
{
|
|
|
|
/* DDRAW_dump_surface_desc handles the smaller size */
|
|
|
|
DDRAW_dump_surface_desc((DDSURFACEDESC2 *)surface_desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetSurfaceDesc(IDirectDrawSurface2 *iface, DDSURFACEDESC *DDSD)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
|
|
|
|
|
|
|
return ddraw_surface3_GetSurfaceDesc(&This->IDirectDrawSurface3_iface, DDSD);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetSurfaceDesc(IDirectDrawSurface *iface, DDSURFACEDESC *DDSD)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, surface_desc %p.\n", iface, DDSD);
|
|
|
|
|
|
|
|
return ddraw_surface3_GetSurfaceDesc(&This->IDirectDrawSurface3_iface, DDSD);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Initialize
|
|
|
|
*
|
|
|
|
* Initializes the surface. This is a no-op in Wine
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DD: Pointer to an DirectDraw interface
|
|
|
|
* DDSD: Surface description for initialization
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_ALREADYINITIALIZED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Initialize(IDirectDrawSurface7 *iface,
|
2010-07-19 12:47:57 +02:00
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC2 *surface_desc)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-07-19 12:47:57 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DDERR_ALREADYINITIALIZED;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Initialize(IDirectDrawSurface4 *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC2 *surface_desc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
|
|
|
return ddraw_surface7_Initialize(&This->IDirectDrawSurface7_iface,
|
|
|
|
ddraw, surface_desc);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Initialize(IDirectDrawSurface3 *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_Initialize(&This->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw, (DDSURFACEDESC2 *)surface_desc);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Initialize(IDirectDrawSurface2 *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
|
|
|
return ddraw_surface7_Initialize(&This->IDirectDrawSurface7_iface,
|
|
|
|
ddraw, (DDSURFACEDESC2 *)surface_desc);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Initialize(IDirectDrawSurface *iface,
|
|
|
|
IDirectDraw *ddraw, DDSURFACEDESC *surface_desc)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, ddraw %p, surface_desc %p.\n", iface, ddraw, surface_desc);
|
|
|
|
|
|
|
|
return ddraw_surface7_Initialize(&This->IDirectDrawSurface7_iface,
|
|
|
|
ddraw, (DDSURFACEDESC2 *)surface_desc);
|
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture1::Initialize
|
|
|
|
*
|
|
|
|
* The sdk says it's not implemented
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* ?
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture1_Initialize(IDirect3DTexture *iface,
|
|
|
|
IDirect3DDevice *device, IDirectDrawSurface *surface)
|
|
|
|
{
|
|
|
|
TRACE("iface %p, device %p, surface %p.\n", iface, device, surface);
|
|
|
|
|
|
|
|
return DDERR_UNSUPPORTED; /* Unchecked */
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::IsLost
|
|
|
|
*
|
|
|
|
* Checks if the surface is lost
|
|
|
|
*
|
|
|
|
* Returns:
|
2008-05-06 15:54:52 +02:00
|
|
|
* DD_OK, if the surface is usable
|
2006-06-09 19:36:12 +02:00
|
|
|
* DDERR_ISLOST if the surface is lost
|
|
|
|
* See IWineD3DSurface::IsLost for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_IsLost(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-04-14 22:44:55 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
/* We lose the surface if the implementation was changed */
|
|
|
|
if(This->ImplType != This->ddraw->ImplType)
|
|
|
|
{
|
|
|
|
/* But this shouldn't happen. When we change the implementation,
|
|
|
|
* all surfaces are re-created automatically, and their content
|
|
|
|
* is copied
|
|
|
|
*/
|
|
|
|
ERR(" (%p) Implementation was changed from %d to %d\n", This, This->ImplType, This->ddraw->ImplType);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_SURFACELOST;
|
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_is_lost(This->wined3d_surface);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
/* D3D8 and 9 loose full devices, thus there's only a DEVICELOST error.
|
|
|
|
* WineD3D uses the same error for surfaces
|
|
|
|
*/
|
|
|
|
case WINED3DERR_DEVICELOST: return DDERR_SURFACELOST;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_IsLost(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_IsLost(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_IsLost(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_IsLost(&This->IDirectDrawSurface7_iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_IsLost(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_IsLost(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_IsLost(IDirectDrawSurface *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_IsLost(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::Restore
|
|
|
|
*
|
|
|
|
* Restores a lost surface. This makes the surface usable again, but
|
|
|
|
* doesn't reload its old contents
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* See IWineD3DSurface::Restore for more details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p.\n", iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(This->ImplType != This->ddraw->ImplType)
|
|
|
|
{
|
|
|
|
/* Call the recreation callback. Make sure to AddRef first */
|
|
|
|
IDirectDrawSurface_AddRef(iface);
|
2010-07-19 18:36:19 +02:00
|
|
|
ddraw_recreate_surfaces_cb(iface, &This->surface_desc, NULL /* Not needed */);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_restore(This->wined3d_surface);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_Restore(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_Restore(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_Restore(IDirectDrawSurface3 *iface)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_Restore(&This->IDirectDrawSurface7_iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_Restore(IDirectDrawSurface2 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_Restore(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_Restore(IDirectDrawSurface *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_Restore(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetOverlayPosition
|
|
|
|
*
|
|
|
|
* Changes the display coordinates of an overlay surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* X:
|
|
|
|
* Y:
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_NOTAOVERLAYSURFACE, because we don't support overlays right now
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetOverlayPosition(IDirectDrawSurface7 *iface, LONG X, LONG Y)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, X, Y);
|
2006-10-05 16:37:42 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_overlay_position(This->wined3d_surface, X, Y);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetOverlayPosition(IDirectDrawSurface4 *iface, LONG x, LONG y)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetOverlayPosition(IDirectDrawSurface3 *iface, LONG x, LONG y)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_SetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetOverlayPosition(IDirectDrawSurface2 *iface, LONG x, LONG y)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetOverlayPosition(IDirectDrawSurface *iface, LONG x, LONG y)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, x %d, y %d.\n", iface, x, y);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetOverlayPosition(&This->IDirectDrawSurface7_iface, x, y);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::UpdateOverlay
|
|
|
|
*
|
|
|
|
* Modifies the attributes of an overlay surface.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* SrcRect: The section of the source being used for the overlay
|
|
|
|
* DstSurface: Address of the surface that is overlaid
|
|
|
|
* DstRect: Place of the overlay
|
|
|
|
* Flags: some DDOVER_* flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED, because we don't support overlays
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_UpdateOverlay(IDirectDrawSurface7 *iface, RECT *SrcRect,
|
|
|
|
IDirectDrawSurface7 *DstSurface, RECT *DstRect, DWORD Flags, DDOVERLAYFX *FX)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *Dst = unsafe_impl_from_IDirectDrawSurface7(DstSurface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(SrcRect), DstSurface, wine_dbgstr_rect(DstRect), Flags, FX);
|
2006-10-05 16:43:26 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_update_overlay(This->wined3d_surface, SrcRect,
|
|
|
|
Dst ? Dst->wined3d_surface : NULL, DstRect, Flags, (WINEDDOVERLAYFX *)FX);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2008-08-05 12:19:43 +02:00
|
|
|
switch(hr) {
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
case WINEDDERR_NOTAOVERLAYSURFACE: return DDERR_NOTAOVERLAYSURFACE;
|
|
|
|
case WINEDDERR_OVERLAYNOTVISIBLE: return DDERR_OVERLAYNOTVISIBLE;
|
|
|
|
default:
|
|
|
|
return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_UpdateOverlay(IDirectDrawSurface4 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface4 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface4(dst_surface);
|
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlay(&This->IDirectDrawSurface7_iface, src_rect,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_UpdateOverlay(IDirectDrawSurface3 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface3 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface3(dst_surface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_UpdateOverlay(&This->IDirectDrawSurface7_iface, src_rect,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_UpdateOverlay(IDirectDrawSurface2 *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface2 *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface2(dst_surface);
|
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlay(&This->IDirectDrawSurface7_iface, src_rect,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_UpdateOverlay(IDirectDrawSurface *iface, RECT *src_rect,
|
|
|
|
IDirectDrawSurface *dst_surface, RECT *dst_rect, DWORD flags, DDOVERLAYFX *fx)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *dst_impl = unsafe_impl_from_IDirectDrawSurface(dst_surface);
|
|
|
|
TRACE("iface %p, src_rect %s, dst_surface %p, dst_rect %s, flags %#x, fx %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(src_rect), dst_surface, wine_dbgstr_rect(dst_rect), flags, fx);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlay(&This->IDirectDrawSurface7_iface, src_rect,
|
|
|
|
dst_impl ? &dst_impl->IDirectDrawSurface7_iface : NULL, dst_rect, flags, fx);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::UpdateOverlayDisplay
|
|
|
|
*
|
|
|
|
* The DX7 sdk says that it's not implemented
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: ?
|
|
|
|
*
|
|
|
|
* Returns: DDERR_UNSUPPORTED, because we don't support overlays
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_UpdateOverlayDisplay(IDirectDrawSurface7 *iface, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, Flags);
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_UpdateOverlayDisplay(IDirectDrawSurface4 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_UpdateOverlayDisplay(IDirectDrawSurface3 *iface, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&This->IDirectDrawSurface7_iface, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_UpdateOverlayDisplay(IDirectDrawSurface2 *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_UpdateOverlayDisplay(IDirectDrawSurface *iface, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, flags %#x.\n", iface, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlayDisplay(&This->IDirectDrawSurface7_iface, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::UpdateOverlayZOrder
|
|
|
|
*
|
|
|
|
* Sets an overlay's Z order
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDOVERZ_* flags
|
|
|
|
* DDSRef: Defines the relative position in the overlay chain
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_NOTOVERLAYSURFACE, because we don't support overlays
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_UpdateOverlayZOrder(IDirectDrawSurface7 *iface,
|
|
|
|
DWORD Flags, IDirectDrawSurface7 *DDSRef)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *Ref = unsafe_impl_from_IDirectDrawSurface7(DDSRef);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2006-10-05 16:41:19 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, Flags, DDSRef);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_update_overlay_z_order(This->wined3d_surface,
|
|
|
|
Flags, Ref ? Ref->wined3d_surface : NULL);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_UpdateOverlayZOrder(IDirectDrawSurface4 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface4 *reference)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *reference_impl = unsafe_impl_from_IDirectDrawSurface4(reference);
|
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&This->IDirectDrawSurface7_iface, flags,
|
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_UpdateOverlayZOrder(IDirectDrawSurface3 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface3 *reference)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *reference_impl = unsafe_impl_from_IDirectDrawSurface3(reference);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&This->IDirectDrawSurface7_iface, flags,
|
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_UpdateOverlayZOrder(IDirectDrawSurface2 *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface2 *reference)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *reference_impl = unsafe_impl_from_IDirectDrawSurface2(reference);
|
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&This->IDirectDrawSurface7_iface, flags,
|
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_UpdateOverlayZOrder(IDirectDrawSurface *iface,
|
|
|
|
DWORD flags, IDirectDrawSurface *reference)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *reference_impl = unsafe_impl_from_IDirectDrawSurface(reference);
|
|
|
|
TRACE("iface %p, flags %#x, reference %p.\n", iface, flags, reference);
|
|
|
|
|
|
|
|
return ddraw_surface7_UpdateOverlayZOrder(&This->IDirectDrawSurface7_iface, flags,
|
|
|
|
reference_impl ? &reference_impl->IDirectDrawSurface7_iface : NULL);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetDDInterface
|
|
|
|
*
|
|
|
|
* Returns the IDirectDraw7 interface pointer of the DirectDraw object this
|
|
|
|
* surface belongs to
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DD: Address to write the interface pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetDDInterface(IDirectDrawSurface7 *iface, void **DD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, DD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!DD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2006-07-10 16:06:33 +02:00
|
|
|
switch(This->version)
|
|
|
|
{
|
|
|
|
case 7:
|
2011-01-19 01:42:43 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw7_iface;
|
2006-07-10 16:06:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
2011-01-19 01:40:53 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw4_iface;
|
2007-02-16 19:09:19 +01:00
|
|
|
break;
|
2006-07-10 16:06:33 +02:00
|
|
|
|
|
|
|
case 2:
|
2011-01-19 01:36:36 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw2_iface;
|
2007-02-16 19:09:19 +01:00
|
|
|
break;
|
|
|
|
|
2006-07-10 16:06:33 +02:00
|
|
|
case 1:
|
2011-01-19 01:33:42 +01:00
|
|
|
*DD = &This->ddraw->IDirectDraw_iface;
|
2006-07-10 16:06:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2009-01-21 09:56:13 +01:00
|
|
|
IUnknown_AddRef((IUnknown *)*DD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetDDInterface(IDirectDrawSurface4 *iface, void **ddraw)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, ddraw);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetDDInterface(&This->IDirectDrawSurface7_iface, ddraw);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetDDInterface(IDirectDrawSurface3 *iface, void **ddraw)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, ddraw);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetDDInterface(&This->IDirectDrawSurface7_iface, ddraw);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetDDInterface(IDirectDrawSurface2 *iface, void **ddraw)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, ddraw %p.\n", iface, ddraw);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetDDInterface(&This->IDirectDrawSurface7_iface, ddraw);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* This seems also windows implementation specific - I don't think WineD3D needs this */
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_ChangeUniquenessValue(IDirectDrawSurface7 *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
volatile IDirectDrawSurfaceImpl* vThis = This;
|
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-23 18:18:02 +02:00
|
|
|
/* A uniqueness value of 0 is apparently special.
|
2007-05-30 15:25:34 +02:00
|
|
|
* This needs to be checked.
|
|
|
|
* TODO: Write tests for this code and check if the volatile, interlocked stuff is really needed
|
|
|
|
*/
|
2006-06-09 19:36:12 +02:00
|
|
|
while (1) {
|
|
|
|
DWORD old_uniqueness_value = vThis->uniqueness_value;
|
|
|
|
DWORD new_uniqueness_value = old_uniqueness_value+1;
|
|
|
|
|
|
|
|
if (old_uniqueness_value == 0) break;
|
|
|
|
if (new_uniqueness_value == 0) new_uniqueness_value = 1;
|
|
|
|
|
|
|
|
if (InterlockedCompareExchange((LONG*)&vThis->uniqueness_value,
|
|
|
|
old_uniqueness_value,
|
|
|
|
new_uniqueness_value)
|
|
|
|
== old_uniqueness_value)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_ChangeUniquenessValue(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p.\n", iface);
|
|
|
|
|
|
|
|
return ddraw_surface7_ChangeUniquenessValue(&This->IDirectDrawSurface7_iface);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetUniquenessValue(IDirectDrawSurface7 *iface, DWORD *pValue)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, value %p.\n", iface, pValue);
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
*pValue = This->uniqueness_value;
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetUniquenessValue(IDirectDrawSurface4 *iface, DWORD *pValue)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, value %p.\n", iface, pValue);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetUniquenessValue(&This->IDirectDrawSurface7_iface, pValue);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetLOD
|
|
|
|
*
|
|
|
|
* Sets the level of detail of a texture
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* MaxLOD: LOD to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDOBJECT if the surface is invalid for this method
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetLOD(IDirectDrawSurface7 *iface, DWORD MaxLOD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, lod %u.\n", iface, MaxLOD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDOBJECT;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
if (!This->wined3d_texture)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
|
|
|
ERR("(%p) The DirectDraw texture has no WineD3DTexture!\n", This);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDOBJECT;
|
|
|
|
}
|
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
hr = wined3d_texture_set_lod(This->wined3d_texture, MaxLOD);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetLOD
|
|
|
|
*
|
|
|
|
* Returns the level of detail of a Direct3D texture
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* MaxLOD: Address to write the LOD to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if MaxLOD is NULL
|
|
|
|
* DDERR_INVALIDOBJECT if the surface is invalid for this method
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetLOD(IDirectDrawSurface7 *iface, DWORD *MaxLOD)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, lod %p.\n", iface, MaxLOD);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!MaxLOD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (!(This->surface_desc.ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDOBJECT;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-03-18 19:10:59 +01:00
|
|
|
*MaxLOD = wined3d_texture_get_lod(This->wined3d_texture);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::BltFast
|
|
|
|
*
|
|
|
|
* Performs a fast Blit.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* dstx: The x coordinate to blit to on the destination
|
|
|
|
* dsty: The y coordinate to blit to on the destination
|
|
|
|
* Source: The source surface
|
|
|
|
* rsrc: The source rectangle
|
|
|
|
* trans: Type of transfer. Some DDBLTFAST_* flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* For more details, see IWineD3DSurface::BltFast
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_BltFast(IDirectDrawSurface7 *iface, DWORD dstx, DWORD dsty,
|
|
|
|
IDirectDrawSurface7 *Source, RECT *rsrc, DWORD trans)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *src = unsafe_impl_from_IDirectDrawSurface7(Source);
|
2010-06-24 12:10:03 +02:00
|
|
|
DWORD src_w, src_h, dst_w, dst_h;
|
2007-04-14 22:44:55 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dstx, dsty, Source, wine_dbgstr_rect(rsrc), trans);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2010-06-24 12:10:03 +02:00
|
|
|
dst_w = This->surface_desc.dwWidth;
|
|
|
|
dst_h = This->surface_desc.dwHeight;
|
|
|
|
|
2007-05-24 22:24:00 +02:00
|
|
|
/* Source must be != NULL, This is not checked by windows. Windows happily throws a 0xc0000005
|
|
|
|
* in that case
|
|
|
|
*/
|
|
|
|
if(rsrc)
|
|
|
|
{
|
2010-06-24 12:10:03 +02:00
|
|
|
src_w = rsrc->right - rsrc->left;
|
|
|
|
src_h = rsrc->bottom - rsrc->top;
|
2007-05-24 22:24:00 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-24 12:10:03 +02:00
|
|
|
src_w = src->surface_desc.dwWidth;
|
|
|
|
src_h = src->surface_desc.dwHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src_w > dst_w || dstx > dst_w - src_w
|
|
|
|
|| src_h > dst_h || dsty > dst_h - src_h)
|
|
|
|
{
|
|
|
|
WARN("Destination area out of bounds, returning DDERR_INVALIDRECT.\n");
|
|
|
|
return DDERR_INVALIDRECT;
|
2007-05-24 22:24:00 +02:00
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_bltfast(This->wined3d_surface, dstx, dsty,
|
2011-06-14 13:02:32 +02:00
|
|
|
src->wined3d_surface, rsrc, trans);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-14 22:44:55 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_NOTAVAILABLE: return DDERR_UNSUPPORTED;
|
|
|
|
case WINED3DERR_WRONGTEXTUREFORMAT: return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
default: return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_BltFast(IDirectDrawSurface4 *iface, DWORD dst_x, DWORD dst_y,
|
|
|
|
IDirectDrawSurface4 *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface4(src_surface);
|
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_BltFast(&This->IDirectDrawSurface7_iface, dst_x, dst_y,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_BltFast(IDirectDrawSurface3 *iface, DWORD dst_x, DWORD dst_y,
|
|
|
|
IDirectDrawSurface3 *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface3(src_surface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_BltFast(&This->IDirectDrawSurface7_iface, dst_x, dst_y,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_BltFast(IDirectDrawSurface2 *iface, DWORD dst_x, DWORD dst_y,
|
|
|
|
IDirectDrawSurface2 *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface2(src_surface);
|
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_BltFast(&This->IDirectDrawSurface7_iface, dst_x, dst_y,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_BltFast(IDirectDrawSurface *iface, DWORD dst_x, DWORD dst_y,
|
|
|
|
IDirectDrawSurface *src_surface, RECT *src_rect, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
IDirectDrawSurfaceImpl *src_impl = unsafe_impl_from_IDirectDrawSurface(src_surface);
|
|
|
|
TRACE("iface %p, dst_x %u, dst_y %u, src_surface %p, src_rect %s, flags %#x.\n",
|
|
|
|
iface, dst_x, dst_y, src_surface, wine_dbgstr_rect(src_rect), flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_BltFast(&This->IDirectDrawSurface7_iface, dst_x, dst_y,
|
|
|
|
src_impl ? &src_impl->IDirectDrawSurface7_iface : NULL, src_rect, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetClipper
|
|
|
|
*
|
|
|
|
* Returns the IDirectDrawClipper interface of the clipper assigned to this
|
|
|
|
* surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Clipper: Address to store the interface pointer at
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Clipper is NULL
|
|
|
|
* DDERR_NOCLIPPERATTACHED if there's no clipper attached
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetClipper(IDirectDrawSurface7 *iface, IDirectDrawClipper **Clipper)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, Clipper);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Clipper)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if(This->clipper == NULL)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DDERR_NOCLIPPERATTACHED;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2009-01-21 09:56:13 +01:00
|
|
|
*Clipper = (IDirectDrawClipper *)This->clipper;
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawClipper_AddRef(*Clipper);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetClipper(IDirectDrawSurface3 *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetClipper(IDirectDrawSurface2 *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetClipper(IDirectDrawSurface *iface, IDirectDrawClipper **clipper)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetClipper
|
|
|
|
*
|
|
|
|
* Sets a clipper for the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Clipper: IDirectDrawClipper interface of the clipper to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:22:55 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetClipper(IDirectDrawSurface7 *iface,
|
|
|
|
IDirectDrawClipper *iclipper)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-06-20 11:22:55 +02:00
|
|
|
IDirectDrawClipperImpl *clipper = unsafe_impl_from_IDirectDrawClipper(iclipper);
|
2007-02-16 19:08:21 +01:00
|
|
|
IDirectDrawClipperImpl *oldClipper = This->clipper;
|
2008-08-07 21:09:19 +02:00
|
|
|
HWND clipWindow;
|
2007-05-30 15:25:34 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-20 11:22:55 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, iclipper);
|
2007-05-30 15:25:34 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-06-20 11:22:55 +02:00
|
|
|
if (clipper == This->clipper)
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
2007-05-30 15:25:34 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-06-20 11:22:55 +02:00
|
|
|
This->clipper = clipper;
|
2007-02-16 19:08:21 +01:00
|
|
|
|
2011-06-20 11:22:55 +02:00
|
|
|
if (clipper != NULL)
|
|
|
|
IDirectDrawClipper_AddRef(iclipper);
|
2007-02-16 19:08:21 +01:00
|
|
|
if(oldClipper)
|
2011-06-20 11:20:41 +02:00
|
|
|
IDirectDrawClipper_Release(&oldClipper->IDirectDrawClipper_iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_clipper(This->wined3d_surface,
|
|
|
|
This->clipper ? This->clipper->wineD3DClipper : NULL);
|
2008-08-07 21:09:19 +02:00
|
|
|
|
2011-04-13 19:14:31 +02:00
|
|
|
if (This->wined3d_swapchain)
|
|
|
|
{
|
2008-08-07 21:09:19 +02:00
|
|
|
clipWindow = NULL;
|
2011-06-20 11:22:55 +02:00
|
|
|
if(clipper) {
|
|
|
|
IDirectDrawClipper_GetHWnd(iclipper, &clipWindow);
|
2008-08-07 21:09:19 +02:00
|
|
|
}
|
|
|
|
|
2011-04-13 19:14:31 +02:00
|
|
|
if (clipWindow)
|
|
|
|
wined3d_swapchain_set_window(This->wined3d_swapchain, clipWindow);
|
|
|
|
else
|
|
|
|
wined3d_swapchain_set_window(This->wined3d_swapchain, This->ddraw->d3d_window);
|
2008-08-07 21:09:19 +02:00
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetClipper(IDirectDrawSurface4 *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetClipper(IDirectDrawSurface3 *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_SetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetClipper(IDirectDrawSurface2 *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetClipper(IDirectDrawSurface *iface, IDirectDrawClipper *clipper)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, clipper %p.\n", iface, clipper);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetClipper(&This->IDirectDrawSurface7_iface, clipper);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetSurfaceDesc
|
|
|
|
*
|
|
|
|
* Sets the surface description. It can override the pixel format, the surface
|
|
|
|
* memory, ...
|
|
|
|
* It's not really tested.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* DDSD: Pointer to the new surface description to set
|
|
|
|
* Flags: Some flags
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if DDSD is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, DDSURFACEDESC2 *DDSD, DWORD Flags)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2010-08-23 18:28:10 +02:00
|
|
|
enum wined3d_format_id newFormat = WINED3DFMT_UNKNOWN;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, DDSD, Flags);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!DDSD)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_PIXELFORMAT)
|
|
|
|
{
|
|
|
|
newFormat = PixelFormat_DD2WineD3D(&DDSD->u4.ddpfPixelFormat);
|
2006-06-23 17:13:10 +02:00
|
|
|
|
|
|
|
if(newFormat == WINED3DFMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
ERR("Requested to set an unknown pixelformat\n");
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-23 17:13:10 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
if(newFormat != PixelFormat_DD2WineD3D(&This->surface_desc.u4.ddpfPixelFormat) )
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_format(This->wined3d_surface, newFormat);
|
|
|
|
if (FAILED(hr))
|
2007-05-30 15:25:34 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-06-23 17:13:10 +02:00
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2006-06-23 17:13:10 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_CKDESTOVERLAY)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_DESTOVERLAY,
|
|
|
|
(WINEDDCOLORKEY *)&DDSD->u3.ddckCKDestOverlay);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2006-06-23 17:13:10 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_CKDESTBLT)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_DESTBLT,
|
|
|
|
(WINEDDCOLORKEY *)&DDSD->ddckCKDestBlt);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2006-06-23 17:13:10 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_CKSRCOVERLAY)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_SRCOVERLAY,
|
|
|
|
(WINEDDCOLORKEY *)&DDSD->ddckCKSrcOverlay);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2006-06-23 17:13:10 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_CKSRCBLT)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(This->wined3d_surface, DDCKEY_SRCBLT,
|
|
|
|
(WINEDDCOLORKEY *)&DDSD->ddckCKSrcBlt);
|
2006-06-23 17:13:10 +02:00
|
|
|
}
|
2007-05-07 19:42:07 +02:00
|
|
|
if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface)
|
2006-07-25 16:38:02 +02:00
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_mem(This->wined3d_surface, DDSD->lpSurface);
|
|
|
|
if (FAILED(hr))
|
2006-07-25 16:38:02 +02:00
|
|
|
{
|
|
|
|
/* No need for a trace here, wined3d does that for us */
|
2007-05-07 19:42:07 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
2009-01-09 23:09:07 +01:00
|
|
|
case WINED3DERR_INVALIDCALL:
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
default:
|
|
|
|
break; /* Go on */
|
2007-05-07 19:42:07 +02:00
|
|
|
}
|
2006-07-25 16:38:02 +02:00
|
|
|
}
|
|
|
|
}
|
2006-06-23 17:13:10 +02:00
|
|
|
|
|
|
|
This->surface_desc = *DDSD;
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetSurfaceDesc(IDirectDrawSurface4 *iface,
|
|
|
|
DDSURFACEDESC2 *surface_desc, DWORD flags)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, surface_desc, flags);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetSurfaceDesc(&This->IDirectDrawSurface7_iface,
|
|
|
|
surface_desc, flags);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetSurfaceDesc(IDirectDrawSurface3 *iface,
|
|
|
|
DDSURFACEDESC *surface_desc, DWORD flags)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, surface_desc, flags);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_SetSurfaceDesc(&This->IDirectDrawSurface7_iface,
|
2010-07-19 18:36:20 +02:00
|
|
|
(DDSURFACEDESC2 *)surface_desc, flags);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::GetPalette
|
|
|
|
*
|
|
|
|
* Returns the IDirectDrawPalette interface of the palette currently assigned
|
|
|
|
* to the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Pal: Address to write the interface pointer to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Pal is NULL
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_GetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette **Pal)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2011-02-02 20:22:52 +01:00
|
|
|
struct wined3d_palette *wined3d_palette;
|
2011-04-29 13:03:41 +02:00
|
|
|
HRESULT hr = DD_OK;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, Pal);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
|
|
|
if(!Pal)
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_palette = wined3d_surface_get_palette(This->wined3d_surface);
|
2011-02-02 20:22:52 +01:00
|
|
|
if (wined3d_palette)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-02-02 20:22:52 +01:00
|
|
|
*Pal = wined3d_palette_get_parent(wined3d_palette);
|
2010-08-31 18:41:40 +02:00
|
|
|
IDirectDrawPalette_AddRef(*Pal);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*Pal = NULL;
|
2006-09-09 13:45:19 +02:00
|
|
|
hr = DDERR_NOPALETTEATTACHED;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_GetPalette(IDirectDrawSurface4 *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPalette(&This->IDirectDrawSurface7_iface, palette);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_GetPalette(IDirectDrawSurface3 *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_GetPalette(&This->IDirectDrawSurface7_iface, palette);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_GetPalette(IDirectDrawSurface2 *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPalette(&This->IDirectDrawSurface7_iface, palette);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_GetPalette(IDirectDrawSurface *iface, IDirectDrawPalette **palette)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
|
|
|
return ddraw_surface7_GetPalette(&This->IDirectDrawSurface7_iface, palette);
|
|
|
|
}
|
|
|
|
|
2007-04-22 21:15:30 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* SetColorKeyEnum
|
|
|
|
*
|
|
|
|
* EnumAttachedSurface callback for SetColorKey. Used to set color keys
|
|
|
|
* recursively in the surface tree
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
struct SCKContext
|
|
|
|
{
|
|
|
|
HRESULT ret;
|
|
|
|
WINEDDCOLORKEY *CKey;
|
|
|
|
DWORD Flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
SetColorKeyEnum(IDirectDrawSurface7 *surface,
|
|
|
|
DDSURFACEDESC2 *desc,
|
|
|
|
void *context)
|
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(surface);
|
2007-04-22 21:15:30 +02:00
|
|
|
struct SCKContext *ctx = context;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_color_key(This->wined3d_surface, ctx->Flags, ctx->CKey);
|
|
|
|
if (FAILED(hr))
|
2007-04-22 21:15:30 +02:00
|
|
|
{
|
|
|
|
WARN("IWineD3DSurface_SetColorKey failed, hr = %08x\n", hr);
|
|
|
|
ctx->ret = hr;
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_EnumAttachedSurfaces(surface, context, SetColorKeyEnum);
|
|
|
|
ddraw_surface7_Release(surface);
|
|
|
|
|
2007-04-22 21:15:30 +02:00
|
|
|
return DDENUMRET_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetColorKey
|
|
|
|
*
|
|
|
|
* Sets the color keying options for the surface. Observations showed that
|
|
|
|
* in case of complex surfaces the color key has to be assigned to all
|
|
|
|
* sublevels.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Flags: DDCKEY_*
|
|
|
|
* CKey: The new color key
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* See IWineD3DSurface::SetColorKey for details
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetColorKey(IDirectDrawSurface7 *iface, DWORD Flags, DDCOLORKEY *CKey)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2009-10-15 00:06:26 +02:00
|
|
|
DDCOLORKEY FixedCKey;
|
|
|
|
struct SCKContext ctx = { DD_OK, (WINEDDCOLORKEY *) (CKey ? &FixedCKey : NULL), Flags };
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, Flags, CKey);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-12-09 23:13:14 +01:00
|
|
|
if (CKey)
|
|
|
|
{
|
2009-10-15 00:06:26 +02:00
|
|
|
FixedCKey = *CKey;
|
|
|
|
/* Handle case where dwColorSpaceHighValue < dwColorSpaceLowValue */
|
|
|
|
if (FixedCKey.dwColorSpaceHighValue < FixedCKey.dwColorSpaceLowValue)
|
|
|
|
FixedCKey.dwColorSpaceHighValue = FixedCKey.dwColorSpaceLowValue;
|
|
|
|
|
2006-12-09 23:13:14 +01:00
|
|
|
switch (Flags & ~DDCKEY_COLORSPACE)
|
|
|
|
{
|
|
|
|
case DDCKEY_DESTBLT:
|
2009-10-15 00:06:26 +02:00
|
|
|
This->surface_desc.ddckCKDestBlt = FixedCKey;
|
2006-12-09 23:13:14 +01:00
|
|
|
This->surface_desc.dwFlags |= DDSD_CKDESTBLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_DESTOVERLAY:
|
2009-10-15 00:06:26 +02:00
|
|
|
This->surface_desc.u3.ddckCKDestOverlay = FixedCKey;
|
2006-12-09 23:13:14 +01:00
|
|
|
This->surface_desc.dwFlags |= DDSD_CKDESTOVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCOVERLAY:
|
2009-10-15 00:06:26 +02:00
|
|
|
This->surface_desc.ddckCKSrcOverlay = FixedCKey;
|
2006-12-09 23:13:14 +01:00
|
|
|
This->surface_desc.dwFlags |= DDSD_CKSRCOVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCBLT:
|
2009-10-15 00:06:26 +02:00
|
|
|
This->surface_desc.ddckCKSrcBlt = FixedCKey;
|
2006-12-09 23:13:14 +01:00
|
|
|
This->surface_desc.dwFlags |= DDSD_CKSRCBLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-12-09 23:13:14 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (Flags & ~DDCKEY_COLORSPACE)
|
|
|
|
{
|
|
|
|
case DDCKEY_DESTBLT:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKDESTBLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_DESTOVERLAY:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKDESTOVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCOVERLAY:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKSRCOVERLAY;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DDCKEY_SRCBLT:
|
|
|
|
This->surface_desc.dwFlags &= ~DDSD_CKSRCBLT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-12-09 23:13:14 +01:00
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
}
|
2011-04-29 13:03:41 +02:00
|
|
|
ctx.ret = wined3d_surface_set_color_key(This->wined3d_surface, Flags, ctx.CKey);
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_EnumAttachedSurfaces(iface, &ctx, SetColorKeyEnum);
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-22 21:15:30 +02:00
|
|
|
switch(ctx.ret)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2007-04-22 21:15:30 +02:00
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
default: return ctx.ret;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetColorKey(IDirectDrawSurface4 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetColorKey(IDirectDrawSurface3 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_SetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetColorKey(IDirectDrawSurface2 *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetColorKey(IDirectDrawSurface *iface, DWORD flags, DDCOLORKEY *color_key)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, flags %#x, color_key %p.\n", iface, flags, color_key);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetColorKey(&This->IDirectDrawSurface7_iface, flags, color_key);
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawSurface7::SetPalette
|
|
|
|
*
|
|
|
|
* Assigns a DirectDrawPalette object to the surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* Pal: Interface to the palette to set
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface7_SetPalette(IDirectDrawSurface7 *iface, IDirectDrawPalette *Pal)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-06 12:57:55 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface7(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawPalette *oldPal;
|
|
|
|
IDirectDrawSurfaceImpl *surf;
|
2009-01-22 10:33:37 +01:00
|
|
|
IDirectDrawPaletteImpl *PalImpl = (IDirectDrawPaletteImpl *)Pal;
|
2006-06-09 19:36:12 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, Pal);
|
2006-06-09 19:36:12 +02:00
|
|
|
|
2008-03-23 00:59:01 +01:00
|
|
|
if (!(This->surface_desc.u4.ddpfPixelFormat.dwFlags & (DDPF_PALETTEINDEXED1 | DDPF_PALETTEINDEXED2 |
|
|
|
|
DDPF_PALETTEINDEXED4 | DDPF_PALETTEINDEXED8 | DDPF_PALETTEINDEXEDTO8))) {
|
|
|
|
return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
}
|
|
|
|
|
2011-08-08 00:26:00 +02:00
|
|
|
if (!This->is_complex_root)
|
|
|
|
{
|
|
|
|
return DDERR_NOTONMIPMAPSUBLEVEL;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/* Find the old palette */
|
2007-05-30 15:25:34 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
hr = IDirectDrawSurface_GetPalette(iface, &oldPal);
|
2007-05-30 15:25:34 +02:00
|
|
|
if(hr != DD_OK && hr != DDERR_NOPALETTEATTACHED)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
|
|
|
}
|
2006-06-09 19:36:12 +02:00
|
|
|
if(oldPal) IDirectDrawPalette_Release(oldPal); /* For the GetPalette */
|
|
|
|
|
|
|
|
/* Set the new Palette */
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_palette(This->wined3d_surface, PalImpl ? PalImpl->wineD3DPalette : NULL);
|
2006-06-09 19:36:12 +02:00
|
|
|
/* AddRef the Palette */
|
|
|
|
if(Pal) IDirectDrawPalette_AddRef(Pal);
|
|
|
|
|
|
|
|
/* Release the old palette */
|
|
|
|
if(oldPal) IDirectDrawPalette_Release(oldPal);
|
|
|
|
|
2007-04-23 21:28:06 +02:00
|
|
|
/* If this is a front buffer, also update the back buffers
|
|
|
|
* TODO: How do things work for palettized cube textures?
|
|
|
|
*/
|
2006-06-09 19:36:12 +02:00
|
|
|
if(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
|
|
|
|
{
|
2007-04-23 21:28:06 +02:00
|
|
|
/* For primary surfaces the tree is just a list, so the simpler scheme fits too */
|
|
|
|
DDSCAPS2 caps2 = { DDSCAPS_PRIMARYSURFACE, 0, 0, 0 };
|
|
|
|
|
|
|
|
surf = This;
|
|
|
|
while(1)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2007-04-23 21:28:06 +02:00
|
|
|
IDirectDrawSurface7 *attach;
|
|
|
|
HRESULT hr;
|
2011-06-05 18:55:04 +02:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surf->IDirectDrawSurface7_iface, &caps2, &attach);
|
2007-04-23 21:28:06 +02:00
|
|
|
if(hr != DD_OK)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-04-27 15:31:12 +02:00
|
|
|
TRACE("Setting palette on %p\n", attach);
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_SetPalette(attach, Pal);
|
2011-06-06 12:57:55 +02:00
|
|
|
surf = impl_from_IDirectDrawSurface7(attach);
|
2010-07-19 18:36:20 +02:00
|
|
|
ddraw_surface7_Release(attach);
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-30 15:25:34 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2006-06-09 19:36:12 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface4_SetPalette(IDirectDrawSurface4 *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface4(iface);
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetPalette(&This->IDirectDrawSurface7_iface, palette);
|
|
|
|
}
|
|
|
|
|
2010-07-19 18:36:20 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface3_SetPalette(IDirectDrawSurface3 *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
2011-05-31 14:34:47 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface3(iface);
|
2010-07-19 18:36:20 +02:00
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
return ddraw_surface7_SetPalette(&This->IDirectDrawSurface7_iface, palette);
|
2010-07-19 18:36:20 +02:00
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface2_SetPalette(IDirectDrawSurface2 *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface2(iface);
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetPalette(&This->IDirectDrawSurface7_iface, palette);
|
|
|
|
}
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static HRESULT WINAPI ddraw_surface1_SetPalette(IDirectDrawSurface *iface, IDirectDrawPalette *palette)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirectDrawSurface(iface);
|
|
|
|
TRACE("iface %p, palette %p.\n", iface, palette);
|
|
|
|
|
|
|
|
return ddraw_surface7_SetPalette(&This->IDirectDrawSurface7_iface, palette);
|
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:18 +02:00
|
|
|
/**********************************************************
|
|
|
|
* IDirectDrawGammaControl::GetGammaRamp
|
|
|
|
*
|
|
|
|
* Returns the current gamma ramp for a surface
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* flags: Ignored
|
|
|
|
* gamma_ramp: Address to write the ramp to
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if gamma_ramp is NULL
|
|
|
|
*
|
|
|
|
**********************************************************/
|
|
|
|
static HRESULT WINAPI ddraw_gamma_control_GetGammaRamp(IDirectDrawGammaControl *iface,
|
|
|
|
DWORD flags, DDGAMMARAMP *gamma_ramp)
|
|
|
|
{
|
2011-06-08 17:23:17 +02:00
|
|
|
IDirectDrawSurfaceImpl *surface = impl_from_IDirectDrawGammaControl(iface);
|
2010-08-18 19:26:18 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, gamma_ramp %p.\n", iface, flags, gamma_ramp);
|
|
|
|
|
|
|
|
if (!gamma_ramp)
|
|
|
|
{
|
|
|
|
WARN("Invalid gamma_ramp passed.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP. */
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_get_gamma_ramp(surface->ddraw->wined3d_device, 0, (WINED3DGAMMARAMP *)gamma_ramp);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Not implemented for non-primary surfaces.\n");
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
* IDirectDrawGammaControl::SetGammaRamp
|
|
|
|
*
|
|
|
|
* Sets the red, green and blue gamma ramps for
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* flags: Can be DDSGR_CALIBRATE to request calibration
|
|
|
|
* gamma_ramp: Structure containing the new gamma ramp
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if gamma_ramp is NULL
|
|
|
|
*
|
|
|
|
**********************************************************/
|
|
|
|
static HRESULT WINAPI ddraw_gamma_control_SetGammaRamp(IDirectDrawGammaControl *iface,
|
|
|
|
DWORD flags, DDGAMMARAMP *gamma_ramp)
|
|
|
|
{
|
2011-06-08 17:23:17 +02:00
|
|
|
IDirectDrawSurfaceImpl *surface = impl_from_IDirectDrawGammaControl(iface);
|
2010-08-18 19:26:18 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, gamma_ramp %p.\n", iface, flags, gamma_ramp);
|
|
|
|
|
|
|
|
if (!gamma_ramp)
|
|
|
|
{
|
|
|
|
WARN("Invalid gamma_ramp passed.\n");
|
|
|
|
return DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
|
|
|
{
|
|
|
|
/* Note: DDGAMMARAMP is compatible with WINED3DGAMMARAMP */
|
2011-05-16 23:01:22 +02:00
|
|
|
wined3d_device_set_gamma_ramp(surface->ddraw->wined3d_device, 0, flags, (WINED3DGAMMARAMP *)gamma_ramp);
|
2010-08-18 19:26:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Not implemented for non-primary surfaces.\n");
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-18 19:26:19 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture2::PaletteChanged
|
|
|
|
*
|
|
|
|
* Informs the texture about a palette change
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* start: Start index of the change
|
|
|
|
* count: The number of changed entries
|
|
|
|
*
|
|
|
|
* Returns
|
|
|
|
* D3D_OK, because it's a stub
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture2_PaletteChanged(IDirect3DTexture2 *iface, DWORD start, DWORD count)
|
|
|
|
{
|
|
|
|
FIXME("iface %p, start %u, count %u stub!\n", iface, start, count);
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_PaletteChanged(IDirect3DTexture *iface, DWORD start, DWORD count)
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
IDirectDrawSurfaceImpl *surface = impl_from_IDirect3DTexture(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, start %u, count %u.\n", iface, start, count);
|
|
|
|
|
2011-07-29 17:55:50 +02:00
|
|
|
return d3d_texture2_PaletteChanged(&surface->IDirect3DTexture2_iface, start, count);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture::Unload
|
|
|
|
*
|
|
|
|
* DX5 SDK: "The IDirect3DTexture2::Unload method is not implemented
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* DDERR_UNSUPPORTED
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture1_Unload(IDirect3DTexture *iface)
|
|
|
|
{
|
|
|
|
WARN("iface %p. Not implemented.\n", iface);
|
|
|
|
|
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture2::GetHandle
|
|
|
|
*
|
|
|
|
* Returns handle for the texture. At the moment, the interface
|
|
|
|
* to the IWineD3DTexture is used.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* device: Device this handle is assigned to
|
|
|
|
* handle: Address to store the handle at.
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture2_GetHandle(IDirect3DTexture2 *iface,
|
|
|
|
IDirect3DDevice2 *device, D3DTEXTUREHANDLE *handle)
|
|
|
|
{
|
2011-07-29 17:52:33 +02:00
|
|
|
IDirectDrawSurfaceImpl *surface = impl_from_IDirect3DTexture2(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
if (!surface->Handle)
|
|
|
|
{
|
|
|
|
DWORD h = ddraw_allocate_handle(&device_from_device2(device)->handle_table, surface, DDRAW_HANDLE_SURFACE);
|
|
|
|
if (h == DDRAW_INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate a texture handle.\n");
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->Handle = h + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Returning handle %08x.\n", surface->Handle);
|
|
|
|
*handle = surface->Handle;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_GetHandle(IDirect3DTexture *iface,
|
|
|
|
IDirect3DDevice *device, D3DTEXTUREHANDLE *handle)
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
IDirectDrawSurfaceImpl *This = impl_from_IDirect3DTexture(iface);
|
2010-08-18 19:26:19 +02:00
|
|
|
IDirect3DDevice2 *device2 = (IDirect3DDevice2 *)&device_from_device1(device)->IDirect3DDevice2_vtbl;
|
|
|
|
|
|
|
|
TRACE("iface %p, device %p, handle %p.\n", iface, device, handle);
|
|
|
|
|
2011-07-29 17:55:50 +02:00
|
|
|
return d3d_texture2_GetHandle(&This->IDirect3DTexture2_iface, device2, handle);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* get_sub_mimaplevel
|
|
|
|
*
|
|
|
|
* Helper function that returns the next mipmap level
|
|
|
|
*
|
|
|
|
* tex_ptr: Surface of which to return the next level
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static IDirectDrawSurfaceImpl *get_sub_mimaplevel(IDirectDrawSurfaceImpl *surface)
|
|
|
|
{
|
|
|
|
/* Now go down the mipmap chain to the next surface */
|
|
|
|
static DDSCAPS2 mipmap_caps = { DDSCAPS_MIPMAP | DDSCAPS_TEXTURE, 0, 0, 0 };
|
|
|
|
IDirectDrawSurface7 *next_level;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
hr = ddraw_surface7_GetAttachedSurface(&surface->IDirectDrawSurface7_iface, &mipmap_caps, &next_level);
|
2010-08-18 19:26:19 +02:00
|
|
|
if (FAILED(hr)) return NULL;
|
|
|
|
|
|
|
|
ddraw_surface7_Release(next_level);
|
|
|
|
|
2011-06-06 12:57:55 +02:00
|
|
|
return impl_from_IDirectDrawSurface7(next_level);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* IDirect3DTexture2::Load
|
|
|
|
*
|
|
|
|
* Loads a texture created with the DDSCAPS_ALLOCONLOAD
|
|
|
|
*
|
|
|
|
* This function isn't relayed to WineD3D because the whole interface is
|
|
|
|
* implemented in DDraw only. For speed improvements a implementation which
|
|
|
|
* takes OpenGL more into account could be placed into WineD3D.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* src_texture: Address of the texture to load
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* D3D_OK on success
|
|
|
|
* D3DERR_TEXTURE_LOAD_FAILED.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTexture2 *src_texture)
|
|
|
|
{
|
2011-07-29 17:52:33 +02:00
|
|
|
IDirectDrawSurfaceImpl *dst_surface = impl_from_IDirect3DTexture2(iface);
|
2011-07-29 15:30:32 +02:00
|
|
|
IDirectDrawSurfaceImpl *src_surface = unsafe_impl_from_IDirect3DTexture2(src_texture);
|
2010-08-18 19:26:19 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("iface %p, src_texture %p.\n", iface, src_texture);
|
|
|
|
|
|
|
|
if (src_surface == dst_surface)
|
|
|
|
{
|
|
|
|
TRACE("copying surface %p to surface %p, why?\n", src_surface, dst_surface);
|
|
|
|
return D3D_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
if (((src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
!= (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP))
|
|
|
|
|| (src_surface->surface_desc.u2.dwMipMapCount != dst_surface->surface_desc.u2.dwMipMapCount))
|
|
|
|
{
|
|
|
|
ERR("Trying to load surfaces with different mip-map counts.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2011-02-02 20:22:52 +01:00
|
|
|
struct wined3d_palette *wined3d_dst_pal, *wined3d_src_pal;
|
2010-08-18 19:26:19 +02:00
|
|
|
IDirectDrawPalette *dst_pal = NULL, *src_pal = NULL;
|
|
|
|
DDSURFACEDESC *src_desc, *dst_desc;
|
|
|
|
|
|
|
|
TRACE("Copying surface %p to surface %p (mipmap level %d).\n",
|
|
|
|
src_surface, dst_surface, src_surface->mipmap_level);
|
|
|
|
|
|
|
|
/* Suppress the ALLOCONLOAD flag */
|
|
|
|
dst_surface->surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_ALLOCONLOAD;
|
|
|
|
|
|
|
|
/* Get the palettes */
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_dst_pal = wined3d_surface_get_palette(dst_surface->wined3d_surface);
|
2011-02-02 20:22:52 +01:00
|
|
|
if (wined3d_dst_pal)
|
|
|
|
dst_pal = wined3d_palette_get_parent(wined3d_dst_pal);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_src_pal = wined3d_surface_get_palette(src_surface->wined3d_surface);
|
2011-02-02 20:22:52 +01:00
|
|
|
if (wined3d_src_pal)
|
|
|
|
src_pal = wined3d_palette_get_parent(wined3d_src_pal);
|
2010-08-18 19:26:19 +02:00
|
|
|
|
|
|
|
if (src_pal)
|
|
|
|
{
|
|
|
|
PALETTEENTRY palent[256];
|
|
|
|
|
|
|
|
if (!dst_pal)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_NOPALETTEATTACHED;
|
|
|
|
}
|
|
|
|
IDirectDrawPalette_GetEntries(src_pal, 0, 0, 256, palent);
|
|
|
|
IDirectDrawPalette_SetEntries(dst_pal, 0, 0, 256, palent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy one surface on the other */
|
|
|
|
dst_desc = (DDSURFACEDESC *)&(dst_surface->surface_desc);
|
|
|
|
src_desc = (DDSURFACEDESC *)&(src_surface->surface_desc);
|
|
|
|
|
|
|
|
if ((src_desc->dwWidth != dst_desc->dwWidth) || (src_desc->dwHeight != dst_desc->dwHeight))
|
|
|
|
{
|
|
|
|
/* Should also check for same pixel format, u1.lPitch, ... */
|
|
|
|
ERR("Error in surface sizes.\n");
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return D3DERR_TEXTURE_LOAD_FAILED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WINED3DLOCKED_RECT src_rect, dst_rect;
|
|
|
|
|
|
|
|
/* Copy also the ColorKeying stuff */
|
|
|
|
if (src_desc->dwFlags & DDSD_CKSRCBLT)
|
|
|
|
{
|
|
|
|
dst_desc->dwFlags |= DDSD_CKSRCBLT;
|
|
|
|
dst_desc->ddckCKSrcBlt.dwColorSpaceLowValue = src_desc->ddckCKSrcBlt.dwColorSpaceLowValue;
|
|
|
|
dst_desc->ddckCKSrcBlt.dwColorSpaceHighValue = src_desc->ddckCKSrcBlt.dwColorSpaceHighValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the main memory texture into the surface that corresponds
|
|
|
|
* to the OpenGL texture object. */
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_map(src_surface->wined3d_surface, &src_rect, NULL, 0);
|
2010-08-18 19:26:19 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to lock source surface, hr %#x.\n", hr);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return D3DERR_TEXTURE_LOAD_FAILED;
|
|
|
|
}
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_map(dst_surface->wined3d_surface, &dst_rect, NULL, 0);
|
2010-08-18 19:26:19 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to lock destination surface, hr %#x.\n", hr);
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_unmap(src_surface->wined3d_surface);
|
2010-08-18 19:26:19 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return D3DERR_TEXTURE_LOAD_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dst_surface->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_FOURCC)
|
|
|
|
memcpy(dst_rect.pBits, src_rect.pBits, src_surface->surface_desc.u1.dwLinearSize);
|
|
|
|
else
|
|
|
|
memcpy(dst_rect.pBits, src_rect.pBits, src_rect.Pitch * src_desc->dwHeight);
|
|
|
|
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_unmap(src_surface->wined3d_surface);
|
|
|
|
wined3d_surface_unmap(dst_surface->wined3d_surface);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
src_surface = get_sub_mimaplevel(src_surface);
|
|
|
|
else
|
|
|
|
src_surface = NULL;
|
|
|
|
|
|
|
|
if (dst_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
dst_surface = get_sub_mimaplevel(dst_surface);
|
|
|
|
else
|
|
|
|
dst_surface = NULL;
|
|
|
|
|
|
|
|
if (!src_surface || !dst_surface)
|
|
|
|
{
|
|
|
|
if (src_surface != dst_surface)
|
|
|
|
ERR("Loading surface with different mipmap structure.\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI d3d_texture1_Load(IDirect3DTexture *iface, IDirect3DTexture *src_texture)
|
|
|
|
{
|
2011-07-27 16:45:13 +02:00
|
|
|
IDirectDrawSurfaceImpl* This = impl_from_IDirect3DTexture(iface);
|
2011-07-27 16:43:24 +02:00
|
|
|
IDirectDrawSurfaceImpl* src_surface = unsafe_impl_from_IDirect3DTexture(src_texture);
|
2010-08-18 19:26:19 +02:00
|
|
|
TRACE("iface %p, src_texture %p.\n", iface, src_texture);
|
|
|
|
|
2011-07-29 17:55:50 +02:00
|
|
|
return d3d_texture2_Load(&This->IDirect3DTexture2_iface,
|
|
|
|
src_surface ? &src_surface->IDirect3DTexture2_iface : NULL);
|
2010-08-18 19:26:19 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* The VTable
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirectDrawSurface7Vtbl ddraw_surface7_vtbl =
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2010-07-19 18:36:20 +02:00
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface7_QueryInterface,
|
|
|
|
ddraw_surface7_AddRef,
|
|
|
|
ddraw_surface7_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface7_AddAttachedSurface,
|
|
|
|
ddraw_surface7_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface7_Blt,
|
|
|
|
ddraw_surface7_BltBatch,
|
|
|
|
ddraw_surface7_BltFast,
|
|
|
|
ddraw_surface7_DeleteAttachedSurface,
|
|
|
|
ddraw_surface7_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface7_EnumOverlayZOrders,
|
|
|
|
ddraw_surface7_Flip,
|
|
|
|
ddraw_surface7_GetAttachedSurface,
|
|
|
|
ddraw_surface7_GetBltStatus,
|
|
|
|
ddraw_surface7_GetCaps,
|
|
|
|
ddraw_surface7_GetClipper,
|
|
|
|
ddraw_surface7_GetColorKey,
|
|
|
|
ddraw_surface7_GetDC,
|
|
|
|
ddraw_surface7_GetFlipStatus,
|
|
|
|
ddraw_surface7_GetOverlayPosition,
|
|
|
|
ddraw_surface7_GetPalette,
|
|
|
|
ddraw_surface7_GetPixelFormat,
|
|
|
|
ddraw_surface7_GetSurfaceDesc,
|
|
|
|
ddraw_surface7_Initialize,
|
|
|
|
ddraw_surface7_IsLost,
|
|
|
|
ddraw_surface7_Lock,
|
|
|
|
ddraw_surface7_ReleaseDC,
|
|
|
|
ddraw_surface7_Restore,
|
|
|
|
ddraw_surface7_SetClipper,
|
|
|
|
ddraw_surface7_SetColorKey,
|
|
|
|
ddraw_surface7_SetOverlayPosition,
|
|
|
|
ddraw_surface7_SetPalette,
|
|
|
|
ddraw_surface7_Unlock,
|
|
|
|
ddraw_surface7_UpdateOverlay,
|
|
|
|
ddraw_surface7_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface7_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface7_GetDDInterface,
|
|
|
|
ddraw_surface7_PageLock,
|
|
|
|
ddraw_surface7_PageUnlock,
|
|
|
|
/* IDirectDrawSurface3 */
|
|
|
|
ddraw_surface7_SetSurfaceDesc,
|
|
|
|
/* IDirectDrawSurface4 */
|
|
|
|
ddraw_surface7_SetPrivateData,
|
|
|
|
ddraw_surface7_GetPrivateData,
|
|
|
|
ddraw_surface7_FreePrivateData,
|
|
|
|
ddraw_surface7_GetUniquenessValue,
|
|
|
|
ddraw_surface7_ChangeUniquenessValue,
|
|
|
|
/* IDirectDrawSurface7 */
|
|
|
|
ddraw_surface7_SetPriority,
|
|
|
|
ddraw_surface7_GetPriority,
|
|
|
|
ddraw_surface7_SetLOD,
|
|
|
|
ddraw_surface7_GetLOD,
|
|
|
|
};
|
|
|
|
|
2011-06-06 13:39:04 +02:00
|
|
|
static const struct IDirectDrawSurface4Vtbl ddraw_surface4_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface4_QueryInterface,
|
|
|
|
ddraw_surface4_AddRef,
|
|
|
|
ddraw_surface4_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface4_AddAttachedSurface,
|
|
|
|
ddraw_surface4_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface4_Blt,
|
|
|
|
ddraw_surface4_BltBatch,
|
|
|
|
ddraw_surface4_BltFast,
|
|
|
|
ddraw_surface4_DeleteAttachedSurface,
|
|
|
|
ddraw_surface4_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface4_EnumOverlayZOrders,
|
|
|
|
ddraw_surface4_Flip,
|
|
|
|
ddraw_surface4_GetAttachedSurface,
|
|
|
|
ddraw_surface4_GetBltStatus,
|
|
|
|
ddraw_surface4_GetCaps,
|
|
|
|
ddraw_surface4_GetClipper,
|
|
|
|
ddraw_surface4_GetColorKey,
|
|
|
|
ddraw_surface4_GetDC,
|
|
|
|
ddraw_surface4_GetFlipStatus,
|
|
|
|
ddraw_surface4_GetOverlayPosition,
|
|
|
|
ddraw_surface4_GetPalette,
|
|
|
|
ddraw_surface4_GetPixelFormat,
|
|
|
|
ddraw_surface4_GetSurfaceDesc,
|
|
|
|
ddraw_surface4_Initialize,
|
|
|
|
ddraw_surface4_IsLost,
|
|
|
|
ddraw_surface4_Lock,
|
|
|
|
ddraw_surface4_ReleaseDC,
|
|
|
|
ddraw_surface4_Restore,
|
|
|
|
ddraw_surface4_SetClipper,
|
|
|
|
ddraw_surface4_SetColorKey,
|
|
|
|
ddraw_surface4_SetOverlayPosition,
|
|
|
|
ddraw_surface4_SetPalette,
|
|
|
|
ddraw_surface4_Unlock,
|
|
|
|
ddraw_surface4_UpdateOverlay,
|
|
|
|
ddraw_surface4_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface4_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface4_GetDDInterface,
|
|
|
|
ddraw_surface4_PageLock,
|
|
|
|
ddraw_surface4_PageUnlock,
|
|
|
|
/* IDirectDrawSurface3 */
|
|
|
|
ddraw_surface4_SetSurfaceDesc,
|
|
|
|
/* IDirectDrawSurface4 */
|
|
|
|
ddraw_surface4_SetPrivateData,
|
|
|
|
ddraw_surface4_GetPrivateData,
|
|
|
|
ddraw_surface4_FreePrivateData,
|
|
|
|
ddraw_surface4_GetUniquenessValue,
|
|
|
|
ddraw_surface4_ChangeUniquenessValue,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirectDrawSurface3Vtbl ddraw_surface3_vtbl =
|
2010-07-19 18:36:20 +02:00
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface3_QueryInterface,
|
|
|
|
ddraw_surface3_AddRef,
|
|
|
|
ddraw_surface3_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface3_AddAttachedSurface,
|
|
|
|
ddraw_surface3_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface3_Blt,
|
|
|
|
ddraw_surface3_BltBatch,
|
|
|
|
ddraw_surface3_BltFast,
|
|
|
|
ddraw_surface3_DeleteAttachedSurface,
|
|
|
|
ddraw_surface3_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface3_EnumOverlayZOrders,
|
|
|
|
ddraw_surface3_Flip,
|
|
|
|
ddraw_surface3_GetAttachedSurface,
|
|
|
|
ddraw_surface3_GetBltStatus,
|
|
|
|
ddraw_surface3_GetCaps,
|
|
|
|
ddraw_surface3_GetClipper,
|
|
|
|
ddraw_surface3_GetColorKey,
|
|
|
|
ddraw_surface3_GetDC,
|
|
|
|
ddraw_surface3_GetFlipStatus,
|
|
|
|
ddraw_surface3_GetOverlayPosition,
|
|
|
|
ddraw_surface3_GetPalette,
|
|
|
|
ddraw_surface3_GetPixelFormat,
|
|
|
|
ddraw_surface3_GetSurfaceDesc,
|
|
|
|
ddraw_surface3_Initialize,
|
|
|
|
ddraw_surface3_IsLost,
|
|
|
|
ddraw_surface3_Lock,
|
|
|
|
ddraw_surface3_ReleaseDC,
|
|
|
|
ddraw_surface3_Restore,
|
|
|
|
ddraw_surface3_SetClipper,
|
|
|
|
ddraw_surface3_SetColorKey,
|
|
|
|
ddraw_surface3_SetOverlayPosition,
|
|
|
|
ddraw_surface3_SetPalette,
|
|
|
|
ddraw_surface3_Unlock,
|
|
|
|
ddraw_surface3_UpdateOverlay,
|
|
|
|
ddraw_surface3_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface3_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface3_GetDDInterface,
|
|
|
|
ddraw_surface3_PageLock,
|
|
|
|
ddraw_surface3_PageUnlock,
|
|
|
|
/* IDirectDrawSurface3 */
|
|
|
|
ddraw_surface3_SetSurfaceDesc,
|
2006-06-09 19:36:12 +02:00
|
|
|
};
|
2010-08-18 19:26:18 +02:00
|
|
|
|
2011-06-09 16:35:15 +02:00
|
|
|
static const struct IDirectDrawSurface2Vtbl ddraw_surface2_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface2_QueryInterface,
|
|
|
|
ddraw_surface2_AddRef,
|
|
|
|
ddraw_surface2_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface2_AddAttachedSurface,
|
|
|
|
ddraw_surface2_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface2_Blt,
|
|
|
|
ddraw_surface2_BltBatch,
|
|
|
|
ddraw_surface2_BltFast,
|
|
|
|
ddraw_surface2_DeleteAttachedSurface,
|
|
|
|
ddraw_surface2_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface2_EnumOverlayZOrders,
|
|
|
|
ddraw_surface2_Flip,
|
|
|
|
ddraw_surface2_GetAttachedSurface,
|
|
|
|
ddraw_surface2_GetBltStatus,
|
|
|
|
ddraw_surface2_GetCaps,
|
|
|
|
ddraw_surface2_GetClipper,
|
|
|
|
ddraw_surface2_GetColorKey,
|
|
|
|
ddraw_surface2_GetDC,
|
|
|
|
ddraw_surface2_GetFlipStatus,
|
|
|
|
ddraw_surface2_GetOverlayPosition,
|
|
|
|
ddraw_surface2_GetPalette,
|
|
|
|
ddraw_surface2_GetPixelFormat,
|
|
|
|
ddraw_surface2_GetSurfaceDesc,
|
|
|
|
ddraw_surface2_Initialize,
|
|
|
|
ddraw_surface2_IsLost,
|
|
|
|
ddraw_surface2_Lock,
|
|
|
|
ddraw_surface2_ReleaseDC,
|
|
|
|
ddraw_surface2_Restore,
|
|
|
|
ddraw_surface2_SetClipper,
|
|
|
|
ddraw_surface2_SetColorKey,
|
|
|
|
ddraw_surface2_SetOverlayPosition,
|
|
|
|
ddraw_surface2_SetPalette,
|
|
|
|
ddraw_surface2_Unlock,
|
|
|
|
ddraw_surface2_UpdateOverlay,
|
|
|
|
ddraw_surface2_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface2_UpdateOverlayZOrder,
|
|
|
|
/* IDirectDrawSurface2 */
|
|
|
|
ddraw_surface2_GetDDInterface,
|
|
|
|
ddraw_surface2_PageLock,
|
|
|
|
ddraw_surface2_PageUnlock,
|
|
|
|
};
|
|
|
|
|
2011-06-09 17:29:36 +02:00
|
|
|
static const struct IDirectDrawSurfaceVtbl ddraw_surface1_vtbl =
|
|
|
|
{
|
|
|
|
/* IUnknown */
|
|
|
|
ddraw_surface1_QueryInterface,
|
|
|
|
ddraw_surface1_AddRef,
|
|
|
|
ddraw_surface1_Release,
|
|
|
|
/* IDirectDrawSurface */
|
|
|
|
ddraw_surface1_AddAttachedSurface,
|
|
|
|
ddraw_surface1_AddOverlayDirtyRect,
|
|
|
|
ddraw_surface1_Blt,
|
|
|
|
ddraw_surface1_BltBatch,
|
|
|
|
ddraw_surface1_BltFast,
|
|
|
|
ddraw_surface1_DeleteAttachedSurface,
|
|
|
|
ddraw_surface1_EnumAttachedSurfaces,
|
|
|
|
ddraw_surface1_EnumOverlayZOrders,
|
|
|
|
ddraw_surface1_Flip,
|
|
|
|
ddraw_surface1_GetAttachedSurface,
|
|
|
|
ddraw_surface1_GetBltStatus,
|
|
|
|
ddraw_surface1_GetCaps,
|
|
|
|
ddraw_surface1_GetClipper,
|
|
|
|
ddraw_surface1_GetColorKey,
|
|
|
|
ddraw_surface1_GetDC,
|
|
|
|
ddraw_surface1_GetFlipStatus,
|
|
|
|
ddraw_surface1_GetOverlayPosition,
|
|
|
|
ddraw_surface1_GetPalette,
|
|
|
|
ddraw_surface1_GetPixelFormat,
|
|
|
|
ddraw_surface1_GetSurfaceDesc,
|
|
|
|
ddraw_surface1_Initialize,
|
|
|
|
ddraw_surface1_IsLost,
|
|
|
|
ddraw_surface1_Lock,
|
|
|
|
ddraw_surface1_ReleaseDC,
|
|
|
|
ddraw_surface1_Restore,
|
|
|
|
ddraw_surface1_SetClipper,
|
|
|
|
ddraw_surface1_SetColorKey,
|
|
|
|
ddraw_surface1_SetOverlayPosition,
|
|
|
|
ddraw_surface1_SetPalette,
|
|
|
|
ddraw_surface1_Unlock,
|
|
|
|
ddraw_surface1_UpdateOverlay,
|
|
|
|
ddraw_surface1_UpdateOverlayDisplay,
|
|
|
|
ddraw_surface1_UpdateOverlayZOrder,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirectDrawGammaControlVtbl ddraw_gamma_control_vtbl =
|
2010-08-18 19:26:18 +02:00
|
|
|
{
|
|
|
|
ddraw_gamma_control_QueryInterface,
|
|
|
|
ddraw_gamma_control_AddRef,
|
|
|
|
ddraw_gamma_control_Release,
|
|
|
|
ddraw_gamma_control_GetGammaRamp,
|
|
|
|
ddraw_gamma_control_SetGammaRamp,
|
|
|
|
};
|
2010-08-18 19:26:19 +02:00
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirect3DTexture2Vtbl d3d_texture2_vtbl =
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
d3d_texture2_QueryInterface,
|
|
|
|
d3d_texture2_AddRef,
|
|
|
|
d3d_texture2_Release,
|
|
|
|
d3d_texture2_GetHandle,
|
|
|
|
d3d_texture2_PaletteChanged,
|
|
|
|
d3d_texture2_Load,
|
|
|
|
};
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
static const struct IDirect3DTextureVtbl d3d_texture1_vtbl =
|
2010-08-18 19:26:19 +02:00
|
|
|
{
|
|
|
|
d3d_texture1_QueryInterface,
|
|
|
|
d3d_texture1_AddRef,
|
|
|
|
d3d_texture1_Release,
|
|
|
|
d3d_texture1_Initialize,
|
|
|
|
d3d_texture1_GetHandle,
|
|
|
|
d3d_texture1_PaletteChanged,
|
|
|
|
d3d_texture1_Load,
|
|
|
|
d3d_texture1_Unload,
|
|
|
|
};
|
2010-08-19 18:57:49 +02:00
|
|
|
|
2011-06-06 11:30:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface7(IDirectDrawSurface7 *iface)
|
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &ddraw_surface7_vtbl);
|
2011-06-05 18:55:04 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface7_iface);
|
2011-06-06 11:30:23 +02:00
|
|
|
}
|
|
|
|
|
2011-06-06 13:08:23 +02:00
|
|
|
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface4(IDirectDrawSurface4 *iface)
|
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2011-06-06 13:39:04 +02:00
|
|
|
assert(iface->lpVtbl == &ddraw_surface4_vtbl);
|
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface4_iface);
|
2011-06-06 13:08:23 +02:00
|
|
|
}
|
|
|
|
|
2011-06-11 20:20:25 +02:00
|
|
|
static IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface3(IDirectDrawSurface3 *iface)
|
2011-05-31 14:49:37 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &ddraw_surface3_vtbl);
|
2011-05-31 13:57:04 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface3_iface);
|
2011-05-31 14:49:37 +02:00
|
|
|
}
|
|
|
|
|
2011-06-11 20:20:25 +02:00
|
|
|
static IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface2(IDirectDrawSurface2 *iface)
|
2011-06-09 16:35:15 +02:00
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &ddraw_surface2_vtbl);
|
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface2_iface);
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:40:19 +02:00
|
|
|
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirectDrawSurface(IDirectDrawSurface *iface)
|
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
2011-06-09 17:29:36 +02:00
|
|
|
assert(iface->lpVtbl == &ddraw_surface1_vtbl);
|
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirectDrawSurface_iface);
|
2011-06-09 16:40:19 +02:00
|
|
|
}
|
|
|
|
|
2011-07-29 15:30:32 +02:00
|
|
|
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture2(IDirect3DTexture2 *iface)
|
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d_texture2_vtbl);
|
2011-07-29 17:55:50 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirect3DTexture2_iface);
|
2011-07-29 15:30:32 +02:00
|
|
|
}
|
|
|
|
|
2011-07-27 16:43:24 +02:00
|
|
|
IDirectDrawSurfaceImpl *unsafe_impl_from_IDirect3DTexture(IDirect3DTexture *iface)
|
|
|
|
{
|
|
|
|
if (!iface) return NULL;
|
|
|
|
assert(iface->lpVtbl == &d3d_texture1_vtbl);
|
2011-07-27 16:45:13 +02:00
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawSurfaceImpl, IDirect3DTexture_iface);
|
2011-07-27 16:43:24 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 22:09:26 +02:00
|
|
|
static void STDMETHODCALLTYPE ddraw_surface_wined3d_object_destroyed(void *parent)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *surface = parent;
|
|
|
|
|
|
|
|
TRACE("surface %p.\n", surface);
|
|
|
|
|
|
|
|
/* Check for attached surfaces and detach them. */
|
|
|
|
if (surface->first_attached != surface)
|
|
|
|
{
|
2011-06-05 18:55:04 +02:00
|
|
|
IDirectDrawSurface7 *root = &surface->first_attached->IDirectDrawSurface7_iface;
|
|
|
|
IDirectDrawSurface7 *detach = &surface->IDirectDrawSurface7_iface;
|
2011-04-20 22:09:26 +02:00
|
|
|
|
|
|
|
/* Well, this shouldn't happen: The surface being attached is
|
|
|
|
* referenced in AddAttachedSurface(), so it shouldn't be released
|
|
|
|
* until DeleteAttachedSurface() is called, because the refcount is
|
|
|
|
* held. It looks like the application released it often enough to
|
|
|
|
* force this. */
|
|
|
|
WARN("Surface is still attached to surface %p.\n", surface->first_attached);
|
|
|
|
|
|
|
|
/* The refcount will drop to -1 here */
|
|
|
|
if (FAILED(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach)))
|
|
|
|
ERR("DeleteAttachedSurface failed.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
while (surface->next_attached)
|
|
|
|
{
|
2011-06-05 18:55:04 +02:00
|
|
|
IDirectDrawSurface7 *root = &surface->IDirectDrawSurface7_iface;
|
|
|
|
IDirectDrawSurface7 *detach = &surface->next_attached->IDirectDrawSurface7_iface;
|
2011-04-20 22:09:26 +02:00
|
|
|
|
|
|
|
if (FAILED(IDirectDrawSurface7_DeleteAttachedSurface(root, 0, detach)))
|
|
|
|
ERR("DeleteAttachedSurface failed.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Having a texture handle set implies that the device still exists. */
|
|
|
|
if (surface->Handle)
|
|
|
|
ddraw_free_handle(&surface->ddraw->d3ddevice->handle_table, surface->Handle - 1, DDRAW_HANDLE_SURFACE);
|
|
|
|
|
|
|
|
/* Reduce the ddraw surface count. */
|
|
|
|
InterlockedDecrement(&surface->ddraw->surfaces);
|
|
|
|
list_remove(&surface->surface_list_entry);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct wined3d_parent_ops ddraw_surface_wined3d_parent_ops =
|
|
|
|
{
|
|
|
|
ddraw_surface_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
2011-04-20 22:09:27 +02:00
|
|
|
static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *parent)
|
|
|
|
{
|
|
|
|
IDirectDrawSurfaceImpl *surface = parent;
|
|
|
|
|
|
|
|
TRACE("surface %p.\n", surface);
|
|
|
|
|
|
|
|
ddraw_surface_cleanup(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops =
|
|
|
|
{
|
|
|
|
ddraw_texture_wined3d_object_destroyed,
|
|
|
|
};
|
|
|
|
|
2011-04-19 20:05:50 +02:00
|
|
|
HRESULT ddraw_surface_create_texture(IDirectDrawSurfaceImpl *surface)
|
|
|
|
{
|
|
|
|
const DDSURFACEDESC2 *desc = &surface->surface_desc;
|
|
|
|
enum wined3d_format_id format;
|
|
|
|
WINED3DPOOL pool;
|
|
|
|
UINT levels;
|
|
|
|
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP)
|
|
|
|
levels = desc->u2.dwMipMapCount;
|
|
|
|
else
|
|
|
|
levels = 1;
|
|
|
|
|
|
|
|
/* DDSCAPS_SYSTEMMEMORY textures are in WINED3DPOOL_SYSTEMMEM.
|
|
|
|
* Should I forward the MANAGED cap to the managed pool? */
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
|
|
|
|
pool = WINED3DPOOL_SYSTEMMEM;
|
|
|
|
else
|
|
|
|
pool = WINED3DPOOL_DEFAULT;
|
|
|
|
|
|
|
|
format = PixelFormat_DD2WineD3D(&surface->surface_desc.u4.ddpfPixelFormat);
|
|
|
|
if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
|
2011-05-16 23:01:22 +02:00
|
|
|
return wined3d_texture_create_cube(surface->ddraw->wined3d_device, desc->dwWidth,
|
2011-04-20 22:09:27 +02:00
|
|
|
levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
|
2011-04-19 20:05:50 +02:00
|
|
|
else
|
2011-05-16 23:01:22 +02:00
|
|
|
return wined3d_texture_create_2d(surface->ddraw->wined3d_device, desc->dwWidth, desc->dwHeight,
|
2011-04-20 22:09:27 +02:00
|
|
|
levels, 0, format, pool, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
|
2011-04-19 20:05:50 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddraw,
|
2011-06-20 08:30:39 +02:00
|
|
|
DDSURFACEDESC2 *desc, UINT mip_level, WINED3DSURFTYPE surface_type, UINT version)
|
2010-08-19 18:57:49 +02:00
|
|
|
{
|
2011-03-08 19:41:05 +01:00
|
|
|
struct wined3d_resource_desc wined3d_desc;
|
2011-03-10 19:07:08 +01:00
|
|
|
struct wined3d_resource *wined3d_resource;
|
2010-08-19 18:57:49 +02:00
|
|
|
WINED3DPOOL pool = WINED3DPOOL_DEFAULT;
|
2010-08-23 18:28:10 +02:00
|
|
|
enum wined3d_format_id format;
|
2010-08-19 18:57:49 +02:00
|
|
|
DWORD usage = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(desc->ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY))
|
|
|
|
&& !((desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
|
|
|
|
&& (desc->ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE)))
|
|
|
|
{
|
|
|
|
/* Tests show surfaces without memory flags get these flags added
|
|
|
|
* right after creation. */
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
|
|
|
|
}
|
|
|
|
|
2010-10-24 21:36:43 +02:00
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
2010-08-19 18:57:49 +02:00
|
|
|
{
|
|
|
|
usage |= WINED3DUSAGE_RENDERTARGET;
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_VISIBLE;
|
|
|
|
}
|
|
|
|
|
2010-10-24 21:39:31 +02:00
|
|
|
if ((desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && !(desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
|
2010-10-24 21:36:43 +02:00
|
|
|
{
|
|
|
|
usage |= WINED3DUSAGE_RENDERTARGET;
|
|
|
|
}
|
|
|
|
|
2010-08-19 18:57:49 +02:00
|
|
|
if (desc->ddsCaps.dwCaps & (DDSCAPS_OVERLAY))
|
|
|
|
{
|
|
|
|
usage |= WINED3DUSAGE_OVERLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ddraw->depthstencil || (desc->ddsCaps.dwCaps & DDSCAPS_ZBUFFER))
|
|
|
|
{
|
|
|
|
/* The depth stencil creation callback sets this flag. Set the
|
|
|
|
* wined3d usage to let it know it's a depth/stencil surface. */
|
|
|
|
usage |= WINED3DUSAGE_DEPTHSTENCIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desc->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
|
|
|
|
{
|
|
|
|
pool = WINED3DPOOL_SYSTEMMEM;
|
|
|
|
}
|
|
|
|
else if (desc->ddsCaps.dwCaps2 & DDSCAPS2_TEXTUREMANAGE)
|
|
|
|
{
|
|
|
|
pool = WINED3DPOOL_MANAGED;
|
|
|
|
/* Managed textures have the system memory flag set. */
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY;
|
|
|
|
}
|
|
|
|
else if (desc->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
|
|
|
|
{
|
|
|
|
/* Videomemory adds localvidmem. This is mutually exclusive with
|
|
|
|
* systemmemory and texturemanage. */
|
|
|
|
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
format = PixelFormat_DD2WineD3D(&desc->u4.ddpfPixelFormat);
|
|
|
|
if (format == WINED3DFMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
WARN("Unsupported / unknown pixelformat.\n");
|
|
|
|
return DDERR_INVALIDPIXELFORMAT;
|
|
|
|
}
|
|
|
|
|
2011-06-05 18:55:04 +02:00
|
|
|
surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
|
2011-06-06 13:39:04 +02:00
|
|
|
surface->IDirectDrawSurface4_iface.lpVtbl = &ddraw_surface4_vtbl;
|
2011-05-31 13:57:04 +02:00
|
|
|
surface->IDirectDrawSurface3_iface.lpVtbl = &ddraw_surface3_vtbl;
|
2011-06-09 16:35:15 +02:00
|
|
|
surface->IDirectDrawSurface2_iface.lpVtbl = &ddraw_surface2_vtbl;
|
2011-06-09 17:29:36 +02:00
|
|
|
surface->IDirectDrawSurface_iface.lpVtbl = &ddraw_surface1_vtbl;
|
2011-06-08 17:23:17 +02:00
|
|
|
surface->IDirectDrawGammaControl_iface.lpVtbl = &ddraw_gamma_control_vtbl;
|
2011-07-29 17:55:50 +02:00
|
|
|
surface->IDirect3DTexture2_iface.lpVtbl = &d3d_texture2_vtbl;
|
2011-07-27 16:45:13 +02:00
|
|
|
surface->IDirect3DTexture_iface.lpVtbl = &d3d_texture1_vtbl;
|
2011-06-19 12:18:22 +02:00
|
|
|
surface->iface_count = 1;
|
2011-06-20 08:30:39 +02:00
|
|
|
surface->version = version;
|
2010-08-19 18:57:49 +02:00
|
|
|
surface->ddraw = ddraw;
|
|
|
|
|
2011-06-20 23:15:55 +02:00
|
|
|
if (version == 7)
|
|
|
|
{
|
|
|
|
surface->ref7 = 1;
|
|
|
|
}
|
|
|
|
else if (version == 4)
|
2011-06-28 01:34:23 +02:00
|
|
|
{
|
|
|
|
surface->ref4 = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-20 23:15:55 +02:00
|
|
|
surface->ref1 = 1;
|
2011-06-28 01:34:23 +02:00
|
|
|
}
|
|
|
|
|
2011-05-23 23:58:46 +02:00
|
|
|
copy_to_surfacedesc2(&surface->surface_desc, desc);
|
2010-08-19 18:57:49 +02:00
|
|
|
|
|
|
|
surface->first_attached = surface;
|
|
|
|
surface->ImplType = surface_type;
|
|
|
|
|
2011-05-16 23:01:22 +02:00
|
|
|
hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format,
|
2010-08-31 18:41:40 +02:00
|
|
|
TRUE /* Lockable */, FALSE /* Discard */, mip_level, usage, pool,
|
|
|
|
WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, surface_type, surface,
|
2011-04-29 13:03:41 +02:00
|
|
|
&ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface);
|
2010-08-19 18:57:49 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create wined3d surface, hr %#x.\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_PIXELFORMAT;
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_resource = wined3d_surface_get_resource(surface->wined3d_surface);
|
2011-03-10 19:07:08 +01:00
|
|
|
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
|
2010-08-19 18:57:49 +02:00
|
|
|
|
|
|
|
format = wined3d_desc.format;
|
|
|
|
if (format == WINED3DFMT_UNKNOWN)
|
|
|
|
{
|
|
|
|
FIXME("IWineD3DSurface::GetDesc returned WINED3DFMT_UNKNOWN.\n");
|
|
|
|
}
|
|
|
|
PixelFormat_WineD3DtoDD(&surface->surface_desc.u4.ddpfPixelFormat, format);
|
|
|
|
|
|
|
|
/* Anno 1602 stores the pitch right after surface creation, so make sure
|
|
|
|
* it's there. TODO: Test other fourcc formats. */
|
|
|
|
if (format == WINED3DFMT_DXT1 || format == WINED3DFMT_DXT2 || format == WINED3DFMT_DXT3
|
|
|
|
|| format == WINED3DFMT_DXT4 || format == WINED3DFMT_DXT5)
|
|
|
|
{
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_LINEARSIZE;
|
|
|
|
if (format == WINED3DFMT_DXT1)
|
|
|
|
{
|
|
|
|
surface->surface_desc.u1.dwLinearSize = max(4, wined3d_desc.width) * max(4, wined3d_desc.height) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
surface->surface_desc.u1.dwLinearSize = max(4, wined3d_desc.width) * max(4, wined3d_desc.height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
surface->surface_desc.dwFlags |= DDSD_PITCH;
|
2011-04-29 13:03:41 +02:00
|
|
|
surface->surface_desc.u1.lPitch = wined3d_surface_get_pitch(surface->wined3d_surface);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_DESTOVERLAY,
|
|
|
|
(WINEDDCOLORKEY *)&desc->u3.ddckCKDestOverlay);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
|
|
|
if (desc->dwFlags & DDSD_CKDESTBLT)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_DESTBLT,
|
|
|
|
(WINEDDCOLORKEY *)&desc->ddckCKDestBlt);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
|
|
|
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_SRCOVERLAY,
|
|
|
|
(WINEDDCOLORKEY *)&desc->ddckCKSrcOverlay);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
|
|
|
if (desc->dwFlags & DDSD_CKSRCBLT)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_SRCBLT,
|
|
|
|
(WINEDDCOLORKEY *)&desc->ddckCKSrcBlt);
|
2010-08-19 18:57:49 +02:00
|
|
|
}
|
|
|
|
if (desc->dwFlags & DDSD_LPSURFACE)
|
|
|
|
{
|
2011-04-29 13:03:41 +02:00
|
|
|
hr = wined3d_surface_set_mem(surface->wined3d_surface, desc->lpSurface);
|
2010-08-19 18:57:49 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to set surface memory, hr %#x.\n", hr);
|
2011-04-29 13:03:41 +02:00
|
|
|
wined3d_surface_decref(surface->wined3d_surface);
|
2010-08-19 18:57:49 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|