VirtualBox

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

最後變更 在這個檔案從23571是 16477,由 vboxsync 提交於 16 年 前

LGPL disclaimer by filemuncher

  • 屬性 svn:eol-style 設為 native
檔案大小: 6.4 KB
 
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 **Obj)
41{
42 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
43
44 TRACE("(%p)->(%p,%p)\n", This, riid, Obj);
45 if (IsEqualGUID(&IID_IUnknown, riid)
46 || IsEqualGUID(&IID_IWineD3DClipper, riid))
47 {
48 *Obj = iface;
49 IWineD3DClipper_AddRef(iface);
50 return S_OK;
51 }
52 else
53 {
54 return E_NOINTERFACE;
55 }
56}
57
58static ULONG WINAPI IWineD3DClipperImpl_AddRef(IWineD3DClipper *iface )
59{
60 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
61 ULONG ref = InterlockedIncrement(&This->ref);
62
63 TRACE("(%p)->() incrementing from %u.\n", This, ref - 1);
64
65 return ref;
66}
67
68static ULONG WINAPI IWineD3DClipperImpl_Release(IWineD3DClipper *iface)
69{
70 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
71 ULONG ref = InterlockedDecrement(&This->ref);
72
73 TRACE("(%p)->() decrementing from %u.\n", This, ref + 1);
74
75 if (ref == 0)
76 {
77 HeapFree(GetProcessHeap(), 0, This);
78 return 0;
79 }
80 else return ref;
81}
82
83static HRESULT WINAPI IWineD3DClipperImpl_GetParent(IWineD3DClipper *iface, IUnknown **Parent)
84{
85 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
86 TRACE("(%p)->(%p)\n", This, Parent);
87
88 *Parent = This->Parent;
89 IUnknown_AddRef(*Parent);
90 return WINED3D_OK;
91}
92
93static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD Flags, HWND hWnd)
94{
95 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
96
97 TRACE("(%p)->(0x%08x,%p)\n", This, Flags, hWnd);
98 if( Flags )
99 {
100 FIXME("Flags = 0x%08x, not supported.\n",Flags);
101 return WINED3DERR_INVALIDCALL;
102 }
103
104 This->hWnd = hWnd;
105 return WINED3D_OK;
106}
107
108static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
109 RGNDATA *ClipList, DWORD *Size)
110{
111 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
112 TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
113
114 if (This->hWnd)
115 {
116 HDC hDC = GetDCEx(This->hWnd, NULL, DCX_WINDOW);
117 if (hDC)
118 {
119 HRGN hRgn = CreateRectRgn(0,0,0,0);
120 if (GetRandomRgn(hDC, hRgn, SYSRGN))
121 {
122 if (GetVersion() & 0x80000000)
123 {
124 /* map region to screen coordinates */
125 POINT org;
126 GetDCOrgEx( hDC, &org );
127 OffsetRgn( hRgn, org.x, org.y );
128 }
129 if (Rect)
130 {
131 HRGN hRgnClip = CreateRectRgn(Rect->left, Rect->top,
132 Rect->right, Rect->bottom);
133 CombineRgn(hRgn, hRgn, hRgnClip, RGN_AND);
134 DeleteObject(hRgnClip);
135 }
136 *Size = GetRegionData(hRgn, *Size, ClipList);
137 }
138 DeleteObject(hRgn);
139 ReleaseDC(This->hWnd, hDC);
140 }
141 return WINED3D_OK;
142 }
143 else
144 {
145 static int warned = 0;
146 if (warned++ < 10)
147 FIXME("(%p,%p,%p,%p),stub!\n",This,Rect,ClipList,Size);
148 if (Size) *Size=0;
149 return WINEDDERR_NOCLIPLIST;
150 }
151}
152
153static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
154{
155 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
156 static int warned = 0;
157
158 if (warned++ < 10 || rgn == NULL)
159 FIXME("(%p,%p,%d),stub!\n",This,rgn,Flags);
160 return WINED3D_OK;
161}
162
163static HRESULT WINAPI IWineD3DClipperImpl_GetHwnd(IWineD3DClipper *iface, HWND *hwnd)
164{
165 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
166 TRACE("(%p)->(%p)\n", This, hwnd);
167
168 *hwnd = This->hWnd;
169 return WINED3D_OK;
170}
171
172static HRESULT WINAPI IWineD3DClipperImpl_IsClipListChanged(IWineD3DClipper *iface, BOOL *changed)
173{
174 IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
175 FIXME("(%p)->(%p),stub!\n",This,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}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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