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.

95 lines
2.6 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1998 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: hmgr.hpp
  6. * Content: Handle Manager header file
  7. *
  8. ***************************************************************************/
  9. #ifndef _HMGR_HPP_
  10. #define _HMGR_HPP_
  11. #include "d3dtempl.hpp"
  12. //-----------------------------------------------------------------------------
  13. //
  14. // D3D Base object class. All objects that are referred to by handles
  15. // should inherit from this class
  16. //
  17. //-----------------------------------------------------------------------------
  18. class CD3DBaseObj
  19. {
  20. public:
  21. virtual ~CD3DBaseObj()
  22. {
  23. return;
  24. }
  25. private:
  26. };
  27. typedef CD3DBaseObj* LPD3DBASEOBJ;
  28. //-----------------------------------------------------------------------------
  29. //
  30. // D3D Handle Class.
  31. //
  32. //-----------------------------------------------------------------------------
  33. struct CHandle
  34. {
  35. CHandle()
  36. {
  37. m_Next = 0;
  38. m_pObj = NULL;
  39. #if DBG
  40. m_tag = 0;
  41. #endif
  42. }
  43. ~CHandle()
  44. {
  45. delete m_pObj;
  46. }
  47. DWORD m_Next; // Used to make list of free handles
  48. LPD3DBASEOBJ m_pObj;
  49. #if DBG
  50. // Non zero means that it has been allocated
  51. DWORD m_tag;
  52. #endif
  53. };
  54. const DWORD __INVALIDHANDLE = 0xFFFFFFFF;
  55. typedef GArrayT<CHandle> CHandleArray;
  56. //-----------------------------------------------------------------------------
  57. //
  58. // D3D HandleFactory Class:
  59. //
  60. // This handle factory assumes that the handle returned can be directly used
  61. // an index into the handle array. This will not work if there is some
  62. // munging required for the handle (in the vertex shader case)
  63. //
  64. //-----------------------------------------------------------------------------
  65. class CHandleFactory
  66. {
  67. public:
  68. CHandleFactory();
  69. CHandleFactory(DWORD dwGrowSize);
  70. DWORD GetSize() const { return m_Handles.GetSize(); }
  71. virtual DWORD CreateNewHandle( LPD3DBASEOBJ pObj );
  72. virtual LPD3DBASEOBJ GetObject( DWORD dwHandle ) const;
  73. virtual UINT HandleFromIndex( DWORD index) const {return index;}
  74. // Sets new object pointer. Returns TRUE if success. Old object is not deleted
  75. virtual BOOL SetObject( DWORD dwHandle, LPD3DBASEOBJ );
  76. virtual void ReleaseHandle(DWORD handle, BOOL bDeleteObject = TRUE);
  77. protected:
  78. CHandleArray m_Handles;
  79. DWORD m_Free; // Header for free elements in the array
  80. };
  81. #endif //_HMGR_HPP_