VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/d3d9/query.c@ 23571

Last change on this file since 23571 was 23571, checked in by vboxsync, 15 years ago

crOpenGL: update to wine 1.1.30

  • Property svn:eol-style set to native
File size: 6.4 KB
Line 
1/*
2 * IDirect3DQuery9 implementation
3 *
4 * Copyright 2002-2003 Raphael Junqueira
5 * Copyright 2002-2003 Jason Edmeades
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/*
24 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
25 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
26 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
27 * a choice of LGPL license versions is made available with the language indicating
28 * that LGPLv2 or any later version may be used, or where a choice of which version
29 * of the LGPL is applied is otherwise unspecified.
30 */
31
32#include "config.h"
33#include "d3d9_private.h"
34
35WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
36
37/* IDirect3DQuery9 IUnknown parts follow: */
38static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(LPDIRECT3DQUERY9 iface, REFIID riid, LPVOID* ppobj) {
39 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
40 TRACE("(%p) Relay\n", This);
41
42 if (IsEqualGUID(riid, &IID_IUnknown)
43 || IsEqualGUID(riid, &IID_IDirect3DQuery9)) {
44 IDirect3DQuery9_AddRef(iface);
45 *ppobj = This;
46 return S_OK;
47 }
48
49 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
50 *ppobj = NULL;
51 return E_NOINTERFACE;
52}
53
54static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
55 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
56 ULONG ref = InterlockedIncrement(&This->ref);
57
58 TRACE("(%p) : AddRef from %d\n", This, ref - 1);
59 return ref;
60}
61
62static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
63 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
64 ULONG ref = InterlockedDecrement(&This->ref);
65
66 TRACE("(%p) : ReleaseRef to %d\n", This, ref);
67
68 if (ref == 0) {
69 wined3d_mutex_lock();
70 IWineD3DQuery_Release(This->wineD3DQuery);
71 wined3d_mutex_unlock();
72
73 IDirect3DDevice9Ex_Release(This->parentDevice);
74 HeapFree(GetProcessHeap(), 0, This);
75 }
76 return ref;
77}
78
79/* IDirect3DQuery9 Interface follow: */
80static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDirect3DDevice9** ppDevice) {
81 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
82 IWineD3DDevice* pDevice;
83 HRESULT hr;
84
85 TRACE("(%p) Relay\n", This);
86
87 wined3d_mutex_lock();
88 hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
89 if(hr != D3D_OK){
90 *ppDevice = NULL;
91 }else{
92 hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
93 IWineD3DDevice_Release(pDevice);
94 }
95 wined3d_mutex_unlock();
96
97 return hr;
98}
99
100static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
101 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
102 HRESULT hr;
103 TRACE("(%p) Relay\n", This);
104
105 wined3d_mutex_lock();
106 hr = IWineD3DQuery_GetType(This->wineD3DQuery);
107 wined3d_mutex_unlock();
108
109 return hr;
110}
111
112static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
113 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
114 DWORD ret;
115 TRACE("(%p) Relay\n", This);
116
117 wined3d_mutex_lock();
118 ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
119 wined3d_mutex_unlock();
120
121 return ret;
122}
123
124static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) {
125 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
126 HRESULT hr;
127 TRACE("(%p) Relay\n", This);
128
129 wined3d_mutex_lock();
130 hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
131 wined3d_mutex_unlock();
132
133 return hr;
134}
135
136static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
137 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
138 HRESULT hr;
139 TRACE("(%p) Relay\n", This);
140
141 wined3d_mutex_lock();
142 hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
143 wined3d_mutex_unlock();
144
145 return hr;
146}
147
148
149static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl =
150{
151 IDirect3DQuery9Impl_QueryInterface,
152 IDirect3DQuery9Impl_AddRef,
153 IDirect3DQuery9Impl_Release,
154 IDirect3DQuery9Impl_GetDevice,
155 IDirect3DQuery9Impl_GetType,
156 IDirect3DQuery9Impl_GetDataSize,
157 IDirect3DQuery9Impl_Issue,
158 IDirect3DQuery9Impl_GetData
159};
160
161
162/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */
163HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
164 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
165 IDirect3DQuery9Impl *object = NULL;
166 HRESULT hr = D3D_OK;
167
168 TRACE("(%p) Relay\n", This);
169
170 if (!ppQuery)
171 {
172 wined3d_mutex_lock();
173 hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
174 wined3d_mutex_unlock();
175
176 return hr;
177 }
178
179 /* Allocate the storage for the device */
180 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
181 if (NULL == object) {
182 ERR("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
183 return D3DERR_OUTOFVIDEOMEMORY;
184 }
185
186 object->lpVtbl = &Direct3DQuery9_Vtbl;
187 object->ref = 1;
188
189 wined3d_mutex_lock();
190 hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
191 wined3d_mutex_unlock();
192
193 if (FAILED(hr)) {
194
195 /* free up object */
196 WARN("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
197 HeapFree(GetProcessHeap(), 0, object);
198 } else {
199 IDirect3DDevice9Ex_AddRef(iface);
200 object->parentDevice = iface;
201 *ppQuery = (LPDIRECT3DQUERY9) object;
202 TRACE("(%p) : Created query %p\n", This , object);
203 }
204 TRACE("(%p) : returning %x\n", This, hr);
205 return hr;
206}
Note: See TracBrowser for help on using the repository browser.

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