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.

229 lines
4.7 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1999 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * XPath.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Interface of GpXPath and its iterator classes
  12. *
  13. * Revision History:
  14. *
  15. * 11/08/1999 ikkof
  16. * Created it.
  17. *
  18. \**************************************************************************/
  19. #ifndef _XPATH_HPP
  20. #define _XPATH_HPP
  21. enum XPathFlags
  22. {
  23. HasBezierFlag = 1,
  24. IsRationalFlag = 2
  25. };
  26. class GpXPath
  27. {
  28. private:
  29. // We now use an ObjectTag to determine if the object is valid
  30. // instead of using a BOOL. This is much more robust and helps
  31. // with debugging. It also enables us to version our objects
  32. // more easily with a version number in the ObjectTag.
  33. ObjectTag Tag; // Keep this as the 1st value in the object!
  34. protected:
  35. VOID SetValid(BOOL valid)
  36. {
  37. Tag = valid ? ObjectTagXPath : ObjectTagInvalid;
  38. }
  39. protected:
  40. INT Flags;
  41. BYTE* Types;
  42. GpXPoints XPoints;
  43. GpFillMode FillMode;
  44. INT SubpathCount; // number of subpaths
  45. public:
  46. GpXPath(const GpPath* path);
  47. GpXPath(
  48. const GpPath* path,
  49. const GpRectF& rect,
  50. const GpPointF* points,
  51. INT count,
  52. WarpMode warpMode
  53. );
  54. ~GpXPath()
  55. {
  56. if(Types)
  57. GpFree(Types);
  58. SetValid(FALSE); // so we don't use a deleted object
  59. }
  60. INT GetPointCount()
  61. {
  62. return XPoints.Count;
  63. }
  64. INT GetPointDimension()
  65. {
  66. return XPoints.Dimension;
  67. }
  68. REALD* GetPathPoints()
  69. {
  70. return XPoints.Data;
  71. }
  72. BYTE* GetPathTypes()
  73. {
  74. return Types;
  75. }
  76. VOID SetFillMode(GpFillMode fillMode)
  77. {
  78. FillMode = fillMode;
  79. }
  80. GpFillMode GetFillMode()
  81. {
  82. return FillMode;
  83. }
  84. VOID SetBezierFlag()
  85. {
  86. Flags |= HasBezierFlag;
  87. }
  88. BOOL HasBezier()
  89. {
  90. if(Flags & HasBezierFlag)
  91. return TRUE;
  92. else
  93. return FALSE;
  94. }
  95. VOID SetRationalFlag()
  96. {
  97. Flags |= IsRationalFlag;
  98. }
  99. BOOL IsRational()
  100. {
  101. if(Flags & IsRationalFlag)
  102. return TRUE;
  103. else
  104. return FALSE;
  105. }
  106. BOOL IsValid() const
  107. {
  108. ASSERT((Tag == ObjectTagXPath) || (Tag == ObjectTagInvalid));
  109. #if DBG
  110. if (Tag == ObjectTagInvalid)
  111. {
  112. WARNING1("Invalid XPath");
  113. }
  114. #endif
  115. return (Tag == ObjectTagXPath);
  116. }
  117. GpStatus
  118. Flatten(
  119. DynByteArray* flattenTypes,
  120. DynPointFArray* flattenPoints,
  121. const GpMatrix *matrix
  122. );
  123. protected:
  124. VOID InitDefaultState()
  125. {
  126. SetValid(FALSE);
  127. Flags = 0;
  128. Types = NULL;
  129. FillMode = FillModeAlternate;
  130. SubpathCount = 0;
  131. }
  132. GpStatus
  133. ConvertToPerspectivePath(
  134. const GpPath* path,
  135. const GpRectF& rect,
  136. const GpPointF* points,
  137. INT count
  138. );
  139. GpStatus
  140. ConvertToBilinearPath(
  141. const GpPath* path,
  142. const GpRectF& rect,
  143. const GpPointF* points,
  144. INT count
  145. );
  146. };
  147. class GpXPathIterator
  148. {
  149. private:
  150. // We now use an ObjectTag to determine if the object is valid
  151. // instead of using a BOOL. This is much more robust and helps
  152. // with debugging. It also enables us to version our objects
  153. // more easily with a version number in the ObjectTag.
  154. ObjectTag Tag; // Keep this as the 1st value in the object!
  155. protected:
  156. VOID SetValid(BOOL valid)
  157. {
  158. Tag = valid ? ObjectTagXPathIterator : ObjectTagInvalid;
  159. }
  160. public:
  161. GpXPathIterator(GpXPath* xpath);
  162. ~GpXPathIterator()
  163. {
  164. SetValid(FALSE); // so we don't use a deleted object
  165. }
  166. INT Enumerate(GpXPoints* xpoints, BYTE* types);
  167. INT NextSubpath(INT* startIndex, INT* endIndex, BOOL* isClosed);
  168. INT EnumerateSubpath(GpXPoints* xpoints, BYTE* types);
  169. INT NextPathType(BYTE* pathType, INT* startIndex, INT* endIndex);
  170. INT EnumeratePathType(GpXPoints* xpoints, BYTE* types);
  171. BOOL IsValid() const
  172. {
  173. ASSERT((Tag == ObjectTagXPathIterator) || (Tag == ObjectTagInvalid));
  174. #if DBG
  175. if (Tag == ObjectTagInvalid)
  176. {
  177. WARNING1("Invalid XPathIterator");
  178. }
  179. #endif
  180. return (Tag == ObjectTagXPathIterator);
  181. }
  182. private:
  183. VOID Initialize();
  184. private:
  185. const BYTE* Types;
  186. GpXPoints XPoints;
  187. INT TotalCount;
  188. INT Index;
  189. INT SubpathStartIndex;
  190. INT SubpathEndIndex;
  191. INT TypeStartIndex;
  192. INT TypeEndIndex;
  193. };
  194. #endif