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
9.4 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: clipobj.hxx
  3. *
  4. * Clipping object
  5. *
  6. * Created: 15-Sep-1990 15:13:06
  7. * Author: Donald Sidoroff [donalds]
  8. *
  9. * Copyright (c) 1990-1999 Microsoft Corporation
  10. *
  11. \**************************************************************************/
  12. #ifndef _CLIPOBJ_HXX
  13. #define _CLIPOBJ_HXX 1
  14. /*********************************Class************************************\
  15. * CLIPLINE structures.
  16. *
  17. * These structures have been divided into two halves. CLIPLINEEENUM
  18. * contains those fields that are needed to hold the state of enumerating
  19. * through a single line and enumerate through a series of lines within a
  20. * path.
  21. *
  22. * ENUMER is also used for holding part of the clipped line state.
  23. *
  24. * History:
  25. * 07-Mar-1991 -by- Eric Kutter [erick]
  26. * Wrote it.
  27. \**************************************************************************/
  28. VOID vIntersectHorizontal(DDA_CLIPLINE*, LONG, POINTL*, POINTL*, LONG*);
  29. VOID vIntersectVertical(DDA_CLIPLINE*, LONG, POINTL*, POINTL*, LONG*);
  30. // the bottom 16 flags have been left blank so that they do not overlap
  31. // the PD_ (PATHDATA) flags. PD_ALL should be set too all PD_ flags so
  32. // (CLO_ALL & PD_ALL) == 0. This is asserted in clipline setup code.
  33. #define CLO_LINEDONE 0x00010000
  34. #define CLO_RECORD 0x00020000
  35. #define CLO_VERTICAL 0x00040000
  36. #define CLO_HORIZONTAL 0x00080000
  37. #define CLO_CLOSING 0x00100000
  38. #define CLO_PATHDONE 0x00200000
  39. #define CLO_LEFTTORIGHT 0x00400000
  40. #define CLO_TOPTOBOTTOM 0x00800000
  41. #define CLO_COMPLEXINTERSECTION 0x01000000
  42. #define CLO_ENUMDONE 0x02000000
  43. #define CLO_ALL 0xffff0000
  44. #define CLO_PATHFLAGS (CLO_CLOSING | CLO_PATHDONE)
  45. typedef struct _CLIPLINEENUM // cle
  46. {
  47. // fields for enumerating through a single line.
  48. ULONG cPoints;
  49. POINTFIX ptfx0;
  50. POINTFIX* pptfx1; // fixed point start
  51. FLONG fl; // misc flags
  52. LONG iStart; // start index of current run - 1
  53. LONG iC; // end index of current run
  54. ULONG cMaxRuns;
  55. ULONG* pcRuns;
  56. RUN* prun;
  57. LONG iPrevStop;
  58. DDA_CLIPLINE dda; // DDA variables for the line
  59. LONG lX0; // dda.lX0 transformed to real coordintates
  60. LONG lY0; // dda.lY0 transformed to real coordintates
  61. LONG lX1; // dda.lX1 transformed to real coordintates
  62. LONG lY1; // dda.lY1 transformed to real coordintates
  63. POINTL ptB; // first point in current segment
  64. POINTL ptC; // last point in current segment
  65. POINTL ptE; // last point in scan
  66. POINTL ptF; // first point out of scan
  67. LONG iE;
  68. LONG lYEnter; // y value entering current scan.
  69. LONG lYLeave; // y value leaving current scan.
  70. // style state:
  71. STYLEPOS spStyleStart; // style position at beginning of current line
  72. STYLEPOS spStyleEnd; // style position at end of current line
  73. STYLEPOS spTotal2; // twice the sum of the style array
  74. LONG* plStyleState; // pointer to style state in LINEATTRS
  75. // style variables from device:
  76. ULONG xStep;
  77. ULONG yStep;
  78. ULONG xyDensity;
  79. // fields for connecting lines properly:
  80. POINTFIX ptfxStartSub; // first point of current sub path
  81. } CLIPLINEENUM, *PCLIPLINEENUM;
  82. /*********************************Class************************************\
  83. *
  84. * Public Interface:
  85. *
  86. * History:
  87. *
  88. * 22-Mar-1991 -by- Eric Kutter [erick]
  89. * Added clipline stuff
  90. *
  91. * 15-Sep-1990 -by- Donald Sidoroff [donalds]
  92. * Wrote it.
  93. *
  94. \**************************************************************************/
  95. // Enumerate stuff
  96. typedef PSCAN (*PSCNFN)(RGNOBJ *, SCAN *, LONG *, BOOL);
  97. typedef struct _ENUMER /* enmr */
  98. {
  99. ERECTL ercl; // Enumerate in this rectangle
  100. PSCAN pscn; // Current scan
  101. COUNT cScans; // How many scans to enumerate
  102. COUNT iFirst; // Start at this wall
  103. COUNT iWall; // Current wall
  104. LONG iOff; // Offset to advance to next wall
  105. COUNT iFinal; // Stop at this wall
  106. ULONG iDir; // Direction we are going
  107. ULONG iType; // Rectangles or trapezoids?
  108. LONG yCurr; // Current y-coordinate
  109. LONG yDelta; // Change in y-coordinate
  110. LONG yFinal; // Stop at this y-coordinate
  111. BOOL bAll; // Enumerate whole CLIPOBJ?
  112. } ENUMER, *PENUMER; // trapezoid broken up by clipping
  113. //
  114. // 'NOTUSED' is a misnomer. This is used to expose the WNDOBJ fields
  115. // and must match the WNDOBJ declaration in 'winddi.h', except for
  116. // 'coClient':
  117. //
  118. class NOTUSED
  119. {
  120. public:
  121. PVOID pvConsumer;
  122. RECTL rclClient;
  123. SURFOBJ* psoOwner;
  124. };
  125. //
  126. // The following values are passed to vSetup.
  127. //
  128. #define CLIP_NOFORCE 0
  129. #define CLIP_FORCE 1
  130. #define CLIP_NOFORCETRIV 2
  131. // XCLIPOBJ is padded to look like WNDOBJ so EWNDOBJ can derive
  132. // from it and use all its methods. Also if we decide to pass
  133. // WNDOBJ instead of CLIPOBJ in DDI one day, we won't need to
  134. // worry about backward compatibility stuff.
  135. class XCLIPOBJ : public _CLIPOBJ, public NOTUSED, public RGNOBJ
  136. {
  137. protected:
  138. ENUMER enmr; // Enumerator
  139. COUNT cObjs; // Number of objects
  140. PCLIPLINEENUM pcle; // Clip line enumeration state
  141. // clipline methods
  142. BOOL bGetLine(EPATHOBJ *ppo, FLONG *pfl);
  143. BOOL bGetMorePoints(EPATHOBJ *ppo, FLONG *pfl);
  144. BOOL bSetup();
  145. BOOL bFindFirstScan();
  146. BOOL bFindFirstSegment();
  147. BOOL bFindNextScan();
  148. BOOL bFindNextSegment();
  149. BOOL bRecordSegment();
  150. BOOL bRecordRun(LONG& iEnd);
  151. BOOL bStyling() {return(pcle->spTotal2 > 0); }
  152. BOOL bComplexIntersection() {return(pcle->fl & CLO_COMPLEXINTERSECTION); }
  153. VOID vSetComplexIntersection() {pcle->fl |= CLO_COMPLEXINTERSECTION; }
  154. VOID vClearComplexIntersection(){pcle->fl &= ~CLO_COMPLEXINTERSECTION;}
  155. BOOL bRecordPending() {return(pcle->fl & CLO_RECORD); }
  156. VOID vSetRecordPending() {pcle->fl |= CLO_RECORD; }
  157. VOID vClearRecordPending() {pcle->fl &= ~CLO_RECORD; }
  158. BOOL bLineDone() {return(pcle->fl & CLO_LINEDONE); }
  159. VOID vSetLineDone() {pcle->fl |= CLO_LINEDONE; }
  160. BOOL bPathDone() {return(pcle->fl & CLO_PATHDONE); }
  161. BOOL bClosing() {return(pcle->fl & CLO_CLOSING); }
  162. BOOL bCloseFigure() {return(pcle->fl & PD_CLOSEFIGURE); }
  163. BOOL bEnumDone() {return(pcle->fl & CLO_ENUMDONE); }
  164. VOID vSetVertical() {pcle->fl |= CLO_VERTICAL; }
  165. VOID vSetHorizontal() {pcle->fl |= CLO_HORIZONTAL; }
  166. BOOL bSimpleClip() {return(pcle->fl & (CLO_VERTICAL |
  167. CLO_HORIZONTAL)); }
  168. // bTopToBottom and bLeftToRight must return 0 or 1.
  169. BOOL bTopToBottom() {return(!!(pcle->fl & CLO_TOPTOBOTTOM)); }
  170. BOOL bLeftToRight() {return(!!(pcle->fl & CLO_LEFTTORIGHT)); }
  171. BOOL bEmptyScan() {return(enmr.pscn->cWalls == 0); }
  172. VOID vSetLeftToRight(BOOL b)
  173. {
  174. if (b)
  175. {
  176. pcle->fl |= CLO_LEFTTORIGHT;
  177. enmr.iOff = 1;
  178. }
  179. else
  180. {
  181. pcle->fl &= ~CLO_LEFTTORIGHT;
  182. enmr.iOff = -1;
  183. }
  184. }
  185. LONG xWall(LONG l)
  186. {
  187. return(xGet(enmr.pscn,(PTRDIFF)(enmr.iWall + l)));
  188. }
  189. VOID vIntersectScan(LONG y, PPOINTL ppt0, PPOINTL ppt1, PLONG pi0);
  190. BOOL bIntersectWall(LONG i, PPOINTL ppt0, PPOINTL ppt1, PLONG pi0);
  191. VOID DBGDISPLAYDDA();
  192. VOID DBGDISPLAYSTATE(PSZ psz);
  193. public:
  194. VOID vSetup(REGION *prgn, ERECTL& ercl_, int iForcedClip = CLIP_NOFORCE);
  195. ERECTL& erclExclude() { return(*((ERECTL *) &rclBounds)); }
  196. // Merge the clipping bounding box with the region in CLIP_bEnum().
  197. VOID vMergeWhenEnumerate() { enmr.bAll = FALSE; }
  198. ULONG cEnumStart(BOOL, ULONG, ULONG, ULONG); // CLIPOBJ.CXX
  199. BOOL bEnum(ULONG, PVOID, ULONG* pcjFilled=0); // CLIPOBJ.CXX
  200. PATHOBJ *ppoGetPath(); // CLIPOBJ.CXX
  201. VOID vEnumPathStart(PATHOBJ*, SURFACE*, LINEATTRS* );
  202. BOOL bEnumPath(PATHOBJ* ppo, ULONG cj, CLIPLINE* pcl);
  203. BOOL bEnumStartLine(FLONG flPath);
  204. BOOL bEnumLine(ULONG cj, CLIPLINE* pcl);
  205. VOID vUpdateStyleState();
  206. LONG lGetStyleState(IN STYLEPOS sp)
  207. {
  208. return(MAKELONG(sp % pcle->xyDensity, sp / pcle->xyDensity));
  209. }
  210. VOID vFindScan(RECTL *prcl, LONG y);
  211. VOID vFindSegment(RECTL *prcl, LONG x, LONG y);
  212. };
  213. class ECLIPOBJ : public XCLIPOBJ
  214. {
  215. public:
  216. ECLIPOBJ(REGION *prgn, ERECTL& ercl_, int iForcedClip = CLIP_NOFORCE)
  217. {
  218. vSetup(prgn,ercl_,iForcedClip);
  219. }
  220. ECLIPOBJ() {prgn = (REGION *) NULL;}
  221. };
  222. // Define some stuff for Engine components that use ECLIPOBJs
  223. #define CLIPOBJ_ENUM_LIMIT 20
  224. typedef struct _CLIPENUMRECT
  225. {
  226. ULONG c;
  227. RECTL arcl[CLIPOBJ_ENUM_LIMIT];
  228. } CLIPENUMRECT;
  229. #endif // #ifndef _CLIPOBJ_HXX