kernel32/tests: Add a few more tests, fix some failures on Windows.
[wine/wine64.git] / dlls / d3d8 / indexbuffer.c
blobc4bd83338b25d2de97eeec325e29e30454cdf054
1 /*
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
21 #include "config.h"
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);
34 *ppobj = This;
35 return S_OK;
38 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
39 *ppobj = NULL;
40 return E_NOINTERFACE;
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);
49 return ref;
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);
58 if (ref == 0) {
59 EnterCriticalSection(&d3d8_cs);
60 IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
61 LeaveCriticalSection(&d3d8_cs);
62 IUnknown_Release(This->parentDevice);
63 HeapFree(GetProcessHeap(), 0, This);
65 return ref;
68 /* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
69 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
70 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
71 HRESULT hr;
72 TRACE("(%p) Relay\n", This);
74 EnterCriticalSection(&d3d8_cs);
75 hr = IDirect3DResource8Impl_GetDevice((LPDIRECT3DRESOURCE8) This, ppDevice);
76 LeaveCriticalSection(&d3d8_cs);
77 return hr;
80 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
81 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
82 HRESULT hr;
83 TRACE("(%p) Relay\n", This);
85 EnterCriticalSection(&d3d8_cs);
86 hr = IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
87 LeaveCriticalSection(&d3d8_cs);
88 return hr;
91 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
92 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
93 HRESULT hr;
94 TRACE("(%p) Relay\n", This);
96 EnterCriticalSection(&d3d8_cs);
97 hr = IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
98 LeaveCriticalSection(&d3d8_cs);
99 return hr;
102 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
103 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
104 HRESULT hr;
105 TRACE("(%p) Relay\n", This);
107 EnterCriticalSection(&d3d8_cs);
108 hr = IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
109 LeaveCriticalSection(&d3d8_cs);
110 return hr;
113 static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
114 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
115 DWORD ret;
116 TRACE("(%p) Relay\n", This);
118 EnterCriticalSection(&d3d8_cs);
119 ret = IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
120 LeaveCriticalSection(&d3d8_cs);
121 return ret;
124 static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
125 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
126 DWORD ret;
127 TRACE("(%p) Relay\n", This);
129 EnterCriticalSection(&d3d8_cs);
130 ret = IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
131 LeaveCriticalSection(&d3d8_cs);
132 return ret;
135 static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
136 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
137 TRACE("(%p) Relay\n", This);
139 EnterCriticalSection(&d3d8_cs);
140 IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
141 LeaveCriticalSection(&d3d8_cs);
144 static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
145 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
146 D3DRESOURCETYPE type;
147 TRACE("(%p) Relay\n", This);
149 EnterCriticalSection(&d3d8_cs);
150 type = IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
151 LeaveCriticalSection(&d3d8_cs);
152 return type;
155 /* IDirect3DIndexBuffer8 Interface follow: */
156 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
157 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
158 HRESULT hr;
159 TRACE("(%p) Relay\n", This);
161 EnterCriticalSection(&d3d8_cs);
162 hr = IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
163 LeaveCriticalSection(&d3d8_cs);
164 return hr;
167 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
168 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
169 HRESULT hr;
170 TRACE("(%p) Relay\n", This);
172 EnterCriticalSection(&d3d8_cs);
173 hr = IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
174 LeaveCriticalSection(&d3d8_cs);
175 return hr;
178 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDesc(LPDIRECT3DINDEXBUFFER8 iface, D3DINDEXBUFFER_DESC *pDesc) {
179 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
180 HRESULT hr;
181 TRACE("(%p) Relay\n", This);
183 EnterCriticalSection(&d3d8_cs);
184 hr = IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, (WINED3DINDEXBUFFER_DESC *) pDesc);
185 LeaveCriticalSection(&d3d8_cs);
186 return hr;
190 const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
192 /* IUnknown */
193 IDirect3DIndexBuffer8Impl_QueryInterface,
194 IDirect3DIndexBuffer8Impl_AddRef,
195 IDirect3DIndexBuffer8Impl_Release,
196 /* IDirect3DResource8 */
197 IDirect3DIndexBuffer8Impl_GetDevice,
198 IDirect3DIndexBuffer8Impl_SetPrivateData,
199 IDirect3DIndexBuffer8Impl_GetPrivateData,
200 IDirect3DIndexBuffer8Impl_FreePrivateData,
201 IDirect3DIndexBuffer8Impl_SetPriority,
202 IDirect3DIndexBuffer8Impl_GetPriority,
203 IDirect3DIndexBuffer8Impl_PreLoad,
204 IDirect3DIndexBuffer8Impl_GetType,
205 /* IDirect3DIndexBuffer8 */
206 IDirect3DIndexBuffer8Impl_Lock,
207 IDirect3DIndexBuffer8Impl_Unlock,
208 IDirect3DIndexBuffer8Impl_GetDesc