VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/indexbuffer.c@ 20227

Last change on this file since 20227 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

  • Property svn:eol-style set to native
File size: 8.2 KB
Line 
1/*
2 * IDirect3DIndexBuffer8 implementation
3 *
4 * Copyright 2005 Oliver Stieber
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21/*
22 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#include "config.h"
31#include "d3d8_private.h"
32
33WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
34
35/* IDirect3DIndexBuffer8 IUnknown parts follow: */
36static HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
37 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
38
39 if (IsEqualGUID(riid, &IID_IUnknown)
40 || IsEqualGUID(riid, &IID_IDirect3DResource8)
41 || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
42 IUnknown_AddRef(iface);
43 *ppobj = This;
44 return S_OK;
45 }
46
47 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
48 *ppobj = NULL;
49 return E_NOINTERFACE;
50}
51
52static ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
53 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
54 ULONG ref = InterlockedIncrement(&This->ref);
55
56 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
57
58 return ref;
59}
60
61static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
62 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
63 ULONG ref = InterlockedDecrement(&This->ref);
64
65 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
66
67 if (ref == 0) {
68 EnterCriticalSection(&d3d8_cs);
69 IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
70 LeaveCriticalSection(&d3d8_cs);
71 IUnknown_Release(This->parentDevice);
72 HeapFree(GetProcessHeap(), 0, This);
73 }
74 return ref;
75}
76
77/* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
78static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
79 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
80 IWineD3DDevice *wined3d_device;
81 HRESULT hr;
82 TRACE("(%p) Relay\n", This);
83
84 EnterCriticalSection(&d3d8_cs);
85 hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
86 if (SUCCEEDED(hr))
87 {
88 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
89 IWineD3DDevice_Release(wined3d_device);
90 }
91 LeaveCriticalSection(&d3d8_cs);
92 return hr;
93}
94
95static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
96 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
97 HRESULT hr;
98 TRACE("(%p) Relay\n", This);
99
100 EnterCriticalSection(&d3d8_cs);
101 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
102 LeaveCriticalSection(&d3d8_cs);
103 return hr;
104}
105
106static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
107 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
108 HRESULT hr;
109 TRACE("(%p) Relay\n", This);
110
111 EnterCriticalSection(&d3d8_cs);
112 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
113 LeaveCriticalSection(&d3d8_cs);
114 return hr;
115}
116
117static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
118 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
119 HRESULT hr;
120 TRACE("(%p) Relay\n", This);
121
122 EnterCriticalSection(&d3d8_cs);
123 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
124 LeaveCriticalSection(&d3d8_cs);
125 return hr;
126}
127
128static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
129 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
130 DWORD ret;
131 TRACE("(%p) Relay\n", This);
132
133 EnterCriticalSection(&d3d8_cs);
134 ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
135 LeaveCriticalSection(&d3d8_cs);
136 return ret;
137}
138
139static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
140 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
141 DWORD ret;
142 TRACE("(%p) Relay\n", This);
143
144 EnterCriticalSection(&d3d8_cs);
145 ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
146 LeaveCriticalSection(&d3d8_cs);
147 return ret;
148}
149
150static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
151 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
152 TRACE("(%p) Relay\n", This);
153
154 EnterCriticalSection(&d3d8_cs);
155 IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
156 LeaveCriticalSection(&d3d8_cs);
157}
158
159static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
160 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
161 TRACE("(%p)\n", This);
162
163 return D3DRTYPE_INDEXBUFFER;
164}
165
166/* IDirect3DIndexBuffer8 Interface follow: */
167static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
168 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
169 HRESULT hr;
170 TRACE("(%p) Relay\n", This);
171
172 EnterCriticalSection(&d3d8_cs);
173 hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
174 LeaveCriticalSection(&d3d8_cs);
175 return hr;
176}
177
178static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
179 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
180 HRESULT hr;
181 TRACE("(%p) Relay\n", This);
182
183 EnterCriticalSection(&d3d8_cs);
184 hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
185 LeaveCriticalSection(&d3d8_cs);
186 return hr;
187}
188
189static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
190 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
191 HRESULT hr;
192 WINED3DBUFFER_DESC desc;
193 TRACE("(%p) Relay\n", This);
194
195 EnterCriticalSection(&d3d8_cs);
196 hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
197 LeaveCriticalSection(&d3d8_cs);
198
199 if (SUCCEEDED(hr)) {
200 pDesc->Format = d3dformat_from_wined3dformat(This->format);
201 pDesc->Type = D3DRTYPE_INDEXBUFFER;
202 pDesc->Usage = desc.Usage;
203 pDesc->Pool = desc.Pool;
204 pDesc->Size = desc.Size;
205 }
206
207 return hr;
208}
209
210
211const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
212{
213 /* IUnknown */
214 IDirect3DIndexBuffer8Impl_QueryInterface,
215 IDirect3DIndexBuffer8Impl_AddRef,
216 IDirect3DIndexBuffer8Impl_Release,
217 /* IDirect3DResource8 */
218 IDirect3DIndexBuffer8Impl_GetDevice,
219 IDirect3DIndexBuffer8Impl_SetPrivateData,
220 IDirect3DIndexBuffer8Impl_GetPrivateData,
221 IDirect3DIndexBuffer8Impl_FreePrivateData,
222 IDirect3DIndexBuffer8Impl_SetPriority,
223 IDirect3DIndexBuffer8Impl_GetPriority,
224 IDirect3DIndexBuffer8Impl_PreLoad,
225 IDirect3DIndexBuffer8Impl_GetType,
226 /* IDirect3DIndexBuffer8 */
227 IDirect3DIndexBuffer8Impl_Lock,
228 IDirect3DIndexBuffer8Impl_Unlock,
229 IDirect3DIndexBuffer8Impl_GetDesc
230};
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