Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenvolume.c
Go to the documentation of this file.
00001 /* 00002 * IDirect3DVolume8 implementation 00003 * 00004 * Copyright 2005 Oliver Stieber 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 #include "config.h" 00022 #include "d3d8_private.h" 00023 00024 WINE_DEFAULT_DEBUG_CHANNEL(d3d8); 00025 00026 static inline IDirect3DVolume8Impl *impl_from_IDirect3DVolume8(IDirect3DVolume8 *iface) 00027 { 00028 return CONTAINING_RECORD(iface, IDirect3DVolume8Impl, IDirect3DVolume8_iface); 00029 } 00030 00031 static HRESULT WINAPI IDirect3DVolume8Impl_QueryInterface(IDirect3DVolume8 *iface, REFIID riid, 00032 void **ppobj) 00033 { 00034 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00035 00036 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), ppobj); 00037 00038 if (IsEqualGUID(riid, &IID_IUnknown) 00039 || IsEqualGUID(riid, &IID_IDirect3DVolume8)) { 00040 IUnknown_AddRef(iface); 00041 *ppobj = This; 00042 return S_OK; 00043 } 00044 00045 WARN("(%p)->(%s,%p),not found\n", This, debugstr_guid(riid), ppobj); 00046 *ppobj = NULL; 00047 return E_NOINTERFACE; 00048 } 00049 00050 static ULONG WINAPI IDirect3DVolume8Impl_AddRef(IDirect3DVolume8 *iface) 00051 { 00052 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00053 00054 TRACE("iface %p.\n", iface); 00055 00056 if (This->forwardReference) { 00057 /* Forward to the containerParent */ 00058 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference); 00059 return IUnknown_AddRef(This->forwardReference); 00060 } else { 00061 /* No container, handle our own refcounting */ 00062 ULONG ref = InterlockedIncrement(&This->ref); 00063 00064 TRACE("%p increasing refcount to %u.\n", iface, ref); 00065 00066 if (ref == 1) 00067 { 00068 wined3d_mutex_lock(); 00069 wined3d_volume_incref(This->wined3d_volume); 00070 wined3d_mutex_unlock(); 00071 } 00072 00073 return ref; 00074 } 00075 } 00076 00077 static ULONG WINAPI IDirect3DVolume8Impl_Release(IDirect3DVolume8 *iface) 00078 { 00079 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00080 00081 TRACE("iface %p.\n", iface); 00082 00083 if (This->forwardReference) { 00084 /* Forward to the containerParent */ 00085 TRACE("(%p) : Forwarding to %p\n", This, This->forwardReference); 00086 return IUnknown_Release(This->forwardReference); 00087 } 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 IDirect3DVolume8Impl_GetDevice(IDirect3DVolume8 *iface, 00105 IDirect3DDevice8 **device) 00106 { 00107 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00108 IDirect3DResource8 *resource; 00109 HRESULT hr; 00110 00111 TRACE("iface %p, device %p.\n", iface, device); 00112 00113 hr = IUnknown_QueryInterface(This->forwardReference, &IID_IDirect3DResource8, (void **)&resource); 00114 if (SUCCEEDED(hr)) 00115 { 00116 hr = IDirect3DResource8_GetDevice(resource, device); 00117 IDirect3DResource8_Release(resource); 00118 00119 TRACE("Returning device %p.\n", *device); 00120 } 00121 00122 return hr; 00123 } 00124 00125 static HRESULT WINAPI IDirect3DVolume8Impl_SetPrivateData(IDirect3DVolume8 *iface, REFGUID refguid, 00126 const void *pData, DWORD SizeOfData, DWORD Flags) 00127 { 00128 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(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 IDirect3DVolume8Impl_GetPrivateData(IDirect3DVolume8 *iface, REFGUID refguid, 00144 void *pData, DWORD *pSizeOfData) 00145 { 00146 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(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 IDirect3DVolume8Impl_FreePrivateData(IDirect3DVolume8 *iface, REFGUID refguid) 00162 { 00163 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(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 IDirect3DVolume8Impl_GetContainer(IDirect3DVolume8 *iface, REFIID riid, 00178 void **ppContainer) 00179 { 00180 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00181 HRESULT res; 00182 00183 TRACE("iface %p, riid %s, container %p.\n", 00184 iface, debugstr_guid(riid), ppContainer); 00185 00186 if (!This->container) return E_NOINTERFACE; 00187 00188 res = IUnknown_QueryInterface(This->container, riid, ppContainer); 00189 00190 TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer); 00191 00192 return res; 00193 } 00194 00195 static HRESULT WINAPI IDirect3DVolume8Impl_GetDesc(IDirect3DVolume8 *iface, D3DVOLUME_DESC *desc) 00196 { 00197 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00198 struct wined3d_resource_desc wined3d_desc; 00199 struct wined3d_resource *wined3d_resource; 00200 00201 TRACE("iface %p, desc %p.\n", iface, desc); 00202 00203 wined3d_mutex_lock(); 00204 wined3d_resource = wined3d_volume_get_resource(This->wined3d_volume); 00205 wined3d_resource_get_desc(wined3d_resource, &wined3d_desc); 00206 wined3d_mutex_unlock(); 00207 00208 desc->Format = d3dformat_from_wined3dformat(wined3d_desc.format); 00209 desc->Type = wined3d_desc.resource_type; 00210 desc->Usage = wined3d_desc.usage & WINED3DUSAGE_MASK; 00211 desc->Pool = wined3d_desc.pool; 00212 desc->Size = wined3d_desc.size; 00213 desc->Width = wined3d_desc.width; 00214 desc->Height = wined3d_desc.height; 00215 desc->Depth = wined3d_desc.depth; 00216 00217 return D3D_OK; 00218 } 00219 00220 static HRESULT WINAPI IDirect3DVolume8Impl_LockBox(IDirect3DVolume8 *iface, 00221 D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags) 00222 { 00223 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00224 HRESULT hr; 00225 00226 TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", 00227 iface, pLockedVolume, pBox, Flags); 00228 00229 wined3d_mutex_lock(); 00230 hr = wined3d_volume_map(This->wined3d_volume, (struct wined3d_mapped_box *)pLockedVolume, 00231 (const struct wined3d_box *)pBox, Flags); 00232 wined3d_mutex_unlock(); 00233 00234 return hr; 00235 } 00236 00237 static HRESULT WINAPI IDirect3DVolume8Impl_UnlockBox(IDirect3DVolume8 *iface) 00238 { 00239 IDirect3DVolume8Impl *This = impl_from_IDirect3DVolume8(iface); 00240 HRESULT hr; 00241 00242 TRACE("iface %p.\n", iface); 00243 00244 wined3d_mutex_lock(); 00245 hr = wined3d_volume_unmap(This->wined3d_volume); 00246 wined3d_mutex_unlock(); 00247 00248 return hr; 00249 } 00250 00251 static const IDirect3DVolume8Vtbl Direct3DVolume8_Vtbl = 00252 { 00253 /* IUnknown */ 00254 IDirect3DVolume8Impl_QueryInterface, 00255 IDirect3DVolume8Impl_AddRef, 00256 IDirect3DVolume8Impl_Release, 00257 /* IDirect3DVolume8 */ 00258 IDirect3DVolume8Impl_GetDevice, 00259 IDirect3DVolume8Impl_SetPrivateData, 00260 IDirect3DVolume8Impl_GetPrivateData, 00261 IDirect3DVolume8Impl_FreePrivateData, 00262 IDirect3DVolume8Impl_GetContainer, 00263 IDirect3DVolume8Impl_GetDesc, 00264 IDirect3DVolume8Impl_LockBox, 00265 IDirect3DVolume8Impl_UnlockBox 00266 }; 00267 00268 static void STDMETHODCALLTYPE volume_wined3d_object_destroyed(void *parent) 00269 { 00270 HeapFree(GetProcessHeap(), 0, parent); 00271 } 00272 00273 static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops = 00274 { 00275 volume_wined3d_object_destroyed, 00276 }; 00277 00278 HRESULT volume_init(IDirect3DVolume8Impl *volume, IDirect3DDevice8Impl *device, UINT width, UINT height, 00279 UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) 00280 { 00281 HRESULT hr; 00282 00283 volume->IDirect3DVolume8_iface.lpVtbl = &Direct3DVolume8_Vtbl; 00284 volume->ref = 1; 00285 00286 hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage, 00287 format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume); 00288 if (FAILED(hr)) 00289 { 00290 WARN("Failed to create wined3d volume, hr %#x.\n", hr); 00291 return hr; 00292 } 00293 00294 return D3D_OK; 00295 } Generated on Sun May 27 2012 04:19:20 for ReactOS by
1.7.6.1
|