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
4.1 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: texiunk.c
  6. * Content: Direct3DViewport 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. * D3DVwp_QueryInterface
  20. */
  21. #undef DPF_MODNAME
  22. #define DPF_MODNAME "Direct3DViewport::QueryInterface"
  23. HRESULT D3DAPI DIRECT3DVIEWPORTI::QueryInterface(REFIID riid, LPVOID* ppvObj)
  24. {
  25. HRESULT ret;
  26. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  27. // Release in the destructor
  28. /*
  29. * validate parms
  30. */
  31. TRY
  32. {
  33. if (!VALID_DIRECT3DVIEWPORT3_PTR(this)) {
  34. D3D_ERR( "Invalid Direct3DViewport pointer" );
  35. return DDERR_INVALIDOBJECT;
  36. }
  37. if (!VALID_OUTPTR(ppvObj)) {
  38. D3D_ERR( "Invalid pointer to pointer" );
  39. return DDERR_INVALIDPARAMS;
  40. }
  41. }
  42. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  43. {
  44. D3D_ERR( "Exception encountered validating parameters" );
  45. return DDERR_INVALIDPARAMS;
  46. }
  47. *ppvObj = NULL;
  48. if(IsEqualIID(riid, IID_IUnknown) ||
  49. IsEqualIID(riid, IID_IDirect3DViewport) ||
  50. IsEqualIID(riid, IID_IDirect3DViewport2) ||
  51. IsEqualIID(riid, IID_IDirect3DViewport3))
  52. {
  53. AddRef();
  54. *ppvObj = (LPVOID)this;
  55. ret = D3D_OK;
  56. }
  57. else
  58. ret = E_NOINTERFACE;
  59. return ret;
  60. } /* D3DVwp_QueryInterface */
  61. /*
  62. * D3DVwp_AddRef
  63. */
  64. #undef DPF_MODNAME
  65. #define DPF_MODNAME "Direct3DViewport::AddRef"
  66. ULONG D3DAPI DIRECT3DVIEWPORTI::AddRef()
  67. {
  68. DWORD rcnt;
  69. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  70. // Release in the destructor
  71. /*
  72. * validate parms
  73. */
  74. TRY
  75. {
  76. if (!VALID_DIRECT3DVIEWPORT3_PTR(this)) {
  77. D3D_ERR( "Invalid Direct3DViewport pointer" );
  78. return 0;
  79. }
  80. }
  81. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  82. {
  83. D3D_ERR( "Exception encountered validating parameters" );
  84. return 0;
  85. }
  86. this->refCnt++;
  87. rcnt = this->refCnt;
  88. return (rcnt);
  89. } /* D3DVwp_AddRef */
  90. /*
  91. * D3DVwp_Release
  92. *
  93. */
  94. ULONG D3DAPI DIRECT3DVIEWPORTI::Release()
  95. {
  96. DWORD lastrefcnt;
  97. CLockD3D lockObject(DPF_MODNAME, REMIND("")); // Takes D3D lock.
  98. // Release in the destructor
  99. /*
  100. * validate parms
  101. */
  102. TRY
  103. {
  104. if (!VALID_DIRECT3DVIEWPORT3_PTR(this)) {
  105. D3D_ERR( "Invalid Direct3DViewport pointer" );
  106. return 0;
  107. }
  108. }
  109. EXCEPT( EXCEPTION_EXECUTE_HANDLER )
  110. {
  111. D3D_ERR( "Exception encountered validating parameters" );
  112. return 0;
  113. }
  114. /*
  115. * decrement the ref count. if we hit 0, free the object
  116. */
  117. this->refCnt--;
  118. lastrefcnt = this->refCnt;
  119. if( lastrefcnt == 0 ) {
  120. delete this;
  121. return 0;
  122. }
  123. return lastrefcnt;
  124. } /* D3DVwp_Release */
  125. DIRECT3DVIEWPORTI::~DIRECT3DVIEWPORTI()
  126. {
  127. LPDIRECT3DLIGHTI lpLightI;
  128. /*
  129. * Drop all the lights currently associated with the viewport.
  130. */
  131. while ((lpLightI = CIRCLE_QUEUE_FIRST(&this->lights)) &&
  132. (lpLightI != (LPDIRECT3DLIGHTI)&this->lights)) {
  133. DeleteLight((LPDIRECT3DLIGHT)lpLightI);
  134. }
  135. /*
  136. * Deallocate rects used for clearing.
  137. */
  138. if (this->clrRects) {
  139. D3DFree(this->clrRects);
  140. }
  141. // remove us from our device
  142. if (this->lpDevI)
  143. this->lpDevI->DeleteViewport(this);
  144. /* remove us from the Direct3D object list of viewports */
  145. LIST_DELETE(this, list);
  146. this->lpDirect3DI->numViewports--;
  147. }