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.

298 lines
11 KiB

  1. /****************************************************************************/
  2. // od.h
  3. //
  4. // Order Decoder Class.
  5. //
  6. // Copyright (c) 1997-1999 Microsoft Corp.
  7. // Portions copyright (c) 1992-1997 Microsoft, PictureTel
  8. /****************************************************************************/
  9. #ifndef _H_OD
  10. #define _H_OD
  11. extern "C" {
  12. #include <adcgdata.h>
  13. }
  14. #include "or.h"
  15. #include "uh.h"
  16. #include "cc.h"
  17. #include "objs.h"
  18. /****************************************************************************/
  19. /* ODORDERFIELDINFO "type" flags. */
  20. /****************************************************************************/
  21. #define OD_OFI_TYPE_FIXED 0x01
  22. #define OD_OFI_TYPE_VARIABLE 0x02
  23. #define OD_OFI_TYPE_COORDINATES 0x04
  24. #define OD_OFI_TYPE_DATA 0x08
  25. #define OD_OFI_TYPE_SIGNED 0x10
  26. #define OD_OFI_TYPE_LONG_VARIABLE 0x20
  27. /****************************************************************************/
  28. /* Define the maximum sizes of fields within encoded orders. */
  29. /****************************************************************************/
  30. #define OD_CONTROL_FLAGS_FIELD_SIZE 1
  31. #define OD_TYPE_FIELD_SIZE 1
  32. #define OD_MAX_FIELD_FLAG_BYTES 3
  33. #define OD_MAX_ADDITIONAL_BOUNDS_BYTES 1
  34. /****************************************************************************/
  35. /* Structure: OD_ORDER_FIELD_INFO */
  36. /* */
  37. /* This structure contains information for a single field in an ORDER */
  38. /* structure */
  39. /* */
  40. /* fieldPos - The byte offset into the order structure to the */
  41. /* start of the field. */
  42. /* */
  43. /* fieldUnencodedLen - The length in bytes of the unencoded field. */
  44. /* */
  45. /* fieldEncodedLen - The length in bytes of the encoded field. This */
  46. /* should always be <= to FieldUnencodedLen. */
  47. /* */
  48. /* fieldSigned - Does this field contain a signed or unsigned value? */
  49. /* */
  50. /* fieldType - A description of the type of the field - this */
  51. /* is used to determine how to decode the */
  52. /* field. */
  53. /****************************************************************************/
  54. typedef struct tagOD_ORDER_FIELD_INFO
  55. {
  56. UINT16 fieldPos;
  57. BYTE fieldUnencodedLen;
  58. BYTE fieldEncodedLen;
  59. BYTE fieldType;
  60. } OD_ORDER_FIELD_INFO, FAR *POD_ORDER_FIELD_INFO;
  61. class COD;
  62. // Fast-path decoding function pointer type.
  63. typedef HRESULT (DCINTERNAL FAR COD::*POD_ORDER_HANDLER_FUNC)(
  64. PUH_ORDER pOrder,
  65. UINT16 uiVarDataLen,
  66. BOOL bBoundsSet);
  67. typedef HRESULT (DCINTERNAL FAR COD::*POD_FAST_ORDER_DECODE_FUNC)(
  68. BYTE ControlFlags,
  69. BYTE FAR * FAR *ppFieldDecode,
  70. DCUINT dataLen,
  71. UINT32 FieldFlags);
  72. /*
  73. typedef void (DCINTERNAL FAR *POD_FAST_ORDER_DECODE_FUNC)(
  74. BYTE ControlFlags,
  75. BYTE FAR * FAR *ppFieldDecode,
  76. UINT32 FieldFlags);
  77. typedef void (DCINTERNAL FAR *POD_ORDER_HANDLER_FUNC)(
  78. PUH_ORDER pOrder,
  79. BOOL bBoundsSet);
  80. */
  81. #define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember))
  82. // Order attribute data, one per order type to store decoding tables and info.
  83. typedef struct tagOD_ORDER_TABLE
  84. {
  85. const OD_ORDER_FIELD_INFO FAR *pOrderTable;
  86. unsigned NumFields;
  87. PUH_ORDER LastOrder;
  88. DCUINT cbMaxOrderLen;
  89. UINT16 cbVariableDataLen;
  90. POD_FAST_ORDER_DECODE_FUNC pFastDecode;
  91. POD_ORDER_HANDLER_FUNC pHandler;
  92. } OD_ORDER_TABLE;
  93. /****************************************************************************/
  94. /* Structure: OD_GLOBAL_DATA */
  95. /* */
  96. /* Description: */
  97. /****************************************************************************/
  98. typedef struct tagOD_GLOBAL_DATA
  99. {
  100. /************************************************************************/
  101. /* A copy of the last order of each type. */
  102. /* These are stored as byte array because we dont have a structure */
  103. /* defined that has the header and the particular order defined. */
  104. /************************************************************************/
  105. BYTE lastDstblt[UH_ORDER_HEADER_SIZE + sizeof(DSTBLT_ORDER)];
  106. BYTE lastPatblt[UH_ORDER_HEADER_SIZE + sizeof(PATBLT_ORDER)];
  107. BYTE lastScrblt[UH_ORDER_HEADER_SIZE + sizeof(SCRBLT_ORDER)];
  108. BYTE lastLineTo[UH_ORDER_HEADER_SIZE + sizeof(LINETO_ORDER)];
  109. BYTE lastOpaqueRect[UH_ORDER_HEADER_SIZE + sizeof(OPAQUERECT_ORDER)];
  110. BYTE lastSaveBitmap[UH_ORDER_HEADER_SIZE + sizeof(SAVEBITMAP_ORDER)];
  111. BYTE lastMembltR2[UH_ORDER_HEADER_SIZE + sizeof(MEMBLT_R2_ORDER)];
  112. BYTE lastMem3bltR2[UH_ORDER_HEADER_SIZE + sizeof(MEM3BLT_R2_ORDER)];
  113. BYTE lastMultiDstBlt[UH_ORDER_HEADER_SIZE + sizeof(MULTI_DSTBLT_ORDER)];
  114. BYTE lastMultiPatBlt[UH_ORDER_HEADER_SIZE + sizeof(MULTI_PATBLT_ORDER)];
  115. BYTE lastMultiScrBlt[UH_ORDER_HEADER_SIZE + sizeof(MULTI_SCRBLT_ORDER)];
  116. BYTE lastMultiOpaqueRect[UH_ORDER_HEADER_SIZE + sizeof(MULTI_OPAQUERECT_ORDER)];
  117. BYTE lastFastIndex[UH_ORDER_HEADER_SIZE + sizeof(FAST_INDEX_ORDER)];
  118. BYTE lastPolygonSC[UH_ORDER_HEADER_SIZE + sizeof(POLYGON_SC_ORDER)];
  119. BYTE lastPolygonCB[UH_ORDER_HEADER_SIZE + sizeof(POLYGON_CB_ORDER)];
  120. BYTE lastPolyLine[UH_ORDER_HEADER_SIZE + sizeof(POLYLINE_ORDER)];
  121. BYTE lastFastGlyph[UH_ORDER_HEADER_SIZE + sizeof(FAST_GLYPH_ORDER)];
  122. BYTE lastEllipseSC[UH_ORDER_HEADER_SIZE + sizeof(ELLIPSE_SC_ORDER)];
  123. BYTE lastEllipseCB[UH_ORDER_HEADER_SIZE + sizeof(ELLIPSE_CB_ORDER)];
  124. BYTE lastIndex[UH_ORDER_HEADER_SIZE + sizeof(INDEX_ORDER)];
  125. #ifdef DRAW_NINEGRID
  126. BYTE lastDrawNineGrid[UH_ORDER_HEADER_SIZE + sizeof(DRAWNINEGRID_ORDER)];
  127. BYTE lastMultiDrawNineGrid[UH_ORDER_HEADER_SIZE + sizeof(MULTI_DRAWNINEGRID_ORDER)];
  128. #endif
  129. /************************************************************************/
  130. /* The type of order, and a pointer to the last order */
  131. /************************************************************************/
  132. BYTE lastOrderType;
  133. PUH_ORDER pLastOrder;
  134. /************************************************************************/
  135. /* The last bounds that were used. */
  136. /************************************************************************/
  137. RECT lastBounds;
  138. #ifdef DC_HICOLOR
  139. //#ifdef DC_DEBUG
  140. /************************************************************************/
  141. /* Used for testing to confirm that we've received each of the order */
  142. /* types */
  143. /************************************************************************/
  144. #define TS_FIRST_SECONDARY_ORDER TS_MAX_ORDERS
  145. UINT32 orderHit[TS_MAX_ORDERS + TS_NUM_SECONDARY_ORDERS];
  146. //#endif
  147. #endif
  148. } OD_GLOBAL_DATA;
  149. class COD
  150. {
  151. public:
  152. COD(CObjs* objs);
  153. ~COD();
  154. public:
  155. //
  156. // API
  157. //
  158. void DCAPI OD_Init(void);
  159. void DCAPI OD_Term(void);
  160. void DCAPI OD_Enable(void);
  161. void DCAPI OD_Disable(void);
  162. HRESULT DCAPI OD_DecodeOrder(PPDCVOID, DCUINT, PUH_ORDER *);
  163. public:
  164. //
  165. // Public data members
  166. //
  167. OD_GLOBAL_DATA _OD;
  168. // Order attributes used for decoding, organized to optimize cache line
  169. // usage. The fourth and fifth fields of each row are the fast-path decode
  170. // and order handler functions, respectively. If a fast-path decode function
  171. // is used, neither a decoding table nor a handler function is needed,
  172. // since fast-path decode functions also perform the handling.
  173. OD_ORDER_TABLE odOrderTable[TS_MAX_ORDERS];
  174. private:
  175. //
  176. // Internal functions
  177. //
  178. /****************************************************************************/
  179. /* FUNCTION PROTOTYPES */
  180. /****************************************************************************/
  181. HRESULT DCINTERNAL ODDecodeFieldSingle(PPDCUINT8, PDCVOID, unsigned, unsigned,
  182. BOOL);
  183. HRESULT ODDecodeMultipleRects(RECT *, UINT32,
  184. CLIP_RECT_VARIABLE_CODEDDELTALIST FAR *,
  185. UINT16 uiVarDataLen);
  186. HRESULT DCINTERNAL ODDecodePathPoints(POINT *, RECT *,
  187. BYTE FAR *pData,
  188. unsigned NumDeltaEntries, unsigned MaxNumDeltaEntries,
  189. unsigned dataLen, unsigned MaxDataLen,
  190. UINT16 uiVarDataLen,
  191. BOOL);
  192. HRESULT DCINTERNAL ODDecodeOpaqueRect(BYTE, BYTE FAR * FAR *, DCUINT, UINT32);
  193. HRESULT DCINTERNAL ODDecodeMemBlt(BYTE, BYTE FAR * FAR *, DCUINT, UINT32);
  194. HRESULT DCINTERNAL ODDecodeLineTo(BYTE, BYTE FAR * FAR *, DCUINT, UINT32);
  195. HRESULT DCINTERNAL ODDecodePatBlt(BYTE, BYTE FAR * FAR *, DCUINT, UINT32);
  196. HRESULT DCINTERNAL ODDecodeFastIndex(BYTE, BYTE FAR * FAR *, DCUINT, UINT32);
  197. HRESULT DCINTERNAL ODHandleMultiPatBlt(PUH_ORDER, UINT16, BOOL);
  198. HRESULT DCINTERNAL ODHandleDstBlts(PUH_ORDER, UINT16, BOOL);
  199. HRESULT DCINTERNAL ODHandleScrBlts(PUH_ORDER, UINT16, BOOL);
  200. HRESULT DCINTERNAL ODHandleMultiOpaqueRect(PUH_ORDER, UINT16, BOOL);
  201. #ifdef DRAW_NINEGRID
  202. HRESULT DCINTERNAL ODHandleDrawNineGrid(PUH_ORDER, UINT16, BOOL);
  203. HRESULT DCINTERNAL ODHandleMultiDrawNineGrid(PUH_ORDER, UINT16, BOOL);
  204. #endif
  205. HRESULT DCINTERNAL ODHandleMem3Blt(PUH_ORDER, UINT16, BOOL);
  206. HRESULT DCINTERNAL ODHandleSaveBitmap(PUH_ORDER, UINT16, BOOL);
  207. HRESULT DCINTERNAL ODHandlePolyLine(PUH_ORDER, UINT16, BOOL);
  208. HRESULT DCINTERNAL ODHandlePolygonSC(PUH_ORDER, UINT16, BOOL);
  209. HRESULT DCINTERNAL ODHandlePolygonCB(PUH_ORDER, UINT16, BOOL);
  210. HRESULT DCINTERNAL ODHandleEllipseSC(PUH_ORDER, UINT16, BOOL);
  211. HRESULT DCINTERNAL ODHandleEllipseCB(PUH_ORDER, UINT16, BOOL);
  212. HRESULT DCINTERNAL ODHandleFastGlyph(PUH_ORDER, UINT16, BOOL);
  213. HRESULT DCINTERNAL ODHandleGlyphIndex(PUH_ORDER, UINT16, BOOL);
  214. #ifdef OS_WINCE
  215. BOOL DCINTERNAL ODHandleAlwaysOnTopRects(LPMULTI_SCRBLT_ORDER pSB);
  216. #endif
  217. private:
  218. COP* _pOp;
  219. CUH* _pUh;
  220. CCC* _pCc;
  221. CUI* _pUi;
  222. CCD* _pCd;
  223. private:
  224. CObjs* _pClientObjects;
  225. };
  226. #endif // _H_OD