1 /* IWineD3DClipper implementation
3 * Copyright 2000 (c) Marcus Meissner
4 * Copyright 2000 (c) TransGaming Technologies Inc.
5 * Copyright 2006 (c) Stefan Dösinger
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wined3d_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
31 ULONG CDECL
wined3d_clipper_incref(struct wined3d_clipper
*clipper
)
33 ULONG refcount
= InterlockedIncrement(&clipper
->ref
);
35 TRACE("%p increasing refcount to %u.\n", clipper
, refcount
);
40 ULONG CDECL
wined3d_clipper_decref(struct wined3d_clipper
*clipper
)
42 ULONG refcount
= InterlockedDecrement(&clipper
->ref
);
44 TRACE("%p decreasing refcount to %u.\n", clipper
, refcount
);
47 HeapFree(GetProcessHeap(), 0, clipper
);
52 HRESULT CDECL
wined3d_clipper_set_window(struct wined3d_clipper
*clipper
, DWORD flags
, HWND window
)
54 TRACE("clipper %p, flags %#x, window %p.\n", clipper
, flags
, window
);
58 FIXME("flags %#x, not supported.\n", flags
);
59 return WINED3DERR_INVALIDCALL
;
62 clipper
->hWnd
= window
;
67 HRESULT CDECL
wined3d_clipper_get_clip_list(const struct wined3d_clipper
*clipper
, const RECT
*rect
,
68 RGNDATA
*clip_list
, DWORD
*clip_list_size
)
70 TRACE("clipper %p, rect %s, clip_list %p, clip_list_size %p.\n",
71 clipper
, wine_dbgstr_rect(rect
), clip_list
, clip_list_size
);
75 HDC hDC
= GetDCEx(clipper
->hWnd
, NULL
, DCX_WINDOW
);
78 HRGN hRgn
= CreateRectRgn(0,0,0,0);
79 if (GetRandomRgn(hDC
, hRgn
, SYSRGN
))
81 if (GetVersion() & 0x80000000)
83 /* map region to screen coordinates */
85 GetDCOrgEx(hDC
, &org
);
86 OffsetRgn(hRgn
, org
.x
, org
.y
);
90 HRGN hRgnClip
= CreateRectRgn(rect
->left
, rect
->top
,
91 rect
->right
, rect
->bottom
);
92 CombineRgn(hRgn
, hRgn
, hRgnClip
, RGN_AND
);
93 DeleteObject(hRgnClip
);
95 *clip_list_size
= GetRegionData(hRgn
, *clip_list_size
, clip_list
);
98 ReleaseDC(clipper
->hWnd
, hDC
);
104 static unsigned int once
;
107 FIXME("clipper %p, rect %s, clip_list %p, clip_list_size %p stub!\n",
108 clipper
, wine_dbgstr_rect(rect
), clip_list
, clip_list_size
);
113 return WINEDDERR_NOCLIPLIST
;
117 HRESULT CDECL
wined3d_clipper_set_clip_list(struct wined3d_clipper
*clipper
, const RGNDATA
*region
, DWORD flags
)
119 static unsigned int once
;
121 if (!once
++ || !region
)
122 FIXME("clipper %p, region %p, flags %#x stub!\n", clipper
, region
, flags
);
127 HRESULT CDECL
wined3d_clipper_get_window(const struct wined3d_clipper
*clipper
, HWND
*window
)
129 TRACE("clipper %p, window %p.\n", clipper
, window
);
131 *window
= clipper
->hWnd
;
136 HRESULT CDECL
wined3d_clipper_is_clip_list_changed(const struct wined3d_clipper
*clipper
, BOOL
*changed
)
138 FIXME("clipper %p, changed %p stub!\n", clipper
, changed
);
140 /* XXX What is safest? */
146 struct wined3d_clipper
* CDECL
wined3d_clipper_create(void)
148 struct wined3d_clipper
*clipper
;
152 clipper
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*clipper
));
155 ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
159 wined3d_clipper_incref(clipper
);