Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygend3d9_baseobject.c
Go to the documentation of this file.
00001 /* 00002 * COPYRIGHT: See COPYING in the top level directory 00003 * PROJECT: ReactOS ReactX 00004 * FILE: dll/directx/d3d9/d3d9_baseobject.c 00005 * PURPOSE: Direct3D9's base object 00006 * PROGRAMERS: Gregor Gullwi <gbrunmar (dot) ros (at) gmail (dot) com> 00007 */ 00008 #include "d3d9_baseobject.h" 00009 #include "d3d9_device.h" 00010 00011 #include <debug.h> 00012 #include "d3d9_helpers.h" 00013 00014 VOID D3D9BaseObject_Destroy(D3D9BaseObject* pBaseObject, BOOL bFreeThis) 00015 { 00016 if (bFreeThis) 00017 { 00018 AlignedFree((LPVOID*) pBaseObject); 00019 } 00020 } 00021 00022 ID3D9BaseObjectVtbl D3D9BaseObject_Vtbl = 00023 { 00024 /* D3D9BaseObject */ 00025 D3D9BaseObject_Destroy 00026 }; 00027 00028 VOID InitD3D9BaseObject(D3D9BaseObject* pBaseObject, enum REF_TYPE RefType, IUnknown* pUnknown) 00029 { 00030 pBaseObject->lpVtbl = &D3D9BaseObject_Vtbl; 00031 pBaseObject->RefType = RefType; 00032 pBaseObject->pUnknown = pUnknown; 00033 } 00034 00035 ULONG D3D9BaseObject_AddRef(D3D9BaseObject* pBaseObject) 00036 { 00037 if (pBaseObject->pUnknown) 00038 { 00039 pBaseObject->pUnknown->lpVtbl->AddRef((IUnknown*) &pBaseObject->pUnknown->lpVtbl); 00040 } 00041 00042 return InterlockedIncrement(&pBaseObject->lRefCnt); 00043 } 00044 00045 ULONG D3D9BaseObject_Release(D3D9BaseObject* pBaseObject) 00046 { 00047 ULONG Ref = 0; 00048 00049 if (pBaseObject) 00050 { 00051 Ref = InterlockedDecrement(&pBaseObject->lRefCnt); 00052 00053 if (Ref == 0) 00054 { 00055 if (pBaseObject->pUnknown) 00056 { 00057 pBaseObject->pUnknown->lpVtbl->Release((IUnknown*) &pBaseObject->pUnknown->lpVtbl); 00058 } 00059 } 00060 } 00061 00062 return Ref; 00063 } 00064 00065 HRESULT D3D9BaseObject_GetDevice(D3D9BaseObject* pBaseObject, IDirect3DDevice9** ppDevice) 00066 { 00067 if (pBaseObject->pUnknown) 00068 { 00069 return IUnknown_QueryInterface(pBaseObject->pUnknown, &IID_IDirect3DDevice9, (void**)ppDevice); 00070 } 00071 00072 return E_NOINTERFACE; 00073 } 00074 00075 HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject* pBaseObject, DIRECT3DDEVICE9_INT** ppDevice) 00076 { 00077 if (NULL == ppDevice) 00078 return D3DERR_INVALIDCALL; 00079 00080 *ppDevice = NULL; 00081 00082 if (pBaseObject->pUnknown) 00083 { 00084 LPDIRECT3DDEVICE9 pDevice; 00085 if (FAILED(IUnknown_QueryInterface(pBaseObject->pUnknown, &IID_IDirect3DDevice9, (void**)&pDevice))) 00086 return E_NOINTERFACE; 00087 00088 *ppDevice = IDirect3DDevice9ToImpl(pDevice); 00089 return D3D_OK; 00090 } 00091 00092 return E_NOINTERFACE; 00093 } 00094 00095 VOID D3D9BaseObject_LockDevice(D3D9BaseObject* pBaseObject) 00096 { 00097 DIRECT3DDEVICE9_INT* pDevice; 00098 if (FAILED(D3D9BaseObject_GetDeviceInt(pBaseObject, &pDevice))) 00099 return; 00100 00101 if (pDevice->bLockDevice) 00102 EnterCriticalSection(&pDevice->CriticalSection); 00103 } 00104 00105 VOID D3D9BaseObject_UnlockDevice(D3D9BaseObject* pBaseObject) 00106 { 00107 DIRECT3DDEVICE9_INT* pDevice; 00108 if (FAILED(D3D9BaseObject_GetDeviceInt(pBaseObject, &pDevice))) 00109 return; 00110 00111 if (pDevice->bLockDevice) 00112 LeaveCriticalSection(&pDevice->CriticalSection); 00113 } Generated on Sun May 27 2012 04:21:13 for ReactOS by
1.7.6.1
|