Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/D3D8Interceptor/Direct3DSwapChain8Functions.cpp
2 views
1
#include "d3d8Wrapper.h"
2
3
extern "C"
4
{
5
namespace D3D8Wrapper
6
{
7
ThreadSafePointerSet IDirect3DSwapChain8::m_List;
8
9
D3D8Wrapper::IDirect3DSwapChain8::IDirect3DSwapChain8(D3D8Base::IDirect3DSwapChain8* realSwapChain) : IDirect3DUnknown((IUnknown*) realSwapChain)
10
{
11
LOG("IDirect3DSwapChain8::IDirect3DSwapChain8( " << realSwapChain << " )\n");
12
m_pD3D = realSwapChain;
13
}
14
15
D3D8Wrapper::IDirect3DSwapChain8* D3D8Wrapper::IDirect3DSwapChain8::GetSwapChain(D3D8Base::IDirect3DSwapChain8* realSwapChain)
16
{
17
LOG("IDirect3DSwapChain8::GetSwapChain( " << realSwapChain << " )\n");
18
D3D8Wrapper::IDirect3DSwapChain8* wrappedSwapChain = (D3D8Wrapper::IDirect3DSwapChain8*) m_List.GetDataPtr(realSwapChain);
19
if( wrappedSwapChain == NULL )
20
{
21
wrappedSwapChain = new D3D8Wrapper::IDirect3DSwapChain8(realSwapChain);
22
m_List.AddMember(realSwapChain, wrappedSwapChain);
23
return wrappedSwapChain;
24
}
25
26
wrappedSwapChain->m_ulRef++;
27
return wrappedSwapChain;
28
}
29
30
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DSwapChain8::Release(THIS)
31
{
32
LOG("IDirect3DSwapChain8::Release()n[ " << this << " ]\n");
33
m_pUnk->Release();
34
35
ULONG ulRef = --m_ulRef;
36
if(ulRef == 0)
37
{
38
m_List.DeleteMember(GetSwapChain8());
39
delete this;
40
return 0;
41
}
42
return ulRef;
43
}
44
45
STDMETHODIMP D3D8Wrapper::IDirect3DSwapChain8::Present(CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion)
46
{
47
LOG("IDirect3DSwapChain8::Present( " << pSourceRect << " , " << pDestRect << " , " << hDestWindowOverride << " , " << pDirtyRegion << " ) [ " << this << " ]\n");
48
return m_pD3D->Present(pSourceRect,pDestRect,hDestWindowOverride,pDirtyRegion);
49
}
50
51
STDMETHODIMP D3D8Wrapper::IDirect3DSwapChain8::GetBackBuffer(UINT BackBuffer,D3D8Base::D3DBACKBUFFER_TYPE Type,D3D8Wrapper::IDirect3DSurface8** ppBackBuffer)
52
{
53
LOG("IDirect3DSwapChain8::GetBackBuffer( " << BackBuffer << " , " << Type << " , " << ppBackBuffer << " ) [ " << this << " ]\n");
54
55
D3D8Base::IDirect3DSurface8* realD3D = NULL;
56
57
HRESULT hr = m_pD3D->GetBackBuffer(BackBuffer,Type,&realD3D);
58
59
D3D8Wrapper::IDirect3DSurface8* wrappedD3D = D3D8Wrapper::IDirect3DSurface8::GetSurface(realD3D);
60
61
*ppBackBuffer = wrappedD3D;
62
63
return hr;
64
}
65
}
66
}
67