Source code of Windows XP (NT5)
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.

647 lines
21 KiB

  1. //
  2. // Order Encoder
  3. //
  4. #ifndef _H_OE
  5. #define _H_OE
  6. //
  7. // Required headers
  8. //
  9. #include <oa.h>
  10. #include <shm.h>
  11. #include <fh.h>
  12. //
  13. // Specific values for OSI escape codes
  14. //
  15. #define OE_ESC(code) (OSI_OE_ESC_FIRST + code)
  16. #define OE_ESC_NEW_FONTS OE_ESC(0)
  17. #define OE_ESC_NEW_CAPABILITIES OE_ESC(1)
  18. //
  19. // Structure: OE_NEW_FONTS
  20. //
  21. // Description:
  22. //
  23. // Structure to pass new font data down to the display driver from the
  24. // Share Core.
  25. //
  26. //
  27. typedef struct tagOE_NEW_FONTS
  28. {
  29. OSI_ESCAPE_HEADER header; // Common header
  30. WORD fontCaps; // R11 font capabilities
  31. WORD countFonts; // Number of fonts in data block
  32. LPLOCALFONT fontData; // Local font table, containing
  33. // FH_MAX_FONTS entries
  34. LPWORD fontIndex; // Font table index, containing
  35. // FH_LOCAL_INDEX_SIZE entries
  36. } OE_NEW_FONTS;
  37. typedef OE_NEW_FONTS FAR * LPOE_NEW_FONTS;
  38. //
  39. // Structure: OE_NEW_CAPABILITIES
  40. //
  41. // Description:
  42. //
  43. // Structure to pass new capabilities down to the display driver from the
  44. // Share Core.
  45. //
  46. //
  47. typedef struct tagOE_NEW_CAPABILITIES
  48. {
  49. OSI_ESCAPE_HEADER header; // Common header
  50. DWORD sendOrders; // Are we allowed to send any
  51. // orders?
  52. DWORD textEnabled; // Are we allowed to send text
  53. // orders?
  54. DWORD baselineTextEnabled;
  55. // Flag to indicate if we should
  56. // encode text orders using
  57. // baseline alignment.
  58. LPBYTE orderSupported; // Array of BYTE-sized booleans
  59. }
  60. OE_NEW_CAPABILITIES;
  61. typedef OE_NEW_CAPABILITIES FAR * LPOE_NEW_CAPABILITIES;
  62. //
  63. // Flag to indicate support of second level order encoding. This is used
  64. // as a bitwise flag so that we can easily determine when parties have
  65. // mixed capabilities. Allowed values are:
  66. //
  67. // OE2_FLAG_UNKNOWN - OE2 supported has not been negotiated yet
  68. // OE2_FLAG_SUPPORTED - OE2 is supported by at least one person
  69. // OE2_FLAG_NOT_SUPPORTED - OE2 is not supported by at least one person
  70. // OE2_FLAG_MIXED - Oh no! This results when we have 2 (or more)
  71. // nodes that have differing OE2 support. In
  72. // this case we must disable OE2 encoding.
  73. //
  74. #define OE2_FLAG_UNKNOWN 0x00
  75. #define OE2_FLAG_SUPPORTED 0x10
  76. #define OE2_FLAG_NOT_SUPPORTED 0x01
  77. #define OE2_FLAG_MIXED 0x11
  78. //
  79. //
  80. // PROTOTYPES
  81. //
  82. //
  83. #ifdef DLL_DISP
  84. //
  85. // Name: OE_DDProcessRequest
  86. //
  87. // Purpose: Process an OE specific request from the Share Core
  88. //
  89. // Returns: TRUE if processed OK, FALSE otherwise
  90. //
  91. // Params: pso - SURFOBJ associated with ther request
  92. // cjIn - size of input buffer
  93. // pvIn - pointer to input buffer
  94. // cjOut - size of output buffer
  95. // pvOut - pointer to output buffer
  96. //
  97. #ifdef IS_16
  98. BOOL OE_DDProcessRequest(UINT fnEscape, LPOSI_ESCAPE_HEADER pResult,
  99. DWORD cbResult);
  100. BOOL OE_DDInit(void);
  101. void OE_DDViewing(BOOL fStart);
  102. #else
  103. ULONG OE_DDProcessRequest(SURFOBJ* pso, UINT cjIn, void* pvIn, UINT cjOut, void* pvOut);
  104. #endif // IS_16
  105. void OE_DDTerm(void);
  106. void OEDDSetNewFonts(LPOE_NEW_FONTS pDataIn);
  107. void OEDDSetNewCapabilities(LPOE_NEW_CAPABILITIES pCaps);
  108. BOOL OE_SendAsOrder(DWORD order);
  109. BOOL OE_RectIntersectsSDA(LPRECT lpRect);
  110. #endif // ifdef DLL_DISP
  111. //
  112. // Function prototypes.
  113. //
  114. //
  115. // OE_GetStringExtent(..)
  116. //
  117. // FUNCTION:
  118. //
  119. // Gets the extent (in logical coords) of the specified string.
  120. // The extent returned encloses all pels of the specified string.
  121. //
  122. //
  123. // PARAMETERS:
  124. //
  125. // hdc - DC handle
  126. //
  127. // pMetric - pointer to text metrics for the font for the string; if NULL,
  128. // use the global text metrics
  129. //
  130. // lpszString - pointer to null terminated string
  131. //
  132. // cbString - number of bytes in string
  133. //
  134. // lpDx - pointer to character increments. If NULL, use default character
  135. // increments
  136. //
  137. // pRect - pointer to rect where string extent is returned
  138. //
  139. // RETURNS:
  140. //
  141. // The amount of overhang included in the returned extent
  142. //
  143. // ------------------------------------....
  144. // | ****:
  145. // | * :
  146. // | *** :
  147. // | * | :
  148. // | * | :
  149. // | **** | :
  150. // ------------------------------------....
  151. // ^
  152. // :-------- bounds are wider
  153. // ^ than text extent
  154. // | due to overhang
  155. // real text extent ends here
  156. //
  157. //
  158. int OE_GetStringExtent(HDC hdc,
  159. TEXTMETRIC* pMetric,
  160. LPSTR lpszString,
  161. UINT cbString,
  162. LPRECT pRect );
  163. //
  164. // Macros to lock down the buffer that we want to use.
  165. //
  166. // NOTE: We do not have any OE specific shared memory, so we'll use the OA
  167. // shared data as a surrogate for the lock. Since the lock is counting, we
  168. // have no worries.
  169. //
  170. #define OE_SHM_START_WRITING OA_SHM_START_WRITING
  171. #define OE_SHM_STOP_WRITING OA_SHM_STOP_WRITING
  172. //
  173. // Number of rectangles that can make up a clip region before it is too
  174. // complicated to send as an order.
  175. //
  176. #define COMPLEX_CLIP_RECT_COUNT 4
  177. //
  178. // Mask and valid values for TextOut flAccel flags
  179. //
  180. #define OE_BAD_TEXT_MASK ( SO_VERTICAL | SO_REVERSED | SO_GLYPHINDEX_TEXTOUT )
  181. #ifdef DLL_DISP
  182. //
  183. // Structure to store brushes used as BLT patterns.
  184. //
  185. // style - Standard brush style (used in order to send brush type).
  186. //
  187. // BS_HATCHED
  188. // BS_PATTERN
  189. // BS_SOLID
  190. // BS_NULL
  191. //
  192. // hatch - Standard hatch definition. Can be one of the following.
  193. //
  194. // style = BS_HATCHED
  195. //
  196. // HS_HORIZONTAL
  197. // HS_VERTICAL
  198. // HS_FDIAGONAL
  199. // HS_BDIAGONAL
  200. // HS_CROSS
  201. // HS_DIAGCROSS
  202. //
  203. // style = BS_PATTERN
  204. //
  205. // This field contains the first byte of the brush definition
  206. // from the brush bitmap.
  207. //
  208. // brushData - bit data for the brush.
  209. //
  210. // fore - foreground color for the brush
  211. //
  212. // back - background color for the brush
  213. //
  214. // brushData - bit data for the brush (8x8x1bpp - 1 (see above) = 7 bytes)
  215. //
  216. //
  217. typedef struct tagOE_BRUSH_DATA
  218. {
  219. BYTE style;
  220. BYTE hatch;
  221. BYTE pad[2];
  222. TSHR_COLOR fore;
  223. TSHR_COLOR back;
  224. BYTE brushData[7];
  225. } OE_BRUSH_DATA, * POE_BRUSH_DATA;
  226. #ifndef IS_16
  227. //
  228. // Structure allowing sufficient stack to be allocated for an ENUMRECTS
  229. // structure containing more than one (in fact COMPLEX_CLIP_RECT_COUNT)
  230. // rectangles.
  231. // This holds one RECTL more than we need to allow us to determine whether
  232. // there are too many rects for order encoding by making a single call to
  233. // CLIPOBJ_bEnumRects.
  234. //
  235. typedef struct tagOE_ENUMRECTS
  236. {
  237. ENUMRECTS rects;
  238. RECTL extraRects[COMPLEX_CLIP_RECT_COUNT];
  239. } OE_ENUMRECTS;
  240. #endif // !IS_16
  241. #endif
  242. //
  243. // Font Alias table structure. The font aliases convert non-existant fonts
  244. // to ones that Windows supports in its default installation.
  245. //
  246. // pszOriginalFontName - Name of the non-existant font to be aliased
  247. //
  248. // pszAliasFontName - Name of the font Windows uses instead of the non
  249. // existant font.
  250. //
  251. // charWidthAdjustment - Character adjustment to make a decent match.
  252. //
  253. typedef struct _FONT_ALIAS_TABLE
  254. {
  255. LPBYTE pszOriginalFontName;
  256. LPBYTE pszAliasFontName;
  257. TSHR_UINT16 charWidthAdjustment;
  258. }
  259. FONT_ALIAS_TABLE;
  260. //
  261. // ROP4 to ROP3 conversion macros. Note that we don't use the full Windows
  262. // 3-way ROP code - we are only interested in the index byte.
  263. //
  264. #define ROP3_HIGH_FROM_ROP4(rop) ((TSHR_INT8)((rop & 0xff00) >> 8))
  265. #define ROP3_LOW_FROM_ROP4(rop) ((TSHR_INT8)((rop & 0x00ff)))
  266. //
  267. // OS specific RECTL to RECT conversion macro. Note that this macro
  268. // guarantees to return a well-ordered rectangle.
  269. //
  270. #define RECT_FROM_RECTL(dcr, rec) if (rec.right < rec.left) \
  271. { \
  272. dcr.left = rec.right; \
  273. dcr.right = rec.left; \
  274. } \
  275. else \
  276. { \
  277. dcr.left = rec.left; \
  278. dcr.right = rec.right; \
  279. } \
  280. if (rec.bottom < rec.top) \
  281. { \
  282. dcr.bottom = rec.top; \
  283. dcr.top = rec.bottom; \
  284. } \
  285. else \
  286. { \
  287. dcr.top = rec.top; \
  288. dcr.bottom = rec.bottom; \
  289. }
  290. //
  291. // OS specific RECTFX to RECT conversion macro. Note that this macro
  292. // guarantees to return a well-ordered rectangle.
  293. //
  294. // A RECTFX uses fixed point (28.4 bit) numbers so we need to truncate the
  295. // fraction and move to the correct integer value, i.e. shift right 4 bits.
  296. //
  297. #define RECT_FROM_RECTFX(dcr, rec) \
  298. if (rec.xRight < rec.xLeft) \
  299. { \
  300. dcr.left = FXTOLFLOOR(rec.xRight); \
  301. dcr.right = FXTOLCEILING(rec.xLeft); \
  302. } \
  303. else \
  304. { \
  305. dcr.left = FXTOLFLOOR(rec.xLeft); \
  306. dcr.right = FXTOLCEILING(rec.xRight); \
  307. } \
  308. if (rec.yBottom < rec.yTop) \
  309. { \
  310. dcr.bottom= FXTOLCEILING(rec.yTop); \
  311. dcr.top = FXTOLFLOOR(rec.yBottom); \
  312. } \
  313. else \
  314. { \
  315. dcr.top = FXTOLFLOOR(rec.yTop); \
  316. dcr.bottom= FXTOLCEILING(rec.yBottom); \
  317. }
  318. #define POINT_FROM_POINTL(dcp, pnt) dcp.x = pnt.x; \
  319. dcp.y = pnt.y
  320. #define POINT_FROM_POINTFIX(dcp, pnt) dcp.x = FXTOLROUND(pnt.x); \
  321. dcp.y = FXTOLROUND(pnt.y)
  322. //
  323. // Macros to check for articular types of ROP code.
  324. //
  325. #define ROP3_NO_PATTERN(rop) ((rop & 0x0f) == (rop >> 4))
  326. #define ROP3_NO_SOURCE(rop) ((rop & 0x33) == ((rop & 0xCC) >> 2))
  327. #define ROP3_NO_TARGET(rop) ((rop & 0x55) == ((rop & 0xAA) >> 1))
  328. //
  329. // Checking for SRCCOPY, PATCOPY, BLACKNESS, WHITENESS
  330. //
  331. #define ROP3_IS_OPAQUE(rop) ( ((rop) == 0xCC) || ((rop) == 0xF0) || \
  332. ((rop) == 0x00) || ((rop) == 0xFF) )
  333. //
  334. // 3-way rop equating to the COPYPEN mix.
  335. //
  336. #define OE_COPYPEN_ROP (BYTE)0xf0
  337. #ifdef DLL_DISP
  338. void OEConvertMask(ULONG mask, LPUINT pBitDepth, LPUINT pShift);
  339. #ifdef IS_16
  340. //
  341. // GDI never made defines for these, so we will.
  342. //
  343. #define PALETTEINDEX_FLAG 0x01000000L
  344. #define PALETTERGB_FLAG 0x02000000L
  345. #define COLOR_FLAGS 0x03000000L
  346. //
  347. // This is a GLOBAL to cut down on stack space, and is only valid during
  348. // the life of a DDI call that is not reentrant.
  349. //
  350. // When we calculate something, we set the bit saying we did. This speeds
  351. // up our code a lot from NM 2.0 which used to calculate the same things
  352. // over and over again.
  353. //
  354. #define OESTATE_SDA_DCB 0x0001 // Send as screen data, use DCBs
  355. #define OESTATE_SDA_SCREEN 0x0002 // Send as screen data, use screen rc
  356. #define OESTATE_SDA_MASK 0x0003 // Send rc as screen data
  357. #define OESTATE_SDA_FONTCOMPLEX 0x0004 // Send as screen data if font too complex
  358. #define OESTATE_OFFBYONEHACK 0x0010 // Add one pixel onto bottom after DDI
  359. #define OESTATE_CURPOS 0x0020 // Save curpos before DDI call
  360. #define OESTATE_DDISTUFF 0x003F
  361. #define OESTATE_COORDS 0x0100
  362. #define OESTATE_PEN 0x0200
  363. #define OESTATE_BRUSH 0x0400
  364. #define OESTATE_REGION 0x0800
  365. #define OESTATE_FONT 0x1000
  366. #define OESTATE_GET_MASK 0x1F00
  367. #define MIN_BRUSH_WIDTH 8
  368. #define MAX_BRUSH_WIDTH 16
  369. #define TRACKED_BRUSH_HEIGHT 8
  370. #define TRACKED_BRUSH_SIZE 8
  371. typedef struct tagOESTATE
  372. {
  373. UINT uFlags;
  374. HDC hdc;
  375. LPDC lpdc;
  376. RECT rc;
  377. //
  378. // These are used when calcing the bounds is too complicated, so we
  379. // let GDI do it for us, albeit slower.
  380. //
  381. UINT uGetDCB;
  382. UINT uSetDCB;
  383. RECT rcDCB;
  384. POINT ptCurPos;
  385. POINT ptDCOrg;
  386. POINT ptPolarity;
  387. LOGPEN logPen;
  388. LOGBRUSH logBrush;
  389. BYTE logBrushExtra[TRACKED_BRUSH_SIZE];
  390. LOGFONT logFont;
  391. int tmAlign;
  392. TEXTMETRIC tmFont;
  393. REAL_RGNDATA rgnData;
  394. } OESTATE, FAR* LPOESTATE;
  395. void OEGetState(UINT uFlags);
  396. BOOL OEBeforeDDI(DDI_PATCH ddiType, HDC hdc, UINT flags);
  397. BOOL OEAfterDDI(DDI_PATCH ddiType, BOOL fWeCare, BOOL fOutputHappened);
  398. #define OECHECK_PEN 0x0001
  399. #define OECHECK_BRUSH 0x0002
  400. #define OECHECK_FONT 0x0004
  401. #define OECHECK_CLIPPING 0x0010
  402. BOOL OECheckOrder(DWORD order, UINT flags);
  403. LPDC OEValidateDC(HDC hdc, BOOL fSrc);
  404. void OEMaybeBitmapHasChanged(LPDC lpdc);
  405. void OEClipAndAddOrder(LPINT_ORDER pOrder, void FAR* lpExtraInfo);
  406. void OEClipAndAddScreenData(LPRECT pRect);
  407. void OELPtoVirtual(HDC hdc, LPPOINT aPts, UINT cPts);
  408. void OELRtoVirtual(HDC hdc, LPRECT aRcs, UINT cRcs);
  409. void OEGetPolarity(void);
  410. void OEPolarityAdjust(LPRECT pRects, UINT cRects);
  411. void OEPenWidthAdjust(LPRECT lprc, UINT divisor);
  412. BOOL OETwoWayRopToThree(int, LPDWORD);
  413. BOOL OEClippingIsSimple(void);
  414. BOOL OEClippingIsComplex(void);
  415. BOOL OECheckPenIsSimple(void);
  416. BOOL OECheckBrushIsSimple(void);
  417. void OEExpandColor(LPBYTE lpField, DWORD clrSrc, DWORD fieldMask);
  418. void OEConvertColor(DWORD rgb, LPTSHR_COLOR lptshrDst, BOOL fAllowDither);
  419. void OEGetBrushInfo(LPTSHR_COLOR pClrBack, LPTSHR_COLOR pClrFore,
  420. LPTSHR_UINT32 lpBrushStyle, LPTSHR_UINT32 lpBrushHatch, LPBYTE lpBrushExtra);
  421. void OEAddLine(POINT ptStart, POINT ptEnd);
  422. void OEAddBlt(DWORD rop);
  423. void OEAddOpaqueRect(LPRECT);
  424. void OEAddRgnPaint(HRGN hrgnnPaint, HBRUSH hbrPaint, UINT rop);
  425. void OEAddPolyline(POINT ptStart, LPPOINT apts, UINT cpts);
  426. void OEAddPolyBezier(POINT ptStart, LPPOINT apts, UINT cpts);
  427. //
  428. // Cached font width info
  429. //
  430. typedef struct tagFH_CACHE
  431. {
  432. UINT fontIndex;
  433. UINT fontWidth;
  434. UINT fontHeight;
  435. UINT fontWeight;
  436. UINT fontFlags;
  437. UINT charWidths[256];
  438. } FH_CACHE, FAR* LPFH_CACHE;
  439. void OEAddText(POINT ptDst, UINT uOptions, LPRECT lprcClip, LPSTR lpszText,
  440. UINT cchText, LPINT lpdxCharSpacing);
  441. int OEGetStringExtent(LPSTR lpszText, UINT cchText, LPINT lpdxCharSpacing, LPRECT lprcExtent);
  442. BOOL OECheckFontIsSupported(LPSTR lpszText, UINT cchText, LPUINT pFontHeight,
  443. LPUINT pFontWidth, LPUINT pFontWeight, LPUINT pFontFlags,
  444. LPUINT pFontIndex, LPBOOL lpfSendDeltaX);
  445. BOOL OEAddDeltaX(LPEXTTEXTOUT_ORDER pExtTextOut, LPSTR lpszText, UINT cchText,
  446. LPINT lpdxCharSpacing, BOOL fSendDeltaX, POINT ptStart);
  447. #else
  448. void OELPtoVirtual(LPPOINT pPoints, UINT cPoints);
  449. void OELRtoVirtual(LPRECT pRects, UINT cRects);
  450. void OEClipAndAddOrder(LPINT_ORDER pOrder, void FAR * pExtraInfo, CLIPOBJ* pco);
  451. void OEClipAndAddScreenData(LPRECT pRect, CLIPOBJ* pco);
  452. BOOL OEClippingIsSimple(CLIPOBJ* pco);
  453. BOOL OEClippingIsComplex(CLIPOBJ* pco);
  454. BOOL OECheckBrushIsSimple(LPOSI_PDEV ppdev, BRUSHOBJ* pbo, POE_BRUSH_DATA * ppBrush);
  455. void OEExpandColor(LPBYTE lpField, ULONG clrSrc, ULONG mask);
  456. void OEConvertColor(LPOSI_PDEV ppdev, LPTSHR_COLOR pDCColor, ULONG osColor, XLATEOBJ* pxlo);
  457. BOOL OEAddLine(LPOSI_PDEV ppdev,
  458. LPPOINT startPoint,
  459. LPPOINT endPoint,
  460. LPRECT rectTrg,
  461. UINT rop2,
  462. UINT width,
  463. UINT color,
  464. CLIPOBJ* pco);
  465. BOOL OEAccumulateOutput(SURFOBJ* pso, CLIPOBJ *pco, LPRECT pRect);
  466. BOOL OEAccumulateOutputRect( SURFOBJ* pso, LPRECT pRect);
  467. BOOL OEStoreBrush(LPOSI_PDEV ppdev,
  468. BRUSHOBJ* pbo,
  469. BYTE style,
  470. LPBYTE pBits,
  471. XLATEOBJ* pxlo,
  472. BYTE hatch,
  473. UINT color1,
  474. UINT color2);
  475. BOOL OECheckFontIsSupported(FONTOBJ* pfo, LPSTR lpszText, UINT cchText,
  476. LPUINT fontHeight, LPUINT pFontAscent, LPUINT pFontWidth,
  477. LPUINT pFontWeight, LPUINT pFontFlags, LPUINT pFontIndex,
  478. LPBOOL pfSendDeltaX);
  479. void OETileBitBltOrder(LPINT_ORDER pOrder,
  480. LPMEMBLT_ORDER_EXTRA_INFO pExtraInfo,
  481. CLIPOBJ* pco);
  482. void OEAddTiledBitBltOrder(LPINT_ORDER pOrder,
  483. LPMEMBLT_ORDER_EXTRA_INFO pExtraInfo,
  484. CLIPOBJ* pco,
  485. int xTile,
  486. int yTile,
  487. UINT tileWidth,
  488. UINT tileHeight);
  489. BOOL OEEncodePatBlt(LPOSI_PDEV ppdev,
  490. BRUSHOBJ *pbo,
  491. POINTL *pptlBrush,
  492. BYTE rop3,
  493. LPRECT pBounds,
  494. LPINT_ORDER *ppOrder);
  495. #endif // !IS_16
  496. #endif // DLL_DISP
  497. //
  498. // Structures and typedefs.
  499. //
  500. //
  501. // Remote font is the structure we store for each font received from a
  502. // remote party. It mirrors the NETWORKFONT structure, with the facename
  503. // replaced with an index value (used to map the remote font handle to the
  504. // correct local font handle).
  505. //
  506. typedef struct _OEREMOTEFONT
  507. {
  508. TSHR_UINT16 rfLocalHandle;
  509. TSHR_UINT16 rfFontFlags;
  510. TSHR_UINT16 rfAveWidth;
  511. TSHR_UINT16 rfAveHeight;
  512. // lonchanc: rfAspectX and rfAspectY are used in network packet header
  513. // for both R11 and R20. So, keep it around!
  514. TSHR_UINT16 rfAspectX; // New field for r1.1
  515. TSHR_UINT16 rfAspectY; // New field for r1.1
  516. TSHR_UINT8 rfSigFats; // New field for r2.0
  517. TSHR_UINT8 rfSigThins; // New field for r2.0
  518. TSHR_UINT16 rfSigSymbol; // New field for r2.0
  519. TSHR_UINT16 rfCodePage; // New field for R2.0
  520. TSHR_UINT16 rfMaxAscent; // New field for R2.0
  521. }
  522. OEREMOTEFONT, * POEREMOTEFONT;
  523. void OEMaybeEnableText(void);
  524. BOOL OERectIntersectsSDA(LPRECT pRectVD);
  525. BOOL OESendRop3AsOrder(BYTE rop3);
  526. #endif // _H_OE