2007-04-28 17:59:37 +02:00
|
|
|
/* IWineD3DClipper implementation
|
|
|
|
*
|
|
|
|
* Copyright 2000 (c) Marcus Meissner
|
|
|
|
* Copyright 2000 (c) TransGaming Technologies Inc.
|
2008-10-18 19:21:20 +02:00
|
|
|
* Copyright 2006 (c) Stefan Dösinger
|
2007-04-28 17:59:37 +02: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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#ifdef HAVE_FLOAT_H
|
|
|
|
# include <float.h>
|
|
|
|
#endif
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
ULONG CDECL wined3d_clipper_incref(struct wined3d_clipper *clipper)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
ULONG refcount = InterlockedIncrement(&clipper->ref);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
TRACE("%p increasing refcount to %u.\n", clipper, refcount);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
return refcount;
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
ULONG CDECL wined3d_clipper_decref(struct wined3d_clipper *clipper)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
ULONG refcount = InterlockedDecrement(&clipper->ref);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
if (!refcount)
|
|
|
|
HeapFree(GetProcessHeap(), 0, clipper);
|
2010-09-14 13:38:39 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
return refcount;
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
HRESULT CDECL wined3d_clipper_set_window(struct wined3d_clipper *clipper, DWORD flags, HWND window)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
TRACE("clipper %p, flags %#x, window %p.\n", clipper, flags, window);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2010-11-18 20:50:40 +01:00
|
|
|
if (flags)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2010-11-18 20:50:40 +01:00
|
|
|
FIXME("flags %#x, not supported.\n", flags);
|
2007-04-28 17:59:37 +02:00
|
|
|
return WINED3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
clipper->hWnd = window;
|
|
|
|
|
2007-04-28 17:59:37 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
HRESULT CDECL wined3d_clipper_get_clip_list(const struct wined3d_clipper *clipper, const RECT *rect,
|
|
|
|
RGNDATA *clip_list, DWORD *clip_list_size)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
TRACE("clipper %p, rect %s, clip_list %p, clip_list_size %p.\n",
|
|
|
|
clipper, wine_dbgstr_rect(rect), clip_list, clip_list_size);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
if (clipper->hWnd)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
HDC hDC = GetDCEx(clipper->hWnd, NULL, DCX_WINDOW);
|
2007-04-28 17:59:37 +02:00
|
|
|
if (hDC)
|
|
|
|
{
|
|
|
|
HRGN hRgn = CreateRectRgn(0,0,0,0);
|
|
|
|
if (GetRandomRgn(hDC, hRgn, SYSRGN))
|
|
|
|
{
|
|
|
|
if (GetVersion() & 0x80000000)
|
|
|
|
{
|
|
|
|
/* map region to screen coordinates */
|
|
|
|
POINT org;
|
2011-02-03 20:14:03 +01:00
|
|
|
GetDCOrgEx(hDC, &org);
|
|
|
|
OffsetRgn(hRgn, org.x, org.y);
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|
2011-02-03 20:14:03 +01:00
|
|
|
if (rect)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
HRGN hRgnClip = CreateRectRgn(rect->left, rect->top,
|
|
|
|
rect->right, rect->bottom);
|
2007-04-28 17:59:37 +02:00
|
|
|
CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
|
|
|
|
DeleteObject(hRgnClip);
|
|
|
|
}
|
2011-02-03 20:14:03 +01:00
|
|
|
*clip_list_size = GetRegionData(hRgn, *clip_list_size, clip_list);
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|
|
|
|
DeleteObject(hRgn);
|
2011-02-03 20:14:03 +01:00
|
|
|
ReleaseDC(clipper->hWnd, hDC);
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
static unsigned int once;
|
|
|
|
|
|
|
|
if (!once++)
|
|
|
|
FIXME("clipper %p, rect %s, clip_list %p, clip_list_size %p stub!\n",
|
|
|
|
clipper, wine_dbgstr_rect(rect), clip_list, clip_list_size);
|
|
|
|
|
|
|
|
if (clip_list_size)
|
|
|
|
*clip_list_size = 0;
|
|
|
|
|
2007-04-28 17:59:37 +02:00
|
|
|
return WINEDDERR_NOCLIPLIST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
HRESULT CDECL wined3d_clipper_set_clip_list(struct wined3d_clipper *clipper, const RGNDATA *region, DWORD flags)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
static unsigned int once;
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
if (!once++ || !region)
|
|
|
|
FIXME("clipper %p, region %p, flags %#x stub!\n", clipper, region, flags);
|
2009-12-21 23:17:26 +01:00
|
|
|
|
2007-04-28 17:59:37 +02:00
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
HRESULT CDECL wined3d_clipper_get_window(const struct wined3d_clipper *clipper, HWND *window)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
TRACE("clipper %p, window %p.\n", clipper, window);
|
|
|
|
|
|
|
|
*window = clipper->hWnd;
|
2007-04-28 17:59:37 +02:00
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
HRESULT CDECL wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper *clipper, BOOL *changed)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:03 +01:00
|
|
|
FIXME("clipper %p, changed %p stub!\n", clipper, changed);
|
2007-04-28 17:59:37 +02:00
|
|
|
|
|
|
|
/* XXX What is safest? */
|
|
|
|
*changed = FALSE;
|
|
|
|
|
|
|
|
return WINED3D_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:03 +01:00
|
|
|
struct wined3d_clipper * CDECL wined3d_clipper_create(void)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
2011-02-03 20:14:04 +01:00
|
|
|
struct wined3d_clipper *clipper;
|
2007-04-28 17:59:37 +02:00
|
|
|
|
2010-08-31 18:41:39 +02:00
|
|
|
TRACE("\n");
|
|
|
|
|
2011-02-03 20:14:04 +01:00
|
|
|
clipper = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*clipper));
|
|
|
|
if (!clipper)
|
2007-04-28 17:59:37 +02:00
|
|
|
{
|
|
|
|
ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-02-03 20:14:04 +01:00
|
|
|
wined3d_clipper_incref(clipper);
|
|
|
|
|
|
|
|
return clipper;
|
2007-04-28 17:59:37 +02:00
|
|
|
}
|