Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenquery.c
Go to the documentation of this file.
00001 /* 00002 * IDirect3DQuery9 implementation 00003 * 00004 * Copyright 2002-2003 Raphael Junqueira 00005 * Copyright 2002-2003 Jason Edmeades 00006 * Copyright 2005 Oliver Stieber 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00021 */ 00022 00023 #include "config.h" 00024 #include "d3d9_private.h" 00025 00026 WINE_DEFAULT_DEBUG_CHANNEL(d3d9); 00027 00028 static inline IDirect3DQuery9Impl *impl_from_IDirect3DQuery9(IDirect3DQuery9 *iface) 00029 { 00030 return CONTAINING_RECORD(iface, IDirect3DQuery9Impl, IDirect3DQuery9_iface); 00031 } 00032 00033 static HRESULT WINAPI IDirect3DQuery9Impl_QueryInterface(IDirect3DQuery9 *iface, REFIID riid, 00034 void **ppobj) 00035 { 00036 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00037 00038 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj); 00039 00040 if (IsEqualGUID(riid, &IID_IUnknown) 00041 || IsEqualGUID(riid, &IID_IDirect3DQuery9)) { 00042 IDirect3DQuery9_AddRef(iface); 00043 *ppobj = This; 00044 return S_OK; 00045 } 00046 00047 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); 00048 *ppobj = NULL; 00049 return E_NOINTERFACE; 00050 } 00051 00052 static ULONG WINAPI IDirect3DQuery9Impl_AddRef(IDirect3DQuery9 *iface) 00053 { 00054 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00055 ULONG ref = InterlockedIncrement(&This->ref); 00056 00057 TRACE("%p increasing refcount to %u.\n", iface, ref); 00058 00059 return ref; 00060 } 00061 00062 static ULONG WINAPI IDirect3DQuery9Impl_Release(IDirect3DQuery9 *iface) 00063 { 00064 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00065 ULONG ref = InterlockedDecrement(&This->ref); 00066 00067 TRACE("%p decreasing refcount to %u.\n", iface, ref); 00068 00069 if (ref == 0) { 00070 wined3d_mutex_lock(); 00071 wined3d_query_decref(This->wineD3DQuery); 00072 wined3d_mutex_unlock(); 00073 00074 IDirect3DDevice9Ex_Release(This->parentDevice); 00075 HeapFree(GetProcessHeap(), 0, This); 00076 } 00077 return ref; 00078 } 00079 00080 static HRESULT WINAPI IDirect3DQuery9Impl_GetDevice(IDirect3DQuery9 *iface, 00081 IDirect3DDevice9 **device) 00082 { 00083 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00084 00085 TRACE("iface %p, device %p.\n", iface, device); 00086 00087 *device = (IDirect3DDevice9 *)This->parentDevice; 00088 IDirect3DDevice9_AddRef(*device); 00089 00090 TRACE("Returning device %p.\n", *device); 00091 00092 return D3D_OK; 00093 } 00094 00095 static D3DQUERYTYPE WINAPI IDirect3DQuery9Impl_GetType(IDirect3DQuery9 *iface) 00096 { 00097 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00098 D3DQUERYTYPE type; 00099 00100 TRACE("iface %p.\n", iface); 00101 00102 wined3d_mutex_lock(); 00103 type = wined3d_query_get_type(This->wineD3DQuery); 00104 wined3d_mutex_unlock(); 00105 00106 return type; 00107 } 00108 00109 static DWORD WINAPI IDirect3DQuery9Impl_GetDataSize(IDirect3DQuery9 *iface) 00110 { 00111 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00112 DWORD ret; 00113 00114 TRACE("iface %p.\n", iface); 00115 00116 wined3d_mutex_lock(); 00117 ret = wined3d_query_get_data_size(This->wineD3DQuery); 00118 wined3d_mutex_unlock(); 00119 00120 return ret; 00121 } 00122 00123 static HRESULT WINAPI IDirect3DQuery9Impl_Issue(IDirect3DQuery9 *iface, DWORD dwIssueFlags) 00124 { 00125 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00126 HRESULT hr; 00127 00128 TRACE("iface %p, flags %#x.\n", iface, dwIssueFlags); 00129 00130 wined3d_mutex_lock(); 00131 hr = wined3d_query_issue(This->wineD3DQuery, dwIssueFlags); 00132 wined3d_mutex_unlock(); 00133 00134 return hr; 00135 } 00136 00137 static HRESULT WINAPI IDirect3DQuery9Impl_GetData(IDirect3DQuery9 *iface, void *pData, 00138 DWORD dwSize, DWORD dwGetDataFlags) 00139 { 00140 IDirect3DQuery9Impl *This = impl_from_IDirect3DQuery9(iface); 00141 HRESULT hr; 00142 00143 TRACE("iface %p, data %p, size %u, flags %#x.\n", 00144 iface, pData, dwSize, dwGetDataFlags); 00145 00146 wined3d_mutex_lock(); 00147 hr = wined3d_query_get_data(This->wineD3DQuery, pData, dwSize, dwGetDataFlags); 00148 wined3d_mutex_unlock(); 00149 00150 return hr; 00151 } 00152 00153 00154 static const IDirect3DQuery9Vtbl Direct3DQuery9_Vtbl = 00155 { 00156 IDirect3DQuery9Impl_QueryInterface, 00157 IDirect3DQuery9Impl_AddRef, 00158 IDirect3DQuery9Impl_Release, 00159 IDirect3DQuery9Impl_GetDevice, 00160 IDirect3DQuery9Impl_GetType, 00161 IDirect3DQuery9Impl_GetDataSize, 00162 IDirect3DQuery9Impl_Issue, 00163 IDirect3DQuery9Impl_GetData 00164 }; 00165 00166 HRESULT query_init(IDirect3DQuery9Impl *query, IDirect3DDevice9Impl *device, D3DQUERYTYPE type) 00167 { 00168 HRESULT hr; 00169 00170 query->IDirect3DQuery9_iface.lpVtbl = &Direct3DQuery9_Vtbl; 00171 query->ref = 1; 00172 00173 wined3d_mutex_lock(); 00174 hr = wined3d_query_create(device->wined3d_device, type, &query->wineD3DQuery); 00175 wined3d_mutex_unlock(); 00176 if (FAILED(hr)) 00177 { 00178 WARN("Failed to create wined3d query, hr %#x.\n", hr); 00179 return hr; 00180 } 00181 00182 query->parentDevice = &device->IDirect3DDevice9Ex_iface; 00183 IDirect3DDevice9Ex_AddRef(query->parentDevice); 00184 00185 return D3D_OK; 00186 } Generated on Sat May 26 2012 04:15:57 for ReactOS by
1.7.6.1
|