ReactOS  0.4.15-dev-1197-g8081ba9
clipper.c File Reference
#include "config.h"
#include "wine/port.h"
#include "ddraw_private.h"
Include dependency graph for clipper.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddraw)
 
static struct ddraw_clipperimpl_from_IDirectDrawClipper (IDirectDrawClipper *iface)
 
static HRESULT WINAPI ddraw_clipper_QueryInterface (IDirectDrawClipper *iface, REFIID iid, void **object)
 
static ULONG WINAPI ddraw_clipper_AddRef (IDirectDrawClipper *iface)
 
static ULONG WINAPI ddraw_clipper_Release (IDirectDrawClipper *iface)
 
static HRESULT WINAPI ddraw_clipper_SetHWnd (IDirectDrawClipper *iface, DWORD flags, HWND window)
 
static HRGN get_window_region (HWND window)
 
static HRESULT WINAPI ddraw_clipper_GetClipList (IDirectDrawClipper *iface, RECT *rect, RGNDATA *clip_list, DWORD *clip_list_size)
 
static HRESULT WINAPI ddraw_clipper_SetClipList (IDirectDrawClipper *iface, RGNDATA *region, DWORD flags)
 
static HRESULT WINAPI ddraw_clipper_GetHWnd (IDirectDrawClipper *iface, HWND *window)
 
static HRESULT WINAPI ddraw_clipper_Initialize (IDirectDrawClipper *iface, IDirectDraw *ddraw, DWORD flags)
 
static HRESULT WINAPI ddraw_clipper_IsClipListChanged (IDirectDrawClipper *iface, BOOL *changed)
 
HRESULT ddraw_clipper_init (struct ddraw_clipper *clipper)
 
struct ddraw_clipperunsafe_impl_from_IDirectDrawClipper (IDirectDrawClipper *iface)
 

Variables

static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl
 

Function Documentation

◆ ddraw_clipper_AddRef()

static ULONG WINAPI ddraw_clipper_AddRef ( IDirectDrawClipper *  iface)
static

Definition at line 54 of file clipper.c.

55 {
56  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
57  ULONG refcount = InterlockedIncrement(&clipper->ref);
58 
59  TRACE("%p increasing refcount to %u.\n", clipper, refcount);
60 
61  return refcount;
62 }
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

◆ ddraw_clipper_GetClipList()

static HRESULT WINAPI ddraw_clipper_GetClipList ( IDirectDrawClipper *  iface,
RECT rect,
RGNDATA clip_list,
DWORD clip_list_size 
)
static

Definition at line 155 of file clipper.c.

