VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/clipper.c@ 25949

Last change on this file since 25949 was 25949, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.36 and disable unnecessary fbo state poll

  • Property svn:eol-style set to native
File size: 6.4 KB
Line 
1/* IWineD3DClipper implementation
2 *
3 * Copyright 2000 (c) Marcus Meissner
4 * Copyright 2000 (c) TransGaming Technologies Inc.
5 * Copyright 2006 (c) Stefan Dösinger
6 *
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.
11 *
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.
16 *
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
20 */
21
22/*
23 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
24 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
25 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
26 * a choice of LGPL license versions is made available with the language indicating
27 * that LGPLv2 or any later version may be used, or where a choice of which version
28 * of the LGPL is applied is otherwise unspecified.
29 */
30
31#include "config.h"
32#include <stdio.h>
33#ifdef HAVE_FLOAT_H
34# include <float.h>
35#endif
36#include "wined3d_private.h"
37
38WINE_DEFAULT_DEBUG_CHANNEL(d3d);
39
40static HRESULT WINAPI IWineD3DClipperImpl_QueryInterface(IWineD3DClipper *iface, REFIID riid, void **object)
41{
42 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
43
44 if (IsEqualGUID(riid, &IID_IWineD3DClipper)
45 || IsEqualGUID(riid, &IID_IWineD3DBase)
46 || IsEqualGUID(riid, &IID_IUnknown))
47 {
48 IUnknown_AddRef(iface);
49 *object = iface;
50 return S_OK;
51 }
52
53 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
54
55 *object = NULL;
56 return E_NOINTERFACE;
57}
58
59static ULONG WINAPI IWineD3DClipperImpl_AddRef(IWineD3DClipper *iface )
60{
61 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
62 ULONG ref = InterlockedIncrement(&This->ref);
63
64 TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
65
66 return ref;
67}
68
69static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
70{
71 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
72 ULONG ref = InterlockedDecrement(&This->ref);
73
74 TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
75
76 if (ref == 0)
77 {
78 HeapFree(GetProcessHeap(), 0, This);
79 return 0;
80 }
81 else return ref;
82}
83
84static HRESULT WINAPI IWineD3DClipperImpl_GetParent(IWineD3DClipper *iface, IUnknown **Parent)
85{
86 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
87 TRACE("(%p)->(%p)\n", This, Parent);
88
89 *Parent = This->Parent;
90 IUnknown_AddRef(*Parent);
91 return WINED3D_OK;
92}
93
94static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd)
95{
96 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
97
98 TRACE("(%p)->(0x%08x,%p)\n", This, Flags, hWnd);
99 if( Flags )
100 {
101 FIXME("Flags = 0x%08x, not supported.\n",Flags);
102 return WINED3DERR_INVALIDCALL;
103 }
104
105 This->hWnd = hWnd;
106 return WINED3D_OK;
107}
108
109static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
110 RGNDATA *ClipList, DWORD *Size)
111{
112 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
113 TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
114
115 if (This->hWnd)
116 {
117 HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
118 if (hDC)
119 {
120 HRGN hRgn = CreateRectRgn(0,0,0,0);
121 if (GetRandomRgn(hDC, hRgn, SYSRGN))
122 {
123 if (GetVersion() & 0x80000000)
124 {
125 /* map region to screen coordinates */
126 POINT org;
127 GetDCOrgEx( hDC, &org );
128 OffsetRgn( hRgn, org.x, org.y );
129 }
130 if (Rect)
131 {
132 HRGN hRgnClip = CreateRectRgn(Rect->left, Rect->top,
133 Rect->right, Rect->bottom);
134 CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
135 DeleteObject(hRgnClip);
136 }
137 *Size = GetRegionData(hRgn, *Size, ClipList);
138 }
139 DeleteObject(hRgn);
140 ReleaseDC(This->hWnd, hDC);
141 }
142 return WINED3D_OK;
143 }
144 else
145 {
146 static int warned = 0;
147 if (warned++ < 10)
148 FIXME("(%p,%p,%p,%p),stub!\n",This,Rect,ClipList,Size);
149 if (Size) *Size=0;
150 return WINEDDERR_NOCLIPLIST;
151 }
152}
153
154static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
155{
156 static int warned = 0;
157
158 if (warned++ < 10 || rgn == NULL)
159 FIXME("iface %p, region %p, flags %#x stub!\n", iface, rgn, Flags);
160
161 return WINED3D_OK;
162}
163
164static HRESULT WINAPI IWineD3DClipperImpl_GetHwnd(IWineD3DClipper *iface, HWND *hwnd)
165{
166 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
167 TRACE("(%p)->(%p)\n", This, hwnd);
168
169 *hwnd = This->hWnd;
170 return WINED3D_OK;
171}
172
173static HRESULT WINAPI IWineD3DClipperImpl_IsClipListChanged(IWineD3DClipper *iface, BOOL *changed)
174{
175 FIXME("iface %p, changed %p stub!\n", iface, changed);
176
177 /* XXX What is safest? */
178 *changed = FALSE;
179
180 return WINED3D_OK;
181}
182
183static const IWineD3DClipperVtbl IWineD3DClipper_Vtbl =
184{
185 IWineD3DClipperImpl_QueryInterface,
186 IWineD3DClipperImpl_AddRef,
187 IWineD3DClipperImpl_Release,
188 IWineD3DClipperImpl_GetParent,
189 IWineD3DClipperImpl_GetClipList,
190 IWineD3DClipperImpl_GetHwnd,
191 IWineD3DClipperImpl_IsClipListChanged,
192 IWineD3DClipperImpl_SetClipList,
193 IWineD3DClipperImpl_SetHwnd
194};
195
196IWineD3DClipper* WINAPI WineDirect3DCreateClipper(IUnknown *Parent)
197{
198 IWineD3DClipperImpl *obj;
199
200 TRACE("Creating clipper, parent %p\n", Parent);
201 obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*obj));
202 if(!obj)
203 {
204 ERR("Out of memory when trying to allocate a WineD3D Clipper\n");
205 return NULL;
206 }
207
208 obj->lpVtbl = &IWineD3DClipper_Vtbl;
209 obj->Parent = Parent;
210
211 IWineD3DClipper_AddRef((IWineD3DClipper *)obj);
212 return (IWineD3DClipper *) obj;
213}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette