VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d8/vertexbuffer.c@ 20227

Last change on this file since 20227 was 19678, checked in by vboxsync, 16 years ago

opengl: update wine to 1.1.21, add d3d9.dll to build list

  • Property svn:eol-style set to native
File size: 8.3 KB
Line 
1/*
2 * IDirect3DVertexBuffer8 implementation
3 *
4 * Copyright 2005 Oliver Stieber
5 *
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.
10 *
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.
15 *
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
19 */
20
21/*
22 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#include "config.h"
31#include "d3d8_private.h"
32
33WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
34
35/* IDirect3DVertexBuffer8 IUnknown parts follow: */
36static HRESULT WINAPI IDirect3DVertexBuffer8Impl_QueryInterface(LPDIRECT3DVERTEXBUFFER8 iface, REFIID riid, LPVOID *ppobj) {
37 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
38
39 if (IsEqualGUID(riid, &IID_IUnknown)
40 || IsEqualGUID(riid, &IID_IDirect3DResource8)
41 || IsEqualGUID(riid, &IID_IDirect3DVertexBuffer8)) {
42 IUnknown_AddRef(iface);
43 *ppobj = This;
44 return S_OK;
45 }
46
47 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
48
49 *ppobj = NULL;
50 return E_NOINTERFACE;
51}
52
53static ULONG WINAPI IDirect3DVertexBuffer8Impl_AddRef(LPDIRECT3DVERTEXBUFFER8 iface) {
54 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
55 ULONG ref = InterlockedIncrement(&This->ref);
56
57 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
58
59 return ref;
60}
61
62static ULONG WINAPI IDirect3DVertexBuffer8Impl_Release(LPDIRECT3DVERTEXBUFFER8 iface) {
63 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
64 ULONG ref = InterlockedDecrement(&This->ref);
65
66 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
67
68 if (ref == 0) {
69 EnterCriticalSection(&d3d8_cs);
70 IWineD3DBuffer_Release(This->wineD3DVertexBuffer);
71 LeaveCriticalSection(&d3d8_cs);
72 IUnknown_Release(This->parentDevice);
73 HeapFree(GetProcessHeap(), 0, This);
74 }
75
76 return ref;
77}
78
79/* IDirect3DVertexBuffer8 IDirect3DResource8 Interface follow: */
80static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDevice(LPDIRECT3DVERTEXBUFFER8 iface, IDirect3DDevice8 **ppDevice) {
81 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
82 IWineD3DDevice *wined3d_device;
83 HRESULT hr;
84 TRACE("(%p) Relay\n", This);
85
86 EnterCriticalSection(&d3d8_cs);
87 hr = IWineD3DBuffer_GetDevice(This->wineD3DVertexBuffer, &wined3d_device);
88 if (SUCCEEDED(hr))
89 {
90 IWineD3DDevice_GetParent(wined3d_device, (IUnknown **)ppDevice);
91 IWineD3DDevice_Release(wined3d_device);
92 }
93 LeaveCriticalSection(&d3d8_cs);
94 return hr;
95}
96
97static HRESULT WINAPI IDirect3DVertexBuffer8Impl_SetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, CONST void *pData, DWORD SizeOfData, DWORD Flags) {
98 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
99 HRESULT hr;
100 TRACE("(%p) Relay\n", This);
101
102 EnterCriticalSection(&d3d8_cs);
103 hr = IWineD3DBuffer_SetPrivateData(This->wineD3DVertexBuffer, refguid, pData, SizeOfData, Flags);
104 LeaveCriticalSection(&d3d8_cs);
105 return hr;
106}
107
108static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetPrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid, void *pData, DWORD *pSizeOfData) {
109 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
110 HRESULT hr;
111 TRACE("(%p) Relay\n", This);
112
113 EnterCriticalSection(&d3d8_cs);
114 hr = IWineD3DBuffer_GetPrivateData(This->wineD3DVertexBuffer, refguid, pData, pSizeOfData);
115 LeaveCriticalSection(&d3d8_cs);
116 return hr;
117}
118
119static HRESULT WINAPI IDirect3DVertexBuffer8Impl_FreePrivateData(LPDIRECT3DVERTEXBUFFER8 iface, REFGUID refguid) {
120 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
121 HRESULT hr;
122 TRACE("(%p) Relay\n", This);
123
124 EnterCriticalSection(&d3d8_cs);
125 hr = IWineD3DBuffer_FreePrivateData(This->wineD3DVertexBuffer, refguid);
126 LeaveCriticalSection(&d3d8_cs);
127 return hr;
128}
129
130static DWORD WINAPI IDirect3DVertexBuffer8Impl_SetPriority(LPDIRECT3DVERTEXBUFFER8 iface, DWORD PriorityNew) {
131 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
132 DWORD ret;
133 TRACE("(%p) Relay\n", This);
134
135 EnterCriticalSection(&d3d8_cs);
136 ret = IWineD3DBuffer_SetPriority(This->wineD3DVertexBuffer, PriorityNew);
137 LeaveCriticalSection(&d3d8_cs);
138 return ret;
139}
140
141static DWORD WINAPI IDirect3DVertexBuffer8Impl_GetPriority(LPDIRECT3DVERTEXBUFFER8 iface) {
142 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
143 DWORD ret;
144 TRACE("(%p) Relay\n", This);
145
146 EnterCriticalSection(&d3d8_cs);
147 ret = IWineD3DBuffer_GetPriority(This->wineD3DVertexBuffer);
148 LeaveCriticalSection(&d3d8_cs);
149 return ret;
150}
151
152static void WINAPI IDirect3DVertexBuffer8Impl_PreLoad(LPDIRECT3DVERTEXBUFFER8 iface) {
153 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
154 TRACE("(%p) Relay\n", This);
155
156 EnterCriticalSection(&d3d8_cs);
157 IWineD3DBuffer_PreLoad(This->wineD3DVertexBuffer);
158 LeaveCriticalSection(&d3d8_cs);
159}
160
161static D3DRESOURCETYPE WINAPI IDirect3DVertexBuffer8Impl_GetType(LPDIRECT3DVERTEXBUFFER8 iface) {
162 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
163 TRACE("(%p)\n", This);
164
165 return D3DRTYPE_VERTEXBUFFER;
166}
167
168/* IDirect3DVertexBuffer8 Interface follow: */
169static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Lock(LPDIRECT3DVERTEXBUFFER8 iface, UINT OffsetToLock, UINT SizeToLock, BYTE **ppbData, DWORD Flags) {
170 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
171 HRESULT hr;
172 TRACE("(%p) Relay\n", This);
173
174 EnterCriticalSection(&d3d8_cs);
175 hr = IWineD3DBuffer_Map(This->wineD3DVertexBuffer, OffsetToLock, SizeToLock, ppbData, Flags);
176 LeaveCriticalSection(&d3d8_cs);
177 return hr;
178}
179
180static HRESULT WINAPI IDirect3DVertexBuffer8Impl_Unlock(LPDIRECT3DVERTEXBUFFER8 iface) {
181 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
182 HRESULT hr;
183 TRACE("(%p) Relay\n", This);
184
185 EnterCriticalSection(&d3d8_cs);
186 hr = IWineD3DBuffer_Unmap(This->wineD3DVertexBuffer);
187 LeaveCriticalSection(&d3d8_cs);
188 return hr;
189}
190
191static HRESULT WINAPI IDirect3DVertexBuffer8Impl_GetDesc(LPDIRECT3DVERTEXBUFFER8 iface, D3DVERTEXBUFFER_DESC *pDesc) {
192 IDirect3DVertexBuffer8Impl *This = (IDirect3DVertexBuffer8Impl *)iface;
193 HRESULT hr;
194 WINED3DBUFFER_DESC desc;
195 TRACE("(%p) Relay\n", This);
196
197 EnterCriticalSection(&d3d8_cs);
198 hr = IWineD3DBuffer_GetDesc(This->wineD3DVertexBuffer, &desc);
199 LeaveCriticalSection(&d3d8_cs);
200
201 if (SUCCEEDED(hr)) {
202 pDesc->Type = D3DRTYPE_VERTEXBUFFER;
203 pDesc->Usage = desc.Usage;
204 pDesc->Pool = desc.Pool;
205 pDesc->Size = desc.Size;
206 pDesc->FVF = This->fvf;
207 pDesc->Format = D3DFMT_VERTEXDATA;
208 }
209
210 return hr;
211}
212
213const IDirect3DVertexBuffer8Vtbl Direct3DVertexBuffer8_Vtbl =
214{
215 /* IUnknown */
216 IDirect3DVertexBuffer8Impl_QueryInterface,
217 IDirect3DVertexBuffer8Impl_AddRef,
218 IDirect3DVertexBuffer8Impl_Release,
219 /* IDirect3DResource8 */
220 IDirect3DVertexBuffer8Impl_GetDevice,
221 IDirect3DVertexBuffer8Impl_SetPrivateData,
222 IDirect3DVertexBuffer8Impl_GetPrivateData,
223 IDirect3DVertexBuffer8Impl_FreePrivateData,
224 IDirect3DVertexBuffer8Impl_SetPriority,
225 IDirect3DVertexBuffer8Impl_GetPriority,
226 IDirect3DVertexBuffer8Impl_PreLoad,
227 IDirect3DVertexBuffer8Impl_GetType,
228 /* IDirect3DVertexBuffer8 */
229 IDirect3DVertexBuffer8Impl_Lock,
230 IDirect3DVertexBuffer8Impl_Unlock,
231 IDirect3DVertexBuffer8Impl_GetDesc
232};
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette