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.

210 lines
7.4 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * **************************
  4. * * DirectDraw SAMPLE CODE *
  5. * **************************
  6. *
  7. * Module Name: dd.h
  8. *
  9. * Content: definitions and macros for DirectDraw
  10. *
  11. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  13. \*****************************************************************************/
  14. #ifndef _DD_H_
  15. #define _DD_H_
  16. extern DWORD ShiftLookup[];
  17. // DirectDraw Macros for determining surface characteristics
  18. #define DDSurf_Width(lpLcl) ( lpLcl->lpGbl->wWidth )
  19. #define DDSurf_Height(lpLcl) ( lpLcl->lpGbl->wHeight )
  20. #define DDSurf_Pitch(lpLcl) (lpLcl->lpGbl->lPitch)
  21. #define DDSurf_Get_dwCaps(lpLcl) (lpLcl->ddsCaps.dwCaps)
  22. #define DDSurf_BitDepth(lpLcl) (lpLcl->lpGbl->ddpfSurface.dwRGBBitCount)
  23. #define DDSurf_AlphaBitDepth(lpLcl) (lpLcl->lpGbl->ddpfSurface.dwAlphaBitDepth)
  24. #define DDSurf_RGBAlphaBitMask(lpLcl) \
  25. (lpLcl->lpGbl->ddpfSurface.dwRGBAlphaBitMask)
  26. #define DDSurf_GetPixelShift(a) (ShiftLookup[(DDSurf_BitDepth(a) >> 3)])
  27. //
  28. // DirectDraw callback functions implemented in this driver
  29. //
  30. DWORD CALLBACK DdCanCreateSurface( LPDDHAL_CANCREATESURFACEDATA pccsd );
  31. DWORD CALLBACK DdCreateSurface( LPDDHAL_CREATESURFACEDATA pcsd );
  32. DWORD CALLBACK DdDestroySurface( LPDDHAL_DESTROYSURFACEDATA psdd );
  33. DWORD CALLBACK DdBlt( LPDDHAL_BLTDATA lpBlt );
  34. //@@BEGIN_DDKSPLIT
  35. #if DX7_ALPHABLT
  36. DWORD CALLBACK DdAlphaBlt( LPDDHAL_BLTDATA lpBlt );
  37. #endif
  38. //@@END_DDKSPLIT
  39. DWORD CALLBACK DdGetDriverInfo(LPDDHAL_GETDRIVERINFODATA lpData);
  40. DWORD CALLBACK DdMapMemory(PDD_MAPMEMORYDATA lpMapMemory);
  41. //
  42. // here are various blitter functions
  43. //
  44. VOID
  45. PermediaPackedCopyBlt (PPDev,
  46. DWORD,
  47. DWORD,
  48. PermediaSurfaceData*,
  49. PermediaSurfaceData*,
  50. RECTL*,
  51. RECTL*,
  52. DWORD,
  53. LONG);
  54. VOID
  55. PermediaPatchedCopyBlt(PPDev,
  56. DWORD,
  57. DWORD,
  58. PermediaSurfaceData*,
  59. PermediaSurfaceData*,
  60. RECTL*,
  61. RECTL*,
  62. DWORD,
  63. LONG);
  64. //@@BEGIN_DDKSPLIT
  65. #if DX7_ALPHABLT
  66. VOID
  67. PermediaSourceAlphaBlt(PPDev ppdev,
  68. LPDDHAL_BLTDATA lpBlt,
  69. PermediaSurfaceData* pDest,
  70. PermediaSurfaceData* pSource,
  71. RECTL *rDest,
  72. RECTL *rSrc,
  73. DWORD windowBase,
  74. DWORD SourceOffset,
  75. ULONG ulDestPixelShift);
  76. VOID
  77. PermediaAlphaFill(PPDev ppdev,
  78. LPDDHAL_BLTDATA lpBlt,
  79. PermediaSurfaceData* pDest,
  80. RECTL *rDest,
  81. DWORD dwWindowBase,
  82. ULONG ulDestPixelShift);
  83. #endif
  84. //@@END_DDKSPLIT
  85. // Clear functions
  86. VOID PermediaFastClear(PPDev, PermediaSurfaceData*,
  87. RECTL*, DWORD, DWORD);
  88. VOID PermediaClearManagedSurface(DWORD,RECTL*,
  89. FLATPTR,LONG,DWORD);
  90. VOID PermediaFastLBClear(PPDev, PermediaSurfaceData*,
  91. RECTL*, DWORD, DWORD);
  92. // FX Blits
  93. VOID PermediaStretchCopyBlt(PPDev, LPDDHAL_BLTDATA, PermediaSurfaceData*,
  94. PermediaSurfaceData*, RECTL *, RECTL *, DWORD,
  95. DWORD);
  96. VOID PermediaStretchCopyChromaBlt(PPDev, LPDDHAL_BLTDATA, PermediaSurfaceData*,
  97. PermediaSurfaceData*, RECTL *, RECTL *,
  98. DWORD, DWORD);
  99. VOID PermediaSourceChromaBlt(PPDev, LPDDHAL_BLTDATA, PermediaSurfaceData*,
  100. PermediaSurfaceData*, RECTL*, RECTL*,
  101. DWORD, DWORD);
  102. VOID PermediaYUVtoRGB(PPDev, DDBLTFX*, PermediaSurfaceData*,
  103. PermediaSurfaceData*, RECTL*, RECTL*, DWORD, DWORD);
  104. // SYSMEM->VIDMEM Blits
  105. VOID PermediaPackedDownload(PPDev, PermediaSurfaceData* pPrivateData,
  106. LPDDRAWI_DDRAWSURFACE_LCL lpSourceSurf,
  107. RECTL* rSrc,
  108. LPDDRAWI_DDRAWSURFACE_LCL lpDestSurf,
  109. RECTL* rDest);
  110. // Texture Downloads
  111. VOID PermediaPatchedTextureDownload(PPDev, PermediaSurfaceData*,FLATPTR,
  112. LONG,RECTL*,FLATPTR,LONG,RECTL*);
  113. // DX Utility functions.
  114. //
  115. HRESULT updateFlipStatus( PPDev ppdev );
  116. // Sysmem->Sysmem Blit
  117. VOID SysMemToSysMemSurfaceCopy(FLATPTR,LONG,DWORD,FLATPTR,
  118. LONG,DWORD,RECTL*,RECTL*);
  119. //
  120. // function to validate RGB format of a DirectDraw surface
  121. //
  122. BOOL ValidRGBAlphaSurfaceformat(DDPIXELFORMAT *pPixFormat, INT *pIndex);
  123. BOOL SetRGBAlphaSurfaceFormat (DDPIXELFORMAT *pPixFormat,
  124. PERMEDIA_SURFACE *pSurfaceFormat);
  125. //
  126. // Initialise DirectDraw structs
  127. //
  128. BOOL InitDDHAL(PPDev ppdev);
  129. //
  130. // setup some DDraw data stored in ppdev
  131. //
  132. VOID SetupDDData(PPDev ppdev);
  133. BOOL bIsStereoMode(PPDev ppdev,PDD_STEREOMODE pDDStereoMode);
  134. // Useful macro
  135. #define ROUND_UP_TO_64K(x) (((ULONG)(x) + 0x10000 - 1) & ~(0x10000 - 1))
  136. // DD Blit helper defines.
  137. #define PIXELS_INTO_RECT_PACKED(rect, PixelPitch, lPixelMask) \
  138. ((rect->top * PixelPitch) + \
  139. (rect->left & ~lPixelMask))
  140. #define RECTS_PIXEL_OFFSET(rS,rD,SourcePitch,DestPitch,Mask) \
  141. (PIXELS_INTO_RECT_PACKED(rS, SourcePitch, Mask) - \
  142. PIXELS_INTO_RECT_PACKED(rD, DestPitch, Mask) )
  143. #define LINEAR_FUDGE(SourcePitch, DestPitch, rectDest) \
  144. ((DestPitch - SourcePitch) * (rectDest->top))
  145. //
  146. // check if privateData for primary surface was properly
  147. // initialized
  148. //
  149. #define DD_CHECK_PRIMARY_SURFACE_DATA( pLcl, pPrivate) \
  150. if ((pLcl->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) ||\
  151. (pLcl->ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER))\
  152. {\
  153. if (!CHECK_P2_SURFACEDATA_VALIDITY(pPrivate))\
  154. {\
  155. ASSERTDD(FALSE, "primary surface data not initialized");\
  156. /*SetupPrimarySurfaceData(ppdev, pLcl);*/\
  157. pPrivate = (PermediaSurfaceData*)pLcl->lpGbl->dwReserved1;\
  158. }\
  159. }\
  160. //@@BEGIN_DDKSPLIT
  161. #if MULTITHREADED
  162. //
  163. // Multithread wrapped DirectDraw callback functions implemented in this driver
  164. //
  165. DWORD CALLBACK MtDdBlt(LPDDHAL_BLTDATA lpBlt);
  166. DWORD CALLBACK MtDdCreateSurface( LPDDHAL_CREATESURFACEDATA pcsd);
  167. DWORD CALLBACK MtDdDestroySurface( LPDDHAL_DESTROYSURFACEDATA psdd);
  168. DWORD CALLBACK MtDdFlip(LPDDHAL_FLIPDATA lpFlipData);
  169. DWORD CALLBACK MtDdFlipToGDISurface(PDD_FLIPTOGDISURFACEDATA lpFlipToGDISurface);
  170. DWORD CALLBACK MtDdGetFlipStatus(LPDDHAL_GETFLIPSTATUSDATA lpGetFlipStatus);
  171. DWORD CALLBACK MtDdLock(LPDDHAL_LOCKDATA lpLockData);
  172. DWORD CALLBACK MtDdSetExclusiveMode(PDD_SETEXCLUSIVEMODEDATA lpSetExclusiveMode);
  173. //
  174. // Multithread wrapped Direct3D callback functions implemented in this driver
  175. //
  176. DWORD CALLBACK MtD3DDrawPrimitives2(LPD3DNTHAL_DRAWPRIMITIVES2DATA);
  177. DWORD CALLBACK MtDdSetColorKey(LPDDHAL_SETCOLORKEYDATA lpSetColorKey);
  178. #endif MULTITHREADED
  179. //@@END_DDKSPLIT
  180. #endif