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.

249 lines
9.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: multi.hxx
  3. *
  4. * Copyright (c) 1996-1999 Microsoft Corporation
  5. \**************************************************************************/
  6. typedef struct _VDEV VDEV, *PVDEV; // Handy forward declaration
  7. typedef struct _DISPSURF DISPSURF, *PDISPSURF; // Handy forward declaration
  8. #define MUL_POINTER_ACTIVE 0x01 // Pointer is visible on this device
  9. #define MUL_POINTER_NOEXCLUDE 0x02 // Driver doesn't need pointer
  10. // exclusion calls when drawing
  11. #define MUL_POINTER_SKIPNEXTMOVE 0x04 // Skip next MovePointer call for
  12. // device because it's an exclusion
  13. // call
  14. // MDSURF is the private structure we use for our compatible bitmaps:
  15. typedef struct _MDSURF
  16. {
  17. VDEV* pvdev;
  18. SURFOBJ** apso;
  19. } MDSURF;
  20. struct _DISPSURF
  21. {
  22. DISPSURF* pdsNext; // For traversing the entire list of dispsurfs
  23. DISPSURF* pdsBltNext; // For screen-to-screen blts only: for
  24. // traversing the sorted list of dispsurfs
  25. ULONG iDispSurf; // Sequentially allocated dispsurf number
  26. BOOL bIsReadable; // TRUE if this surface is readable
  27. LONG iCompatibleColorFormat;
  28. // This surface's color depth/format is ...
  29. // 0 - same as the primary
  30. // Plus value - higher colour depth than primary
  31. // Minus value - lower colour depth than primary
  32. RECTL rcl; // DispSurf's coordinates
  33. HDEV hdev; // Handle that GDI knows us by
  34. PDEVOBJ po; // PDEVOBJ for this display surface
  35. SURFOBJ* pso; // Drawing surface
  36. POINTL Off; // Offset that should be added
  37. // to any coordinates before drawing on
  38. // this surface
  39. };
  40. typedef struct _VDEV
  41. {
  42. DISPSURF* pds; // Points to beginning of the list of device
  43. // surfaces
  44. DISPSURF* pdsBlt; // For screen-to-screen blts only: points to
  45. // beginning of the sorted list of device
  46. // surfaces
  47. ULONG cSurfaces; // Number of surfaces controlled by this layer
  48. HSURF hsurf; // Handle to our virtual surface
  49. HDEV hdev; // Handle to our "driver layer"
  50. HDEV hdevPrimary; // Handle to primary device
  51. SURFOBJ* pso; // Pointer to our "driver layer" SURFOBJ
  52. CLIPOBJ* pco; // A temporary CLIPOBJ that we can modify
  53. ULONG iBitmapFormat; // Current colour depth
  54. FLONG flHooks; // Those functions that the main driver
  55. // is hooking
  56. RECTL rclBounds; // Bounding rectangle for all of the surfaces
  57. SURFOBJ* psoCacheMask; // Mask surface cache for pointer tags
  58. SURFOBJ* psoCacheColor; // Color surface cache for pointer tags
  59. } VDEV, *PVDEV;
  60. /*********************************Class************************************\
  61. * class MSURF
  62. *
  63. * Helper class for enumerating those display surfaces that are affected
  64. * by a drawing operation.
  65. *
  66. \**************************************************************************/
  67. class MSURF
  68. {
  69. private:
  70. VDEV* pvdev; // Our context
  71. RECTL rclOriginalBounds; // Save rclBounds of CLIPOBJ passed in
  72. BYTE iOriginalDComplexity; // Save iDComplexity of CLIPOBJ passed in
  73. MDSURF* pmdsurf; // Non-NULL when handling DIB surfaces
  74. RECTL rclDraw; // Area affected by current drawing
  75. // command
  76. public:
  77. DISPSURF* pds; // Current surface
  78. SURFOBJ* pso; // Current surface
  79. CLIPOBJ* pco; // Current clipping
  80. POINTL* pOffset; // Vector offset that should be added
  81. // to any coordinates before drawing on
  82. // this surface
  83. public:
  84. BOOL bFindSurface(SURFOBJ*, CLIPOBJ*, RECTL*);
  85. BOOL bNextSurface();
  86. void vRestore();
  87. };
  88. /*********************************Class************************************\
  89. * class MULTISURF
  90. *
  91. * Helper class for enumerating those display surfaces that are used
  92. * by a drawing operation.
  93. *
  94. \**************************************************************************/
  95. #define MULTISURF_SET_AS_DIB 0x0001 // Modified original surface fields
  96. #define MULTISURF_USE_COPY 0x0002 // Use copy for other device destinations
  97. #define MULTISURF_SYNCHRONIZED 0x0004 // Surface has been synchronized
  98. class MULTISURF
  99. {
  100. private:
  101. SURFACE *psurfOrg; // Original source surface
  102. RECTL rclOrg; // Copy of original source rect
  103. FLONG fl;
  104. DHPDEV dhpdevOrg; // Save dhpdev of psurfOrg
  105. DHSURF dhsurfOrg; // Save dhsurf of psurfOrg
  106. FLONG flagsOrg; // Save SurfFlags of psurfOrg
  107. SURFMEM SurfDIB; // Intermediate DIB of source
  108. RECTL rclDIB; // Source rect/origin when using DIB
  109. public:
  110. MDSURF* pmdsurf; // Non-NULL when handling Meta DEVBITMAP surfaces
  111. SURFOBJ* pso; // Current source surface
  112. RECTL* prcl; // Current source rect (and origin)
  113. POINTL* pptl() // Current origin (extracted from prcl)
  114. {
  115. return (POINTL*)prcl;
  116. }
  117. public:
  118. MULTISURF(SURFOBJ *psoOriginal)
  119. {
  120. ASSERTGDI(psoOriginal,"MULTISURF: Null psoOriginal\n");
  121. RECTL rclOriginal = { 0, 0, psoOriginal->sizlBitmap.cx,psoOriginal->sizlBitmap.cy};
  122. vInit(psoOriginal,&rclOriginal);
  123. }
  124. MULTISURF(SURFOBJ *psoOriginal, RECTL *prclOriginal)
  125. {
  126. vInit(psoOriginal, prclOriginal);
  127. }
  128. MULTISURF(SURFOBJ *psoOriginal, POINTL *pptlOriginal, LONG cx, LONG cy)
  129. {
  130. RECTL rclOriginal;
  131. if (psoOriginal != NULL)
  132. {
  133. rclOriginal.left = pptlOriginal->x;
  134. rclOriginal.top = pptlOriginal->y;
  135. rclOriginal.right = pptlOriginal->x + cx;
  136. rclOriginal.bottom = pptlOriginal->y + cy;
  137. vInit(psoOriginal, &rclOriginal);
  138. }
  139. else
  140. {
  141. vInit(psoOriginal, NULL);
  142. }
  143. }
  144. ~MULTISURF()
  145. {
  146. if (fl & MULTISURF_SET_AS_DIB)
  147. {
  148. if (pmdsurf != NULL)
  149. {
  150. psurfOrg->iType(STYPE_DEVBITMAP);
  151. }
  152. psurfOrg->dhpdev(dhpdevOrg);
  153. psurfOrg->dhsurf(dhsurfOrg);
  154. psurfOrg->flags(flagsOrg);
  155. }
  156. }
  157. BOOL bLoadSource(DISPSURF*);
  158. BOOL bLoadSource(HDEV);
  159. private:
  160. void vInit(SURFOBJ*, RECTL*);
  161. BOOL bCreateDIB();
  162. BOOL bLoadSourceNotMetaDEVBITMAP(HDEV);
  163. };
  164. #define PPFNMGET(msurf,name) \
  165. ((SURFOBJ_TO_SURFACE_NOT_NULL(msurf.pso)->flags() & HOOK_##name) ? \
  166. ((PFN_Drv##name) (msurf.pds->po).ppfn(INDEX_Drv##name)) : \
  167. ((PFN_Drv##name) Eng##name))
  168. /******************************Public*Routine******************************\
  169. * Macro SUBTRACT_RECT
  170. *
  171. * Takes an outer rectangle and an inner rectangle. It returns the
  172. * (up to) 4 rectangles that result from subtracting the inner from the
  173. * outer.
  174. *
  175. \**************************************************************************/
  176. #define SUBTRACT_RECT(arclOuter, crcl, rclOuter, rclInner)\
  177. {\
  178. crcl = 0;\
  179. if (rclInner.top > rclOuter.top)\
  180. {\
  181. arclOuter[crcl].top = rclOuter.top;\
  182. arclOuter[crcl].bottom = rclInner.top;\
  183. arclOuter[crcl].left = rclOuter.left;\
  184. arclOuter[crcl].right = rclOuter.right;\
  185. crcl++;\
  186. }\
  187. if (rclInner.bottom < rclOuter.bottom)\
  188. {\
  189. arclOuter[crcl].top = rclInner.bottom;\
  190. arclOuter[crcl].bottom = rclOuter.bottom;\
  191. arclOuter[crcl].left = rclOuter.left;\
  192. arclOuter[crcl].right = rclOuter.right;\
  193. crcl++;\
  194. }\
  195. if (rclInner.left > rclOuter.left)\
  196. {\
  197. arclOuter[crcl].top = rclInner.top;\
  198. arclOuter[crcl].bottom = rclInner.bottom;\
  199. arclOuter[crcl].left = rclOuter.left;\
  200. arclOuter[crcl].right = rclInner.left;\
  201. crcl++;\
  202. }\
  203. if (rclInner.right < rclOuter.right)\
  204. {\
  205. arclOuter[crcl].top = rclInner.top;\
  206. arclOuter[crcl].bottom = rclInner.bottom;\
  207. arclOuter[crcl].left = rclInner.right;\
  208. arclOuter[crcl].right = rclOuter.right;\
  209. crcl++;\
  210. }\
  211. }
  212. // Miscellaneous prototypes:
  213. extern DRVFN gadrvfnMulti[];
  214. extern ULONG gcdrvfnMulti;
  215. extern BOOL gbMultiMonMismatchColor;
  216. VOID MulDisableSurface(DHPDEV dhpdev);
  217. BOOL MulUpdateColors(SURFOBJ *pso, CLIPOBJ *pco, XLATEOBJ *pxlo);
  218. HDEV hdevFindDeviceHdev(HDEV hdevMeta, RECTL rect, PEWNDOBJ pwo);
  219. BOOL MulCopyDeviceToDIB( SURFOBJ *pso, SURFMEM *pDibSurf, RECTL *prclSrc);