157 {
158  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
159  HRGN region;
160 
161  TRACE("iface %p, rect %s, clip_list %p, clip_list_size %p.\n",
162  iface, wine_dbgstr_rect(rect), clip_list, clip_list_size);
163 
165 
166  if (clipper->window)
167  {
168  if (!(region = get_window_region(clipper->window)))
169  {
171  WARN("Failed to get window region.\n");
172  return E_FAIL;
173  }
174  }
175  else
176  {
177  if (!(region = clipper->region))
178  {
180  WARN("No clip list set.\n");
181  return DDERR_NOCLIPLIST;
182  }
183  }
184 
185  if (rect)
186  {
187  HRGN clip_region;
188 
189  if (!(clip_region = CreateRectRgnIndirect(rect)))
190  {
192  ERR("Failed to create region.\n");
193  if (clipper->window)
195  return E_FAIL;
196  }
197 
198  if (CombineRgn(clip_region, region, clip_region, RGN_AND) == ERROR)
199  {
201  ERR("Failed to combine regions.\n");
202  DeleteObject(clip_region);
203  if (clipper->window)
205  return E_FAIL;
206  }
207 
208  if (clipper->window)
210  region = clip_region;
211  }
212 
213  *clip_list_size = GetRegionData(region, *clip_list_size, clip_list);
214  if (rect || clipper->window)
216 
218  return DD_OK;
219 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define ERROR(name)
Definition: error_private.h:53
#define WARN(fmt,...)
Definition: debug.h:112
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define E_FAIL
Definition: ddrawi.h:102
& rect
Definition: startmenu.cpp:1413
#define RGN_AND
Definition: wingdi.h:355
#define DD_OK
Definition: ddraw.h:186
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define TRACE(s)
Definition: solgame.cpp:4
const char * wine_dbgstr_rect(const RECT *rect)
#define ERR(fmt,...)
Definition: debug.h:110
static HRGN get_window_region(HWND window)
Definition: clipper.c:100
#define DDERR_NOCLIPLIST
Definition: ddraw.h:87
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
DWORD WINAPI GetRegionData(_In_ HRGN hrgn, _In_ DWORD nCount, _Out_writes_bytes_to_opt_(nCount, return) LPRGNDATA lpRgnData)

◆ ddraw_clipper_GetHWnd()

static HRESULT WINAPI ddraw_clipper_GetHWnd ( IDirectDrawClipper *  iface,
HWND window 
)
static

Definition at line 265 of file clipper.c.

266 {
267  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
268 
269  TRACE("iface %p, window %p.\n", iface, window);
270 
272  *window = clipper->window;
274 
275  return DD_OK;
276 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define DD_OK
Definition: ddraw.h:186
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define TRACE(s)
Definition: solgame.cpp:4
static IHTMLWindow2 * window
Definition: events.c:77
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ ddraw_clipper_init()

HRESULT ddraw_clipper_init ( struct ddraw_clipper clipper)

Definition at line 321 of file clipper.c.

322 {
323  clipper->IDirectDrawClipper_iface.lpVtbl = &ddraw_clipper_vtbl;
324  clipper->ref = 1;
325 
326  return DD_OK;
327 }
#define DD_OK
Definition: ddraw.h:186
static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl
Definition: clipper.c:308
IDirectDrawClipper IDirectDrawClipper_iface

Referenced by DirectDrawCreateClipper().

◆ ddraw_clipper_Initialize()

static HRESULT WINAPI ddraw_clipper_Initialize ( IDirectDrawClipper *  iface,
IDirectDraw *  ddraw,
DWORD  flags 
)
static

Definition at line 278 of file clipper.c.

280 {
281  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
282 
283  TRACE("iface %p, ddraw %p, flags %#x.\n", iface, ddraw, flags);
284 
286  if (clipper->initialized)
287  {
290  }
291 
292  clipper->initialized = TRUE;
294 
295  return DD_OK;
296 }
#define TRUE
Definition: types.h:120
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define DD_OK
Definition: ddraw.h:186
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define DDERR_ALREADYINITIALIZED
Definition: ddraw.h:67
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ ddraw_clipper_IsClipListChanged()

static HRESULT WINAPI ddraw_clipper_IsClipListChanged ( IDirectDrawClipper *  iface,
BOOL changed 
)
static

Definition at line 298 of file clipper.c.

299 {
300  FIXME("iface %p, changed %p stub!\n", iface, changed);
301 
302  /* XXX What is safest? */
303  *changed = FALSE;
304 
305  return DD_OK;
306 }
#define DD_OK
Definition: ddraw.h:186
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111

◆ ddraw_clipper_QueryInterface()

static HRESULT WINAPI ddraw_clipper_QueryInterface ( IDirectDrawClipper *  iface,
REFIID  iid,
void **  object 
)
static

Definition at line 34 of file clipper.c.

35 {
36  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
37 
38  TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object);
39 
40  if (IsEqualGUID(&IID_IDirectDrawClipper, iid)
41  || IsEqualGUID(&IID_IUnknown, iid))
42  {
43  IDirectDrawClipper_AddRef(&clipper->IDirectDrawClipper_iface);
44  *object = &clipper->IDirectDrawClipper_iface;
45  return S_OK;
46  }
47 
48  WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
49  *object = NULL;
50 
51  return E_NOINTERFACE;
52 }
#define E_NOINTERFACE
Definition: winerror.h:2364
#define WARN(fmt,...)
Definition: debug.h:112
smooth NULL
Definition: ftsmooth.c:416
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
const GUID IID_IUnknown
IDirectDrawClipper IDirectDrawClipper_iface
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112

◆ ddraw_clipper_Release()

static ULONG WINAPI ddraw_clipper_Release ( IDirectDrawClipper *  iface)
static

Definition at line 64 of file clipper.c.

65 {
66  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
67  ULONG refcount = InterlockedDecrement(&clipper->ref);
68 
69  TRACE("%p decreasing refcount to %u.\n", clipper, refcount);
70 
71  if (!refcount)
72  {
73  if (clipper->region)
74  DeleteObject(clipper->region);
75  heap_free(clipper);
76  }
77 
78  return refcount;
79 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

◆ ddraw_clipper_SetClipList()

static HRESULT WINAPI ddraw_clipper_SetClipList ( IDirectDrawClipper *  iface,
RGNDATA region,
DWORD  flags 
)
static

Definition at line 235 of file clipper.c.

236 {
237  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
238 
239  TRACE("iface %p, region %p, flags %#x.\n", iface, region, flags);
240 
242 
243  if (clipper->window)
244  {
247  }
248 
249  if (clipper->region)
250  DeleteObject(clipper->region);
251  if (!region)
252  clipper->region = NULL;
253  else if (!(clipper->region = ExtCreateRegion(NULL, 0, region)))
254  {
256  ERR("Failed to create region.\n");
257  return E_FAIL;
258  }
259 
261 
262  return DD_OK;
263 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define E_FAIL
Definition: ddrawi.h:102
#define DD_OK
Definition: ddraw.h:186
smooth NULL
Definition: ftsmooth.c:416
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
#define ERR(fmt,...)
Definition: debug.h:110
HRGN WINAPI ExtCreateRegion(_In_opt_ const XFORM *lpx, _In_ DWORD nCount, _In_reads_bytes_(nCount) const RGNDATA *lpData)
#define DDERR_CLIPPERISUSINGHWND
Definition: ddraw.h:141
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373

◆ ddraw_clipper_SetHWnd()

static HRESULT WINAPI ddraw_clipper_SetHWnd ( IDirectDrawClipper *  iface,
DWORD  flags,
HWND  window 
)
static

Definition at line 81 of file clipper.c.

82 {
83  struct ddraw_clipper *clipper = impl_from_IDirectDrawClipper(iface);
84 
85  TRACE("iface %p, flags %#x, window %p.\n", iface, flags, window);
86 
87  if (flags)
88  {
89  FIXME("flags %#x, not supported.\n", flags);
90  return DDERR_INVALIDPARAMS;
91  }
92 
94  clipper->window = window;
96 
97  return DD_OK;
98 }
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:368
#define DD_OK
Definition: ddraw.h:186
#define FIXME(fmt,...)
Definition: debug.h:111
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
#define TRACE(s)
Definition: solgame.cpp:4
GLbitfield flags
Definition: glext.h:7161
static IHTMLWindow2 * window
Definition: events.c:77
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:373
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ get_window_region()

static HRGN get_window_region ( HWND  window)
static

Definition at line 100 of file clipper.c.

101 {
102  POINT origin;
103  HRGN rgn;
104  HDC dc;
105 
106  if (!(dc = GetDC(window)))
107  {
108  WARN("Failed to get dc.\n");
109  return NULL;
110  }
111 
112  if (!(rgn = CreateRectRgn(0, 0, 0, 0)))
113  {
114  ERR("Failed to create region.\n");
115  ReleaseDC(window, dc);
116  return NULL;
117  }
118 
119  if (GetRandomRgn(dc, rgn, SYSRGN) != 1)
120  {
121  ERR("Failed to get window region.\n");
122  DeleteObject(rgn);
123  ReleaseDC(window, dc);
124  return NULL;
125  }
126 
127  if (GetVersion() & 0x80000000)
128  {
129  GetDCOrgEx(dc, &origin);
130  OffsetRgn(rgn, origin.x, origin.y);
131  }
132 
133  ReleaseDC(window, dc);
134  return rgn;
135 }
HDC WINAPI GetDC(_In_opt_ HWND)
#define WARN(fmt,...)
Definition: debug.h:112
static HDC
Definition: imagelist.c:92
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
voidpf uLong int origin
Definition: ioapi.h:142
int WINAPI OffsetRgn(_In_ HRGN, _In_ int, _In_ int)
DWORD WINAPI GetVersion(VOID)
Definition: version.c:22
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
static IHTMLWindow2 * window
Definition: events.c:77
#define ERR(fmt,...)
Definition: debug.h:110
int WINAPI GetRandomRgn(_In_ HDC, _In_ HRGN, _In_ INT)
static const WCHAR dc[]
#define SYSRGN
Definition: GetRandomRgn.c:13
BOOL WINAPI GetDCOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:825

Referenced by ddraw_clipper_GetClipList().

◆ impl_from_IDirectDrawClipper()

static struct ddraw_clipper* impl_from_IDirectDrawClipper ( IDirectDrawClipper *  iface)
inlinestatic

Definition at line 29 of file clipper.c.

30 {
32 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
IDirectDrawClipper IDirectDrawClipper_iface

Referenced by ddraw_clipper_AddRef(), ddraw_clipper_GetClipList(), ddraw_clipper_GetHWnd(), ddraw_clipper_Initialize(), ddraw_clipper_QueryInterface(), ddraw_clipper_Release(), ddraw_clipper_SetClipList(), ddraw_clipper_SetHWnd(), and unsafe_impl_from_IDirectDrawClipper().

◆ unsafe_impl_from_IDirectDrawClipper()

struct ddraw_clipper* unsafe_impl_from_IDirectDrawClipper ( IDirectDrawClipper *  iface)

Definition at line 329 of file clipper.c.

330 {
331  if (!iface)
332  return NULL;
333  assert(iface->lpVtbl == &ddraw_clipper_vtbl);
334 
335  return impl_from_IDirectDrawClipper(iface);
336 }
#define assert(x)
Definition: debug.h:53
smooth NULL
Definition: ftsmooth.c:416
static struct ddraw_clipper * impl_from_IDirectDrawClipper(IDirectDrawClipper *iface)
Definition: clipper.c:29
static const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl
Definition: clipper.c:308

Referenced by ddraw_surface7_SetClipper().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddraw  )

Variable Documentation

◆ ddraw_clipper_vtbl

const struct IDirectDrawClipperVtbl ddraw_clipper_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI ddraw_clipper_AddRef(IDirectDrawClipper *iface)
Definition: clipper.c:54
static HRESULT WINAPI ddraw_clipper_Initialize(IDirectDrawClipper *iface, IDirectDraw *ddraw, DWORD flags)
Definition: clipper.c:278
static HRESULT WINAPI ddraw_clipper_IsClipListChanged(IDirectDrawClipper *iface, BOOL *changed)
Definition: clipper.c:298
static HRESULT WINAPI ddraw_clipper_SetClipList(IDirectDrawClipper *iface, RGNDATA *region, DWORD flags)
Definition: clipper.c:235
static HRESULT WINAPI ddraw_clipper_QueryInterface(IDirectDrawClipper *iface, REFIID iid, void **object)
Definition: clipper.c:34
static HRESULT WINAPI ddraw_clipper_SetHWnd(IDirectDrawClipper *iface, DWORD flags, HWND window)
Definition: clipper.c:81
static ULONG WINAPI ddraw_clipper_Release(IDirectDrawClipper *iface)
Definition: clipper.c:64
static HRESULT WINAPI ddraw_clipper_GetClipList(IDirectDrawClipper *iface, RECT *rect, RGNDATA *clip_list, DWORD *clip_list_size)
Definition: clipper.c:155
static HRESULT WINAPI ddraw_clipper_GetHWnd(IDirectDrawClipper *iface, HWND *window)
Definition: clipper.c:265

Definition at line 308 of file clipper.c.

Referenced by ddraw_clipper_init(), and unsafe_impl_from_IDirectDrawClipper().