Get rid of HEAP_strdupWtoA calls.
[wine/multimedia.git] / dlls / d3d9 / indexbuffer.c
blobfc90cc70bc650a359fb4033faf5b175f3db93f05
1 /*
2 * IDirect3DIndexBuffer9 implementation
4 * Copyright 2002-2004 Jason Edmeades
5 * Raphael Junqueira
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "config.h"
23 #include "d3d9_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
27 /* IDirect3DIndexBuffer9 IUnknown parts follow: */
28 HRESULT WINAPI IDirect3DIndexBuffer9Impl_QueryInterface(LPDIRECT3DINDEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
29 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
31 if (IsEqualGUID(riid, &IID_IUnknown)
32 || IsEqualGUID(riid, &IID_IDirect3DResource9)
33 || IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)) {
34 IDirect3DIndexBuffer9Impl_AddRef(iface);
35 *ppobj = This;
36 return D3D_OK;
39 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
40 return E_NOINTERFACE;
43 ULONG WINAPI IDirect3DIndexBuffer9Impl_AddRef(LPDIRECT3DINDEXBUFFER9 iface) {
44 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
45 TRACE("(%p) : AddRef from %ld\n", This, This->ref);
46 return InterlockedIncrement(&This->ref);
49 ULONG WINAPI IDirect3DIndexBuffer9Impl_Release(LPDIRECT3DINDEXBUFFER9 iface) {
50 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
51 ULONG ref = InterlockedDecrement(&This->ref);
52 TRACE("(%p) : ReleaseRef to %ld\n", This, This->ref);
53 if (ref == 0) {
54 IWineD3DIndexBuffer_Release(This->wineD3DIndexBuffer);
55 HeapFree(GetProcessHeap(), 0, This);
57 return ref;
60 /* IDirect3DIndexBuffer9 IDirect3DResource9 Interface follow: */
61 HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDevice(LPDIRECT3DINDEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
62 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
63 return IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
66 HRESULT WINAPI IDirect3DIndexBuffer9Impl_SetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
67 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
68 return IWineD3DIndexBuffer_SetPrivateData(This->wineD3DIndexBuffer, refguid, pData, SizeOfData, Flags);
71 HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetPrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
72 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
73 return IWineD3DIndexBuffer_GetPrivateData(This->wineD3DIndexBuffer, refguid, pData, pSizeOfData);
76 HRESULT WINAPI IDirect3DIndexBuffer9Impl_FreePrivateData(LPDIRECT3DINDEXBUFFER9 iface, REFGUID refguid) {
77 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
78 return IWineD3DIndexBuffer_FreePrivateData(This->wineD3DIndexBuffer, refguid);
81 DWORD WINAPI IDirect3DIndexBuffer9Impl_SetPriority(LPDIRECT3DINDEXBUFFER9 iface, DWORD PriorityNew) {
82 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
83 return IWineD3DIndexBuffer_SetPriority(This->wineD3DIndexBuffer, PriorityNew);
86 DWORD WINAPI IDirect3DIndexBuffer9Impl_GetPriority(LPDIRECT3DINDEXBUFFER9 iface) {
87 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
88 return IWineD3DIndexBuffer_GetPriority(This->wineD3DIndexBuffer);
91 void WINAPI IDirect3DIndexBuffer9Impl_PreLoad(LPDIRECT3DINDEXBUFFER9 iface) {
92 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
93 IWineD3DIndexBuffer_PreLoad(This->wineD3DIndexBuffer);
94 return ;
97 D3DRESOURCETYPE WINAPI IDirect3DIndexBuffer9Impl_GetType(LPDIRECT3DINDEXBUFFER9 iface) {
98 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
99 return IWineD3DIndexBuffer_GetType(This->wineD3DIndexBuffer);
102 /* IDirect3DIndexBuffer9 Interface follow: */
103 HRESULT WINAPI IDirect3DIndexBuffer9Impl_Lock(LPDIRECT3DINDEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
104 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
105 return IWineD3DIndexBuffer_Lock(This->wineD3DIndexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
108 HRESULT WINAPI IDirect3DIndexBuffer9Impl_Unlock(LPDIRECT3DINDEXBUFFER9 iface) {
109 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
110 return IWineD3DIndexBuffer_Unlock(This->wineD3DIndexBuffer);
113 HRESULT WINAPI IDirect3DIndexBuffer9Impl_GetDesc(LPDIRECT3DINDEXBUFFER9 iface, D3DINDEXBUFFER_DESC *pDesc) {
114 IDirect3DIndexBuffer9Impl *This = (IDirect3DIndexBuffer9Impl *)iface;
115 return IWineD3DIndexBuffer_GetDesc(This->wineD3DIndexBuffer, pDesc);
119 IDirect3DIndexBuffer9Vtbl Direct3DIndexBuffer9_Vtbl =
121 IDirect3DIndexBuffer9Impl_QueryInterface,
122 IDirect3DIndexBuffer9Impl_AddRef,
123 IDirect3DIndexBuffer9Impl_Release,
124 IDirect3DIndexBuffer9Impl_GetDevice,
125 IDirect3DIndexBuffer9Impl_SetPrivateData,
126 IDirect3DIndexBuffer9Impl_GetPrivateData,
127 IDirect3DIndexBuffer9Impl_FreePrivateData,
128 IDirect3DIndexBuffer9Impl_SetPriority,
129 IDirect3DIndexBuffer9Impl_GetPriority,
130 IDirect3DIndexBuffer9Impl_PreLoad,
131 IDirect3DIndexBuffer9Impl_GetType,
132 IDirect3DIndexBuffer9Impl_Lock,
133 IDirect3DIndexBuffer9Impl_Unlock,
134 IDirect3DIndexBuffer9Impl_GetDesc
138 /* IDirect3DDevice9 IDirect3DIndexBuffer9 Methods follow: */
139 HRESULT WINAPI IDirect3DDevice9Impl_CreateIndexBuffer(LPDIRECT3DDEVICE9 iface,
140 UINT Length, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool,
141 IDirect3DIndexBuffer9** ppIndexBuffer, HANDLE* pSharedHandle) {
143 IDirect3DIndexBuffer9Impl *object;
144 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
146 /* Allocate the storage for the device */
147 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DIndexBuffer9Impl));
148 object->lpVtbl = &Direct3DIndexBuffer9_Vtbl;
149 object->ref = 1;
150 IWineD3DDevice_CreateIndexBuffer(This->WineD3DDevice, Length, Usage, Format, Pool, &(object->wineD3DIndexBuffer), pSharedHandle, (IUnknown *)object);
152 *ppIndexBuffer = (LPDIRECT3DINDEXBUFFER9) object;
153 return D3D_OK;