2 * IDirect3DIndexBuffer8 implementation
4 * Copyright 2005 Oliver Stieber
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.
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.
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
22 #include "d3d8_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
26 /* IDirect3DIndexBuffer8 IUnknown parts follow: */
27 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_QueryInterface(LPDIRECT3DINDEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
28 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
30 if (IsEqualGUID(riid, &IID_IUnknown)
31 || IsEqualGUID(riid, &IID_IDirect3DResource8)
32 || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer8)) {
33 IUnknown_AddRef(iface);
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
43 static ULONG WINAPI IDirect3DIndexBuffer8Impl_AddRef(LPDIRECT3DINDEXBUFFER8 iface) {
44 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
45 ULONG ref = InterlockedIncrement(&This->ref);
47 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
52 static ULONG WINAPI IDirect3DIndexBuffer8Impl_Release(LPDIRECT3DINDEXBUFFER8 iface) {
53 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
54 ULONG ref = InterlockedDecrement(&This->ref);
56 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
59 EnterCriticalSection(&d3d8_cs);
60 IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
61 LeaveCriticalSection(&d3d8_cs);
62 IUnknown_Release(This->parentDevice);
63 HeapFree(GetProcessHeap(), 0, This);
68 /* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
69 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
70 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
71 IWineD3DDevice *wined3d_device;
73 TRACE("(%p) Relay\n", This);
75 EnterCriticalSection(&d3d8_cs);
76 hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
79 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
80 IWineD3DDevice_Release(wined3d_device);
82 LeaveCriticalSection(&d3d8_cs);
86 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
87 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
89 TRACE("(%p) Relay\n", This);
91 EnterCriticalSection(&d3d8_cs);
92 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
93 LeaveCriticalSection(&d3d8_cs);
97 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
98 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
100 TRACE("(%p) Relay\n", This);
102 EnterCriticalSection(&d3d8_cs);
103 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
104 LeaveCriticalSection(&d3d8_cs);
108 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
109 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
111 TRACE("(%p) Relay\n", This);
113 EnterCriticalSection(&d3d8_cs);
114 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
115 LeaveCriticalSection(&d3d8_cs);
119 static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
120 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
122 TRACE("(%p) Relay\n", This);
124 EnterCriticalSection(&d3d8_cs);
125 ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
126 LeaveCriticalSection(&d3d8_cs);
130 static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
131 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
133 TRACE("(%p) Relay\n", This);
135 EnterCriticalSection(&d3d8_cs);
136 ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
137 LeaveCriticalSection(&d3d8_cs);
141 static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
142 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
143 TRACE("(%p) Relay\n", This);
145 EnterCriticalSection(&d3d8_cs);
146 IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
147 LeaveCriticalSection(&d3d8_cs);
150 static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
151 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
152 TRACE("(%p)\n", This);
154 return D3DRTYPE_INDEXBUFFER;
157 /* IDirect3DIndexBuffer8 Interface follow: */
158 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
159 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
161 TRACE("(%p) Relay\n", This);
163 EnterCriticalSection(&d3d8_cs);
164 hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
165 LeaveCriticalSection(&d3d8_cs);
169 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
170 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
172 TRACE("(%p) Relay\n", This);
174 EnterCriticalSection(&d3d8_cs);
175 hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
176 LeaveCriticalSection(&d3d8_cs);
180 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
181 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
183 WINED3DBUFFER_DESC desc;
184 TRACE("(%p) Relay\n", This);
186 EnterCriticalSection(&d3d8_cs);
187 hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
188 LeaveCriticalSection(&d3d8_cs);
191 pDesc->Format = d3dformat_from_wined3dformat(This->format);
192 pDesc->Type = D3DRTYPE_INDEXBUFFER;
193 pDesc->Usage = desc.Usage;
194 pDesc->Pool = desc.Pool;
195 pDesc->Size = desc.Size;
202 const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
205 IDirect3DIndexBuffer8Impl_QueryInterface,
206 IDirect3DIndexBuffer8Impl_AddRef,
207 IDirect3DIndexBuffer8Impl_Release,
208 /* IDirect3DResource8 */
209 IDirect3DIndexBuffer8Impl_GetDevice,
210 IDirect3DIndexBuffer8Impl_SetPrivateData,
211 IDirect3DIndexBuffer8Impl_GetPrivateData,
212 IDirect3DIndexBuffer8Impl_FreePrivateData,
213 IDirect3DIndexBuffer8Impl_SetPriority,
214 IDirect3DIndexBuffer8Impl_GetPriority,
215 IDirect3DIndexBuffer8Impl_PreLoad,
216 IDirect3DIndexBuffer8Impl_GetType,
217 /* IDirect3DIndexBuffer8 */
218 IDirect3DIndexBuffer8Impl_Lock,
219 IDirect3DIndexBuffer8Impl_Unlock,
220 IDirect3DIndexBuffer8Impl_GetDesc