2006-06-09 17:36:12 +00:00
|
|
|
/* DirectDrawClipper implementation
|
2000-04-09 14:30:50 +00:00
|
|
|
*
|
2006-06-09 17:36:12 +00:00
|
|
|
* Copyright 2000 (c) Marcus Meissner
|
|
|
|
* Copyright 2000 (c) TransGaming Technologies Inc.
|
2008-10-18 17:19:45 +00:00
|
|
|
* Copyright 2006 (c) Stefan Dösinger
|
2002-03-09 23:29:33 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-04-09 14:30:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2010-08-18 17:26:20 +00:00
|
|
|
#include "wine/port.h"
|
2001-07-18 21:04:23 +00:00
|
|
|
|
2000-04-09 14:30:50 +00:00
|
|
|
#include "ddraw_private.h"
|
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
|
2000-04-09 14:30:50 +00:00
|
|
|
|
2011-06-20 09:20:41 +00:00
|
|
|
static inline IDirectDrawClipperImpl *impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IDirectDrawClipperImpl, IDirectDrawClipper_iface);
|
|
|
|
}
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2006-06-09 17:36:12 +00: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 09:20:41 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_QueryInterface(IDirectDrawClipper *iface, REFIID riid,
|
|
|
|
void **ppvObj)
|
|
|
|
{
|
2010-08-19 16:57:50 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppvObj);
|
|
|
|
|
2010-09-08 09:24:49 +00:00
|
|
|
if (IsEqualGUID(&IID_IDirectDrawClipper, riid)
|
|
|
|
|| IsEqualGUID(&IID_IUnknown, riid))
|
2006-06-09 17:36:12 +00:00
|
|
|
{
|
2009-01-21 08:56:13 +00:00
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
*ppvObj = iface;
|
|
|
|
return S_OK;
|
2006-06-09 17:36:12 +00:00
|
|
|
}
|
2010-09-08 09:24:49 +00:00
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
2006-06-09 17:36:12 +00:00
|
|
|
}
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::AddRef
|
|
|
|
*
|
|
|
|
* Increases the reference count of the interface, returns the new count
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2011-06-20 09:20:41 +00:00
|
|
|
static ULONG WINAPI IDirectDrawClipperImpl_AddRef(IDirectDrawClipper *iface)
|
2006-06-09 17:36:12 +00:00
|
|
|
{
|
2011-06-20 09:20:41 +00:00
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2006-06-09 17:36:12 +00:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2010-08-19 16:57:50 +00:00
|
|
|
TRACE("%p increasing refcount to %u.\n", This, ref);
|
2000-04-09 14:30:50 +00:00
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
return ref;
|
2000-04-09 14:30:50 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00: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 09:20:41 +00:00
|
|
|
static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2006-06-09 17:36:12 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2010-08-19 16:57:50 +00:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", This, ref);
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
if (ref == 0)
|
|
|
|
{
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-03 19:14:03 +00:00
|
|
|
wined3d_clipper_decref(This->wineD3DClipper);
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
2007-04-28 15:59:37 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
return 0;
|
2006-06-09 17:36:12 +00:00
|
|
|
}
|
|
|
|
else return ref;
|
2001-01-04 22:44:55 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
/*****************************************************************************
|
2011-11-09 15:17:13 +00:00
|
|
|
* IDirectDrawClipper::SetHWnd
|
2006-06-09 17:36:12 +00:00
|
|
|
*
|
|
|
|
* 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-11-09 15:17:13 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_SetHWnd(IDirectDrawClipper *iface, DWORD dwFlags,
|
2011-06-20 09:20:41 +00:00
|
|
|
HWND hWnd)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-04-28 15:59:37 +00:00
|
|
|
HRESULT hr;
|
2010-08-19 16:57:50 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, flags %#x, window %p.\n", iface, dwFlags, hWnd);
|
2000-04-09 14:30:50 +00:00
|
|
|
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-03 19:14:03 +00:00
|
|
|
hr = wined3d_clipper_set_window(This->wineD3DClipper, dwFlags, hWnd);
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-04-28 15:59:37 +00:00
|
|
|
switch(hr)
|
|
|
|
{
|
|
|
|
case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS;
|
|
|
|
default: return hr;
|
2000-04-09 14:30:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00: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 09:20:41 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList(IDirectDrawClipper *iface, RECT *lpRect,
|
|
|
|
RGNDATA *lpClipList, DWORD *lpdwSize)
|
2004-08-24 20:14:26 +00:00
|
|
|
{
|
2011-06-20 09:20:41 +00:00
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-05-20 21:51:26 +00:00
|
|
|
HRESULT hr;
|
2010-08-19 16:57:50 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
|
|
|
|
iface, wine_dbgstr_rect(lpRect), lpClipList, lpdwSize);
|
2004-08-24 20:14:26 +00:00
|
|
|
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-03 19:14:03 +00:00
|
|
|
hr = wined3d_clipper_get_clip_list(This->wineD3DClipper, lpRect, lpClipList, lpdwSize);
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-20 21:51:26 +00:00
|
|
|
return hr;
|
2000-04-09 14:30:50 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::SetClipList
|
|
|
|
*
|
|
|
|
* Sets or deletes (if lprgn is NULL) the clip list
|
|
|
|
*
|
2006-06-23 16:18:02 +00:00
|
|
|
* This implementation is a stub and returns DD_OK always to make the app
|
2006-06-09 17:36:12 +00: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 09:20:41 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList(IDirectDrawClipper *iface, RGNDATA *lprgn,
|
|
|
|
DWORD dwFlag)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-05-20 21:51:26 +00:00
|
|
|
HRESULT hr;
|
2007-04-28 15:59:37 +00:00
|
|
|
|
2010-08-19 16:57:50 +00:00
|
|
|
TRACE("iface %p, clip_list %p, flags %#x.\n", iface, lprgn, dwFlag);
|
|
|
|
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-03 19:14:03 +00:00
|
|
|
hr = wined3d_clipper_set_clip_list(This->wineD3DClipper, lprgn, dwFlag);
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-20 21:51:26 +00:00
|
|
|
return hr;
|
2000-04-09 14:30:50 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
/*****************************************************************************
|
2011-11-09 15:17:13 +00:00
|
|
|
* IDirectDrawClipper::GetHWnd
|
2006-06-09 17:36:12 +00:00
|
|
|
*
|
2011-11-09 15:17:13 +00:00
|
|
|
* Returns the hwnd assigned with SetHWnd
|
2006-06-09 17:36:12 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* hWndPtr: Address to store the HWND at
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* Always returns DD_OK;
|
|
|
|
*****************************************************************************/
|
2011-06-20 09:20:41 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd(IDirectDrawClipper *iface, HWND *hWndPtr)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2007-05-20 21:51:26 +00:00
|
|
|
HRESULT hr;
|
2010-08-19 16:57:50 +00:00
|
|
|
|
|
|
|
TRACE("iface %p, window %p.\n", iface, hWndPtr);
|
2000-04-09 14:30:50 +00:00
|
|
|
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_lock();
|
2011-02-03 19:14:03 +00:00
|
|
|
hr = wined3d_clipper_get_window(This->wineD3DClipper, hWndPtr);
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
|
|
|
|
2007-05-20 21:51:26 +00:00
|
|
|
return hr;
|
2000-04-09 14:30:50 +00:00
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00: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 16:18:02 +00:00
|
|
|
* DDERR_ALREADYINITIALIZED if this interface isn't initialized already
|
2006-06-09 17:36:12 +00:00
|
|
|
*****************************************************************************/
|
2011-06-20 09:20:41 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_Initialize(IDirectDrawClipper *iface,
|
|
|
|
IDirectDraw *ddraw, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
IDirectDrawClipperImpl *This = impl_from_IDirectDrawClipper(iface);
|
2010-08-19 16:57:50 +00:00
|
|
|
|
2011-06-20 09:20:41 +00:00
|
|
|
TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, dwFlags);
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_lock();
|
2010-07-19 10:47:57 +00:00
|
|
|
if (This->initialized)
|
2007-05-20 21:51:26 +00:00
|
|
|
{
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
2007-05-20 21:51:26 +00:00
|
|
|
return DDERR_ALREADYINITIALIZED;
|
|
|
|
}
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2010-07-19 10:47:57 +00:00
|
|
|
This->initialized = TRUE;
|
2011-11-13 18:52:24 +00:00
|
|
|
wined3d_mutex_unlock();
|
2001-01-04 22:44:55 +00:00
|
|
|
|
2000-04-09 14:30:50 +00:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* IDirectDrawClipper::IsClipListChanged
|
|
|
|
*
|
|
|
|
* This function is a stub
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* Changed:
|
|
|
|
*
|
|
|
|
* Return values:
|
|
|
|
* DD_OK, because it's a stub
|
|
|
|
*****************************************************************************/
|
2011-06-20 09:20:41 +00:00
|
|
|
static HRESULT WINAPI IDirectDrawClipperImpl_IsClipListChanged(IDirectDrawClipper *iface,
|
|
|
|
BOOL *lpbChanged)
|
|
|
|
{
|
2010-08-19 16:57:50 +00:00
|
|
|
FIXME("iface %p, changed %p stub!\n", iface, lpbChanged);
|
2001-01-04 22:44:55 +00:00
|
|
|
|
|
|
|
/* XXX What is safest? */
|
|
|
|
*lpbChanged = FALSE;
|
|
|
|
|
2000-04-09 14:30:50 +00:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2006-06-09 17:36:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* The VTable
|
|
|
|
*****************************************************************************/
|
2010-08-18 17:26:25 +00:00
|
|
|
static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl =
|
2000-04-09 14:30:50 +00:00
|
|
|
{
|
2006-06-09 17:36:12 +00:00
|
|
|
IDirectDrawClipperImpl_QueryInterface,
|
|
|
|
IDirectDrawClipperImpl_AddRef,
|
|
|
|
IDirectDrawClipperImpl_Release,
|
|
|
|
IDirectDrawClipperImpl_GetClipList,
|
|
|
|
IDirectDrawClipperImpl_GetHWnd,
|
|
|
|
IDirectDrawClipperImpl_Initialize,
|
|
|
|
IDirectDrawClipperImpl_IsClipListChanged,
|
|
|
|
IDirectDrawClipperImpl_SetClipList,
|
2011-11-09 15:17:13 +00:00
|
|
|
IDirectDrawClipperImpl_SetHWnd
|
2000-04-09 14:30:50 +00:00
|
|
|
};
|
2010-08-18 17:26:25 +00:00
|
|
|
|
|
|
|
HRESULT ddraw_clipper_init(IDirectDrawClipperImpl *clipper)
|
|
|
|
{
|
2011-06-20 09:20:41 +00:00
|
|
|
clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl;
|
2010-08-18 17:26:25 +00:00
|
|
|
clipper->ref = 1;
|
2011-02-03 19:14:03 +00:00
|
|
|
clipper->wineD3DClipper = wined3d_clipper_create();
|
2010-08-18 17:26:25 +00:00
|
|
|
if (!clipper->wineD3DClipper)
|
|
|
|
{
|
|
|
|
WARN("Failed to create wined3d clipper.\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
2011-06-20 09:22:55 +00:00
|
|
|
|
|
|
|
IDirectDrawClipperImpl *unsafe_impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
|
|
|
|
{
|
|
|
|
if (!iface)
|
|
|
|
return NULL;
|
|
|
|
assert(iface->lpVtbl == &ddraw_clipper_vtbl);
|
|
|
|
|
|
|
|
return impl_from_IDirectDrawClipper(iface);
|
|
|
|
}
|