oleaut32: Use WIC to decode PNG images.
[wine/multimedia.git] / dlls / d3d8 / indexbuffer.c
blobb59b1ab292d18660c7ec5483f5b664b45e5c2a7b
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 wined3d_mutex_lock();
60 IWineD3DBuffer_Release(This->wineD3DIndexBuffer);
61 wined3d_mutex_unlock();
63 IUnknown_Release(This->parentDevice);
64 HeapFree(GetProcessHeap(), 0, This);
66 return ref;
69 /* IDirect3DIndexBuffer8 IDirect3DResource8 Interface follow: */
70 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetDevice(LPDIRECT3DINDEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
71 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
72 IWineD3DDevice *wined3d_device;
73 HRESULT hr;
74 TRACE("(%p) Relay\n", This);
76 wined3d_mutex_lock();
77 hr = IWineD3DBuffer_GetDevice(This->wineD3DIndexBuffer, &wined3d_device);
78 if (SUCCEEDED(hr))
80 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
81 IWineD3DDevice_Release(wined3d_device);
83 wined3d_mutex_unlock();
85 return hr;
88 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
89 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
90 HRESULT hr;
91 TRACE("(%p) Relay\n", This);
93 wined3d_mutex_lock();
94 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
95 wined3d_mutex_unlock();
97 return hr;
100 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
101 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
102 HRESULT hr;
103 TRACE("(%p) Relay\n", This);
105 wined3d_mutex_lock();
106 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
107 wined3d_mutex_unlock();
109 return hr;
112 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER8 iface, REFGUID refguid) {
113 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
114 HRESULT hr;
115 TRACE("(%p) Relay\n", This);
117 wined3d_mutex_lock();
118 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
119 wined3d_mutex_unlock();
121 return hr;
124 static DWORD WINAPI IDirect3DIndexBuffer8Impl_SetPriority(LPDIRECT3DINDEXBUFFER8 iface, DWORD PriorityNew) {
125 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
126 DWORD ret;
127 TRACE("(%p) Relay\n", This);
129 wined3d_mutex_lock();
130 ret = IWineD3DBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
131 wined3d_mutex_unlock();
133 return ret;
136 static DWORD WINAPI IDirect3DIndexBuffer8Impl_GetPriority(LPDIRECT3DINDEXBUFFER8 iface) {
137 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
138 DWORD ret;
139 TRACE("(%p) Relay\n", This);
141 wined3d_mutex_lock();
142 ret = IWineD3DBuffer_GetPriority(This->wineD3DIndexBuffer);
143 wined3d_mutex_unlock();
145 return ret;
148 static void WINAPI IDirect3DIndexBuffer8Impl_PreLoad(LPDIRECT3DINDEXBUFFER8 iface) {
149 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
150 TRACE("(%p) Relay\n", This);
152 wined3d_mutex_lock();
153 IWineD3DBuffer_PreLoad(This->wineD3DIndexBuffer);
154 wined3d_mutex_unlock();
157 static D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer8Impl_GetType(LPDIRECT3DINDEXBUFFER8 iface) {
158 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
159 TRACE("(%p)\n", This);
161 return D3DRTYPE_INDEXBUFFER;
164 /* IDirect3DIndexBuffer8 Interface follow: */
165 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Lock(LPDIRECT3DINDEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
166 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
167 HRESULT hr;
168 TRACE("(%p) Relay\n", This);
170 wined3d_mutex_lock();
171 hr = IWineD3DBuffer_Map(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
172 wined3d_mutex_unlock();
174 return hr;
177 static HRESULT WINAPI IDirect3DIndexBuffer8Impl_Unlock(LPDIRECT3DINDEXBUFFER8 iface) {
178 IDirect3DIndexBuffer8Impl *This = (IDirect3DIndexBuffer8Impl *)iface;
179 HRESULT hr;
180 TRACE("(%p) Relay\n", This);
182 wined3d_mutex_lock();
183 hr = IWineD3DBuffer_Unmap(This->wineD3DIndexBuffer);
184 wined3d_mutex_unlock();
186 return hr;
189 static 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);
195 wined3d_mutex_lock();
196 hr = IWineD3DBuffer_GetDesc(This->wineD3DIndexBuffer, &desc);
197 wined3d_mutex_unlock();
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;
207 return hr;
211 const IDirect3DIndexBuffer8Vtbl Direct3DIndexBuffer8_Vtbl =
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