2000-04-09 16:30:50 +02:00
|
|
|
/* DirectDrawClipper implementation
|
|
|
|
*
|
|
|
|
* Copyright 2000 Marcus Meissner
|
2001-01-04 23:44:55 +01:00
|
|
|
* Copyright 2000 TransGaming Technologies Inc.
|
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
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
#define CONST_VTABLE
|
|
|
|
|
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
|
|
|
|
|
|
|
/******************************************************************************
|
2001-06-11 22:14:43 +02:00
|
|
|
* DirectDrawCreateClipper (DDRAW.@)
|
2000-04-09 16:30:50 +02:00
|
|
|
*/
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectDrawClipperVtbl DDRAW_Clipper_VTable;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
HRESULT WINAPI DirectDrawCreateClipper(
|
|
|
|
DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter
|
|
|
|
) {
|
2001-01-04 23:44:55 +01:00
|
|
|
IDirectDrawClipperImpl* This;
|
|
|
|
TRACE("(%08lx,%p,%p)\n", dwFlags, lplpDDClipper, pUnkOuter);
|
|
|
|
|
|
|
|
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(IDirectDrawClipperImpl));
|
|
|
|
if (This == NULL) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ICOM_INIT_INTERFACE(This, IDirectDrawClipper, DDRAW_Clipper_VTable);
|
|
|
|
This->ref = 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
This->hWnd = 0;
|
2001-01-04 23:44:55 +01:00
|
|
|
This->ddraw_owner = NULL;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
*lplpDDClipper = ICOM_INTERFACE(This, IDirectDrawClipper);
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
/* This is the classfactory implementation. */
|
|
|
|
HRESULT DDRAW_CreateDirectDrawClipper(IUnknown* pUnkOuter, REFIID riid,
|
|
|
|
LPVOID* ppObj)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
LPDIRECTDRAWCLIPPER pClip;
|
|
|
|
|
|
|
|
hr = DirectDrawCreateClipper(0, &pClip, pUnkOuter);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
hr = IDirectDrawClipper_QueryInterface(pClip, riid, ppObj);
|
|
|
|
IDirectDrawClipper_Release(pClip);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* IDirectDrawClipper
|
|
|
|
*/
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_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;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2005-03-21 11:28:49 +01:00
|
|
|
TRACE("(%p)->(0x%08lx,0x%08lx)\n", This, dwFlags, (DWORD)hWnd);
|
2000-04-09 16:30:50 +02:00
|
|
|
if( dwFlags ) {
|
|
|
|
FIXME("dwFlags = 0x%08lx, not supported.\n",dwFlags);
|
2002-06-01 01:06:46 +02:00
|
|
|
return DDERR_INVALIDPARAMS;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
This->hWnd = hWnd;
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
static void Main_DirectDrawClipper_Destroy(IDirectDrawClipperImpl* This)
|
|
|
|
{
|
|
|
|
if (This->ddraw_owner != NULL)
|
|
|
|
Main_DirectDraw_RemoveClipper(This->ddraw_owner, This);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0 ,This);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Main_DirectDrawClipper_ForceDestroy(IDirectDrawClipperImpl* This)
|
|
|
|
{
|
|
|
|
WARN("deleting clipper %p with refcnt %lu\n", This, This->ref);
|
|
|
|
Main_DirectDrawClipper_Destroy(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
ULONG WINAPI Main_DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2005-01-09 18:29:21 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2005-01-09 18:29:21 +01:00
|
|
|
TRACE("(%p)->() decrementing from %lu.\n", This, ref + 1);
|
|
|
|
|
|
|
|
if (ref == 0)
|
2001-01-04 23:44:55 +01:00
|
|
|
{
|
|
|
|
Main_DirectDrawClipper_Destroy(This);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-01-09 18:29:21 +01:00
|
|
|
else return ref;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2004-08-23 20:50:14 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IDirectDrawClipper::GetClipList
|
|
|
|
*
|
|
|
|
* Retrieve a copy of the clip list
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpRect Rectangle to be used to clip the clip list or NULL for the
|
|
|
|
* entire clip list
|
|
|
|
* lpClipList structure for the resulting copy of the clip list.
|
|
|
|
If NULL, fills lpdwSize up to the number of bytes necessary to hold
|
|
|
|
the entire clip.
|
|
|
|
* lpdwSize Size of resulting clip list; size of the buffer at lpClipList
|
|
|
|
or, if lpClipList is NULL, receives the required size of the buffer
|
|
|
|
in bytes
|
|
|
|
* RETURNS
|
|
|
|
* Either DD_OK or DDERR_*
|
|
|
|
*/
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_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;
|
2004-08-24 22:14:26 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
if (This->hWnd)
|
|
|
|
{
|
|
|
|
HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
|
|
|
|
if (hDC)
|
|
|
|
{
|
|
|
|
HRGN hRgn = CreateRectRgn(0,0,0,0);
|
|
|
|
if (GetRandomRgn(hDC, hRgn, SYSRGN))
|
|
|
|
{
|
|
|
|
if (lpRect)
|
|
|
|
{
|
|
|
|
HRGN hRgnClip = CreateRectRgn(lpRect->left, lpRect->top,
|
|
|
|
lpRect->right, lpRect->bottom);
|
|
|
|
CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
|
|
|
|
DeleteObject(hRgnClip);
|
|
|
|
}
|
|
|
|
*lpdwSize = GetRegionData(hRgn, *lpdwSize, lpClipList);
|
|
|
|
}
|
|
|
|
DeleteObject(hRgn);
|
|
|
|
ReleaseDC(This->hWnd, hDC);
|
|
|
|
}
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static int warned = 0;
|
|
|
|
if (warned++ < 10)
|
|
|
|
FIXME("(%p,%p,%p,%p),stub!\n",This,lpRect,lpClipList,lpdwSize);
|
|
|
|
if (lpdwSize) *lpdwSize=0;
|
|
|
|
return DDERR_NOCLIPLIST;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2004-08-23 20:50:14 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IDirectDrawClipper::SetClipList
|
|
|
|
*
|
|
|
|
* Sets or deletes (if lprgn is NULL) the clip list
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lprgn Pointer to a LRGNDATA structure or NULL
|
|
|
|
* dwFlags not used, must be 0
|
|
|
|
* RETURNS
|
|
|
|
* Either DD_OK or DDERR_*
|
|
|
|
*/
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_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;
|
2004-08-23 20:50:14 +02:00
|
|
|
static int warned = 0;
|
|
|
|
if (warned++ < 10 || lprgn == NULL)
|
|
|
|
FIXME("(%p,%p,%ld),stub!\n",This,lprgn,dwFlag);
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_QueryInterface(
|
2000-04-09 16:30:50 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, REFIID riid, LPVOID* ppvObj
|
|
|
|
) {
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid)
|
|
|
|
|| IsEqualGUID(&IID_IDirectDrawClipper, riid))
|
|
|
|
{
|
|
|
|
*ppvObj = ICOM_INTERFACE(This, IDirectDrawClipper);
|
2005-01-09 18:29:21 +01:00
|
|
|
InterlockedIncrement(&This->ref);
|
2001-01-04 23:44:55 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
ULONG WINAPI Main_DirectDrawClipper_AddRef( LPDIRECTDRAWCLIPPER iface )
|
2000-04-09 16:30:50 +02:00
|
|
|
{
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2005-01-09 18:29:21 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->() incrementing from %lu.\n", This, ref - 1);
|
|
|
|
|
|
|
|
return ref;
|
2000-04-09 16:30:50 +02:00
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_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;
|
2005-03-21 11:28:49 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, hWndPtr);
|
2000-04-09 16:30:50 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
*hWndPtr = This->hWnd;
|
2000-04-09 16:30:50 +02:00
|
|
|
|
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_Initialize(
|
2000-04-09 16:30:50 +02:00
|
|
|
LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags
|
|
|
|
) {
|
2001-01-04 23:44:55 +01:00
|
|
|
IDirectDrawImpl* pOwner;
|
2004-09-08 03:50:37 +02:00
|
|
|
IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface;
|
2005-03-21 11:28:49 +01:00
|
|
|
TRACE("(%p)->(%p,0x%08lx)\n", This, lpDD, dwFlags);
|
2001-01-04 23:44:55 +01:00
|
|
|
|
|
|
|
if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED;
|
|
|
|
|
|
|
|
pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD);
|
|
|
|
This->ddraw_owner = pOwner;
|
|
|
|
Main_DirectDraw_AddClipper(pOwner, This);
|
|
|
|
|
2000-04-09 16:30:50 +02:00
|
|
|
return DD_OK;
|
|
|
|
}
|
|
|
|
|
2001-01-04 23:44:55 +01:00
|
|
|
HRESULT WINAPI Main_DirectDrawClipper_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;
|
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectDrawClipperVtbl DDRAW_Clipper_VTable =
|
2000-04-09 16:30:50 +02:00
|
|
|
{
|
2001-01-04 23:44:55 +01:00
|
|
|
Main_DirectDrawClipper_QueryInterface,
|
|
|
|
Main_DirectDrawClipper_AddRef,
|
|
|
|
Main_DirectDrawClipper_Release,
|
|
|
|
Main_DirectDrawClipper_GetClipList,
|
|
|
|
Main_DirectDrawClipper_GetHWnd,
|
|
|
|
Main_DirectDrawClipper_Initialize,
|
|
|
|
Main_DirectDrawClipper_IsClipListChanged,
|
|
|
|
Main_DirectDrawClipper_SetClipList,
|
|
|
|
Main_DirectDrawClipper_SetHwnd
|
2000-04-09 16:30:50 +02:00
|
|
|
};
|