VirtualBox

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

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

crOpenGL: update to wine 1.1.43

  • Property svn:eol-style set to native
File size: 5.5 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
41 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj);
42
43 if (IsEqualGUID(riid, &IID_IUnknown)
44 || IsEqualGUID(riid, &IID_IDirect3DQuery9)) {
45 IDirect3DQuery9_AddRef(iface);
46 *ppobj = This;
47 return S_OK;
48 }
49
50 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj);
51 *ppobj = NULL;
52 return E_NOINTERFACE;
53}
54
55static ULONG WINAPI IDirect3DQuery9Impl_AddRef(LPDIRECT3DQUERY9 iface) {
56 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
57 ULONG ref = InterlockedIncrement(&This->ref);
58
59 TRACE("%p increasing refcount to %u.\n", iface, ref);
60
61 return ref;
62}
63
64static ULONG WINAPI IDirect3DQuery9Impl_Release(LPDIRECT3DQUERY9 iface) {
65 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
66 ULONG ref = InterlockedDecrement(&This->ref);
67
68 TRACE("%p decreasing refcount to %u.\n", iface, ref);
69
70 if (ref == 0) {
71 wined3d_mutex_lock();
72 IWineD3DQuery_Release(This->wineD3DQuery);
73 wined3d_mutex_unlock();
74
75 IDirect3DDevice9Ex_Release(This->parentDevice);
76 HeapFree(GetProcessHeap(), 0, This);
77 }
78 return ref;
79}
80
81/* IDirect3DQuery9 Interface follow: */
82static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, IDirect3DDevice9 **device)
83{
84 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
85
86 TRACE("iface %p, device %p.\n", iface, device);
87
88 *device = (IDirect3DDevice9 *)This->parentDevice;
89 IDirect3DDevice9_AddRef(*device);
90
91 TRACE("Returning device %p.\n", *device);
92
93 return D3D_OK;
94}
95
96static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(LPDIRECT3DQUERY9 iface) {
97 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
98 HRESULT hr;
99
100 TRACE("iface %p.\n", iface);
101
102 wined3d_mutex_lock();
103 hr = IWineD3DQuery_GetType(This->wineD3DQuery);
104 wined3d_mutex_unlock();
105
106 return hr;
107}
108
109static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(LPDIRECT3DQUERY9 iface) {
110 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
111 DWORD ret;
112
113 TRACE("iface %p.\n", iface);
114
115 wined3d_mutex_lock();
116 ret = IWineD3DQuery_GetDataSize(This->wineD3DQuery);
117 wined3d_mutex_unlock();
118
119 return ret;
120}
121
122static HRESULT WINAPI IDirect3DQuery9Impl_Issue(LPDIRECT3DQUERY9 iface, DWORD dwIssueFlags) {
123 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
124 HRESULT hr;
125
126 TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags);
127
128 wined3d_mutex_lock();
129 hr = IWineD3DQuery_Issue(This->wineD3DQuery, dwIssueFlags);
130 wined3d_mutex_unlock();
131
132 return hr;
133}
134
135static HRESULT WINAPI IDirect3DQuery9Impl_GetData(LPDIRECT3DQUERY9 iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) {
136 IDirect3DQuery9Impl *This = (IDirect3DQuery9Impl *)iface;
137 HRESULT hr;
138
139 TRACE("iface %p, data %p, size %u, flags %#x.\n",
140 iface, pData, dwSize, dwGetDataFlags);
141
142 wined3d_mutex_lock();
143 hr = IWineD3DQuery_GetData(This->wineD3DQuery, pData, dwSize, dwGetDataFlags);
144 wined3d_mutex_unlock();
145
146 return hr;
147}
148
149
150static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl =
151{
152 IDirect3DQuery9Impl_QueryInterface,
153 IDirect3DQuery9Impl_AddRef,
154 IDirect3DQuery9Impl_Release,
155 IDirect3DQuery9Impl_GetDevice,
156 IDirect3DQuery9Impl_GetType,
157 IDirect3DQuery9Impl_GetDataSize,
158 IDirect3DQuery9Impl_Issue,
159 IDirect3DQuery9Impl_GetData
160};
161
162HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type)
163{
164 HRESULT hr;
165
166 query->lpVtbl = &Direct3DQuery9_Vtbl;
167 query->ref = 1;
168
169 wined3d_mutex_lock();
170 hr = IWineD3DDevice_CreateQuery(device->WineD3DDevice, type, &query->wineD3DQuery, (IUnknown *)query);
171 wined3d_mutex_unlock();
172 if (FAILED(hr))
173 {
174 WARN("Failed to create wined3d query, hr %#x.\n", hr);
175 return hr;
176 }
177
178 query->parentDevice = (IDirect3DDevice9Ex *)device;
179 IDirect3DDevice9Ex_AddRef(query->parentDevice);
180
181 return D3D_OK;
182}
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