~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d9/vertexbuffer.c

Version: ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * IDirect3DVertexBuffer9 implementation
  3  *
  4  * Copyright 2002-2004 Jason Edmeades
  5  * Copyright 2002-2004 Raphael Junqueira
  6  * Copyright 2005 Oliver Stieber
  7  *
  8  * This library is free software; you can redistribute it and/or
  9  * modify it under the terms of the GNU Lesser General Public
 10  * License as published by the Free Software Foundation; either
 11  * version 2.1 of the License, or (at your option) any later version.
 12  *
 13  * This library is distributed in the hope that it will be useful,
 14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 16  * Lesser General Public License for more details.
 17  *
 18  * You should have received a copy of the GNU Lesser General Public
 19  * License along with this library; if not, write to the Free Software
 20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 21  */
 22 
 23 #include "config.h"
 24 #include "d3d9_private.h"
 25 
 26 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
 27 
 28 /* IDirect3DVertexBuffer9 IUnknown parts follow: */
 29 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER9 iface, REFIID riid, LPVOID* ppobj) {
 30     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
 31 
 32     if (IsEqualGUID(riid, &IID_IUnknown)
 33         || IsEqualGUID(riid, &IID_IDirect3DResource9)
 34         || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer9)) {
 35         IDirect3DVertexBuffer9_AddRef(iface);
 36         *ppobj = This;
 37         return S_OK;
 38     }
 39 
 40     WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
 41     *ppobj = NULL;
 42     return E_NOINTERFACE;
 43 }
 44 
 45 static ULONG WINAPI IDirect3DVertexBuffer9Impl_AddRef(LPDIRECT3DVERTEXBUFFER9 iface) {
 46     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
 47     ULONG ref = InterlockedIncrement(&This->ref);
 48 
 49     TRACE("(%p) : AddRef from %d\n", This, ref - 1);
 50 
 51     return ref;
 52 }
 53 
 54 static ULONG WINAPI IDirect3DVertexBuffer9Impl_Release(LPDIRECT3DVERTEXBUFFER9 iface) {
 55     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
 56     ULONG ref = InterlockedDecrement(&This->ref);
 57 
 58     TRACE("(%p) : ReleaseRef to %d\n", This, ref);
 59 
 60     if (ref == 0) {
 61         EnterCriticalSection(&d3d9_cs);
 62         IWineD3DVertexBuffer_Release(This->wineD3DVertexBuffer);
 63         LeaveCriticalSection(&d3d9_cs);
 64         IDirect3DDevice9Ex_Release(This->parentDevice);
 65         HeapFree(GetProcessHeap(), 0, This);
 66     }
 67     return ref;
 68 }
 69 
 70 /* IDirect3DVertexBuffer9 IDirect3DResource9 Interface follow: */
 71 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDevice(LPDIRECT3DVERTEXBUFFER9 iface, IDirect3DDevice9** ppDevice) {
 72     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
 73     HRESULT hr;
 74     TRACE("(%p) Relay\n", This);
 75 
 76     EnterCriticalSection(&d3d9_cs);
 77     hr = IDirect3DResource9Impl_GetDevice((LPDIRECT3DRESOURCE9) This, ppDevice);
 78     LeaveCriticalSection(&d3d9_cs);
 79     return hr;
 80 }
 81 
 82 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
 83     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
 84     TRACE("(%p) Relay\n", This);
 85     return IWineD3DVertexBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
 86 }
 87 
 88 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
 89     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
 90     HRESULT hr;
 91     TRACE("(%p) Relay\n", This);
 92 
 93     EnterCriticalSection(&d3d9_cs);
 94     hr = IWineD3DVertexBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
 95     LeaveCriticalSection(&d3d9_cs);
 96     return hr;
 97 }
 98 
 99 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER9 iface, REFGUID refguid) {
100     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
101     HRESULT hr;
102     TRACE("(%p) Relay\n", This);
103 
104     EnterCriticalSection(&d3d9_cs);
105     hr = IWineD3DVertexBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
106     LeaveCriticalSection(&d3d9_cs);
107     return hr;
108 }
109 
110 static DWORD WINAPI IDirect3DVertexBuffer9Impl_SetPriority(LPDIRECT3DVERTEXBUFFER9 iface, DWORD PriorityNew) {
111     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
112     HRESULT hr;
113     TRACE("(%p) Relay\n", This);
114 
115     EnterCriticalSection(&d3d9_cs);
116     hr = IWineD3DVertexBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
117     LeaveCriticalSection(&d3d9_cs);
118     return hr;
119 }
120 
121 static DWORD WINAPI IDirect3DVertexBuffer9Impl_GetPriority(LPDIRECT3DVERTEXBUFFER9 iface) {
122     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
123     HRESULT hr;
124     TRACE("(%p) Relay\n", This);
125 
126     EnterCriticalSection(&d3d9_cs);
127     hr = IWineD3DVertexBuffer_GetPriority(This->wineD3DVertexBuffer);
128     LeaveCriticalSection(&d3d9_cs);
129     return hr;
130 }
131 
132 static void WINAPI IDirect3DVertexBuffer9Impl_PreLoad(LPDIRECT3DVERTEXBUFFER9 iface) {
133     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
134     TRACE("(%p) Relay\n", This);
135 
136     EnterCriticalSection(&d3d9_cs);
137     IWineD3DVertexBuffer_PreLoad(This->wineD3DVertexBuffer);
138     LeaveCriticalSection(&d3d9_cs);
139     return ;
140 }
141 
142 static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer9Impl_GetType(LPDIRECT3DVERTEXBUFFER9 iface) {
143     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
144     D3DRESOURCETYPE ret;
145     TRACE("(%p) Relay\n", This);
146 
147     EnterCriticalSection(&d3d9_cs);
148     ret = IWineD3DVertexBuffer_GetType(This->wineD3DVertexBuffer);
149     LeaveCriticalSection(&d3d9_cs);
150     return ret;
151 }
152 
153 /* IDirect3DVertexBuffer9 Interface follow: */
154 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Lock(LPDIRECT3DVERTEXBUFFER9 iface, UINT OffsetToLock, UINT SizeToLock, void** ppbData, DWORD Flags) {
155     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
156     HRESULT hr;
157     TRACE("(%p) Relay\n", This);
158 
159     EnterCriticalSection(&d3d9_cs);
160     hr = IWineD3DVertexBuffer_Lock(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, (BYTE **)ppbData, Flags);
161     LeaveCriticalSection(&d3d9_cs);
162     return hr;
163 }
164 
165 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_Unlock(LPDIRECT3DVERTEXBUFFER9 iface) {
166     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
167     HRESULT hr;
168     TRACE("(%p) Relay\n", This);
169 
170     EnterCriticalSection(&d3d9_cs);
171     hr = IWineD3DVertexBuffer_Unlock(This->wineD3DVertexBuffer);
172     LeaveCriticalSection(&d3d9_cs);
173     return hr;
174 }
175 
176 static HRESULT WINAPI IDirect3DVertexBuffer9Impl_GetDesc(LPDIRECT3DVERTEXBUFFER9 iface, D3DVERTEXBUFFER_DESC* pDesc) {
177     IDirect3DVertexBuffer9Impl *This = (IDirect3DVertexBuffer9Impl *)iface;
178     HRESULT hr;
179     TRACE("(%p) Relay\n", This);
180 
181     EnterCriticalSection(&d3d9_cs);
182     hr = IWineD3DVertexBuffer_GetDesc(This->wineD3DVertexBuffer, (WINED3DVERTEXBUFFER_DESC *) pDesc);
183     LeaveCriticalSection(&d3d9_cs);
184     return hr;
185 }
186 
187 static const IDirect3DVertexBuffer9Vtbl Direct3DVertexBuffer9_Vtbl =
188 {
189     /* IUnknown */
190     IDirect3DVertexBuffer9Impl_QueryInterface,
191     IDirect3DVertexBuffer9Impl_AddRef,
192     IDirect3DVertexBuffer9Impl_Release,
193     /* IDirect3DResource9 */
194     IDirect3DVertexBuffer9Impl_GetDevice,
195     IDirect3DVertexBuffer9Impl_SetPrivateData,
196     IDirect3DVertexBuffer9Impl_GetPrivateData,
197     IDirect3DVertexBuffer9Impl_FreePrivateData,
198     IDirect3DVertexBuffer9Impl_SetPriority,
199     IDirect3DVertexBuffer9Impl_GetPriority,
200     IDirect3DVertexBuffer9Impl_PreLoad,
201     IDirect3DVertexBuffer9Impl_GetType,
202     /* IDirect3DVertexBuffer9 */
203     IDirect3DVertexBuffer9Impl_Lock,
204     IDirect3DVertexBuffer9Impl_Unlock,
205     IDirect3DVertexBuffer9Impl_GetDesc
206 };
207 
208 
209 /* IDirect3DDevice9 IDirect3DVertexBuffer9 Methods follow: */
210 HRESULT WINAPI IDirect3DDevice9Impl_CreateVertexBuffer(LPDIRECT3DDEVICE9EX iface,
211                                 UINT Size, DWORD Usage, DWORD FVF, D3DPOOL Pool,
212                                 IDirect3DVertexBuffer9** ppVertexBuffer, HANDLE* pSharedHandle) {
213     
214     IDirect3DVertexBuffer9Impl *object;
215     IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
216     HRESULT hrc = D3D_OK;
217 
218     /* Allocate the storage for the device */
219     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DVertexBuffer9Impl));
220     if (NULL == object) {
221         FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
222         return D3DERR_OUTOFVIDEOMEMORY;
223     }
224 
225     object->lpVtbl = &Direct3DVertexBuffer9_Vtbl;
226     object->ref = 1;
227     EnterCriticalSection(&d3d9_cs);
228     hrc = IWineD3DDevice_CreateVertexBuffer(This->WineD3DDevice, Size, Usage & WINED3DUSAGE_MASK, FVF, (WINED3DPOOL) Pool, &(object->wineD3DVertexBuffer), pSharedHandle, (IUnknown *)object);
229     LeaveCriticalSection(&d3d9_cs);
230     
231     if (hrc != D3D_OK) {
232 
233         /* free up object */
234         WARN("(%p) call to IWineD3DDevice_CreateVertexBuffer failed\n", This);
235         HeapFree(GetProcessHeap(), 0, object);
236     } else {
237         IDirect3DDevice9Ex_AddRef(iface);
238         object->parentDevice = iface;
239         TRACE("(%p) : Created vertex buffer %p\n", This, object);
240         *ppVertexBuffer = (LPDIRECT3DVERTEXBUFFER9) object;
241     }
242     return hrc;
243 }
244 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.