Path: blob/master/libmupen64plus/D3D8Interceptor/Direct3DSwapChain8Functions.cpp
2 views
#include "d3d8Wrapper.h"12extern "C"3{4namespace D3D8Wrapper5{6ThreadSafePointerSet IDirect3DSwapChain8::m_List;78D3D8Wrapper::IDirect3DSwapChain8::IDirect3DSwapChain8(D3D8Base::IDirect3DSwapChain8* realSwapChain) : IDirect3DUnknown((IUnknown*) realSwapChain)9{10LOG("IDirect3DSwapChain8::IDirect3DSwapChain8( " << realSwapChain << " )\n");11m_pD3D = realSwapChain;12}1314D3D8Wrapper::IDirect3DSwapChain8* D3D8Wrapper::IDirect3DSwapChain8::GetSwapChain(D3D8Base::IDirect3DSwapChain8* realSwapChain)15{16LOG("IDirect3DSwapChain8::GetSwapChain( " << realSwapChain << " )\n");17D3D8Wrapper::IDirect3DSwapChain8* wrappedSwapChain = (D3D8Wrapper::IDirect3DSwapChain8*) m_List.GetDataPtr(realSwapChain);18if( wrappedSwapChain == NULL )19{20wrappedSwapChain = new D3D8Wrapper::IDirect3DSwapChain8(realSwapChain);21m_List.AddMember(realSwapChain, wrappedSwapChain);22return wrappedSwapChain;23}2425wrappedSwapChain->m_ulRef++;26return wrappedSwapChain;27}2829STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DSwapChain8::Release(THIS)30{31LOG("IDirect3DSwapChain8::Release()n[ " << this << " ]\n");32m_pUnk->Release();3334ULONG ulRef = --m_ulRef;35if(ulRef == 0)36{37m_List.DeleteMember(GetSwapChain8());38delete this;39return 0;40}41return ulRef;42}4344STDMETHODIMP D3D8Wrapper::IDirect3DSwapChain8::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)45{46LOG("IDirect3DSwapChain8::Present( " << pSourceRect << " , " << pDestRect << " , " << hDestWindowOverride << " , " << pDirtyRegion << " ) [ " << this << " ]\n");47return m_pD3D->Present(pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion);48}4950STDMETHODIMP D3D8Wrapper::IDirect3DSwapChain8::GetBackBuffer(UINT BackBuffer,D3D8Base::D3DBACKBUFFER_TYPE Type,D3D8Wrapper::IDirect3DSurface8** ppBackBuffer)51{52LOG("IDirect3DSwapChain8::GetBackBuffer( " << BackBuffer << " , " << Type << " , " << ppBackBuffer << " ) [ " << this << " ]\n");5354D3D8Base::IDirect3DSurface8* realD3D = NULL;5556HRESULT hr = m_pD3D->GetBackBuffer(BackBuffer,Type,&realD3D);5758D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);5960*ppBackBuffer = wrappedD3D;6162return hr;63}64}65}6667