2 * Copyright 2000 (c) Marcus Meissner
3 * Copyright 2000 (c) TransGaming Technologies Inc.
4 * Copyright 2006 (c) Stefan Dösinger
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
30 ULONG CDECL
wined3d_clipper_incref(struct wined3d_clipper
*clipper
)
32 ULONG refcount
= InterlockedIncrement(&clipper
->ref
);
34 TRACE("%p increasing refcount to %u.\n", clipper
, refcount
);
39 ULONG CDECL
wined3d_clipper_decref(struct wined3d_clipper
*clipper
)
41 ULONG refcount
= InterlockedDecrement(&clipper
->ref
);
43 TRACE("%p decreasing refcount to %u.\n", clipper
, refcount
);
46 HeapFree(GetProcessHeap(), 0, clipper
);
51 HRESULT CDECL
wined3d_clipper_set_window(struct wined3d_clipper
*clipper
, DWORD flags
, HWND window
)
53 TRACE("clipper %p, flags %#x, window %p.\n", clipper
, flags
, window
);
57 FIXME("flags %#x, not supported.\n", flags
);
58 return WINED3DERR_INVALIDCALL
;
61 clipper
->hWnd
= window
;
66 HRESULT CDECL
wined3d_clipper_get_clip_list(const struct wined3d_clipper
*clipper
, const RECT
*rect
,
67 RGNDATA
*clip_list
, DWORD
*clip_list_size
)
69 TRACE("clipper %p, rect %s, clip_list %p, clip_list_size %p.\n",
70 clipper
, wine_dbgstr_rect(rect
), clip_list
, clip_list_size
);
74 HDC hDC
= GetDCEx(clipper
->hWnd
, NULL
, DCX_WINDOW
);
77 HRGN hRgn
= CreateRectRgn(0,0,0,0);
78 if (GetRandomRgn(hDC
, hRgn
, SYSRGN
))
80 if (GetVersion() & 0x80000000)
82 /* map region to screen coordinates */
84 GetDCOrgEx(hDC
, &org
);
85 OffsetRgn(hRgn
, org
.x
, org
.y
);
89 HRGN hRgnClip
= CreateRectRgn(rect
->left
, rect
->top
,
90 rect
->right
, rect
->bottom
);
91 CombineRgn(hRgn
, hRgn
, hRgnClip
, RGN_AND
);
92 DeleteObject(hRgnClip
);
94 *clip_list_size
= GetRegionData(hRgn
, *clip_list_size
, clip_list
);
97 ReleaseDC(clipper
->hWnd
, hDC
);
103 static unsigned int once
;
106 FIXME("clipper %p, rect %s, clip_list %p, clip_list_size %p stub!\n",
107 clipper
, wine_dbgstr_rect(rect
), clip_list
, clip_list_size
);
112 return WINEDDERR_NOCLIPLIST
;
116 HRESULT CDECL
wined3d_clipper_set_clip_list(struct wined3d_clipper
*clipper
, const RGNDATA
*region
, DWORD flags
)
118 static unsigned int once
;
120 if (!once
++ || !region
)
121 FIXME("clipper %p, region %p, flags %#x stub!\n", clipper
, region
, flags
);
126 HRESULT CDECL
wined3d_clipper_get_window(const struct wined3d_clipper
*clipper
, HWND
*window
)
128 TRACE("clipper %p, window %p.\n", clipper
, window
);
130 *window
= clipper
->hWnd
;
135 HRESULT CDECL
wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper
*clipper
, BOOL
*changed
)
137 FIXME("clipper %p, changed %p stub!\n", clipper
, changed
);
139 /* XXX What is safest? */
145 struct wined3d_clipper
* CDECL
wined3d_clipper_create(void)
147 struct wined3d_clipper
*clipper
;
151 clipper
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*clipper
));
154 ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
158 wined3d_clipper_incref(clipper
);