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.

101 lines
2.5 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: deviunk.c
  6. * Content: Direct3DDevice IUnknown
  7. *@@BEGIN_MSINTERNAL
  8. *
  9. * $Id$
  10. *
  11. * History:
  12. * Date By Reason
  13. * ==== == ======
  14. * 07/12/95 stevela Merged Colin's changes.
  15. * 10/12/95 stevela Removed AGGREGATE_D3D.
  16. *@@END_MSINTERNAL
  17. *
  18. ***************************************************************************/
  19. #include "pch.cpp"
  20. #pragma hdrstop
  21. /*
  22. * D3DDev_QueryInterface
  23. */
  24. #undef DPF_MODNAME
  25. #define DPF_MODNAME "Direct3DDevice::QueryInterface"
  26. HRESULT D3DAPI DIRECT3DDEVICEI::QueryInterface(REFIID riid, LPVOID* ppvObj)
  27. {
  28. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  29. if (!VALID_OUTPTR(ppvObj)) {
  30. D3D_ERR( "Invalid pointer to object pointer" );
  31. return DDERR_INVALIDPARAMS;
  32. }
  33. D3D_INFO(3, "Direct3DDevice IUnknown QueryInterface");
  34. *ppvObj = NULL;
  35. if (IsEqualIID(riid, IID_IUnknown) || IsEqualIID(riid, IID_IDirect3DDevice7))
  36. {
  37. AddRef();
  38. *ppvObj = static_cast<LPVOID>(this);
  39. }
  40. else
  41. {
  42. D3D_ERR("unknown interface");
  43. return (E_NOINTERFACE);
  44. }
  45. return (D3D_OK);
  46. } /* D3DDev_QueryInterface */
  47. /*
  48. * D3DDev_AddRef
  49. */
  50. #undef DPF_MODNAME
  51. #define DPF_MODNAME "Direct3DDevice::AddRef"
  52. ULONG D3DAPI DIRECT3DDEVICEI::AddRef()
  53. {
  54. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  55. // Release in the destructor
  56. this->refCnt++;
  57. D3D_INFO(3, "Direct3DDevice IUnknown AddRef: Reference count = %d", this->refCnt);
  58. return (this->refCnt);
  59. } /* D3DDev_AddRef */
  60. /*
  61. * D3DDev_Release
  62. */
  63. #undef DPF_MODNAME
  64. #define DPF_MODNAME "Direct3DDevice::Release"
  65. ULONG D3DAPI DIRECT3DDEVICEI::Release()
  66. {
  67. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  68. // Release in the destructor
  69. /*
  70. * decrement the ref count. if we hit 0, free the object
  71. */
  72. this->refCnt--;
  73. D3D_INFO(3, "Direct3DDevice IUnknown Release: Reference count = %d", this->refCnt);
  74. if( this->refCnt == 0 )
  75. {
  76. delete this; // suicide
  77. return 0;
  78. }
  79. return this->refCnt;
  80. } /* D3DDev_Release */