Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/D3D8Interceptor/Direct3DSurface8Functions.cpp
2 views
1
#include "d3d8Wrapper.h"
2
3
extern "C"
4
{
5
namespace D3D8Wrapper
6
{
7
ThreadSafePointerSet IDirect3DSurface8::m_List;
8
9
D3D8Wrapper::IDirect3DSurface8::IDirect3DSurface8(D3D8Base::IDirect3DSurface8* realSurface) : IDirect3DUnknown((IUnknown*) realSurface)
10
{
11
LOG("IDirect3DSurface8::IDirect3DSurface8( " << realSurface << " )\n");
12
m_pD3D = realSurface;
13
}
14
15
D3D8Wrapper::IDirect3DSurface8* D3D8Wrapper::IDirect3DSurface8::GetSurface(D3D8Base::IDirect3DSurface8* realSurface)
16
{
17
LOG("IDirect3DSurface8::GetSurface( " << realSurface << " )\n");
18
D3D8Wrapper::IDirect3DSurface8* wrappedSurface = (D3D8Wrapper::IDirect3DSurface8*) m_List.GetDataPtr(realSurface);
19
if(wrappedSurface == NULL)
20
{
21
wrappedSurface = new IDirect3DSurface8(realSurface);
22
m_List.AddMember(realSurface, wrappedSurface);
23
return wrappedSurface;
24
}
25
26
wrappedSurface->m_ulRef++;
27
return wrappedSurface;
28
}
29
30
STDMETHODIMP_(ULONG) D3D8Wrapper::IDirect3DSurface8::Release(THIS)
31
{
32
LOG("IDirect3DSurface8::Release() [ " << this << " ]\n");
33
m_pUnk->Release();
34
35
ULONG ulRef = --m_ulRef;
36
if(ulRef == 0)
37
{
38
m_List.DeleteMember(GetSurface());
39
delete this;
40
return 0;
41
}
42
return ulRef;
43
}
44
45
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::GetDevice(D3D8Wrapper::IDirect3DDevice8** ppDevice)
46
{
47
LOG("IDirect3DSurface8::GetDevice( " << ppDevice << " ) [ " << this << " ]\n");
48
49
D3D8Base::IDirect3DDevice8* realD3D = NULL;
50
51
HRESULT hr = m_pD3D->GetDevice(&realD3D);
52
53
D3D8Wrapper::IDirect3DDevice8* wrappedD3D = new D3D8Wrapper::IDirect3DDevice8(realD3D);
54
55
*ppDevice = wrappedD3D;
56
57
return hr;
58
}
59
60
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
61
{
62
LOG("IDirect3DSurface8::SetPrivateData( " << &refguid << " , " << pData << " , " << SizeOfData << " , " << Flags << " ) [ " << this << " ]\n");
63
return m_pD3D->SetPrivateData(refguid,pData,SizeOfData,Flags);
64
}
65
66
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
67
{
68
LOG("IDirect3DSurface8::GetPrivateData( " << &refguid << " , " << pData << " , " << pSizeOfData << " ) [ " << this << " ]\n");
69
return m_pD3D->GetPrivateData(refguid,pData,pSizeOfData);
70
}
71
72
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::FreePrivateData(REFGUID refguid)
73
{
74
LOG("IDirect3DSurface8::FreePrivateData( " << &refguid << " ) [ " << this << " ]\n");
75
return m_pD3D->FreePrivateData(refguid);
76
}
77
78
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::GetContainer(REFIID riid,void** ppContainer)
79
{
80
LOG("IDirect3DSurface8::GetContainer( " << &riid << " , " << ppContainer << " ) [ " << this << " ]\n");
81
return m_pD3D->GetContainer(riid,ppContainer);
82
}
83
84
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::GetDesc(D3D8Base::D3DSURFACE_DESC *pDesc)
85
{
86
LOG("IDirect3DSurface8::GetDesc( " << pDesc << " ) [ " << this << " ]\n");
87
return m_pD3D->GetDesc(pDesc);
88
}
89
90
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::LockRect(D3D8Base::D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
91
{
92
#ifdef LOGGING
93
LOG("IDirect3DSurface8::LockRect( " << pLockedRect << " , " << pRect);
94
if (pRect != NULL)
95
{
96
LOG("{ " << pRect->left << " , " << pRect->top << " , " << pRect->right << " , " << pRect->bottom << " }");
97
}
98
LOG(" , " << Flags << " ) [ " << this << " ]\n");
99
#endif
100
return m_pD3D->LockRect(pLockedRect,pRect,Flags);
101
}
102
103
STDMETHODIMP D3D8Wrapper::IDirect3DSurface8::UnlockRect()
104
{
105
LOG("IDirect3DSurface8::UnlockRect() [ " << this << " ]\n");
106
return m_pD3D->UnlockRect();
107
}
108
}
109
}
110