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.

373 lines
10 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: rgnobj.hxx
  3. *
  4. * Region user object
  5. *
  6. * Created: 27-Jun-1990 12:39:38
  7. * Author: Donald Sidoroff [donalds]
  8. *
  9. * Copyright (c) 1990-1999 Microsoft Corporation
  10. \**************************************************************************/
  11. #ifndef _RGNOBJ_HXX
  12. #define _RGNOBJ_HXX 1
  13. // Constants for bSubtract
  14. #define SR_LEFT_NOTCH 0x00
  15. #define SR_HORIZ_CLIP 0x01
  16. #define SR_HORIZ_NOTCH 0x02
  17. #define SR_RIGHT_NOTCH 0x03
  18. #define SR_TOP_NOTCH 0x00
  19. #define SR_VERT_CLIP 0x04
  20. #define SR_VERT_NOTCH 0x08
  21. #define SR_BOTTOM_NOTCH 0x0c
  22. class EPATHOBJ;
  23. class STACKOBJ;
  24. class PDEVOBJ;
  25. #include "region.hxx"
  26. class EDGE;
  27. typedef EDGE *PEDGE;
  28. /*********************************Class************************************\
  29. * class RGNOBJ
  30. *
  31. * User object for REGION class.
  32. *
  33. * Public Interface:
  34. *
  35. * RGNOBJ Constructor for derived classes
  36. * ~RGNOBJ() Destructor
  37. *
  38. * BOOL bValid Validator
  39. * HRGN hrgn Get handle to region
  40. * VOID vCopy Copy region (source <= target)
  41. * BOOL bCopy Copy region
  42. * BOOL bSwap Swap region
  43. * BOOL bDelete Delete region
  44. * BOOL bExpand Expand region
  45. * VOID vGet_rcl Get bounding rectangle of region
  46. * COUNT cGet_cRefs Get reference count
  47. * VOID vSelect Select region into this HDC
  48. * VOID vUnselect Unselect region
  49. * PSCAN pscnGet Get next scan
  50. * PSCAN pscnGot Get previous scan
  51. * LONG iComplexity Get region complexity
  52. * BOOL bBounded Is point in bounding rectangle
  53. * VOID vTighten Tighten the bounding rectandle
  54. * LONG xGet Get X coordinate
  55. * BOOL bInside Is point in region
  56. * BOOL bInside Is rectangle in regon
  57. * BOOL bEqual Is region equal
  58. * BOOL bOffset Offset region
  59. * VOID vSet Set region to NULL region
  60. * VOID vSet Set region to SINGLE rectangle
  61. * BOOL bSet Set region to OR of rectangles
  62. * PSCAN pscnMerge Merge scans
  63. * BOOL bMerge Merge regions
  64. * LONG iCombine Combine regions
  65. * LONG iCombine Combine rect and region
  66. *
  67. * History:
  68. * 05-Apr-1991 -by- Wendy Wu [wendywu]
  69. * Added protected member functions used by RGNMEMOBJ to convert paths into
  70. * regions.
  71. *
  72. * 09-Jul-1990 -by- Donald Sidoroff [donalds]
  73. * Wrote it.
  74. \**************************************************************************/
  75. class RGNOBJ /* ro */
  76. {
  77. public:
  78. REGION *prgn;
  79. protected:
  80. public:
  81. RGNOBJ() {}
  82. RGNOBJ(REGION *prgn_) { prgn = prgn_; }
  83. ~RGNOBJ() {}
  84. REGION *prgnGet() { return(prgn); }
  85. VOID vSetRgn(REGION *prgn_) { prgn = prgn_; }
  86. HRGN hrgnAssociate()
  87. {
  88. #if DBG
  89. RGNLOG rl(prgn,"RGNOBJ::hrgnAssociate");
  90. HRGN hrgn = (HRGN)HmgInsertObject(prgn,0,RGN_TYPE);
  91. rl.vRet((ULONG_PTR)(hrgn));
  92. return(hrgn);
  93. #else
  94. return((HRGN)HmgInsertObject(prgn,0,RGN_TYPE));
  95. #endif
  96. }
  97. VOID vCopy(RGNOBJ&);
  98. BOOL bCopy(RGNOBJ&);
  99. BOOL bSwap(RGNOBJ *);
  100. BOOL bExpand(ULONGSIZE_T);
  101. VOID vStamp() {prgn->vStamp();}
  102. BOOL bValid() { return(prgn != (REGION *) NULL); }
  103. VOID vDeleteRGNOBJ();
  104. //
  105. // The compiler is smart enough to optimize out the
  106. // return TRUE and if it's left inline the compiler
  107. // can optimize out constant conditionals based on bDelete.
  108. //
  109. BOOL bDeleteRGNOBJ()
  110. {
  111. vDeleteRGNOBJ();
  112. return(TRUE);
  113. }
  114. LONG xGet(SCAN *pscn, PTRDIFF i) { return(pscn->ai_x[i].x); }
  115. ULONGSIZE_T sizeRgn() { return(prgn->sizeRgn); }
  116. VOID vGet_rcl(RECTL *prcl) { *prcl = prgn->rcl; }
  117. SCAN *pscnGet(SCAN *pscn) {return((SCAN *) ((BYTE *) pscn + pscn->sizeGet()));}
  118. SCAN *pscnGot(SCAN *pscn)
  119. {
  120. pscn = (SCAN *) &((COUNT *) pscn)[-1];
  121. return((SCAN *) ((BYTE *) pscn - (pscn->sizeGet() - sizeof(COUNT))));
  122. }
  123. // Return rectangle that lies completely within region. Essentially
  124. // enumerate first rectange in region.
  125. VOID vGetSubRect(RECTL *prcl);
  126. BOOL bIsRectEntirelyInRegion(RECTL *prcl);
  127. COUNT cGet_cRefs() { return(prgn->cRefs); }
  128. VOID vSelect(HDC hdc_)
  129. {
  130. RGNLOG rl(prgn,"RGNOBJ::vSelect",PtrToUlong(hdc_),prgn->cRefs);
  131. prgn->cRefs++;
  132. }
  133. VOID vUnselect()
  134. {
  135. RGNLOG rl(prgn,"RGNOBJ::vUnselect",(LONG)prgn->cRefs);
  136. ASSERTGDI(prgn->cRefs, "Invalid ref count\n");
  137. prgn->cRefs--;
  138. }
  139. LONG iComplexity()
  140. {
  141. if (prgn->cScans == 1)
  142. return(NULLREGION);
  143. else if (prgn->sizeRgn <= SINGLE_REGION_SIZE)
  144. return(SIMPLEREGION);
  145. else
  146. return(COMPLEXREGION);
  147. }
  148. BOOL bRectl() {return(prgn->sizeRgn == SINGLE_REGION_SIZE);}
  149. BOOL bBounded(POINTL *pptl)
  150. {
  151. return((pptl->x >= prgn->rcl.left) &&
  152. (pptl->y < prgn->rcl.bottom) &&
  153. (pptl->x < prgn->rcl.right) &&
  154. (pptl->y >= prgn->rcl.top));
  155. }
  156. BOOL bContain(RGNOBJ& ro)
  157. {
  158. return((prgn->rcl.left <= ro.prgn->rcl.left)&&
  159. (prgn->rcl.right >= ro.prgn->rcl.right)&&
  160. (prgn->rcl.top <= ro.prgn->rcl.top)&&
  161. (prgn->rcl.bottom >= ro.prgn->rcl.bottom));
  162. }
  163. BOOL bContain(RECTL& rcl)
  164. {
  165. return((prgn->rcl.left <= rcl.left)&&
  166. (prgn->rcl.right >= rcl.right)&&
  167. (prgn->rcl.top <= rcl.top)&&
  168. (prgn->rcl.bottom >= rcl.bottom));
  169. }
  170. VOID vTighten(); // RGNOBJ.CXX
  171. ULONGSIZE_T sizeSave();
  172. BOOL bCreate(EPATHOBJ&, EXFORMOBJ *); // RGNOBJ.CXX
  173. BOOL bOutline(EPATHOBJ&, EXFORMOBJ *); // RGNOBJ.CXX
  174. LONG xMyGet(SCAN*, LONG, LONG); // RGNOBJ.CXX
  175. BOOL bInside(POINTL *);
  176. BOOL bInside(RECTL *);
  177. BOOL bEqual(RGNOBJ&);
  178. BOOL bOffset(POINTL *);
  179. VOID vSet();
  180. VOID vSet(RECTL *);
  181. BOOL bMerge(RGNOBJ&, RGNOBJ&, FCHAR);
  182. LONG iCombine(RGNOBJ&, RGNOBJ&, LONG);
  183. VOID vDownload(VOID *);
  184. VOID vComputeUncoveredSpriteRegion(PDEVOBJ&);
  185. BOOL SyncUserRgn();
  186. VOID UpdateUserRgn();
  187. BOOL bSet(ULONG cRect, RECTL *prcl);
  188. #if DBG
  189. VOID vPrintScans();
  190. BOOL bValidateFramedRegion();
  191. #endif
  192. };
  193. /*********************************Class************************************\
  194. * class RGNOBJAPI : public RGNOBJ
  195. *
  196. * User object for REGION class for API regions.
  197. *
  198. * History:
  199. * 27-Oct-1992 -by- Donald Sidoroff [donalds]
  200. * Wrote it.
  201. \**************************************************************************/
  202. class RGNOBJAPI : public RGNOBJ
  203. {
  204. private:
  205. BOOL bSubtractComplex(RECTL *, RECTL *, int);
  206. public:
  207. HRGN hrgn_;
  208. BOOL bSelect_;
  209. RGNOBJAPI(HRGN hrgn,BOOL bSelect);
  210. ~RGNOBJAPI()
  211. {
  212. RGNLOG rl(hrgn_,prgn,"RGNOBJAPI::~RGNOBJAPI");
  213. if (!bSelect_)
  214. {
  215. UpdateUserRgn();
  216. }
  217. if (prgn != (REGION *)NULL)
  218. {
  219. DEC_EXCLUSIVE_REF_CNT(prgn);
  220. }
  221. }
  222. BOOL bCopy(RGNOBJ& roSrc);
  223. BOOL bSwap(RGNOBJ *pro);
  224. BOOL bDeleteRGNOBJAPI();
  225. BOOL bDeleteHandle();
  226. BOOL bSubtract(RECTL *, RECTL *, int);
  227. HRGN hrgn() { return(hrgn_); }
  228. LONG iCombine(RGNOBJ& roSrc1,RGNOBJ& roSrc2,LONG iMode);
  229. };
  230. /*********************************Class************************************\
  231. * class RGNMEMOBJ : public RGNOBJ
  232. *
  233. * Memory object for REGION class.
  234. *
  235. * Public Interface:
  236. *
  237. * RGNMEMOBJ Constructor for derived classes
  238. * RGNMEMOBJ(EPATHOBJ&, FLONG) Constructor for converting paths to regions.
  239. * ~RGNMEMOBJ() Destructor
  240. *
  241. * VOID vInit Initialize memory object
  242. *
  243. * History:
  244. * 05-Apr-1991 -by- Wendy Wu [wendywu]
  245. * Added RGNMEMOBJ constructor for converting paths into regions.
  246. *
  247. * 09-Jul-1990 -by- Donald Sidoroff [donalds]
  248. * Wrote it.
  249. \**************************************************************************/
  250. class RGNMEMOBJ : public RGNOBJ /* rmo */
  251. {
  252. public:
  253. RGNMEMOBJ();
  254. RGNMEMOBJ(ULONGSIZE_T);
  255. RGNMEMOBJ(BOOL);
  256. RGNMEMOBJ(EPATHOBJ& po, FLONG fl = ALTERNATE, RECTL *pb = NULL ) {vCreate(po,fl,pb);}
  257. VOID vInitialize(ULONGSIZE_T);
  258. ~RGNMEMOBJ() {}
  259. VOID vCreate(EPATHOBJ& epo, FLONG fl, RECTL *pBound = NULL);
  260. VOID vInit(ULONGSIZE_T size)
  261. {
  262. vSet();
  263. prgn->sizeObj = size;
  264. prgn->cRefs = 0;
  265. prgn->iUnique = 0;
  266. }
  267. LONG iReduce(RGNOBJ& roSrc); // only because bBuster is so bad
  268. BOOL bMergeScanline(STACKOBJ& sto);
  269. private:
  270. BOOL bFastFillWrapper(EPATHOBJ&);
  271. BOOL bFastFill(EPATHOBJ&,LONG,POINTFIX*);
  272. BOOL bAddScans(LONG, PEDGE, FLONG);
  273. BOOL bAddNullScan(LONG, LONG);
  274. };
  275. /*********************************Class************************************\
  276. *
  277. * Public Interface:
  278. *
  279. * History:
  280. * 22-Oct-1993 -by- Eric Kutter [erick]
  281. * Wrote it.
  282. \**************************************************************************/
  283. class RGNMEMOBJTMP : public RGNMEMOBJ /* rmo */
  284. {
  285. public:
  286. RGNMEMOBJTMP() : RGNMEMOBJ() {}
  287. RGNMEMOBJTMP(ULONGSIZE_T s) : RGNMEMOBJ(s) {}
  288. RGNMEMOBJTMP(BOOL b) : RGNMEMOBJ(b) {}
  289. RGNMEMOBJTMP(EPATHOBJ& po, FLONG fl = ALTERNATE, RECTL *pb = NULL) : RGNMEMOBJ(po,fl,pb) {}
  290. ~RGNMEMOBJTMP()
  291. {
  292. RGNLOG rl(prgn,"RGNMEMOBJTMP::~RGNMEMOBJTMP");
  293. bDeleteRGNOBJ();
  294. }
  295. };
  296. int
  297. GreExtSelectClipRgnLocked(
  298. XDCOBJ &dco,
  299. PRECTL prcl,
  300. int iMode);
  301. extern FCHAR gafjRgnOp[]; // Table of op-codes for bMerge
  302. #endif // #ifndef _RGNOBJ_HXX