2006-06-09 19:36:12 +02:00
|
|
|
/* DirectDrawClipper implementation
|
2000-04-09 16:30:50 +02:00
|
|
|
*
|
2006-06-09 19:36:12 +02:00
|
|
|
* Copyright 2000 (c) Marcus Meissner
|
|
|
|
* Copyright 2000 (c) TransGaming Technologies Inc.
|
2008-10-18 19:19:45 +02:00
|
|
|
* Copyright 2006 (c) Stefan Dösinger
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-04-09 16:30:50 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-04-09 16:30:50 +02:00
|
|
|
#include <stdlib.h>
|
2001-01-26 21:43:40 +01:00
|
|
|
#include <string.h>
|
2001-07-18 23:04:23 +02:00
|
|
|
|
2008-11-25 11:57:39 +01:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
#include "ddraw.h"
|
2001-01-26 21:43:40 +01:00
|
|
|
#include "winerror.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
#include "ddraw_private.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IUnknown methods
|
|
|
|
*****************************************************************************/
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::QueryInterface
|
|
|
|
*
|
|
|
|
* Can query the IUnknown and IDirectDrawClipper interface from a
|
|
|
|
* Clipper object. The IUnknown Interface is equal to the IDirectDrawClipper
|
|
|
|
* interface. Can't create other interfaces.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* riid: Interface id asked for
|
|
|
|
* ppvObj: Returns the pointer to the interface
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* DD_OK on success
|
|
|
|
* E_NOINTERFACE if the requested interface wasn't found.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(
|
|
|
|
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
|
2000-04-09 16:30:50 +02:00
|
|
|
) {
|
2006-06-09 19:36:12 +02:00
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid)
|
|
|
|
|| IsEqualGUID(&IID_IDirectDrawClipper, riid))
|
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ppvObj = iface;
|
|
|
|
return S_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::AddRef
|
|
|
|
*
|
|
|
|
* Increases the reference count of the interface, returns the new count
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static ULONG WINAPI IDirectDrawClipperImpl_AddRef( LPDIRECTDRAWCLIPPER iface )
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
return ref;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::Release
|
|
|
|
*
|
|
|
|
* Decreases the reference count of the interface, returns the new count
|
|
|
|
* If the refcount is decreased to 0, the interface is destroyed.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) {
|
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
if (ref == 0)
|
|
|
|
{
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-04-28 17:59:37 +02:00
|
|
|
IWineD3DClipper_Release(This->wineD3DClipper);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2007-05-20 23:51:26 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-28 17:59:37 +02:00
|
|
|
return 0;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
|
|
|
else return ref;
|
2001-01-04 23:44:55 +01:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::SetHwnd
|
|
|
|
*
|
|
|
|
* Assigns a hWnd to the clipper interface.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Flags: Unsupported so far
|
|
|
|
* hWnd: The hWnd to set
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* DD_OK on success
|
|
|
|
* DDERR_INVALIDPARAMS if Flags was != 0
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(
|
2000-04-09 16:30:50 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, DWORD dwFlags, HWND hWnd
|
|
|
|
) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2007-04-28 17:59:37 +02:00
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p)->(%08x,%p)\n", This, dwFlags, hWnd);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2007-04-28 17:59:37 +02:00
|
|
|
hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper,
|
|
|
|
dwFlags,
|
|
|
|
hWnd);
|
2007-05-20 23:51:26 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2007-04-28 17:59:37 +02:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
default: return hr;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::GetClipList
|
|
|
|
*
|
|
|
|
* Retrieve a copy of the clip list
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Rect: Rectangle to be used to clip the clip list or NULL for the
|
|
|
|
* entire clip list
|
|
|
|
* ClipList: structure for the resulting copy of the clip list.
|
|
|
|
* If NULL, fills Size up to the number of bytes necessary to hold
|
|
|
|
* the entire clip.
|
|
|
|
* Size: Size of resulting clip list; size of the buffer at ClipList
|
|
|
|
* or, if ClipList is NULL, receives the required size of the buffer
|
|
|
|
* in bytes
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Either DD_OK or DDERR_*
|
|
|
|
************************************************************************/
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(
|
2004-08-23 20:50:14 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, LPRECT lpRect, LPRGNDATA lpClipList,
|
2004-08-24 22:14:26 +02:00
|
|
|
LPDWORD lpdwSize)
|
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2007-05-20 23:51:26 +02:00
|
|
|
HRESULT hr;
|
2005-03-21 11:28:49 +01:00
|
|
|
TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize);
|
2004-08-24 22:14:26 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DClipper_GetClipList(This->wineD3DClipper,
|
|
|
|
lpRect,
|
|
|
|
lpClipList,
|
|
|
|
lpdwSize);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::SetClipList
|
|
|
|
*
|
|
|
|
* Sets or deletes (if lprgn is NULL) the clip list
|
|
|
|
*
|
2006-06-23 18:18:02 +02:00
|
|
|
* This implementation is a stub and returns DD_OK always to make the app
|
2006-06-09 19:36:12 +02:00
|
|
|
* happy.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lprgn Pointer to a LRGNDATA structure or NULL
|
|
|
|
* dwFlags not used, must be 0
|
|
|
|
* RETURNS
|
|
|
|
* Either DD_OK or DDERR_*
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(
|
2004-08-23 20:50:14 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag
|
2000-04-09 16:30:50 +02:00
|
|
|
) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2007-05-20 23:51:26 +02:00
|
|
|
HRESULT hr;
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DClipper_SetClipList(This->wineD3DClipper,
|
|
|
|
lprgn,
|
|
|
|
dwFlag);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::GetHwnd
|
|
|
|
*
|
|
|
|
* Returns the hwnd assigned with SetHwnd
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* hWndPtr: Address to store the HWND at
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* Always returns DD_OK;
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(
|
2000-04-09 16:30:50 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr
|
|
|
|
) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2007-05-20 23:51:26 +02:00
|
|
|
HRESULT hr;
|
2005-03-21 11:28:49 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, hWndPtr);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
|
|
|
hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper,
|
|
|
|
hWndPtr);
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return hr;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::Initialize
|
|
|
|
*
|
|
|
|
* Initializes the interface. Well, there isn't much to do for this
|
|
|
|
* implementation, but it stores the DirectDraw Interface.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* DD: Pointer to a IDirectDraw interface
|
|
|
|
* Flags: Unsupported by now
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* DD_OK on success
|
2006-06-23 18:18:02 +02:00
|
|
|
* DDERR_ALREADYINITIALIZED if this interface isn't initialized already
|
2006-06-09 19:36:12 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(
|
2000-04-09 16:30:50 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
|
|
|
|
) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2006-10-10 19:23:27 +02:00
|
|
|
TRACE("(%p)->(%p,0x%08x)\n", This, lpDD, dwFlags);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2010-07-19 12:47:57 +02:00
|
|
|
if (This->initialized)
|
2007-05-20 23:51:26 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
|
|
|
return DDERR_ALREADYINITIALIZED;
|
|
|
|
}
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2010-07-19 12:47:57 +02:00
|
|
|
This->initialized = TRUE;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
LeaveCriticalSection(&ddraw_cs);
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::IsClipListChanged
|
|
|
|
*
|
|
|
|
* This function is a stub
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Changed:
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*****************************************************************************/
|
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(
|
2000-04-09 16:30:50 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, BOOL* lpbChanged
|
|
|
|
) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2000-04-09 16:30:50 +02:00
|
|
|
FIXME("(%p)->(%p),stub!\n",This,lpbChanged);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
/* XXX What is safest? */
|
|
|
|
*lpbChanged = FALSE;
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-09 19:36:12 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* The VTable
|
|
|
|
*****************************************************************************/
|
|
|
|
const IDirectDrawClipperVtbl IDirectDrawClipper_Vtbl =
|
2000-04-09 16:30:50 +02:00
|
|
|
{
|
2006-06-09 19:36:12 +02:00
|
|
|
IDirectDrawClipperImpl_QueryInterface,
|
|
|
|
IDirectDrawClipperImpl_AddRef,
|
|
|
|
IDirectDrawClipperImpl_Release,
|
|
|
|
IDirectDrawClipperImpl_GetClipList,
|
|
|
|
IDirectDrawClipperImpl_GetHWnd,
|
|
|
|
IDirectDrawClipperImpl_Initialize,
|
|
|
|
IDirectDrawClipperImpl_IsClipListChanged,
|
|
|
|
IDirectDrawClipperImpl_SetClipList,
|
|
|
|
IDirectDrawClipperImpl_SetHwnd
|
2000-04-09 16:30:50 +02:00
|
|
|
};
|