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.

293 lines
10 KiB

  1. //
  2. // Order Encoder 2nd Level
  3. //
  4. #ifndef _H_OE2
  5. #define _H_OE2
  6. //
  7. //
  8. // TYPEDEFS
  9. //
  10. //
  11. //
  12. // The party order data structure contains all the data that is used by
  13. // either the 2nd level encoder or decoder to store info on a party.
  14. //
  15. // The encoder contains just 1 instance of this structure, for the local
  16. // party.
  17. //
  18. // The decoder contains 1 instance of the structure per remote party.
  19. //
  20. typedef struct _PARTYORDERDATA
  21. {
  22. STRUCTURE_STAMP
  23. //
  24. // A copy of the last order of each type.
  25. // These are stored as byte array because we dont have a structure
  26. // defined that has the header and the particular order defined.
  27. //
  28. BYTE LastDstblt[sizeof(COM_ORDER_HEADER)+sizeof(DSTBLT_ORDER)];
  29. BYTE LastPatblt[sizeof(COM_ORDER_HEADER)+sizeof(PATBLT_ORDER)];
  30. BYTE LastScrblt[sizeof(COM_ORDER_HEADER)+sizeof(SCRBLT_ORDER)];
  31. BYTE LastMemblt[sizeof(COM_ORDER_HEADER)+sizeof(MEMBLT_ORDER)];
  32. BYTE LastMem3blt[sizeof(COM_ORDER_HEADER)+sizeof(MEM3BLT_ORDER)];
  33. BYTE LastRectangle[sizeof(COM_ORDER_HEADER)+sizeof(RECTANGLE_ORDER)];
  34. BYTE LastLineTo[sizeof(COM_ORDER_HEADER)+sizeof(LINETO_ORDER)];
  35. BYTE LastTextOut[sizeof(COM_ORDER_HEADER)+sizeof(TEXTOUT_ORDER)];
  36. BYTE LastExtTextOut[sizeof(COM_ORDER_HEADER)+sizeof(EXTTEXTOUT_ORDER)];
  37. BYTE LastOpaqueRect[sizeof(COM_ORDER_HEADER)+sizeof(OPAQUERECT_ORDER)];
  38. BYTE LastSaveBitmap[sizeof(COM_ORDER_HEADER)+sizeof(SAVEBITMAP_ORDER)];
  39. BYTE LastDeskScroll[sizeof(COM_ORDER_HEADER)+sizeof(DESKSCROLL_ORDER)];
  40. BYTE LastMembltR2[sizeof(COM_ORDER_HEADER)+sizeof(MEMBLT_R2_ORDER)];
  41. BYTE LastMem3bltR2[sizeof(COM_ORDER_HEADER)+sizeof(MEM3BLT_R2_ORDER)];
  42. BYTE LastPolygon[sizeof(COM_ORDER_HEADER)+sizeof(POLYGON_ORDER)];
  43. BYTE LastPie[sizeof(COM_ORDER_HEADER)+sizeof(PIE_ORDER)];
  44. BYTE LastEllipse[sizeof(COM_ORDER_HEADER)+sizeof(ELLIPSE_ORDER)];
  45. BYTE LastArc[sizeof(COM_ORDER_HEADER)+sizeof(ARC_ORDER)];
  46. BYTE LastChord[sizeof(COM_ORDER_HEADER)+sizeof(CHORD_ORDER)];
  47. BYTE LastPolyBezier[sizeof(COM_ORDER_HEADER)+sizeof(POLYBEZIER_ORDER)];
  48. BYTE LastRoundRect[sizeof(COM_ORDER_HEADER)+sizeof(ROUNDRECT_ORDER)];
  49. //
  50. // The type and a pointer to the last order
  51. //
  52. BYTE LastOrderType;
  53. LPCOM_ORDER pLastOrder;
  54. //
  55. // Details of the last font that was used
  56. //
  57. HFONT LastHFONT;
  58. UINT LastCodePage;
  59. UINT LastFontWidth;
  60. UINT LastFontHeight;
  61. UINT LastFontWeight;
  62. UINT LastFontFlags;
  63. UINT LastFontFaceLen;
  64. char LastFaceName[FH_FACESIZE];
  65. //
  66. // The last bounds that were used.
  67. //
  68. TSHR_RECT16 LastBounds;
  69. //
  70. // Font metrics, currently unused by the encoder.
  71. //
  72. TEXTMETRIC LastFontMetrics;
  73. //
  74. // An array of pointers to the last orders of each type.
  75. //
  76. void * LastOrder[OE2_NUM_TYPES];
  77. }
  78. PARTYORDERDATA, * PPARTYORDERDATA, * * PPPARTYORDERDATA;
  79. //
  80. // This structure contains information for a single field in an ORDER
  81. // structure
  82. //
  83. // FieldPos - The byte offset into the order structure to the
  84. // start of the field.
  85. //
  86. // FieldUnencodedLen - The length in bytes of the unencoded field.
  87. //
  88. // FieldEncodedLen - The length in bytes of the encoded field. This
  89. // should always be <= to FieldUnencodedLen.
  90. //
  91. // FieldSigned - Does this field contain a signed or unsigned value?
  92. //
  93. // FieldType - A description of the type of the field - this
  94. // is used to determine how to encode / decode the
  95. // field.
  96. //
  97. //
  98. typedef struct tagOE2ETFIELD
  99. {
  100. UINT FieldPos;
  101. UINT FieldUnencodedLen;
  102. UINT FieldEncodedLen;
  103. BOOL FieldSigned;
  104. UINT FieldType;
  105. }OE2ETFIELD;
  106. typedef OE2ETFIELD const FAR * POE2ETFIELD;
  107. //
  108. // Array of pointers to the entries in the encoding table
  109. //
  110. typedef POE2ETFIELD OE2ETTYPE[OE2_NUM_TYPES];
  111. //
  112. // This structure contains information allowing an ORDER structure to be
  113. // encoded or decoded into a DCEO2ORDER structure.
  114. // The order table comprises
  115. //
  116. // - an array of POE2ETFIELD pointers, indexed by the encoded type
  117. // index:
  118. //
  119. // typedef OE2ETTYPE POE2ETFIELD[OE2_NUM_TYPES]
  120. //
  121. // - one array of OE2ETFIELD structures for each of the 7 order
  122. // types (each order type has a different number of fields).
  123. // Note that there may not be more than 24 entries for a single
  124. // ORDER type. The entries for an order type are terminated
  125. // by an entry with the FieldPos field set to 0. The first
  126. // FieldPos is non-zero since it is the offset to the second
  127. // field of the order (type is ignored).
  128. //
  129. // pFields - an array of POE2ETFIELD pointers, indexed by the encoded
  130. // type index. This is used to identify the entry in this
  131. // table for an ORDER type.
  132. //
  133. // NumFields - an array of bytes containing the number of fields in each
  134. // order structure for each order.
  135. //
  136. // DstBltFields - array of OE2ETFIELD structures (one for each field)
  137. // for the DSTBLT_ORDER
  138. //
  139. // PatBltFields - array of OE2ETFIELD structures (one for each field)
  140. // for the PATBLT_ORDER
  141. //
  142. // ScrBltFields - array of OE2ETFIELD structures (one for each field)
  143. // for the SCRBLT_ORDER
  144. //
  145. // MemBltFields - array of OE2ETFIELD structures (one for each field)
  146. // for the MEMBLT_ORDER
  147. //
  148. // Mem3BltFields - array of OE2ETFIELD structures (one for each field)
  149. // for the MEM3BLT_ORDER
  150. //
  151. // TextOutFields - array of OE2ETFIELD structures (one for each field)
  152. // for the TEXTOUT_ORDER
  153. //
  154. // ExtTextOutFields - array of OE2ETFIELD structures (one for each field)
  155. // for the EXTTEXTOUT_ORDER
  156. //
  157. // RectangleFields - array of OE2ETFIELD structures (one for each field)
  158. // for the RECTANGLE_ORDER
  159. //
  160. // LineToFields - array of OE2ETFIELD structures (one for each field)
  161. // for the LINETO_ORDER
  162. //
  163. // OpaqueRectFields - array of OE2ETFIELD structures (one for each field)
  164. // for the OPQAUERECT_ORDER
  165. //
  166. // SaveBitmapFields - array of OE2ETFIELD structures (one for each field)
  167. // for the SAVEBITMAP_ORDER
  168. //
  169. // DeskScrollFields - array of OE2ETFIELD structures (one for each field)
  170. // for the DESKSCROLL_ORDER
  171. // etc.
  172. //
  173. //
  174. typedef struct tagOE2ETTABLE
  175. {
  176. POE2ETFIELD pFields [OE2_NUM_TYPES];
  177. BYTE NumFields [OE2_NUM_TYPES];
  178. OE2ETFIELD DstBltFields [OE2_NUM_DSTBLT_FIELDS];
  179. OE2ETFIELD PatBltFields [OE2_NUM_PATBLT_FIELDS];
  180. OE2ETFIELD ScrBltFields [OE2_NUM_SCRBLT_FIELDS];
  181. OE2ETFIELD MemBltFields [OE2_NUM_MEMBLT_FIELDS];
  182. OE2ETFIELD Mem3BltFields [OE2_NUM_MEM3BLT_FIELDS];
  183. OE2ETFIELD TextOutFields [OE2_NUM_TEXTOUT_FIELDS];
  184. OE2ETFIELD ExtTextOutFields [OE2_NUM_EXTTEXTOUT_FIELDS];
  185. OE2ETFIELD RectangleFields [OE2_NUM_RECTANGLE_FIELDS];
  186. OE2ETFIELD LineToFields [OE2_NUM_LINETO_FIELDS];
  187. OE2ETFIELD OpaqueRectFields [OE2_NUM_OPAQUERECT_FIELDS];
  188. OE2ETFIELD SaveBitmapFields [OE2_NUM_SAVEBITMAP_FIELDS];
  189. OE2ETFIELD DeskScrollFields [OE2_NUM_DESKSCROLL_FIELDS];
  190. OE2ETFIELD MemBltR2Fields [OE2_NUM_MEMBLT_R2_FIELDS];
  191. OE2ETFIELD Mem3BltR2Fields [OE2_NUM_MEM3BLT_R2_FIELDS];
  192. OE2ETFIELD PolygonFields [OE2_NUM_POLYGON_FIELDS];
  193. OE2ETFIELD PieFields [OE2_NUM_PIE_FIELDS];
  194. OE2ETFIELD EllipseFields [OE2_NUM_ELLIPSE_FIELDS];
  195. OE2ETFIELD ArcFields [OE2_NUM_ARC_FIELDS];
  196. OE2ETFIELD ChordFields [OE2_NUM_CHORD_FIELDS];
  197. OE2ETFIELD PolyBezierFields [OE2_NUM_POLYBEZIER_FIELDS];
  198. OE2ETFIELD RoundRectFields [OE2_NUM_ROUNDRECT_FIELDS];
  199. } OE2ETTABLE;
  200. //
  201. //
  202. // MACROS
  203. //
  204. //
  205. //
  206. // #define used to check that there is enough room left in the buffer
  207. // for the encoded data which is about to be copied in.
  208. //
  209. #define ENOUGH_BUFFER(bend, start, datalen) \
  210. ( ((LPBYTE)(start)+(datalen)) <= (bend) )
  211. //
  212. // FUNCTION: OE2GetOrderType
  213. //
  214. // DESCRIPTION:
  215. //
  216. // This function converts the two byte flag used in an ORDER to record the
  217. // type of order into an internal single byte value
  218. //
  219. // PARAMETERS:
  220. //
  221. // pOrder - A pointer to the order
  222. //
  223. // RETURNS:
  224. //
  225. // The type of the order (internal single byte value - see above)
  226. //
  227. //
  228. BYTE OE2GetOrderType(LPCOM_ORDER pOrder);
  229. BOOL OE2CanUseDeltaCoords(void * pNewCoords,
  230. void * pOldCoords,
  231. UINT fieldLength,
  232. BOOL signedValue,
  233. UINT numElements);
  234. void OE2CopyToDeltaCoords(LPTSHR_INT8* ppDestination,
  235. void * pNewCoords,
  236. void * pOldCoords,
  237. UINT fieldLength,
  238. BOOL signedValue,
  239. UINT numElements);
  240. //
  241. // FUNCTION: OE2EncodeField
  242. //
  243. // DESCRIPTION:
  244. //
  245. // Convert a field which is an array of 1 or more elements, from its
  246. // encoded form to its decoded form.
  247. //
  248. // PARAMETERS:
  249. //
  250. // pSrc - Array of source values.
  251. // ppDest - Array of destination values.
  252. // srcFieldLength - The size of each of the elements in the source array.
  253. // destFieldLength - The size of each of the elements in the destination
  254. // array.
  255. // signedValue - Is the element a signed value ?
  256. // numElements - The number of elements in the arrays.
  257. //
  258. // RETURNS:
  259. //
  260. // None.
  261. //
  262. //
  263. void OE2EncodeField(void * pSrc,
  264. PBYTE* ppDest,
  265. UINT srcFieldLength,
  266. UINT destFieldLength,
  267. BOOL signedValue,
  268. UINT numElements);
  269. #endif // _H_OE2