Source code of Windows XP (NT5)
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.

218 lines
7.4 KiB

  1. #ifndef __glnamesint_h
  2. #define __glnamesint_h
  3. /*
  4. ** Copyright 1991, 1922, Silicon Graphics, Inc.
  5. ** All Rights Reserved.
  6. **
  7. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ** the contents of this file may not be disclosed to third parties, copied or
  9. ** duplicated in any form, in whole or in part, without the prior written
  10. ** permission of Silicon Graphics, Inc.
  11. **
  12. ** RESTRICTED RIGHTS LEGEND:
  13. ** Use, duplication or disclosure by the Government is subject to restrictions
  14. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ** rights reserved under the Copyright Laws of the United States.
  18. **
  19. ** Display list internal structure description.
  20. **
  21. ** $Revision: 1.2 $
  22. ** $Date: 1995/01/25 18:05:43 $
  23. */
  24. /************************************************************************/
  25. /*
  26. ** Names Manager Interface
  27. **
  28. ** This file contains the Name Space Management types and structures.
  29. **
  30. ** The Name Space Management code is used to store and retreive named
  31. ** data structures. The data being stored is referred to with void
  32. ** pointers to allow for the storage of any type of structure.
  33. **
  34. ** The Name Space is implemented as a 2-3 tree. For a detailed
  35. ** description of its implementation, see lib/opengl/soft/so_names.c.
  36. **
  37. ** __GLnamesArray is declared in types.h.
  38. */
  39. /************************************************************************/
  40. /*
  41. ** A tree can be used to hold different types of data,
  42. ** e.g. display lists or texture objects. This is the structure
  43. ** that contains information needed for each tree type. For
  44. ** example, this structure contains a pointer to a dummy empty
  45. ** structure and a callback for freeing memory associated with
  46. ** the structure.
  47. */
  48. struct __GLnamesArrayTypeInfoRec {
  49. void *empty; /* ptr to empty info structure */
  50. GLuint dataSize; /* sizeof data structure in bytes */
  51. void (WINAPIV *free)(__GLcontext *gc, void *memory);
  52. /* callback for freeing data */
  53. GLboolean (WINAPIV *alloc)(__GLcontext *gc, size_t size);
  54. /* callback for allocating data */
  55. };
  56. typedef struct __GLnamesArrayTypeInfoRec __GLnamesArrayTypeInfo;
  57. /*
  58. ** The number of spare branches and leaves that we keep about in case
  59. ** we run out of memory. At that point, we complete the current operation
  60. ** by using the extra leaves and branches, and we report an OUT_OF_MEMORY
  61. ** error when a new operation is requested (unless we can fill our extras
  62. ** again!)
  63. **
  64. ** These constants were not chosen terribly carefully. As best as I can
  65. ** figure, we only need one spare branch per level in the tree (so 16
  66. ** supports a tree with 65536 leaves). And even then, the user would have
  67. ** to be extremely devious to actually force 16 new branches to appear in
  68. ** the tree at just the same moment that the system runs out of memory.
  69. **
  70. ** The number of spare leaves required, I believe, is one. Three is chosen
  71. ** to allow for some slop.
  72. */
  73. #define __GL_DL_EXTRA_BRANCHES 16
  74. #define __GL_DL_EXTRA_LEAVES 3
  75. /*
  76. ** This is the structure that contains information that is needed
  77. ** for each instance of a names tree. It needs to be public
  78. ** so the refcount can be managed.
  79. */
  80. typedef struct __GLnamesArrayTypeInfoRec __GLnamesArrayTypeInfo;
  81. typedef struct __GLnamesBranchRec __GLnamesBranch;
  82. typedef struct __GLnamesLeafRec __GLnamesLeaf;
  83. struct __GLnamesArrayRec {
  84. __GLnamesBranch *tree; /* points to the top of the names tree */
  85. GLuint depth; /* depth of tree */
  86. GLint refcount; /*# ctxs using this array: create with 1, delete at 0*/
  87. __GLnamesArrayTypeInfo *dataInfo; /* ptr to data type info */
  88. GLuint nbranches, nleaves; /* should basically always be at max */
  89. __GLnamesBranch *branches[__GL_DL_EXTRA_BRANCHES];
  90. __GLnamesLeaf *leaves[__GL_DL_EXTRA_LEAVES];
  91. #ifdef NT
  92. CRITICAL_SECTION critsec;
  93. #endif
  94. };
  95. #ifdef NT
  96. // Locking macros to enable or disable locking
  97. #define __GL_NAMES_LOCK(array) EnterCriticalSection(&(array)->critsec)
  98. #define __GL_NAMES_UNLOCK(array) LeaveCriticalSection(&(array)->critsec)
  99. #if DBG
  100. typedef struct _RTL_CRITICAL_SECTION *LPCRITICAL_SECTION;
  101. extern void APIENTRY CheckCritSectionIn(LPCRITICAL_SECTION pcs);
  102. #define __GL_NAMES_ASSERT_LOCKED(array) CheckCritSectionIn(&(array)->critsec)
  103. #else
  104. #define __GL_NAMES_ASSERT_LOCKED(array)
  105. #endif
  106. #endif
  107. /*
  108. ** Clean up an item whose refcount has fallen to zero due to unlocking
  109. */
  110. typedef void (FASTCALL *__GLnamesCleanupFunc)(__GLcontext *gc, void *data);
  111. /*
  112. ** Allocate and initialize a new array structure.
  113. */
  114. extern __GLnamesArray * FASTCALL __glNamesNewArray(__GLcontext *gc,
  115. __GLnamesArrayTypeInfo *dataInfo);
  116. /*
  117. ** Free the array structure.
  118. */
  119. extern void FASTCALL __glNamesFreeArray(__GLcontext *gc, __GLnamesArray *array);
  120. /*
  121. ** Save a new display list in the array. A return value of GL_FALSE
  122. ** indicates and OUT_OF_MEMORY error, indicating that the list was
  123. ** not stored.
  124. */
  125. extern GLboolean FASTCALL __glNamesNewData(__GLcontext *gc, __GLnamesArray *array,
  126. GLuint name, void *data);
  127. /*
  128. ** Find and lock the list specified with "listnum". A return value of NULL
  129. ** indicates that there was no such list. __glNamesUnlockList() needs to
  130. ** be called to unlock the list otherwise.
  131. */
  132. extern void * FASTCALL __glNamesLockData(__GLcontext *gc, __GLnamesArray *array,
  133. GLuint name);
  134. /*
  135. ** Unlock a list locked with __glNamesLockList(). If this is not called, then
  136. ** any memory associated with the list will never be freed when the list
  137. ** is deleted.
  138. */
  139. extern void FASTCALL __glNamesUnlockData(__GLcontext *gc, void *data,
  140. __GLnamesCleanupFunc cleanup);
  141. /*
  142. ** Same as __glNamesLockList() except that a bunch of lists are locked and
  143. ** returned simultaneously. Any listbase previously specified is used as
  144. ** an offset to the entries in the array.
  145. */
  146. extern void FASTCALL __glNamesLockDataList(__GLcontext *gc, __GLnamesArray *array,
  147. GLsizei n, GLenum type, GLuint base,
  148. const GLvoid *names, void *dataList[]);
  149. /*
  150. ** Same as __glNamesUnlockList() except that the entire array of names
  151. ** is unlocked at once.
  152. */
  153. extern void FASTCALL __glNamesUnlockDataList(__GLcontext *gc, GLsizei n,
  154. void *dataList[],
  155. __GLnamesCleanupFunc cleanup);
  156. #ifdef NT
  157. /*
  158. ** Locks entire array
  159. */
  160. #define __glNamesLockArray(gc, array) __GL_NAMES_LOCK(array)
  161. /*
  162. ** Unlocks array
  163. */
  164. #define __glNamesUnlockArray(gc, array) __GL_NAMES_UNLOCK(array)
  165. #endif
  166. /*
  167. ** Generates a list of names.
  168. */
  169. extern GLuint FASTCALL __glNamesGenRange(__GLcontext *gc, __GLnamesArray *array,
  170. GLsizei range);
  171. /*
  172. ** Returns GL_TRUE if name has been generated for this array.
  173. */
  174. extern GLboolean FASTCALL __glNamesIsName(__GLcontext *gc, __GLnamesArray *array,
  175. GLuint name);
  176. /*
  177. ** Deletes a range of names.
  178. */
  179. extern void FASTCALL __glNamesDeleteRange(__GLcontext *gc, __GLnamesArray *array,
  180. GLuint name, GLsizei range);
  181. /*
  182. ** Generates a list of (not necessarily contiguous) names.
  183. */
  184. extern void FASTCALL __glNamesGenNames(__GLcontext *gc, __GLnamesArray *array,
  185. GLsizei n, GLuint* names);
  186. /*
  187. ** Deletes a list of (not necessarily contiguous) names.
  188. */
  189. extern void FASTCALL __glNamesDeleteNames(__GLcontext *gc, __GLnamesArray *array,
  190. GLsizei n, const GLuint* names);
  191. #endif /* __glnamesint_h */