Windows NT 4.0 source code leak
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.

220 lines
8.0 KiB

4 years ago
  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)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 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. // Shared section size
  75. #define SHARED_SECTION_SIZE 8192
  76. // Driver context function prototypes
  77. typedef BOOL (APIENTRY *PFN_DRVVALIDATEVERSION) (ULONG);
  78. typedef VOID (APIENTRY *PFN_DRVSETCALLBACKPROCS)(INT, PROC *);
  79. // Driver data
  80. typedef struct _GLDRIVER {
  81. HINSTANCE hModule; // Module handle
  82. // Driver function pointers
  83. // Required
  84. DHGLRC (APIENTRY *pfnDrvCreateContext)(HDC);
  85. BOOL (APIENTRY *pfnDrvDeleteContext)(DHGLRC);
  86. PGLCLTPROCTABLE (APIENTRY *pfnDrvSetContext)(HDC, DHGLRC,
  87. PFN_SETPROCTABLE);
  88. BOOL (APIENTRY *pfnDrvReleaseContext)(DHGLRC);
  89. // Optional
  90. BOOL (APIENTRY *pfnDrvCopyContext)(DHGLRC, DHGLRC, UINT);
  91. DHGLRC (APIENTRY *pfnDrvCreateLayerContext)(HDC, int);
  92. BOOL (APIENTRY *pfnDrvShareLists)(DHGLRC, DHGLRC);
  93. PROC (APIENTRY *pfnDrvGetProcAddress)(LPCSTR);
  94. BOOL (APIENTRY *pfnDrvDescribeLayerPlane)(HDC, INT, INT, UINT,
  95. LPLAYERPLANEDESCRIPTOR);
  96. INT (APIENTRY *pfnDrvSetLayerPaletteEntries)(HDC, INT, INT,
  97. INT,
  98. CONST COLORREF *);
  99. INT (APIENTRY *pfnDrvGetLayerPaletteEntries)(HDC, INT, INT,
  100. INT, COLORREF *);
  101. BOOL (APIENTRY *pfnDrvRealizeLayerPalette)(HDC, INT, BOOL);
  102. BOOL (APIENTRY *pfnDrvSwapLayerBuffers)(HDC, UINT);
  103. #if defined(_CLIENTSIDE_)
  104. LONG (APIENTRY *pfnDrvDescribePixelFormat)(HDC, LONG, ULONG,
  105. PIXELFORMATDESCRIPTOR *);
  106. BOOL (APIENTRY *pfnDrvSetPixelFormat)(HDC, LONG);
  107. BOOL (APIENTRY *pfnDrvSwapBuffers)(HDC);
  108. #endif
  109. struct _GLDRIVER *pGLDriver; // Next loaded GL driver
  110. WCHAR wszDrvName[MAX_GLDRIVER_NAME+1]; // Null terminated unicode
  111. // driver name
  112. } GLDRIVER, *PGLDRIVER;
  113. extern PGLDRIVER APIENTRY pgldrvLoadInstalledDriver(HDC hdc);
  114. /****************************************************************************/
  115. // Local RC object
  116. #define LRC_IDENTIFIER 0x2043524C /* 'LRC ' */
  117. typedef struct _LRC {
  118. DHGLRC dhrc; // Driver handle
  119. HGLRC hrc; // Client handle
  120. int iPixelFormat; // Pixel format index
  121. DWORD ident; // LRC_IDENTIFIER
  122. DWORD tidCurrent; // Thread id if the DC is current,
  123. // INVALID_THREAD_ID otherwise
  124. PGLDRIVER pGLDriver; // Driver data
  125. HDC hdcCurrent; // hdc associated with the current context
  126. #ifdef GL_METAFILE
  127. GLuint uiGlsContext; // GLS context for metafile RC's
  128. BOOL fCapturing; // GLS is in BeginCapture
  129. HDC hdcMeta; // GLS metafile context, needed even
  130. // when the RC is not current
  131. // GLS playback scaling factors
  132. int iGlsSubtractX;
  133. int iGlsSubtractY;
  134. int iGlsNumeratorX;
  135. int iGlsNumeratorY;
  136. int iGlsDenominatorX;
  137. int iGlsDenominatorY;
  138. int iGlsAddX;
  139. int iGlsAddY;
  140. GLfloat fGlsScaleX;
  141. GLfloat fGlsScaleY;
  142. #endif
  143. // vertex array data
  144. void * apVertex;
  145. void * apNormal;
  146. void * apColor;
  147. void * apIndex;
  148. void * apTexCoord;
  149. void * apEdgeFlag;
  150. void * pfnEnable ;
  151. void * pfnDisable ;
  152. void * pfnIsEnabled ;
  153. void * pfnGetBooleanv;
  154. void * pfnGetDoublev ;
  155. void * pfnGetFloatv ;
  156. void * pfnGetIntegerv;
  157. void * pfnGetString ;
  158. GLubyte *pszExtensions;
  159. #ifdef GL_METAFILE
  160. XFORM xformMeta; // World transform storage during GLS blocks
  161. LPRECTL prclGlsBounds; // Bounds during GLS recording
  162. #endif
  163. } LRC, *PLRC;
  164. // Declare support functions.
  165. ULONG iAllocHandle(ULONG iType,ULONG hgre,PVOID pv);
  166. VOID vFreeHandle(ULONG h);
  167. LONG cLockHandle(ULONG h);
  168. VOID vUnlockHandle(ULONG h);
  169. #define GdiSetLastError(x) SetLastError(x)
  170. // NT 3.51 specific function pointers
  171. extern PROC pfnNtdllCsrClientSendMessage;
  172. extern PROC pfnGdi32pstackConnect;
  173. extern PROC pfnGdi32GdiConvertDC;