diff options
Diffstat (limited to 'src/libs/dxvk-native-1.9.2a/src/d3d9/d3d9_device_child.h')
-rw-r--r-- | src/libs/dxvk-native-1.9.2a/src/d3d9/d3d9_device_child.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/libs/dxvk-native-1.9.2a/src/d3d9/d3d9_device_child.h b/src/libs/dxvk-native-1.9.2a/src/d3d9/d3d9_device_child.h new file mode 100644 index 00000000..433a269a --- /dev/null +++ b/src/libs/dxvk-native-1.9.2a/src/d3d9/d3d9_device_child.h @@ -0,0 +1,61 @@ +#pragma once + +#include "d3d9_include.h" + +namespace dxvk { + + class D3D9DeviceEx; + + template <typename Base> + class D3D9DeviceChild : public ComObjectClamp<Base> { + + public: + + D3D9DeviceChild(D3D9DeviceEx* pDevice) + : m_parent( pDevice ) { } + + ULONG STDMETHODCALLTYPE AddRef() { + uint32_t refCount = this->m_refCount++; + if (unlikely(!refCount)) { + this->AddRefPrivate(); + GetDevice()->AddRef(); + } + + return refCount + 1; + } + + ULONG STDMETHODCALLTYPE Release() { + uint32_t refCount = --this->m_refCount; + if (unlikely(!refCount)) { + auto* pDevice = GetDevice(); + this->ReleasePrivate(); + pDevice->Release(); + } + return refCount; + } + + HRESULT STDMETHODCALLTYPE GetDevice(IDirect3DDevice9** ppDevice) { + InitReturnPtr(ppDevice); + + if (ppDevice == nullptr) + return D3DERR_INVALIDCALL; + + *ppDevice = ref(GetDevice()); + return D3D_OK; + } + + IDirect3DDevice9Ex* GetDevice() { + return reinterpret_cast<IDirect3DDevice9Ex*>(m_parent); + } + + D3D9DeviceEx* GetParent() { + return m_parent; + } + + protected: + + D3D9DeviceEx* m_parent; + + }; + +}
\ No newline at end of file |