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.

157 lines
3.7 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: bufiunk.c
  6. * Content: Direct3DExecuteBuffer IUnknown implementation
  7. *@@BEGIN_MSINTERNAL
  8. *
  9. * History:
  10. * Date By Reason
  11. * ==== == ======
  12. * 10/12/95 stevela Initial rev with this header.
  13. *@@END_MSINTERNAL
  14. *
  15. ***************************************************************************/
  16. #include "pch.cpp"
  17. #pragma hdrstop
  18. /*
  19. * D3DBuf_QueryInterface
  20. */
  21. #undef DPF_MODNAME
  22. #define DPF_MODNAME "Direct3DExecuteBuffer::QueryInterface"
  23. HRESULT D3DAPI DIRECT3DEXECUTEBUFFERI::QueryInterface(REFIID riid, LPVOID* ppvObj)
  24. {
  25. /*
  26. * validate parms
  27. */
  28. TRY
  29. {
  30. if (!VALID_DIRECT3DEXECUTEBUFFER_PTR(this)) {
  31. D3D_ERR( "Invalid Direct3DExecuteBuffer pointer" );
  32. return DDERR_INVALIDOBJECT;
  33. }
  34. if (!VALID_OUTPTR(ppvObj)) {
  35. D3D_ERR( "Invalid object pointer" );
  36. return DDERR_INVALIDPARAMS;
  37. }
  38. }
  39. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  40. {
  41. D3D_ERR( "Exception encountered validating parameters" );
  42. return DDERR_INVALIDPARAMS;
  43. }
  44. *ppvObj = NULL;
  45. if( IsEqualIID(riid, IID_IUnknown) ||
  46. IsEqualIID(riid, IID_IDirect3DExecuteBuffer) )
  47. {
  48. AddRef();
  49. *ppvObj = static_cast<LPVOID>(static_cast<LPUNKNOWN>(this));
  50. return (D3D_OK);
  51. }
  52. return (E_NOINTERFACE);
  53. } /* D3DBuf_QueryInterface */
  54. /*
  55. * D3DBuf_AddRef
  56. */
  57. #undef DPF_MODNAME
  58. #define DPF_MODNAME "Direct3DExecuteBuffer::AddRef"
  59. ULONG D3DAPI DIRECT3DEXECUTEBUFFERI::AddRef()
  60. {
  61. DWORD rcnt;
  62. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  63. // Release in the destructor
  64. /*
  65. * validate parms
  66. */
  67. TRY
  68. {
  69. if (!VALID_DIRECT3DEXECUTEBUFFER_PTR(this)) {
  70. D3D_ERR( "Invalid Direct3DExecuteBuffer pointer" );
  71. return 0;
  72. }
  73. }
  74. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  75. {
  76. D3D_ERR( "Exception encountered validating parameters" );
  77. return 0;
  78. }
  79. this->refCnt++;
  80. rcnt = this->refCnt;
  81. return (rcnt);
  82. } /* D3DBuf_AddRef */
  83. /*
  84. * D3DBuf_Release
  85. *
  86. */
  87. #undef DPF_MODNAME
  88. #define DPF_MODNAME "Direct3DExecuteBuffer::Release"
  89. ULONG D3DAPI DIRECT3DEXECUTEBUFFERI::Release()
  90. {
  91. DWORD lastrefcnt;
  92. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  93. // Release in the destructor
  94. /*
  95. * validate parms
  96. */
  97. TRY
  98. {
  99. if (!VALID_DIRECT3DEXECUTEBUFFER_PTR(this)) {
  100. D3D_ERR( "Invalid Direct3DExecuteBuffer pointer" );
  101. return 0;
  102. }
  103. }
  104. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  105. {
  106. D3D_ERR( "Exception encountered validating parameters" );
  107. return 0;
  108. }
  109. /*
  110. * decrement the ref count. if we hit 0, free the object
  111. */
  112. this->refCnt--;
  113. lastrefcnt = this->refCnt;
  114. if( lastrefcnt == 0 )
  115. {
  116. delete this;
  117. return 0;
  118. }
  119. return lastrefcnt;
  120. } /* D3DBuf_Release */
  121. DIRECT3DEXECUTEBUFFERI::~DIRECT3DEXECUTEBUFFERI()
  122. {
  123. if (this->locked)
  124. Unlock();
  125. /* remove us from the Direct3DDevice object list of execute buffers */
  126. LIST_DELETE(this, list);
  127. if (this->hBuf)
  128. {
  129. D3DHAL_DeallocateBuffer(this->lpDevI, this->hBuf);
  130. }
  131. }