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"
|
2010-08-18 19:26:20 +02:00
|
|
|
#include "wine/port.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
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2011-06-20 11:20:41 +02:00
|
|
|
static inline IDirectDrawClipperImpl *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawClipperImpl, IDirectDrawClipper_iface);
|
|
|
|
}
|
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.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(IDirectDrawClipper *iface, REFIID riid,
|
|
|
|
void **ppvObj)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppvObj);
|
|
|
|
|
2010-09-08 11:24:49 +02:00
|
|
|
if (IsEqualGUID(&IID_IDirectDrawClipper, riid)
|
|
|
|
|| IsEqualGUID(&IID_IUnknown, riid))
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2009-01-21 09:56:13 +01:00
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ppvObj = iface;
|
|
|
|
return S_OK;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
2010-09-08 11:24:49 +02:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2006-06-09 19:36:12 +02:00
|
|
|
}
|
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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static ULONG WINAPI IDirectDrawClipperImpl_AddRef(IDirectDrawClipper *iface)
|
2006-06-09 19:36:12 +02:00
|
|
|
{
|
2011-06-20 11:20:41 +02:00
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
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.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2006-06-09 19:36:12 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
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);
|
2011-02-03 20:14:03 +01:00
|
|
|
wined3d_clipper_decref(This->wineD3DClipper);
|
2007-04-28 17:59:37 +02:00
|
|
|
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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd(IDirectDrawClipper *iface, DWORD dwFlags,
|
|
|
|
HWND hWnd)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-04-28 17:59:37 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-02-03 20:14:03 +01:00
|
|
|
hr = wined3d_clipper_set_window(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_*
|
|
|
|
************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *iface, RECT *lpRect,
|
|
|
|
RGNDATA *lpClipList, DWORD *lpdwSize)
|
2004-08-24 22:14:26 +02:00
|
|
|
{
|
2011-06-20 11:20:41 +02:00
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-05-20 23:51:26 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize);
|
2004-08-24 22:14:26 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-02-03 20:14:03 +01:00
|
|
|
hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize);
|
2007-05-20 23:51:26 +02:00
|
|
|
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_*
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *iface, RGNDATA *lprgn,
|
|
|
|
DWORD dwFlag)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-05-20 23:51:26 +02:00
|
|
|
HRESULT hr;
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2010-08-19 18:57:50 +02:00
|
|
|
TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag);
|
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-02-03 20:14:03 +01:00
|
|
|
hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag);
|
2007-05-20 23:51:26 +02:00
|
|
|
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;
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface, HWND *hWndPtr)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-05-20 23:51:26 +02:00
|
|
|
HRESULT hr;
|
2010-08-19 18:57:50 +02:00
|
|
|
|
|
|
|
TRACE("iface %p, window %p.\n", iface, hWndPtr);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2007-05-20 23:51:26 +02:00
|
|
|
EnterCriticalSection(&ddraw_cs);
|
2011-02-03 20:14:03 +01:00
|
|
|
hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr);
|
2007-05-20 23:51:26 +02:00
|
|
|
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
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *iface,
|
|
|
|
IDirectDraw *ddraw, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2010-08-19 18:57:50 +02:00
|
|
|
|
2011-06-20 11:20:41 +02:00
|
|
|
TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, 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
|
|
|
|
*****************************************************************************/
|
2011-06-20 11:20:41 +02:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(IDirectDrawClipper *iface,
|
|
|
|
BOOL *lpbChanged)
|
|
|
|
{
|
2010-08-19 18:57:50 +02:00
|
|
|
FIXME("iface %p, changed %p stub!\n", iface, 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
|
|
|
|
*****************************************************************************/
|
2010-08-18 19:26:25 +02:00
|
|
|
static const struct IDirectDrawClipperVtbl ddraw_clipper_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
|
|
|
};
|
2010-08-18 19:26:25 +02:00
|
|
|
|
|
|
|
HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
|
|
|
|
{
|
2011-06-20 11:20:41 +02:00
|
|
|
clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl;
|
2010-08-18 19:26:25 +02:00
|
|
|
clipper->ref = 1;
|
2011-02-03 20:14:03 +01:00
|
|
|
clipper->wineD3DClipper = wined3d_clipper_create();
|
2010-08-18 19:26:25 +02:00
|
|
|
if (!clipper->wineD3DClipper)
|
|
|
|
{
|
|
|
|
WARN("Failed to create wined3d clipper.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
2011-06-20 11:22:55 +02:00
|
|
|
|
|
|
|
IDirectDrawClipperImpl *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &ddraw_clipper_vtbl);
|
|
|
|
|
|
|
|
return impl_from_IDirectDrawClipper(iface);
|
|
|
|
}
|