ReactOS  0.4.13-dev-101-g0ca4b50
d3d9_baseobject.h File Reference
#include "d3d9_common.h"
#include <d3d9.h>
Include dependency graph for d3d9_baseobject.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _D3D9BaseObjectVtbl
 
struct  _D3D9BaseObject
 

Typedefs

typedef struct _D3D9BaseObjectVtbl ID3D9BaseObjectVtbl
 
typedef struct _D3D9BaseObject D3D9BaseObject
 

Enumerations

enum  REF_TYPE { RT_EXTERNAL, RT_BUILTIN, RT_INTERNAL }
 

Functions

VOID InitD3D9BaseObject (D3D9BaseObject *pBaseObject, enum REF_TYPE RefType, IUnknown *pUnknown)
 
ULONG D3D9BaseObject_AddRef (D3D9BaseObject *pBaseObject)
 
ULONG D3D9BaseObject_Release (D3D9BaseObject *pBaseObject)
 
HRESULT D3D9BaseObject_GetDevice (D3D9BaseObject *pBaseObject, IDirect3DDevice9 **ppDevice)
 
HRESULT D3D9BaseObject_GetDeviceInt (D3D9BaseObject *pBaseObject, struct _Direct3DDevice9_INT **ppDevice)
 
VOID D3D9BaseObject_LockDevice (D3D9BaseObject *pBaseObject)
 
VOID D3D9BaseObject_UnlockDevice (D3D9BaseObject *pBaseObject)
 

Typedef Documentation

◆ D3D9BaseObject

◆ ID3D9BaseObjectVtbl

Enumeration Type Documentation

◆ REF_TYPE

Enumerator
RT_EXTERNAL 
RT_BUILTIN 
RT_INTERNAL 

Definition at line 17 of file d3d9_baseobject.h.

Function Documentation

◆ D3D9BaseObject_AddRef()

ULONG D3D9BaseObject_AddRef ( D3D9BaseObject pBaseObject)

Definition at line 35 of file d3d9_baseobject.c.

36 {
37  if (pBaseObject->pUnknown)
38  {
39  pBaseObject->pUnknown->lpVtbl->AddRef((IUnknown*) &pBaseObject->pUnknown->lpVtbl);
40  }
41 
42  return InterlockedIncrement(&pBaseObject->lRefCnt);
43 }
IUnknown * pUnknown
ULONG AddRef()
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by D3D9MipMap_AddRef(), and Direct3DSwapChain9_AddRef().

◆ D3D9BaseObject_GetDevice()

HRESULT D3D9BaseObject_GetDevice ( D3D9BaseObject pBaseObject,
IDirect3DDevice9 **  ppDevice 
)

Definition at line 65 of file d3d9_baseobject.c.

66 {
67  if (pBaseObject->pUnknown)
68  {
69  return IUnknown_QueryInterface(pBaseObject->pUnknown, &IID_IDirect3DDevice9, (void**)ppDevice);
70  }
71 
72  return E_NOINTERFACE;
73 }
#define E_NOINTERFACE
Definition: winerror.h:2364
IUnknown * pUnknown

Referenced by D3D9MipMap_GetDevice(), and Direct3DSwapChain9_GetDevice().

◆ D3D9BaseObject_GetDeviceInt()

HRESULT D3D9BaseObject_GetDeviceInt ( D3D9BaseObject pBaseObject,
struct _Direct3DDevice9_INT **  ppDevice 
)

Definition at line 75 of file d3d9_baseobject.c.

76 {
77  if (NULL == ppDevice)
78  return D3DERR_INVALIDCALL;
79 
80  *ppDevice = NULL;
81 
82  if (pBaseObject->pUnknown)
83  {
84  LPDIRECT3DDEVICE9 pDevice;
85  if (FAILED(IUnknown_QueryInterface(pBaseObject->pUnknown, &IID_IDirect3DDevice9, (void**)&pDevice)))
86  return E_NOINTERFACE;
87 
88  *ppDevice = IDirect3DDevice9ToImpl(pDevice);
89  return D3D_OK;
90  }
91 
92  return E_NOINTERFACE;
93 }
#define E_NOINTERFACE
Definition: winerror.h:2364
struct IDirect3DDevice9 * LPDIRECT3DDEVICE9
Definition: d3d9.h:130
IUnknown * pUnknown
#define D3DERR_INVALIDCALL
smooth NULL
Definition: ftsmooth.c:416
LPDIRECT3DDEVICE9_INT IDirect3DDevice9ToImpl(LPDIRECT3DDEVICE9 iface)
Definition: d3d9_device.c:19
#define D3D_OK
Definition: d3d.h:106

Referenced by D3D9BaseObject_LockDevice(), D3D9BaseObject_UnlockDevice(), and Direct3DSwapChain9_Init().

◆ D3D9BaseObject_LockDevice()

VOID D3D9BaseObject_LockDevice ( D3D9BaseObject pBaseObject)

Definition at line 95 of file d3d9_baseobject.c.

96 {
97  DIRECT3DDEVICE9_INT* pDevice;
98  if (FAILED(D3D9BaseObject_GetDeviceInt(pBaseObject, &pDevice)))
99  return;
100 
101  if (pDevice->bLockDevice)
103 }
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject *pBaseObject, DIRECT3DDEVICE9_INT **ppDevice)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CRITICAL_SECTION CriticalSection
Definition: d3d9_device.h:89

◆ D3D9BaseObject_Release()

ULONG D3D9BaseObject_Release ( D3D9BaseObject pBaseObject)

Definition at line 45 of file d3d9_baseobject.c.

46 {
47  ULONG Ref = 0;
48 
49  if (pBaseObject)
50  {
51  Ref = InterlockedDecrement(&pBaseObject->lRefCnt);
52 
53  if (Ref == 0)
54  {
55  if (pBaseObject->pUnknown)
56  {
57  pBaseObject->pUnknown->lpVtbl->Release((IUnknown*) &pBaseObject->pUnknown->lpVtbl);
58  }
59  }
60  }
61 
62  return Ref;
63 }
IUnknown * pUnknown
ULONG Release()
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1

Referenced by D3D9MipMap_Release(), and Direct3DSwapChain9_Release().

◆ D3D9BaseObject_UnlockDevice()

VOID D3D9BaseObject_UnlockDevice ( D3D9BaseObject pBaseObject)

Definition at line 105 of file d3d9_baseobject.c.

106 {
107  DIRECT3DDEVICE9_INT* pDevice;
108  if (FAILED(D3D9BaseObject_GetDeviceInt(pBaseObject, &pDevice)))
109  return;
110 
111  if (pDevice->bLockDevice)
113 }
HRESULT D3D9BaseObject_GetDeviceInt(D3D9BaseObject *pBaseObject, DIRECT3DDEVICE9_INT **ppDevice)
CRITICAL_SECTION CriticalSection
Definition: d3d9_device.h:89
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

◆ InitD3D9BaseObject()

VOID InitD3D9BaseObject ( D3D9BaseObject pBaseObject,
enum REF_TYPE  RefType,
IUnknown pUnknown 
)

Definition at line 28 of file d3d9_baseobject.c.

29 {
30  pBaseObject->lpVtbl = &D3D9BaseObject_Vtbl;
31  pBaseObject->RefType = RefType;
32  pBaseObject->pUnknown = pUnknown;
33 }
ID3D9BaseObjectVtbl * lpVtbl
IUnknown * pUnknown
ID3D9BaseObjectVtbl D3D9BaseObject_Vtbl
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
enum REF_TYPE RefType

Referenced by CreateDirect3DSwapChain9(), and InitDirect3DResource9().