Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
3.8 KiB

  1. #include "common.hpp"
  2. #include "id3dsurf.h"
  3. class CDirect3DSurface8: public IDirect3DSurface8Clone
  4. {
  5. public:
  6. CDirect3DSurface8();
  7. ~CDirect3DSurface8();
  8. /* ULONG AddRef();
  9. HRESULT QueryInterface(REFIID iid, void **ppvObject);
  10. ULONG Release();*/
  11. // IUnknown methods
  12. STDMETHOD(QueryInterface) (REFIID riid,
  13. VOID **ppvObj);
  14. STDMETHOD_(ULONG,AddRef) ();
  15. STDMETHOD_(ULONG,Release) ();
  16. // IBuffer methods
  17. STDMETHOD(SetPrivateData)(REFGUID riid,
  18. CONST VOID *pvData,
  19. DWORD cbData,
  20. DWORD dwFlags);
  21. STDMETHOD(GetPrivateData)(REFGUID riid,
  22. VOID *pvData,
  23. DWORD *pcbData);
  24. STDMETHOD(FreePrivateData)(REFGUID riid);
  25. STDMETHOD(GetContainer)(REFIID riid,
  26. void **ppContainer);
  27. STDMETHOD(GetDevice)(IDirect3DDevice8 **ppDevice);
  28. // IDirect3DSurface8 methods
  29. STDMETHOD_(D3DSURFACE_DESC, GetDesc)();
  30. STDMETHOD(LockRect)(D3DLOCKED_RECT *pLockedRectData,
  31. CONST RECT *pRect,
  32. DWORD dwFlags);
  33. STDMETHOD(UnlockRect)();
  34. BOOL Create(int iWidth, int iHeight);
  35. /* HRESULT GetDevice(IDirect3DDevice8** ppDevice);
  36. HRESULT SetPrivateData(REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
  37. HRESULT GetPrivateData(REFGUID refguid, void* pData, DWORD* pSizeOfData);
  38. HRESULT FreePrivateData(REFGUID refguid);
  39. HRESULT GetContainer(REFIID riid, void** ppContainer);
  40. D3DSURFACE_DESC GetDesc();
  41. HRESULT LockRect(D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
  42. HRESULT UnlockRect();*/
  43. private:
  44. int m_iRefCount;
  45. BYTE *m_pData;
  46. D3DSURFACE_DESC m_Desc;
  47. };
  48. CDirect3DSurface8::CDirect3DSurface8() : m_pData(NULL), m_iRefCount(1)
  49. {
  50. }
  51. CDirect3DSurface8::~CDirect3DSurface8()
  52. {
  53. delete[] m_pData;
  54. }
  55. BOOL CDirect3DSurface8::Create(int iWidth, int iHeight)
  56. {
  57. m_pData = new BYTE[iWidth * iHeight * 4];
  58. if (!m_pData) return FALSE;
  59. m_Desc.Format = D3DFMT_A8R8G8B8;
  60. m_Desc.Type = D3DRTYPE_SURFACE;
  61. m_Desc.Usage = 0;
  62. m_Desc.Pool = D3DPOOL_SYSTEMMEM;
  63. m_Desc.Size = iWidth * iHeight * 4;
  64. m_Desc.MultiSampleType = D3DMULTISAMPLE_NONE;
  65. m_Desc.Width = iWidth;
  66. m_Desc.Height = iHeight;
  67. return TRUE;
  68. }
  69. STDMETHODIMP_(ULONG) CDirect3DSurface8::AddRef()
  70. {
  71. return ++m_iRefCount;
  72. }
  73. STDMETHODIMP CDirect3DSurface8::QueryInterface(REFIID iid, void **ppvObject)
  74. {
  75. return E_NOINTERFACE;
  76. }
  77. STDMETHODIMP_(ULONG) CDirect3DSurface8::Release()
  78. {
  79. if (!--m_iRefCount)
  80. {
  81. delete this;
  82. return 0;
  83. }
  84. return m_iRefCount;
  85. }
  86. /////////// Dummy implementations ///////////////
  87. STDMETHODIMP CDirect3DSurface8::SetPrivateData(REFGUID riid, CONST VOID *pvData, DWORD cbData, DWORD dwFlags)
  88. {
  89. return S_OK;
  90. }
  91. STDMETHODIMP CDirect3DSurface8::GetPrivateData(REFGUID riid, VOID *pvData, DWORD *pcbData)
  92. {
  93. return S_OK;
  94. }
  95. STDMETHODIMP CDirect3DSurface8::FreePrivateData(REFGUID riid)
  96. {
  97. return S_OK;
  98. }
  99. STDMETHODIMP CDirect3DSurface8::GetContainer(REFIID riid, void **ppContainer)
  100. {
  101. return S_OK;
  102. }
  103. STDMETHODIMP CDirect3DSurface8::GetDevice(IDirect3DDevice8 **ppDevice)
  104. {
  105. return S_OK;
  106. }
  107. // Required implementation
  108. STDMETHODIMP_(D3DSURFACE_DESC) CDirect3DSurface8::GetDesc()
  109. {
  110. return m_Desc;
  111. }
  112. // Assume the entire surface is being locked.
  113. STDMETHODIMP CDirect3DSurface8::LockRect(D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags)
  114. {
  115. pLockedRect->Pitch = m_Desc.Width * 4;
  116. pLockedRect->pBits = m_pData;
  117. return S_OK;
  118. }
  119. STDMETHODIMP CDirect3DSurface8::UnlockRect()
  120. {
  121. return S_OK;
  122. }
  123. IDirect3DSurface8 *GetCloneSurface(int iWidth, int iHeight)
  124. {
  125. CDirect3DSurface8 *pSurf = new CDirect3DSurface8;
  126. if (!pSurf) return NULL;
  127. if (!pSurf->Create(iWidth, iHeight))
  128. {
  129. delete pSurf;
  130. return NULL;
  131. }
  132. return (IDirect3DSurface8*)pSurf;
  133. }