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.

264 lines
8.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: d3drmdevice3obj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // d3drmDeviceObj.cpp : Implementation of CDirectApp and DLL registration.
  11. #include "stdafx.h"
  12. #include "Direct.h"
  13. #include "dms.h"
  14. #include "d3drmDevice3Obj.h"
  15. #include "d3drmViewportArrayObj.h"
  16. C_dxj_Direct3dRMDevice3Object::C_dxj_Direct3dRMDevice3Object(){
  17. m__dxj_Direct3dRMDevice3=NULL;
  18. parent=NULL;
  19. pinterface=NULL;
  20. creationid = ++g_creationcount;
  21. parent2 =NULL;
  22. DPF1(1,"Constructor Creation Direct3dRMDevice3[%d] \n",g_creationcount);
  23. nextobj = g_dxj_Direct3dRMDevice3;
  24. g_dxj_Direct3dRMDevice3 = (void *)this;
  25. }
  26. C_dxj_Direct3dRMDevice3Object::~C_dxj_Direct3dRMDevice3Object(){
  27. DPF1(1,"Destructor Direct3dRMDevice3 [%d] \n",creationid);
  28. C_dxj_Direct3dRMDevice3Object *prev=NULL;
  29. for(C_dxj_Direct3dRMDevice3Object *ptr=(C_dxj_Direct3dRMDevice3Object *)g_dxj_Direct3dRMDevice3;
  30. ptr;
  31. ptr=(C_dxj_Direct3dRMDevice3Object *)ptr->nextobj)
  32. {
  33. if(ptr == this)
  34. {
  35. if(prev)
  36. prev->nextobj = ptr->nextobj;
  37. else
  38. g_dxj_Direct3dRMDevice3 = (void*)ptr->nextobj;
  39. break;
  40. }
  41. prev = ptr;
  42. }
  43. if(m__dxj_Direct3dRMDevice3){
  44. int count = IUNK(m__dxj_Direct3dRMDevice3)->Release();
  45. DPF1(1,"DirectX real IDirect3dRMDevice3 Ref count %d \n",count);
  46. if(count==0){
  47. m__dxj_Direct3dRMDevice3 = NULL;
  48. }
  49. }
  50. if (parent)
  51. IUNK(parent)->Release();
  52. if (parent2)
  53. IUNK(parent2)->Release();
  54. }
  55. DWORD C_dxj_Direct3dRMDevice3Object::InternalAddRef(){
  56. DWORD i;
  57. i=CComObjectRoot::InternalAddRef();
  58. DPF2(1,"Direct3dRMDevice3[%d] AddRef %d \n",creationid,i);
  59. return i;
  60. }
  61. DWORD C_dxj_Direct3dRMDevice3Object::InternalRelease(){
  62. DWORD i;
  63. i=CComObjectRoot::InternalRelease();
  64. DPF2(1,"Direct3dRMDevice3 [%d] Release %d \n",creationid,i);
  65. return i;
  66. }
  67. GETSET_OBJECT(_dxj_Direct3dRMDevice3);
  68. CLONE_R(_dxj_Direct3dRMDevice3,Direct3DRMDevice3);
  69. SETNAME_R(_dxj_Direct3dRMDevice3);
  70. GETNAME_R(_dxj_Direct3dRMDevice3);
  71. GETCLASSNAME_R(_dxj_Direct3dRMDevice3);
  72. ADDDESTROYCALLBACK_R(_dxj_Direct3dRMDevice3);
  73. DELETEDESTROYCALLBACK_R(_dxj_Direct3dRMDevice3);
  74. //CLONETO_RX(_dxj_Direct3dRMDevice3, WinDevice, IID_IDirect3DRMWinDevice);
  75. PASS_THROUGH_R(_dxj_Direct3dRMDevice3, update, Update)
  76. PASS_THROUGH1_R(_dxj_Direct3dRMDevice3, setDither, SetDither, long)
  77. PASS_THROUGH1_R(_dxj_Direct3dRMDevice3, setShades, SetShades, int)
  78. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMDevice3, setAppData, SetAppData, long,(DWORD));
  79. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMDevice3, setBufferCount, SetBufferCount,long,(DWORD));
  80. //PASS_THROUGH_CAST_2_R(_dxj_Direct3dRMDevice3, init, Init, long,(DWORD),long,(DWORD));
  81. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMDevice3, setQuality, SetQuality, d3drmRenderQuality, (enum D3DRMRENDERQUALITY));
  82. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMDevice3, setTextureQuality, SetTextureQuality, d3drmTextureQuality, (enum _D3DRMTEXTUREQUALITY));
  83. PASS_THROUGH_CAST_1_R(_dxj_Direct3dRMDevice3, setRenderMode, SetRenderMode,long,(DWORD));
  84. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getHeight, GetHeight, int)
  85. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getWidth, GetWidth, int)
  86. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getDither, GetDither, long);
  87. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getShades, GetShades, long);
  88. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getQuality, GetQuality,long);
  89. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getAppData, GetAppData,long);
  90. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getColorModel, GetColorModel, d3dColorModel);
  91. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getBufferCount, GetBufferCount, long);
  92. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getTextureQuality, GetTextureQuality, d3drmTextureQuality);
  93. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getTrianglesDrawn, GetTrianglesDrawn, long);
  94. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getWireframeOptions, GetWireframeOptions, long);
  95. GET_DIRECT_R(_dxj_Direct3dRMDevice3, getRenderMode, GetRenderMode, long);
  96. RETURN_NEW_ITEM_R(_dxj_Direct3dRMDevice3, getViewports, GetViewports, _dxj_Direct3dRMViewportArray);
  97. /////////////////////////////////////////////////////////////////////////////
  98. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::addUpdateCallback( I_dxj_Direct3dRMDeviceUpdateCallback3 *devC, IUnknown *args)
  99. {
  100. // killed by companion DeleteUpdate
  101. DeviceUpdateCallback3 *ucb;
  102. ucb = (DeviceUpdateCallback3*)AddCallbackLink(
  103. (void**)&DeviceUpdateCallbacks3, (I_dxj_Direct3dRMCallback*)devC, (void*) args);
  104. if( !ucb ) {
  105. DPF(1,"AddUpdateCallback failed!\r\n");
  106. return E_FAIL;
  107. }
  108. if( FAILED(m__dxj_Direct3dRMDevice3->AddUpdateCallback((D3DRMDEVICE3UPDATECALLBACK)myAddUpdateCallback3, ucb)) )
  109. return E_FAIL;
  110. devC->AddRef();
  111. return S_OK;
  112. }
  113. /////////////////////////////////////////////////////////////////////////////
  114. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::deleteUpdateCallback( I_dxj_Direct3dRMDeviceUpdateCallback3 *devC, IUnknown *args)
  115. {
  116. DeviceUpdateCallback3 *ucb = DeviceUpdateCallbacks3;
  117. // look for our own specific entry
  118. for ( ; ucb; ucb = ucb->next ) {
  119. if( (ucb->c == devC) && (ucb->pUser == args) ) {
  120. //note: assume the callback is not called: only removed from a list.
  121. m__dxj_Direct3dRMDevice3->DeleteUpdateCallback(
  122. (D3DRMDEVICE3UPDATECALLBACK)myAddUpdateCallback3, ucb);
  123. // Remove ourselves in a thread-safe manner.
  124. UndoCallbackLink((GeneralCallback*)ucb,
  125. (GeneralCallback**)&DeviceUpdateCallbacks3);
  126. devC->Release();
  127. return S_OK;
  128. }
  129. }
  130. return E_FAIL;
  131. }
  132. #if 0
  133. /////////////////////////////////////////////////////////////////////////////
  134. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::getDirect3dRMWinDevice( I_dxj_Direct3dRMWinDevice __RPC_FAR *__RPC_FAR *retv)
  135. {
  136. HRESULT hr;
  137. LPDIRECT3DRMWINDEVICE pWinDev=NULL;
  138. hr=m__dxj_Direct3dRMDevice3->QueryInterface(IID_IDirect3DRMWinDevice,(void**)&pWinDev);
  139. if FAILED(hr) return hr;
  140. INTERNAL_CREATE(_dxj_Direct3dRMWinDevice,pWinDev,retv);
  141. return hr;
  142. }
  143. #endif
  144. #if 0
  145. /////////////////////////////////////////////////////////////////////////////
  146. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::getDirect3DDevice3( I_dxj_Direct3dDevice3 __RPC_FAR *__RPC_FAR *retv)
  147. {
  148. HRESULT hr;
  149. LPDIRECT3DDEVICE2 pDev2=NULL;
  150. LPDIRECT3DDEVICE3 pDev3=NULL;
  151. hr=m__dxj_Direct3dRMDevice3->GetDirect3DDevice2(&pDev2);
  152. if FAILED(hr) return hr;
  153. if (!retv) return E_INVALIDARG;
  154. *retv=NULL;
  155. if (!pDev2) return S_OK;
  156. hr=pDev2->QueryInterface(IID_IDirect3DDevice3,(void**)&pDev3);
  157. pDev2->Release();
  158. if FAILED(hr) return hr;
  159. INTERNAL_CREATE(_dxj_Direct3dDevice3,pDev3,retv);
  160. return hr;
  161. }
  162. #endif
  163. /////////////////////////////////////////////////////////////////////////////
  164. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::findPreferredTextureFormat(
  165. /* [in] */ long bitDepth,
  166. /* [in] */ long flags,
  167. /* [out][in] */ DDPixelFormat __RPC_FAR *ddpf)
  168. {
  169. HRESULT hr;
  170. DDPIXELFORMAT realDDPF;
  171. realDDPF.dwSize=sizeof(DDPIXELFORMAT);
  172. hr=m__dxj_Direct3dRMDevice3->FindPreferredTextureFormat((DWORD)bitDepth,(DWORD) flags,&realDDPF);
  173. if FAILED(hr) return hr;
  174. hr=CopyOutDDPixelFormat(ddpf,&realDDPF);
  175. if FAILED(hr) return hr;
  176. return hr;
  177. }
  178. //PASS_THROUGH_CAST_1_R(C_dxj_Direct3dRMDevice3Object, handleActivate, HandleActivate, int, (unsigned short))
  179. /////////////////////////////////////////////////////////////////////////////
  180. //
  181. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::handlePaint(long hdcThing)
  182. {
  183. LPDIRECT3DRMWINDEVICE pWinDevice=NULL;
  184. HRESULT hr;
  185. hr=m__dxj_Direct3dRMDevice3->QueryInterface(IID_IDirect3DRMWinDevice,(void**)&pWinDevice);
  186. if FAILED(hr) return hr;
  187. hr=pWinDevice->HandlePaint((HDC)hdcThing);
  188. pWinDevice->Release();
  189. return hr;
  190. }
  191. STDMETHODIMP C_dxj_Direct3dRMDevice3Object::handleActivate(long wParam)
  192. {
  193. LPDIRECT3DRMWINDEVICE pWinDevice=NULL;
  194. HRESULT hr;
  195. hr=m__dxj_Direct3dRMDevice3->QueryInterface(IID_IDirect3DRMWinDevice,(void**)&pWinDevice);
  196. if FAILED(hr) return hr;
  197. hr=pWinDevice->HandleActivate((WORD)wParam);
  198. pWinDevice->Release();
  199. return hr;
  200. }