VirtualBox

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

Last change on this file since 16684 was 16477, checked in by vboxsync, 16 years ago

LGPL disclaimer by filemuncher

  • Property svn:eol-style set to native
File size: 6.6 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 EnterCriticalSection(&d3d9_cs);
70 IWineD3DQuery_Release(This->wineD3DQuery);
71 LeaveCriticalSection(&d3d9_cs);
72 IDirect3DDevice9Ex_Release(This->parentDevice);
73 HeapFree(GetProcessHeap(), 0, This);
74 }
75 return ref;
76}
77
78/* IDirect3DQuery9 Interface follow: */
79static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(LPDIRECT3DQUERY9 iface, IDirect3DDevice9** ppDevice) {
80 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
81 IWineD3DDevice* pDevice;
82 HRESULT hr;
83
84 TRACE("(%p) Relay\n", This);
85
86 EnterCriticalSection(&d3d9_cs);
87 hr = IWineD3DQuery_GetDevice(This->wineD3DQuery, &pDevice);
88 if(hr != D3D_OK){
89 *ppDevice = NULL;
90 }else{
91 hr = IWineD3DDevice_GetParent(pDevice, (IUnknown **)ppDevice);
92 IWineD3DDevice_Release(pDevice);
93 }
94 LeaveCriticalSection(&d3d9_cs);
95 return hr;
96}
97
98static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
99 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
100 HRESULT hr;
101 TRACE("(%p) Relay\n", This);
102
103 EnterCriticalSection(&d3d9_cs);
104 hr = IWineD3DQuery_GetType(This->wineD3DQuery);
105 LeaveCriticalSection(&d3d9_cs);
106 return hr;
107}
108
109static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
110 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
111 DWORD ret;
112 TRACE("(%p) Relay\n", This);
113
114 EnterCriticalSection(&d3d9_cs);
115 ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
116 LeaveCriticalSection(&d3d9_cs);
117 return ret;
118}
119
120static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) {
121 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
122 HRESULT hr;
123 TRACE("(%p) Relay\n", This);
124
125 EnterCriticalSection(&d3d9_cs);
126 hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
127 LeaveCriticalSection(&d3d9_cs);
128 return hr;
129}
130
131static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
132 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
133 HRESULT hr;
134 TRACE("(%p) Relay\n", This);
135
136 EnterCriticalSection(&d3d9_cs);
137 hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
138 LeaveCriticalSection(&d3d9_cs);
139 return hr;
140}
141
142
143static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl =
144{
145 IDirect3DQuery9Impl_QueryInterface,
146 IDirect3DQuery9Impl_AddRef,
147 IDirect3DQuery9Impl_Release,
148 IDirect3DQuery9Impl_GetDevice,
149 IDirect3DQuery9Impl_GetType,
150 IDirect3DQuery9Impl_GetDataSize,
151 IDirect3DQuery9Impl_Issue,
152 IDirect3DQuery9Impl_GetData
153};
154
155
156/* IDirect3DDevice9 IDirect3DQuery9 Methods follow: */
157HRESULT WINAPI IDirect3DDevice9Impl_CreateQuery(LPDIRECT3DDEVICE9EX iface, D3DQUERYTYPE Type, IDirect3DQuery9** ppQuery) {
158 IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
159 IDirect3DQuery9Impl *object = NULL;
160 HRESULT hr = D3D_OK;
161
162 TRACE("(%p) Relay\n", This);
163
164 if (!ppQuery)
165 {
166 EnterCriticalSection(&d3d9_cs);
167 hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, NULL, NULL);
168 LeaveCriticalSection(&d3d9_cs);
169 return hr;
170 }
171
172 /* Allocate the storage for the device */
173 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DQuery9Impl));
174 if (NULL == object) {
175 FIXME("Allocation of memory failed, returning D3DERR_OUTOFVIDEOMEMORY\n");
176 return D3DERR_OUTOFVIDEOMEMORY;
177 }
178
179 object->lpVtbl = &Direct3DQuery9_Vtbl;
180 object->ref = 1;
181 EnterCriticalSection(&d3d9_cs);
182 hr = IWineD3DDevice_CreateQuery(This->WineD3DDevice, Type, &object->wineD3DQuery, (IUnknown *)object);
183 LeaveCriticalSection(&d3d9_cs);
184
185 if (FAILED(hr)) {
186
187 /* free up object */
188 FIXME("(%p) call to IWineD3DDevice_CreateQuery failed\n", This);
189 HeapFree(GetProcessHeap(), 0, object);
190 } else {
191 IDirect3DDevice9Ex_AddRef(iface);
192 object->parentDevice = iface;
193 *ppQuery = (LPDIRECT3DQUERY9) object;
194 TRACE("(%p) : Created query %p\n", This , object);
195 }
196 TRACE("(%p) : returning %x\n", This, hr);
197 return hr;
198}
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