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.

224 lines
6.0 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: w95priv.c
  6. * Content: Private interface between DDRAW and the display driver
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 23-jan-95 craige initial implementation
  11. * 27-feb-95 craige new sync. macros
  12. * 01-apr-95 craige happy fun joy updated header file
  13. * 14-may-95 craige cleaned out obsolete junk
  14. * 16-jun-95 craige new surface structure
  15. * 19-jun-95 craige added DD32_StreamingNotify
  16. * 22-jun-95 craige added DD32_ClippingNotify
  17. * 24-jun-95 craige trap faults in ClippinyNotify
  18. * 25-jun-95 craige one ddraw mutex
  19. * 02-jul-95 craige commented out streaming, clipper notification
  20. * 18-jan-97 colinmc AGP support
  21. * 31-oct-97 johnstep Added DD32_HandleExternalModeChange
  22. *
  23. ***************************************************************************/
  24. #include "ddrawpr.h"
  25. #ifdef STREAMING
  26. /*
  27. * DD32_StreamingNotify
  28. */
  29. void EXTERN_DDAPI DD32_StreamingNotify( DWORD ptr )
  30. {
  31. } /* DD32_StreamingNotify */
  32. #endif
  33. #ifdef CLIPPER_NOTIFY
  34. /*
  35. * DD32_ClippingNotify
  36. */
  37. void EXTERN_DDAPI DD32_ClippingNotify( LPWINWATCH pww, DWORD code )
  38. {
  39. LPDDRAWI_DDRAWCLIPPER_LCL this_lcl;
  40. LPDDRAWI_DDRAWCLIPPER_GBL this;
  41. try
  42. {
  43. this_lcl = pww->lpDDClipper;
  44. this = this_lcl->lpGbl;
  45. if( pww->lpCallback != NULL )
  46. {
  47. pww->lpCallback( (LPDIRECTDRAWCLIPPER) this_lcl, (HWND) pww->hWnd,
  48. code, pww->lpContext );
  49. }
  50. }
  51. except( EXCEPTION_EXECUTE_HANDLER )
  52. {
  53. DPF( 1, "Trapped Exception in ClippingNotify" );
  54. }
  55. } /* DD32_ClippingNotify */
  56. /*
  57. * DD32_WWClose
  58. */
  59. void EXTERN_DDAPI DD32_WWClose( LPWINWATCH pww )
  60. {
  61. WWClose( pww );
  62. } /* DD32_WWClose */
  63. #endif
  64. /*
  65. * DDHAL32_VidMemAlloc
  66. */
  67. FLATPTR EXTERN_DDAPI DDHAL32_VidMemAlloc(
  68. LPDDRAWI_DIRECTDRAW_GBL this,
  69. int heap,
  70. DWORD dwWidth,
  71. DWORD dwHeight )
  72. {
  73. FLATPTR ptr;
  74. ENTER_DDRAW();
  75. if( heap >= (int) this->vmiData.dwNumHeaps )
  76. {
  77. ptr = (FLATPTR) NULL;
  78. }
  79. else
  80. {
  81. HANDLE hdev;
  82. #ifdef WIN95
  83. BOOLEAN close;
  84. #endif /* WIN95 */
  85. #ifdef WIN95
  86. /* See if the global VXD handle contains a valid value. If not,
  87. * then just get a valid VXD handle from GetDXVxdHandle().
  88. * (snene 2/23/98)
  89. */
  90. if( INVALID_HANDLE_VALUE == (HANDLE)this->hDDVxd )
  91. {
  92. /*
  93. * As we may need to commit AGP memory we need a VXD handle
  94. * to communicate with the DirectX VXD. Rather than hunting
  95. * through the driver object list hoping we will find a
  96. * local object for this process we just create a handle
  97. * and discard it after the allocation. This should not be
  98. * performance critical code to start with.
  99. */
  100. hdev = GetDXVxdHandle();
  101. if ( INVALID_HANDLE_VALUE == hdev )
  102. {
  103. LEAVE_DDRAW()
  104. return (FLATPTR) NULL;
  105. }
  106. close = TRUE;
  107. }
  108. /* If the global handle is valid, then we are being called as a
  109. * result of CreateSurface being called and so we just use the
  110. * global handle to speed things up.
  111. * (snene 2/23/98)
  112. */
  113. else
  114. {
  115. hdev = (HANDLE)this->hDDVxd;
  116. close = FALSE;
  117. }
  118. #else /* WIN95 */
  119. hdev = INVALID_HANDLE_VALUE;
  120. #endif /* WIN95 */
  121. /* Pass NULL Alignment and new pitch pointer */
  122. ptr = HeapVidMemAlloc( &(this->vmiData.pvmList[ heap ]),
  123. dwWidth, dwHeight, hdev , NULL , NULL, NULL );
  124. #ifdef WIN95
  125. if( close )
  126. CloseHandle( hdev );
  127. #endif /* WIN95 */
  128. }
  129. LEAVE_DDRAW()
  130. return ptr;
  131. } /* DDHAL32_VidMemAlloc */
  132. /*
  133. * DDHAL32_VidMemFree
  134. */
  135. void EXTERN_DDAPI DDHAL32_VidMemFree(
  136. LPDDRAWI_DIRECTDRAW_GBL this,
  137. int heap,
  138. FLATPTR ptr )
  139. {
  140. ENTER_DDRAW()
  141. if( this && heap < (int) this->vmiData.dwNumHeaps )
  142. {
  143. VidMemFree( this->vmiData.pvmList[ heap ].lpHeap, ptr );
  144. }
  145. LEAVE_DDRAW()
  146. } /* DDHAL32_VidMemFree */
  147. #ifdef POSTPONED
  148. //=============================================================================
  149. //
  150. // Function: DD32_HandleExternalModeChange
  151. //
  152. // This function is ONLY called by DDRAw16 on an external mode change.
  153. //
  154. // Parameters:
  155. //
  156. // LPDEVMODE pdm [IN] - includes the name of the display device
  157. //
  158. // Return:
  159. //
  160. // FALSE if display settings should not be changed
  161. //
  162. //=============================================================================
  163. static char szDisplay[] = "display";
  164. static char szDisplay1[] = "\\\\.\\Display1";
  165. BOOL EXTERN_DDAPI DD32_HandleExternalModeChange(LPDEVMODE pdm)
  166. {
  167. LPDDRAWI_DIRECTDRAW_LCL pdrv_lcl;
  168. BOOL primary;
  169. //
  170. // This is ONLY called from DDRAW16 once we already have the Win16
  171. // lock. We have to give it up before enterint DDraw because some other
  172. // process may be inside DDraw.
  173. //
  174. INCW16CNT();
  175. LEAVE_WIN16LOCK();
  176. ENTER_DDRAW();
  177. ENTER_WIN16LOCK();
  178. //
  179. // We'll get szDisplay for the primary display, rather than szDisplay1,
  180. // but a multimon-aware app may have explicitly created a device object
  181. // for szDisplay1, so we need to handle this case.
  182. //
  183. primary = !lstrcmpi(pdm->dmDeviceName, szDisplay);
  184. for (pdrv_lcl = lpDriverLocalList; pdrv_lcl; pdrv_lcl = pdrv_lcl->lpLink)
  185. {
  186. if (!lstrcmpi(pdrv_lcl->lpGbl->cDriverName, pdm->dmDeviceName) ||
  187. (primary && !lstrcmpi(pdrv_lcl->lpGbl->cDriverName, szDisplay1)))
  188. {
  189. DPF(4, "Mode change on device: %s", pdrv_lcl->lpGbl->cDriverName);
  190. InvalidateAllSurfaces(pdrv_lcl->lpGbl, NULL, FALSE);
  191. }
  192. }
  193. LEAVE_DDRAW();
  194. DECW16CNT();
  195. return TRUE;
  196. }
  197. #endif