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.

328 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: local.h *
  3. * *
  4. * Definitions needed for client side objects and attribute caching. *
  5. * *
  6. * Modified: 3-Aug-1992 22:35:30 by Gerrit van Wingerden [gerritv] *
  7. * Added client side transform support. *
  8. * *
  9. * Created: 30-May-1991 21:55:01 *
  10. * Author: Charles Whitmer [chuckwh] *
  11. * *
  12. * Copyright (c) 1993 Microsoft Corporation *
  13. \**************************************************************************/
  14. /**************************************************************************\
  15. *
  16. * Local handle macros
  17. *
  18. \**************************************************************************/
  19. // Handle uniqueness is nice to check but an unnecesary performance cost in
  20. // a free build.
  21. // To match the uniqness field: If the handle uniqness == 0, let it through
  22. // anyway. This is a method for WOW to only keep track of the low 16 bits but
  23. // still get reasonable performance. Even if a 32 bit app does this, all it
  24. // can do is hose it self, not the system or another app.
  25. #define INDEX_MASK 0xFFFF
  26. #define UNIQ_SHIFT 16
  27. #define UNIQ_MASK 0xFFFF
  28. #define HIPART(x) *(((USHORT *) &(x))+1)
  29. #define MATCHUNIQ(plhe,h) ((USHORT) plhe->iUniq == HIPART(h))
  30. #define MASKINDEX(h) ((UINT)((UINT_PTR)h & INDEX_MASK))
  31. #define LHANDLE(i) (i+((ULONG)pLocalTable[i].iUniq<<UNIQ_SHIFT))
  32. //!!!XXX -- Do we really need typing? Not really, but we may add more
  33. //!!!XXX later. So eventually we might take it out, but its nice for now.
  34. // Define the types of local objects.
  35. enum LO_TYPE
  36. {
  37. LO_NULL,
  38. LO_RC,
  39. LO_LAST
  40. };
  41. #define INVALID_INDEX 0xFFFFFFFFL
  42. #define COMMIT_COUNT (4096/sizeof(LHE))
  43. #define MAX_HANDLES (16384/COMMIT_COUNT)*COMMIT_COUNT
  44. // Define a Local Handle Entry. Our Local Handle Table, pLocalTable, is an
  45. // array of these.
  46. typedef struct _LHE
  47. {
  48. ULONG_PTR hgre; // GRE Handle.
  49. USHORT cRef; // Reference count of the object.
  50. BYTE iType; // Object type.
  51. BYTE iUniq; // Handle uniqueness field. Always non-zero.
  52. PVOID pv; // Pointer to local object.
  53. ULONG metalink; // Non-zero if object is a "metafile friend".
  54. // Points to a metafile DC object if it's a metafile.
  55. // Also links the free list.
  56. DWORD tidOwner; // Per-thread lock owner.
  57. LONG cLock; // Lock count.
  58. } LHE,*PLHE;
  59. extern LHE *pLocalTable; // Points to handle table.
  60. extern ULONG iFreeLhe; // Identifies a free handle index.
  61. extern ULONG cLheCommitted; // Count of LHEs with committed RAM.
  62. extern CRITICAL_SECTION semLocal; // Semaphore for handle allocation.
  63. extern CRITICAL_SECTION wfo_cs; // Semaphore for wglUseFontOutlines
  64. // Semaphore utilities
  65. #define INITIALIZECRITICALSECTION(psem) InitializeCriticalSection((psem))
  66. #define ENTERCRITICALSECTION(hsem) EnterCriticalSection((hsem))
  67. #define LEAVECRITICALSECTION(hsem) LeaveCriticalSection((hsem))
  68. #define DELETECRITICALSECTION(psem) DeleteCriticalSection((psem))
  69. // Local data structures
  70. // Maximum OpenGL driver name
  71. #define MAX_GLDRIVER_NAME MAX_PATH
  72. // GetCurrentThreadID will never return this value
  73. #define INVALID_THREAD_ID 0
  74. // Driver context function prototypes
  75. typedef BOOL (APIENTRY *PFN_DRVVALIDATEVERSION) (ULONG);
  76. typedef VOID (APIENTRY *PFN_DRVSETCALLBACKPROCS)(INT, PROC *);
  77. // Driver flags.
  78. // Driver wants buffer calls sent to ICD DLL rather than the display
  79. // driver. This is required on Win95.
  80. #define GLDRIVER_CLIENT_BUFFER_CALLS 0x00000001
  81. // Driver does not want glFinish called during swap. Only
  82. // applies to client swap calls.
  83. #define GLDRIVER_NO_FINISH_ON_SWAP 0x00000002
  84. // Driver had registry key rather than just registry value.
  85. // This provides a way to check for new-style registry information.
  86. #define GLDRIVER_FULL_REGISTRY 0x80000000
  87. // Driver data
  88. typedef struct _GLDRIVER {
  89. HINSTANCE hModule; // Module handle
  90. DWORD dwFlags;
  91. // Driver function pointers
  92. // Required
  93. DHGLRC (APIENTRY *pfnDrvCreateContext)(HDC);
  94. BOOL (APIENTRY *pfnDrvDeleteContext)(DHGLRC);
  95. PGLCLTPROCTABLE (APIENTRY *pfnDrvSetContext)(HDC, DHGLRC,
  96. PFN_SETPROCTABLE);
  97. BOOL (APIENTRY *pfnDrvReleaseContext)(DHGLRC);
  98. // Optional
  99. BOOL (APIENTRY *pfnDrvCopyContext)(DHGLRC, DHGLRC, UINT);
  100. DHGLRC (APIENTRY *pfnDrvCreateLayerContext)(HDC, int);
  101. BOOL (APIENTRY *pfnDrvShareLists)(DHGLRC, DHGLRC);
  102. PROC (APIENTRY *pfnDrvGetProcAddress)(LPCSTR);
  103. BOOL (APIENTRY *pfnDrvDescribeLayerPlane)(HDC, INT, INT, UINT,
  104. LPLAYERPLANEDESCRIPTOR);
  105. INT (APIENTRY *pfnDrvSetLayerPaletteEntries)(HDC, INT, INT,
  106. INT,
  107. CONST COLORREF *);
  108. INT (APIENTRY *pfnDrvGetLayerPaletteEntries)(HDC, INT, INT,
  109. INT, COLORREF *);
  110. BOOL (APIENTRY *pfnDrvRealizeLayerPalette)(HDC, INT, BOOL);
  111. BOOL (APIENTRY *pfnDrvSwapLayerBuffers)(HDC, UINT);
  112. DHGLRC (APIENTRY *pfnDrvCreateDirectDrawContext)
  113. (HDC, LPDIRECTDRAWSURFACE, int);
  114. int (APIENTRY *pfnDrvEnumTextureFormats)(int, DDSURFACEDESC *);
  115. BOOL (APIENTRY *pfnDrvBindDirectDrawTexture)
  116. (LPDIRECTDRAWSURFACE);
  117. DWORD (APIENTRY *pfnDrvSwapMultipleBuffers)(UINT,
  118. CONST WGLSWAP *);
  119. // The following functions are only called if driver asks for them.
  120. // This is required on Win95.
  121. LONG (APIENTRY *pfnDrvDescribePixelFormat)(HDC, LONG, ULONG,
  122. PIXELFORMATDESCRIPTOR *);
  123. BOOL (APIENTRY *pfnDrvSetPixelFormat)(HDC, LONG);
  124. BOOL (APIENTRY *pfnDrvSwapBuffers)(HDC);
  125. struct _GLDRIVER *pGLDriver; // Next loaded GL driver
  126. TCHAR tszDllName[MAX_GLDRIVER_NAME+1]; // Null terminated DLL name
  127. } GLDRIVER, *PGLDRIVER;
  128. extern PGLDRIVER APIENTRY pgldrvLoadInstalledDriver(HDC hdc);
  129. /****************************************************************************/
  130. void APIENTRY glDrawRangeElementsWIN( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
  131. void APIENTRY glAddSwapHintRectWIN(IN GLint, IN GLint, IN GLint, IN GLint);
  132. void glColorTableEXT( GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *data);
  133. void glColorSubTableEXT( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
  134. void glGetColorTableEXT( GLenum target, GLenum format, GLenum type, GLvoid *data);
  135. void glGetColorTableParameterivEXT( GLenum target, GLenum pname, GLint *params);
  136. void glGetColorTableParameterfvEXT( GLenum target, GLenum pname, GLfloat *params);
  137. void APIENTRY glColorTableParameterivEXT(GLenum target,
  138. GLenum pname,
  139. const GLint *params);
  140. void APIENTRY glColorTableParameterfvEXT(GLenum target,
  141. GLenum pname,
  142. const GLfloat *params);
  143. #ifdef GL_WIN_multiple_textures
  144. void APIENTRY glCurrentTextureIndexWIN
  145. (GLuint index);
  146. void APIENTRY glMultiTexCoord1dWIN
  147. (GLbitfield mask, GLdouble s);
  148. void APIENTRY glMultiTexCoord1dvWIN
  149. (GLbitfield mask, const GLdouble *v);
  150. void APIENTRY glMultiTexCoord1fWIN
  151. (GLbitfield mask, GLfloat s);
  152. void APIENTRY glMultiTexCoord1fvWIN
  153. (GLbitfield mask, const GLfloat *v);
  154. void APIENTRY glMultiTexCoord1iWIN
  155. (GLbitfield mask, GLint s);
  156. void APIENTRY glMultiTexCoord1ivWIN
  157. (GLbitfield mask, const GLint *v);
  158. void APIENTRY glMultiTexCoord1sWIN
  159. (GLbitfield mask, GLshort s);
  160. void APIENTRY glMultiTexCoord1svWIN
  161. (GLbitfield mask, const GLshort *v);
  162. void APIENTRY glMultiTexCoord2dWIN
  163. (GLbitfield mask, GLdouble s, GLdouble t);
  164. void APIENTRY glMultiTexCoord2dvWIN
  165. (GLbitfield mask, const GLdouble *v);
  166. void APIENTRY glMultiTexCoord2fWIN
  167. (GLbitfield mask, GLfloat s, GLfloat t);
  168. void APIENTRY glMultiTexCoord2fvWIN
  169. (GLbitfield mask, const GLfloat *v);
  170. void APIENTRY glMultiTexCoord2iWIN
  171. (GLbitfield mask, GLint s, GLint t);
  172. void APIENTRY glMultiTexCoord2ivWIN
  173. (GLbitfield mask, const GLint *v);
  174. void APIENTRY glMultiTexCoord2sWIN
  175. (GLbitfield mask, GLshort s, GLshort t);
  176. void APIENTRY glMultiTexCoord2svWIN
  177. (GLbitfield mask, const GLshort *v);
  178. void APIENTRY glMultiTexCoord3dWIN
  179. (GLbitfield mask, GLdouble s, GLdouble t, GLdouble r);
  180. void APIENTRY glMultiTexCoord3dvWIN
  181. (GLbitfield mask, const GLdouble *v);
  182. void APIENTRY glMultiTexCoord3fWIN
  183. (GLbitfield mask, GLfloat s, GLfloat t, GLfloat r);
  184. void APIENTRY glMultiTexCoord3fvWIN
  185. (GLbitfield mask, const GLfloat *v);
  186. void APIENTRY glMultiTexCoord3iWIN
  187. (GLbitfield mask, GLint s, GLint t, GLint r);
  188. void APIENTRY glMultiTexCoord3ivWIN
  189. (GLbitfield mask, const GLint *v);
  190. void APIENTRY glMultiTexCoord3sWIN
  191. (GLbitfield mask, GLshort s, GLshort t, GLshort r);
  192. void APIENTRY glMultiTexCoord3svWIN
  193. (GLbitfield mask, const GLshort *v);
  194. void APIENTRY glMultiTexCoord4dWIN
  195. (GLbitfield mask, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
  196. void APIENTRY glMultiTexCoord4dvWIN
  197. (GLbitfield mask, const GLdouble *v);
  198. void APIENTRY glMultiTexCoord4fWIN
  199. (GLbitfield mask, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
  200. void APIENTRY glMultiTexCoord4fvWIN
  201. (GLbitfield mask, const GLfloat *v);
  202. void APIENTRY glMultiTexCoord4iWIN
  203. (GLbitfield mask, GLint s, GLint t, GLint r, GLint q);
  204. void APIENTRY glMultiTexCoord4ivWIN
  205. (GLbitfield mask, const GLint *v);
  206. void APIENTRY glMultiTexCoord4sWIN
  207. (GLbitfield mask, GLshort s, GLshort t, GLshort r, GLshort q);
  208. void APIENTRY glMultiTexCoord4svWIN
  209. (GLbitfield mask, const GLshort *v);
  210. void APIENTRY glBindNthTextureWIN
  211. (GLuint index, GLenum target, GLuint texture);
  212. void APIENTRY glNthTexCombineFuncWIN
  213. (GLuint index,
  214. GLenum leftColorFactor, GLenum colorOp, GLenum rightColorFactor,
  215. GLenum leftAlphaFactor, GLenum alphaOp, GLenum rightAlphaFactor);
  216. #endif // GL_WIN_multiple_textures
  217. /****************************************************************************/
  218. // Local RC object
  219. #define LRC_IDENTIFIER 0x2043524C /* 'LRC ' */
  220. typedef struct _LRC {
  221. DHGLRC dhrc; // Driver handle
  222. HGLRC hrc; // Client handle
  223. int iPixelFormat; // Pixel format index
  224. DWORD ident; // LRC_IDENTIFIER
  225. DWORD tidCurrent; // Thread id if the DC is current,
  226. // INVALID_THREAD_ID otherwise
  227. PGLDRIVER pGLDriver; // Driver data
  228. GLWINDOWID gwidCurrent; // Current surface ID
  229. GLWINDOWID gwidCreate; // Creation surface ID
  230. #ifdef GL_METAFILE
  231. GLuint uiGlsCaptureContext; // GLS capturing context for metafile RC's
  232. GLuint uiGlsPlaybackContext; // GLS context for playback
  233. BOOL fCapturing; // GLS is in BeginCapture
  234. // GLS playback scaling factors
  235. int iGlsSubtractX;
  236. int iGlsSubtractY;
  237. int iGlsNumeratorX;
  238. int iGlsNumeratorY;
  239. int iGlsDenominatorX;
  240. int iGlsDenominatorY;
  241. int iGlsAddX;
  242. int iGlsAddY;
  243. GLfloat fGlsScaleX;
  244. GLfloat fGlsScaleY;
  245. #endif
  246. GLubyte *pszExtensions;
  247. #ifdef GL_METAFILE
  248. XFORM xformMeta; // World transform storage during GLS blocks
  249. LPRECTL prclGlsBounds; // Bounds during GLS recording
  250. #endif
  251. struct _DDSURFACEDESC *pddsdTexFormats;
  252. int nDdTexFormats;
  253. } LRC, *PLRC;
  254. // Various dispatch tables available
  255. extern GLCLTPROCTABLE glNullCltProcTable;
  256. extern GLCLTPROCTABLE glCltRGBAProcTable;
  257. extern GLCLTPROCTABLE glCltCIProcTable;
  258. extern GLEXTPROCTABLE glNullExtProcTable;
  259. extern GLEXTPROCTABLE glExtProcTable;
  260. #ifdef GL_METAFILE
  261. extern GLCLTPROCTABLE gcptGlsProcTable;
  262. extern GLEXTPROCTABLE geptGlsExtProcTable;
  263. #endif
  264. // Declare support functions.
  265. ULONG iAllocHandle(ULONG iType,ULONG hgre,PVOID pv);
  266. VOID vFreeHandle(ULONG_PTR h);
  267. LONG cLockHandle(ULONG_PTR h);
  268. VOID vUnlockHandle(ULONG_PTR h);
  269. VOID vCleanupAllLRC(VOID);
  270. VOID vFreeLRC(PLRC plrc);
  271. BOOL bMakeNoCurrent(void);
  272. VOID GLInitializeThread(ULONG ulReason);
  273. // Macro to call glFlush only if a RC is current.
  274. #define GLFLUSH() if (GLTEB_CLTCURRENTRC()) glFlush()