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.

449 lines
19 KiB

  1. /****************************************************************************/
  2. // noedisp.h
  3. //
  4. // DD-only definitions and prototypes for OE.
  5. //
  6. // Copyright (C) 1997-2000 Microsoft Corporation
  7. /****************************************************************************/
  8. #ifndef __NOEDISP_H
  9. #define __NOEDISP_H
  10. #include <aoeapi.h>
  11. #include <nddapi.h>
  12. #include <aoaapi.h>
  13. #include <nsbcdisp.h>
  14. #include <aordprot.h>
  15. // From Winbench99 Business Graphics benchmark, we found
  16. // creating offscreen bitmaps of 2K or smaller does not
  17. // improve our bandwidth. This parameter needs to be highly
  18. // tuned.
  19. // We also don't want to cache any cursor bitmaps for offscreen
  20. // the maximum cursor size is 32x32, which is less than the
  21. // minBitmapSize.
  22. #define MIN_OFFSCREEN_BITMAP_PIXELS 2048
  23. /****************************************************************************/
  24. /* Number of rectangles that can make up a clip region before it is too */
  25. /* complicated to send as an order. */
  26. /* */
  27. /* The File Open dialog is drawn with 41 clip rects(!), so we use a number */
  28. /* larger than this to allow it to be sent as orders rather than Screen */
  29. /* Data, */
  30. /****************************************************************************/
  31. #define COMPLEX_CLIP_RECT_COUNT 45
  32. /****************************************************************************/
  33. // Define minimum and maximum coords. Note that positive value needs to be
  34. // one less than the max signed 16-bit value since on 16-bit clients,
  35. // conversion from inclusive to exclusive coords for sending to GDI
  36. // would otherwise overflow.
  37. /****************************************************************************/
  38. #define OE_MIN_COORD -32768
  39. #define OE_MAX_COORD 32766
  40. #define OE_GL_MAX_INDEX_ENTRIES 256
  41. typedef struct tagGLYPHCONTEXT
  42. {
  43. UINT32 fontId;
  44. UINT_PTR cacheTag;
  45. unsigned cbDataSize;
  46. unsigned cbTotalDataSize;
  47. unsigned cbBufferSize;
  48. unsigned nCacheHit;
  49. unsigned nCacheIndex;
  50. unsigned rgCacheIndex[OE_GL_MAX_INDEX_ENTRIES];
  51. unsigned indexNextSend;
  52. } GLYPHCONTEXT, *PGLYPHCONTEXT;
  53. #define OE_FG_MIN_FRAG_SIZE 10
  54. #define OE_FG_MAX_FRAG_SIZE 28
  55. typedef struct tagFRAGCONTEXT
  56. {
  57. void *cacheHandle;
  58. unsigned cbCellSize;
  59. unsigned nCacheIndex;
  60. unsigned rgCacheIndex[OE_GL_MAX_INDEX_ENTRIES];
  61. } FRAGCONTEXT, *PFRAGCONTEXT;
  62. /****************************************************************************/
  63. /* Structure to store brushes used as BLT patterns. */
  64. /* */
  65. /* style - Standard brush style (used in order to send brush type). */
  66. /* BS_HATCHED */
  67. /* BS_PATTERN */
  68. /* BS_SOLID */
  69. /* BS_NULL */
  70. /* */
  71. /* hatch - Standard hatch definition. Can be one of the following. */
  72. /* style = BS_HATCHED */
  73. /* HS_HORIZONTAL */
  74. /* HS_VERTICAL */
  75. /* HS_FDIAGONAL */
  76. /* HS_BDIAGONAL */
  77. /* HS_CROSS */
  78. /* HS_DIAGCROSS */
  79. /* */
  80. /* style = BS_PATTERN */
  81. /* */
  82. /* This field contains the first byte of the brush definition */
  83. /* from the brush bitmap. */
  84. /* */
  85. /* brushData - bit data for the brush. */
  86. /* */
  87. /* fore - foreground color for the brush */
  88. /* */
  89. /* back - background color for the brush */
  90. /* */
  91. /* brushData - bit data for the brush (8x8x1bpp - 1 (see above) = 7 bytes) */
  92. /****************************************************************************/
  93. #define MAX_UNIQUE_COLORS 256
  94. typedef struct tagOE_BRUSH_DATA
  95. {
  96. BYTE style;
  97. BYTE hatch;
  98. UINT16 pad1;
  99. INT32 brushId;
  100. UINT32 cacheEntry;
  101. DCCOLOR fore;
  102. DCCOLOR back;
  103. ULONG iBitmapFormat;
  104. SIZEL sizlBitmap;
  105. UINT32 key1, key2;
  106. ULONG iBytes;
  107. BYTE brushData[7];
  108. } OE_BRUSH_DATA, *POE_BRUSH_DATA;
  109. /****************************************************************************/
  110. /* Structure allowing sufficient stack to be allocated for an ENUMRECTS */
  111. /* structure containing more than one (in fact COMPLEX_CLIP_RECT_COUNT) */
  112. /* rectangles. */
  113. /* This holds one RECTL more than we need to allow us to determine whether */
  114. /* there are too many rects for order encoding by making a single call to */
  115. /* CLIPOBJ_bEnumRects. */
  116. /****************************************************************************/
  117. typedef struct tagOE_ENUMRECTS
  118. {
  119. ENUMRECTS rects;
  120. RECTL extraRects[COMPLEX_CLIP_RECT_COUNT];
  121. } OE_ENUMRECTS;
  122. /****************************************************************************/
  123. // OS specific RECTL to well-ordered RECT conversion macro.
  124. /****************************************************************************/
  125. #define RECT_FROM_RECTL(dcr, rec) if (rec.right >= rec.left) { \
  126. dcr.left = rec.left; \
  127. dcr.right = rec.right; \
  128. } \
  129. else { \
  130. dcr.left = rec.right; \
  131. dcr.right = rec.left; \
  132. } \
  133. if (rec.bottom >= rec.top) { \
  134. dcr.top = rec.top; \
  135. dcr.bottom = rec.bottom; \
  136. } \
  137. else { \
  138. dcr.bottom = rec.top; \
  139. dcr.top = rec.bottom; \
  140. }
  141. /****************************************************************************/
  142. // RECTFX to RECT conversion macro. Note that this macro guarantees to return
  143. // a well-ordered rectangle.
  144. //
  145. // A RECTFX uses fixed point (28.4 bit) numbers so we need to truncate the
  146. // fraction and move to the correct integer value, i.e. shift right 4 bits.
  147. /****************************************************************************/
  148. #define RECT_FROM_RECTFX(dcr, rec) \
  149. if (rec.xRight >= rec.xLeft) { \
  150. dcr.left = FXTOLFLOOR(rec.xLeft); \
  151. dcr.right = FXTOLCEILING(rec.xRight); \
  152. } \
  153. else { \
  154. dcr.left = FXTOLFLOOR(rec.xRight); \
  155. dcr.right = FXTOLCEILING(rec.xLeft); \
  156. } \
  157. if (rec.yBottom >= rec.yTop) { \
  158. dcr.top = FXTOLFLOOR(rec.yTop); \
  159. dcr.bottom= FXTOLCEILING(rec.yBottom); \
  160. } \
  161. else { \
  162. dcr.bottom= FXTOLCEILING(rec.yTop); \
  163. dcr.top = FXTOLFLOOR(rec.yBottom); \
  164. }
  165. /****************************************************************************/
  166. // cast 32bit rectl to 16bit rect
  167. /****************************************************************************/
  168. #define RECTL_TO_TSRECT16(dst, src) \
  169. (dst).left = (TSINT16)(src).left; \
  170. (dst).top = (TSINT16)(src).top; \
  171. (dst).right = (TSINT16)(src).right; \
  172. (dst).bottom = (TSINT16)(src).bottom;
  173. /****************************************************************************/
  174. // cast 32bit pointl to 16bit point
  175. /****************************************************************************/
  176. #define POINTL_TO_TSPOINT16(dst, src) \
  177. (dst).x = (TSINT16)(src).x; \
  178. (dst).y = (TSINT16)(src).y;
  179. /****************************************************************************/
  180. // POINTFIX to POINTL conversion macro.
  181. /****************************************************************************/
  182. #define POINT_FROM_POINTFIX(dcp, pnt) dcp.x = FXTOLROUND(pnt.x); \
  183. dcp.y = FXTOLROUND(pnt.y)
  184. /****************************************************************************/
  185. // ROP codes and conversions.
  186. /****************************************************************************/
  187. #define ROP3_NO_PATTERN(rop) ((rop & 0x0f) == (rop >> 4))
  188. #define ROP3_NO_SOURCE(rop) ((rop & 0x33) == ((rop & 0xCC) >> 2))
  189. #define ROP3_NO_TARGET(rop) ((rop & 0x55) == ((rop & 0xAA) >> 1))
  190. // Checking for SRCCOPY, PATCOPY, BLACKNESS, WHITENESS
  191. #define ROP3_IS_OPAQUE(rop) (((rop) == 0xCC) || ((rop) == 0xF0) || \
  192. ((rop) == 0x00) || ((rop) == 0xFF) )
  193. #define OE_PATCOPY_ROP 0xF0
  194. #define OE_COPYPEN_ROP3 0xF0
  195. // ROP4 to ROP3 conversion macros. Note that we don't use the full Windows
  196. // 3-way ROP code - we are only interested in the index byte.
  197. #define ROP3_HIGH_FROM_ROP4(rop) ((BYTE)((rop & 0xff00) >> 8))
  198. #define ROP3_LOW_FROM_ROP4(rop) ((BYTE)((rop & 0x00ff)))
  199. // Rop 0x5f is used by MSDN to highlight search keywords. This XOR's a
  200. // pattern with the destination, producing markedly different (and
  201. // sometimes unreadable) shadow output. As this rop appears not to be
  202. // widely used in other scenarios, we special-case not encoding it.
  203. #define OESendRop3AsOrder(_rop3) ((_rop3) != 0x5F)
  204. /****************************************************************************/
  205. // Extra font info specific to our driver.
  206. /****************************************************************************/
  207. typedef struct
  208. {
  209. UINT32 fontId;
  210. INT32 cacheId;
  211. void *cacheHandle;
  212. INT32 shareId;
  213. UINT32 listIndex;
  214. } FONTCACHEINFO, *PFONTCACHEINFO;
  215. /****************************************************************************/
  216. // Prototypes
  217. /****************************************************************************/
  218. void OE_InitShm();
  219. void RDPCALL OE_Update();
  220. void OE_Reset();
  221. void OE_ClearOrderEncoding();
  222. BOOL RDPCALL OE_RectIntersectsSDA(PRECTL);
  223. #ifdef NotUsed
  224. void RDPCALL OEConvertMask(
  225. ULONG mask,
  226. PUSHORT pBitDepth,
  227. PUSHORT pShift);
  228. #endif
  229. void RDPCALL OEConvertColor(
  230. PDD_PDEV ppdev,
  231. DCCOLOR *pDCColor,
  232. ULONG osColor,
  233. XLATEOBJ *pxlo);
  234. BOOL RDPCALL OEStoreBrush(PDD_PDEV ppdev,
  235. BRUSHOBJ* pbo,
  236. BYTE style,
  237. ULONG iBitmapFormat,
  238. SIZEL *sizlBitmap,
  239. ULONG iBytes,
  240. PBYTE pBits,
  241. XLATEOBJ* pxlo,
  242. BYTE hatch,
  243. PBYTE pEncode,
  244. PUINT32 pColors,
  245. UINT32 numColors);
  246. BOOL RDPCALL OECheckBrushIsSimple(
  247. PDD_PDEV ppdev,
  248. BRUSHOBJ *pbo,
  249. POE_BRUSH_DATA *ppBrush);
  250. PFONTCACHEINFO RDPCALL OEGetFontCacheInfo(FONTOBJ *);
  251. unsigned OEGetIntersectionsWithClipRects(RECTL *, OE_ENUMRECTS *,
  252. OE_ENUMRECTS *);
  253. unsigned OEBuildPrecodeMultiClipFields(OE_ENUMRECTS *, BYTE **,
  254. UINT32 *, BYTE *);
  255. void RDPCALL OEClipAndAddScreenDataAreaByIntersectRects(PRECTL, OE_ENUMRECTS *);
  256. void RDPCALL OEClipAndAddScreenDataArea(PRECTL, CLIPOBJ *);
  257. unsigned OEDirectEncodeRect(RECTL *, RECT *, BYTE **, BYTE *);
  258. BOOL RDPCALL OETileBitBltOrder(PDD_PDEV, PPOINTL, RECTL *, unsigned,
  259. unsigned, PMEMBLT_ORDER_EXTRA_INFO, OE_ENUMRECTS *);
  260. BOOL RDPCALL OEAddTiledBitBltOrder(PDD_PDEV, PINT_ORDER,
  261. PMEMBLT_ORDER_EXTRA_INFO, OE_ENUMRECTS *, int, int);
  262. BOOL RDPCALL OEEncodeLineToOrder(PDD_PDEV, PPOINTL, PPOINTL, UINT32,
  263. UINT32, OE_ENUMRECTS *);
  264. BOOL RDPCALL OEEncodeOpaqueRect(RECTL *, BRUSHOBJ *, PDD_PDEV, OE_ENUMRECTS *);
  265. BOOL RDPCALL OEEncodePatBlt(PDD_PDEV, BRUSHOBJ *, RECTL *, POINTL *, BYTE,
  266. OE_ENUMRECTS *);
  267. BOOL RDPCALL OEEncodeMemBlt(RECTL *, MEMBLT_ORDER_EXTRA_INFO *, unsigned,
  268. unsigned, BYTE, POINTL *, POINTL *, BRUSHOBJ *, PDD_PDEV,
  269. OE_ENUMRECTS *);
  270. BOOL RDPCALL OEEncodeScrBlt(RECTL *, BYTE, POINTL *, PDD_PDEV, OE_ENUMRECTS *,
  271. CLIPOBJ *);
  272. BOOL RDPCALL OEEncodeDstBlt(RECTL *, BYTE, PDD_PDEV, OE_ENUMRECTS *);
  273. #ifdef DRAW_NINEGRID
  274. BOOL RDPCALL OEEncodeDrawNineGrid(RECTL *, RECTL *, unsigned, PDD_PDEV,
  275. OE_ENUMRECTS *);
  276. #endif
  277. BOOL RDPCALL OESendSwitchSurfacePDU(PDD_PDEV ppdev, PDD_DSURF pdsurf);
  278. unsigned OEBuildMultiClipOrder(PDD_PDEV,
  279. CLIP_RECT_VARIABLE_CODEDDELTALIST *, OE_ENUMRECTS *);
  280. BOOL OEEmitReplayOrders(PDD_PDEV, unsigned, OE_ENUMRECTS *);
  281. BOOL RDPCALL OECacheGlyphs(STROBJ *, FONTOBJ *, PFONTCACHEINFO, PGLYPHCONTEXT);
  282. BOOL RDPCALL OESendGlyphs(SURFOBJ *, STROBJ *, FONTOBJ *,
  283. PFONTCACHEINFO, PGLYPHCONTEXT);
  284. BOOL OESendGlyphAndIndexOrder(PDD_PDEV, STROBJ *, OE_ENUMRECTS *, PRECTL,
  285. POE_BRUSH_DATA, PFONTCACHEINFO, PGLYPHCONTEXT);
  286. unsigned RDPCALL OESendIndexOrder(PDD_PDEV, STROBJ *, OE_ENUMRECTS *, PRECTL,
  287. POE_BRUSH_DATA, PFONTCACHEINFO, PGLYPHCONTEXT, unsigned,
  288. unsigned, int, int, int, int, int, int, PBYTE, unsigned);
  289. BOOL RDPCALL OESendIndexes(SURFOBJ *, STROBJ *, FONTOBJ *, OE_ENUMRECTS *,
  290. PRECTL, POE_BRUSH_DATA, POINTL *, PFONTCACHEINFO, PGLYPHCONTEXT);
  291. void OETransformClipRectsForScrBlt(OE_ENUMRECTS *, PPOINTL, RECTL *, CLIPOBJ *);
  292. BOOL RDPCALL OEGetClipRects(CLIPOBJ *, OE_ENUMRECTS *);
  293. BOOL RDPCALL OEDeviceBitmapCachable(PDD_PDEV ppdev, SIZEL sizl, ULONG iFormat);
  294. #ifdef PERF_SPOILING
  295. BOOL RDPCALL OEIsSDAIncluded(PRECTL pRects, UINT rectCount);
  296. #endif
  297. #ifdef DRAW_NINEGRID
  298. #if 0
  299. // These are the drawstream prototype work, keep it for future reference
  300. BOOL RDPCALL OESendCreateDrawStreamOrder(PDD_PDEV ppdev,
  301. unsigned drawStreamBitmapId, SIZEL *sizl, unsigned bitmapBpp);
  302. BOOL RDPCALL OESendDrawStreamOrder(PDD_PDEV ppdev, unsigned bitmapId,
  303. unsigned ulIn, PVOID pvIn, PPOINTL dstOffset, RECTL *bounds,
  304. OE_ENUMRECTS *clipRects);
  305. BOOL RDPCALL OESendDrawNineGridOrder(PDD_PDEV ppdev, unsigned bitmapId,
  306. PRECTL prclSrc, RECTL *bounds, OE_ENUMRECTS *clipRects);
  307. #endif
  308. BOOL RDPCALL OESendCreateNineGridBitmapOrder(PDD_PDEV ppdev, unsigned bitmapId,
  309. SIZEL *sizl, unsigned bitmapBpp, PNINEGRID png);
  310. BOOL RDPCALL OECacheDrawNineGridBitmap(PDD_PDEV ppdev, SURFOBJ *psoSrc,
  311. PNINEGRID png, unsigned *bitmapId);
  312. BOOL RDPCALL OESendStreamBitmapOrder(PDD_PDEV ppdev, unsigned bitmapId,
  313. SIZEL *sizl, unsigned bitmapBpp, PBYTE BitmapBuffer, unsigned BitmapSize,
  314. BOOL compressed);
  315. #endif
  316. #ifdef DRAW_GDIPLUS
  317. BOOL RDPCALL OECreateDrawGdiplusOrder(PDD_PDEV ppdev, RECTL *prcl, ULONG cjIn, PVOID pvIn);
  318. BOOL RDPCALL OECacheDrawGdiplus(PDD_PDEV ppdev, PVOID pvIn, unsigned int *CacheID);
  319. BOOL RDPCALL OESendDrawGdiplusOrder(PDD_PDEV ppdev, RECTL *prcl, ULONG cjIn, PVOID pvIn, ULONG TotalEmfSize);
  320. BOOL RDPCALL OESendDrawGdiplusCacheOrder(PDD_PDEV ppdev, PVOID pvIn, unsigned int *CacheID, TSUINT16 CacheType,
  321. TSUINT16 RemoveCacheNum, TSUINT16 *RemoveCacheIDList);
  322. #endif
  323. #define CLIPRECTS_OK 0
  324. #define CLIPRECTS_TOO_COMPLEX 1
  325. #define CLIPRECTS_NO_INTERSECTIONS 2
  326. unsigned RDPCALL OEGetIntersectingClipRects(CLIPOBJ *, RECTL *, unsigned,
  327. OE_ENUMRECTS *);
  328. /****************************************************************************/
  329. // Inlined functions
  330. /****************************************************************************/
  331. /****************************************************************************/
  332. // OEClipPoint
  333. //
  334. // Clips a point to a 16-bit range.
  335. /****************************************************************************/
  336. __inline void RDPCALL OEClipPoint(PPOINTL pPoint)
  337. {
  338. if (pPoint->x >= OE_MIN_COORD && pPoint->x <= OE_MAX_COORD)
  339. goto ClipY;
  340. if (pPoint->x > OE_MAX_COORD)
  341. pPoint->x = OE_MAX_COORD;
  342. else if (pPoint->x < OE_MIN_COORD)
  343. pPoint->x = OE_MIN_COORD;
  344. ClipY:
  345. if (pPoint->y >= OE_MIN_COORD && pPoint->y <= OE_MAX_COORD)
  346. return;
  347. if (pPoint->y > OE_MAX_COORD)
  348. pPoint->y = OE_MAX_COORD;
  349. else if (pPoint->y < OE_MIN_COORD)
  350. pPoint->y = OE_MIN_COORD;
  351. }
  352. /****************************************************************************/
  353. // OEClipRect
  354. //
  355. // Clips a rect to be within the 16-bit wire encoding size.
  356. /****************************************************************************/
  357. __inline void RDPCALL OEClipRect(PRECTL pRect)
  358. {
  359. OEClipPoint((PPOINTL)(&pRect->left));
  360. OEClipPoint((PPOINTL)(&pRect->right));
  361. }
  362. #endif // !defined(__NOEDISP_H)