Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvolume.c
Go to the documentation of this file.
00001 /* 00002 * IDirect3DVolume9 implementation 00003 * 00004 * Copyright 2002-2005 Jason Edmeades 00005 * Raphael Junqueira 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00020 */ 00021 00022 #include "config.h" 00023 #include "d3d9_private.h" 00024 00025 WINE_DEFAULT_DEBUG_CHANNEL(d3d9); 00026 00027 static inline IDirect3DVolume9Impl *impl_from_IDirect3DVolume9(IDirect3DVolume9 *iface) 00028 { 00029 return CONTAINING_RECORD(iface, IDirect3DVolume9Impl, IDirect3DVolume9_iface); 00030 } 00031 00032 static HRESULT WINAPI IDirect3DVolume9Impl_QueryInterface(IDirect3DVolume9 *iface, REFIID riid, 00033 void **ppobj) 00034 { 00035 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00036 00037 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj); 00038 00039 if (IsEqualGUID(riid, &IID_IUnknown) 00040 || IsEqualGUID(riid, &IID_IDirect3DVolume9)) { 00041 IDirect3DVolume9_AddRef(iface); 00042 *ppobj = This; 00043 return S_OK; 00044 } 00045 00046 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); 00047 *ppobj = NULL; 00048 return E_NOINTERFACE; 00049 } 00050 00051 static ULONG WINAPI IDirect3DVolume9Impl_AddRef(IDirect3DVolume9 *iface) 00052 { 00053 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00054 00055 TRACE("iface %p.\n", iface); 00056 00057 if (This->forwardReference) { 00058 /* Forward refcounting */ 00059 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference); 00060 return IUnknown_AddRef(This->forwardReference); 00061 } else { 00062 /* No container, handle our own refcounting */ 00063 ULONG ref = InterlockedIncrement(&This->ref); 00064 00065 TRACE("%p increasing refcount to %u.\n", iface, ref); 00066 00067 if (ref == 1) 00068 { 00069 wined3d_mutex_lock(); 00070 wined3d_volume_incref(This->wined3d_volume); 00071 wined3d_mutex_unlock(); 00072 } 00073 00074 return ref; 00075 } 00076 } 00077 00078 static ULONG WINAPI IDirect3DVolume9Impl_Release(IDirect3DVolume9 *iface) 00079 { 00080 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00081 00082 TRACE("iface %p.\n", iface); 00083 00084 if (This->forwardReference) { 00085 /* Forward refcounting */ 00086 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference); 00087 return IUnknown_Release(This->forwardReference); 00088 } else { 00089 /* No container, handle our own refcounting */ 00090 ULONG ref = InterlockedDecrement(&This->ref); 00091 00092 TRACE("%p decreasing refcount to %u.\n", iface, ref); 00093 00094 if (ref == 0) { 00095 wined3d_mutex_lock(); 00096 wined3d_volume_decref(This->wined3d_volume); 00097 wined3d_mutex_unlock(); 00098 } 00099 00100 return ref; 00101 } 00102 } 00103 00104 static HRESULT WINAPI IDirect3DVolume9Impl_GetDevice(IDirect3DVolume9 *iface, 00105 IDirect3DDevice9 **device) 00106 { 00107 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00108 IDirect3DResource9 *resource; 00109 HRESULT hr; 00110 00111 TRACE("iface %p, device %p.\n", iface, device); 00112 00113 hr = IUnknown_QueryInterface(This->forwardReference, &IID_IDirect3DResource9, (void **)&resource); 00114 if (SUCCEEDED(hr)) 00115 { 00116 hr = IDirect3DResource9_GetDevice(resource, device); 00117 IDirect3DResource9_Release(resource); 00118 00119 TRACE("Returning device %p.\n", *device); 00120 } 00121 00122 return hr; 00123 } 00124 00125 static HRESULT WINAPI IDirect3DVolume9Impl_SetPrivateData(IDirect3DVolume9 *iface, REFGUID refguid, 00126 const void *pData, DWORD SizeOfData, DWORD Flags) 00127 { 00128 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00129 struct wined3d_resource *resource; 00130 HRESULT hr; 00131 00132 TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n", 00133 iface, debugstr_guid(refguid), pData, SizeOfData, Flags); 00134 00135 wined3d_mutex_lock(); 00136 resource = wined3d_volume_get_resource(This->wined3d_volume); 00137 hr = wined3d_resource_set_private_data(resource, refguid, pData, SizeOfData, Flags); 00138 wined3d_mutex_unlock(); 00139 00140 return hr; 00141 } 00142 00143 static HRESULT WINAPI IDirect3DVolume9Impl_GetPrivateData(IDirect3DVolume9 *iface, REFGUID refguid, 00144 void *pData, DWORD *pSizeOfData) 00145 { 00146 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00147 struct wined3d_resource *resource; 00148 HRESULT hr; 00149 00150 TRACE("iface %p, guid %s, data %p, data_size %p.\n", 00151 iface, debugstr_guid(refguid), pData, pSizeOfData); 00152 00153 wined3d_mutex_lock(); 00154 resource = wined3d_volume_get_resource(This->wined3d_volume); 00155 hr = wined3d_resource_get_private_data(resource, refguid, pData, pSizeOfData); 00156 wined3d_mutex_unlock(); 00157 00158 return hr; 00159 } 00160 00161 static HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(IDirect3DVolume9 *iface, REFGUID refguid) 00162 { 00163 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00164 struct wined3d_resource *resource; 00165 HRESULT hr; 00166 00167 TRACE("iface %p, guid %s.\n", iface, debugstr_guid(refguid)); 00168 00169 wined3d_mutex_lock(); 00170 resource = wined3d_volume_get_resource(This->wined3d_volume); 00171 hr = wined3d_resource_free_private_data(resource, refguid); 00172 wined3d_mutex_unlock(); 00173 00174 return hr; 00175 } 00176 00177 static HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(IDirect3DVolume9 *iface, REFIID riid, 00178 void **ppContainer) 00179 { 00180 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00181 HRESULT res; 00182 00183 TRACE("iface %p, riid %s, container %p.\n", iface, debugstr_guid(riid), ppContainer); 00184 00185 if (!This->container) return E_NOINTERFACE; 00186 00187 res = IUnknown_QueryInterface(This->container, riid, ppContainer); 00188 00189 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer); 00190 00191 return res; 00192 } 00193 00194 static HRESULT WINAPI IDirect3DVolume9Impl_GetDesc(IDirect3DVolume9 *iface, D3DVOLUME_DESC *desc) 00195 { 00196 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00197 struct wined3d_resource_desc wined3d_desc; 00198 struct wined3d_resource *wined3d_resource; 00199 00200 TRACE("iface %p, desc %p.\n", iface, desc); 00201 00202 wined3d_mutex_lock(); 00203 wined3d_resource = wined3d_volume_get_resource(This->wined3d_volume); 00204 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); 00205 wined3d_mutex_unlock(); 00206 00207 desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); 00208 desc->Type = wined3d_desc.resource_type; 00209 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; 00210 desc->Pool = wined3d_desc.pool; 00211 desc->Width = wined3d_desc.width; 00212 desc->Height = wined3d_desc.height; 00213 desc->Depth = wined3d_desc.depth; 00214 00215 return D3D_OK; 00216 } 00217 00218 static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(IDirect3DVolume9 *iface, 00219 D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags) 00220 { 00221 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00222 HRESULT hr; 00223 00224 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", 00225 iface, pLockedVolume, pBox, Flags); 00226 00227 wined3d_mutex_lock(); 00228 hr = wined3d_volume_map(This->wined3d_volume, (struct wined3d_mapped_box *)pLockedVolume, 00229 (const struct wined3d_box *)pBox, Flags); 00230 wined3d_mutex_unlock(); 00231 00232 return hr; 00233 } 00234 00235 static HRESULT WINAPI IDirect3DVolume9Impl_UnlockBox(IDirect3DVolume9 *iface) 00236 { 00237 IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); 00238 HRESULT hr; 00239 00240 TRACE("iface %p.\n", iface); 00241 00242 wined3d_mutex_lock(); 00243 hr = wined3d_volume_unmap(This->wined3d_volume); 00244 wined3d_mutex_unlock(); 00245 00246 return hr; 00247 } 00248 00249 static const IDirect3DVolume9Vtbl Direct3DVolume9_Vtbl = 00250 { 00251 /* IUnknown */ 00252 IDirect3DVolume9Impl_QueryInterface, 00253 IDirect3DVolume9Impl_AddRef, 00254 IDirect3DVolume9Impl_Release, 00255 /* IDirect3DVolume9 */ 00256 IDirect3DVolume9Impl_GetDevice, 00257 IDirect3DVolume9Impl_SetPrivateData, 00258 IDirect3DVolume9Impl_GetPrivateData, 00259 IDirect3DVolume9Impl_FreePrivateData, 00260 IDirect3DVolume9Impl_GetContainer, 00261 IDirect3DVolume9Impl_GetDesc, 00262 IDirect3DVolume9Impl_LockBox, 00263 IDirect3DVolume9Impl_UnlockBox 00264 }; 00265 00266 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) 00267 { 00268 HeapFree(GetProcessHeap(), 0, parent); 00269 } 00270 00271 static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops = 00272 { 00273 volume_wined3d_object_destroyed, 00274 }; 00275 00276 HRESULT volume_init(IDirect3DVolume9Impl *volume, IDirect3DDevice9Impl *device, UINT width, UINT height, 00277 UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) 00278 { 00279 HRESULT hr; 00280 00281 volume->IDirect3DVolume9_iface.lpVtbl = &Direct3DVolume9_Vtbl; 00282 volume->ref = 1; 00283 00284 hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage & WINED3DUSAGE_MASK, 00285 format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wined3d_volume); 00286 if (FAILED(hr)) 00287 { 00288 WARN("Failed to create wined3d volume, hr %#x.\n", hr); 00289 return hr; 00290 } 00291 00292 return D3D_OK; 00293 } Generated on Fri May 25 2012 04:17:26 for ReactOS by
1.7.6.1
|