widl: Set the default calling convention at header generation time, not at parsing...
[wine/hramrach.git] / dlls / wined3d / clipper.c
blob8be3a95863be09f4efc64ac07216bcd14ec841e6
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
22 #include "config.h"
23 #include <stdio.h>
24 #ifdef HAVE_FLOAT_H
25 # include <float.h>
26 #endif
27 #include "wined3d_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
31 static HRESULT WINAPI IWineD3DClipperImpl_QueryInterface(IWineD3DClipper *iface, REFIID riid, void **object)
33 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
35 if (IsEqualGUID(riid, &IID_IWineD3DClipper)
36 || IsEqualGUID(riid, &IID_IWineD3DBase)
37 || IsEqualGUID(riid, &IID_IUnknown))
39 IUnknown_AddRef(iface);
40 *object = iface;
41 return S_OK;
44 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
46 *object = NULL;
47 return E_NOINTERFACE;
50 static ULONG WINAPI IWineD3DClipperImpl_AddRef(IWineD3DClipper *iface )
52 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
53 ULONG ref = InterlockedIncrement(&This->ref);
55 TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
57 return ref;
60 static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
62 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
63 ULONG ref = InterlockedDecrement(&This->ref);
65 TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
67 if (ref == 0)
69 HeapFree(GetProcessHeap(), 0, This);
70 return 0;
72 else return ref;
75 static HRESULT WINAPI IWineD3DClipperImpl_GetParent(IWineD3DClipper *iface, IUnknown **Parent)
77 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
78 TRACE("(%p)->(%p)\n", This, Parent);
80 *Parent = This->Parent;
81 IUnknown_AddRef(*Parent);
82 return WINED3D_OK;
85 static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd)
87 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
89 TRACE("(%p)->(0x%08x,%p)\n", This, Flags, hWnd);
90 if( Flags )
92 FIXME("Flags = 0x%08x, not supported.\n",Flags);
93 return WINED3DERR_INVALIDCALL;
96 This->hWnd = hWnd;
97 return WINED3D_OK;
100 static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
101 RGNDATA *ClipList, DWORD *Size)
103 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
104 TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
106 if (This->hWnd)
108 HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
109 if (hDC)
111 HRGN hRgn = CreateRectRgn(0,0,0,0);
112 if (GetRandomRgn(hDC, hRgn, SYSRGN))
114 if (GetVersion() & 0x80000000)
116 /* map region to screen coordinates */
117 POINT org;
118 GetDCOrgEx( hDC, &org );
119 OffsetRgn( hRgn, org.x, org.y );
121 if (Rect)
123 HRGN hRgnClip = CreateRectRgn(Rect->left, Rect->top,
124 Rect->right, Rect->bottom);
125 CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
126 DeleteObject(hRgnClip);
128 *Size = GetRegionData(hRgn, *Size, ClipList);
130 DeleteObject(hRgn);
131 ReleaseDC(This->hWnd, hDC);
133 return WINED3D_OK;
135 else
137 static int warned = 0;
138 if (warned++ < 10)
139 FIXME("(%p,%p,%p,%p),stub!\n",This,Rect,ClipList,Size);
140 if (Size) *Size=0;
141 return WINEDDERR_NOCLIPLIST;
145 static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
147 static int warned = 0;
149 if (warned++ < 10 || rgn == NULL)
150 FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags);
152 return WINED3D_OK;
155 static HRESULT WINAPI IWineD3DClipperImpl_GetHwnd(IWineD3DClipper *iface, HWND *hwnd)
157 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
158 TRACE("(%p)->(%p)\n", This, hwnd);
160 *hwnd = This->hWnd;
161 return WINED3D_OK;
164 static HRESULT WINAPI IWineD3DClipperImpl_IsClipListChanged(IWineD3DClipper *iface, BOOL *changed)
166 FIXME("iface %p, changed %p stub!\n", iface, changed);
168 /* XXX What is safest? */
169 *changed = FALSE;
171 return WINED3D_OK;
174 static const IWineD3DClipperVtbl IWineD3DClipper_Vtbl =
176 IWineD3DClipperImpl_QueryInterface,
177 IWineD3DClipperImpl_AddRef,
178 IWineD3DClipperImpl_Release,
179 IWineD3DClipperImpl_GetParent,
180 IWineD3DClipperImpl_GetClipList,
181 IWineD3DClipperImpl_GetHwnd,
182 IWineD3DClipperImpl_IsClipListChanged,
183 IWineD3DClipperImpl_SetClipList,
184 IWineD3DClipperImpl_SetHwnd
187 IWineD3DClipper* WINAPI WineDirect3DCreateClipper(IUnknown *Parent)
189 IWineD3DClipperImpl *obj;
191 TRACE("Creating clipper, parent %p\n", Parent);
192 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
193 if(!obj)
195 ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
196 return NULL;
199 obj->lpVtbl = &IWineD3DClipper_Vtbl;
200 obj->Parent = Parent;
202 IWineD3DClipper_AddRef((IWineD3DClipper *)obj);
203 return (IWineD3DClipper *) obj;