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.

294 lines
6.2 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * DpPath
  8. *
  9. * Abstract:
  10. *
  11. * A DDI-level path object. Corresponds to a GpPath object.
  12. *
  13. * Notes:
  14. *
  15. *
  16. *
  17. * Created:
  18. *
  19. * 12/01/1998 andrewgo
  20. * Created it.
  21. * 03/24/1999 agodfrey
  22. * Moved into separate file.
  23. *
  24. \**************************************************************************/
  25. #ifndef _DPPATH_HPP
  26. #define _DPPATH_HPP
  27. //--------------------------------------------------------------------------
  28. // Represent a path
  29. //--------------------------------------------------------------------------
  30. class DpPath : public GpObject
  31. {
  32. public:
  33. enum DpPathFlags // !!! Rename and move?
  34. {
  35. PossiblyNonConvex = 0x00,
  36. Convex = 0x01,
  37. ConvexRectangle = 0x03 // Used for Rectangle and Oval.
  38. };
  39. ~DpPath() {}
  40. // Start/end a subpath
  41. virtual VOID StartFigure()
  42. {
  43. IsSubpathActive = FALSE;
  44. UpdateUid();
  45. }
  46. virtual GpStatus CloseFigure();
  47. virtual GpStatus CloseFigures();
  48. BOOL HasCurve() const
  49. {
  50. return HasBezier;
  51. }
  52. virtual BOOL IsValid() const
  53. {
  54. return GpObject::IsValid(ObjectTagPath);
  55. }
  56. BOOL IsConvex() const
  57. {
  58. return ((Flags & Convex) != 0);
  59. }
  60. INT GetSubpathCount() const
  61. {
  62. return SubpathCount;
  63. }
  64. virtual GpStatus Flatten(
  65. DynByteArray *flattenTypes,
  66. DynPointFArray *flattenPoints,
  67. const GpMatrix *matrix = NULL,
  68. const REAL flatness = FlatnessDefault
  69. ) const = 0;
  70. virtual const DpPath*
  71. GetFlattenedPath(
  72. const GpMatrix* matrix,
  73. DpEnumerationType type,
  74. const DpPen* pen = NULL
  75. ) const = 0;
  76. virtual GpStatus
  77. GetBounds(
  78. GpRect *bounds,
  79. const GpMatrix *matrix = NULL,
  80. const DpPen* pen = NULL,
  81. REAL dpiX = 0,
  82. REAL dpiY = 0
  83. ) const = 0;
  84. virtual GpStatus
  85. GetBounds(
  86. GpRectF *bounds,
  87. const GpMatrix *matrix = NULL,
  88. const DpPen* pen = NULL,
  89. REAL dpiX = 0,
  90. REAL dpiY = 0
  91. ) const = 0;
  92. VOID
  93. Offset(
  94. REAL dx,
  95. REAL dy
  96. );
  97. GpFillMode GetFillMode() const
  98. {
  99. return FillMode;
  100. }
  101. VOID SetFillMode(GpFillMode fillMode)
  102. {
  103. if (FillMode != fillMode)
  104. {
  105. FillMode = fillMode;
  106. UpdateUid();
  107. }
  108. }
  109. // Get path data
  110. INT GetPointCount() const
  111. {
  112. return Points.GetCount();
  113. }
  114. const GpPointF* GetPathPoints() const
  115. {
  116. // NOTE: We're returning a pointer to our
  117. // internal buffer here. No copy is made.
  118. return Points.GetDataBuffer();
  119. }
  120. const BYTE* GetPathTypes() const
  121. {
  122. // NOTE: We're returning a pointer to our
  123. // internal buffer here. No copy is made.
  124. return Types.GetDataBuffer();
  125. }
  126. BOOL IsRectangular() const
  127. {
  128. const GpPointF *points;
  129. INT count;
  130. if (HasCurve() || (GetSubpathCount() != 1))
  131. {
  132. return FALSE;
  133. }
  134. count = GetPointCount();
  135. points = GetPathPoints();
  136. if (count > 0 && points != NULL)
  137. {
  138. for (INT i=0; i<count; i++)
  139. {
  140. INT j = (i+1) % count;
  141. if (REALABS(points[i].X-points[j].X) > REAL_EPSILON &&
  142. REALABS(points[i].Y-points[j].Y) > REAL_EPSILON)
  143. {
  144. // Points are not at 90 degree angles, not rectangular.
  145. return FALSE;
  146. }
  147. }
  148. return TRUE;
  149. }
  150. return FALSE;
  151. }
  152. static BOOL
  153. ValidatePathTypes(
  154. const BYTE* types,
  155. INT count,
  156. INT* subpathCount,
  157. BOOL* hasBezier
  158. );
  159. GpStatus GetPathData(GpPathData* pathData);
  160. GpStatus SetPathData(const GpPathData* pathData);
  161. virtual ObjectType GetObjectType() const { return ObjectTypePath; }
  162. virtual UINT GetDataSize() const;
  163. virtual GpStatus GetData(IStream * stream) const;
  164. virtual GpStatus SetData(const BYTE * dataBuffer, UINT size);
  165. virtual DpPath*
  166. CreateWidenedPath(
  167. const DpPen* pen,
  168. DpContext* context,
  169. BOOL outline = FALSE
  170. ) const
  171. {
  172. return DpcCreateWidenedPath(this, pen, context, outline);
  173. }
  174. virtual VOID
  175. DeletePath()
  176. {
  177. DpcDeletePath(this);
  178. }
  179. virtual DpPath*
  180. ClonePath()
  181. {
  182. return DpcClonePath(this);
  183. }
  184. virtual VOID
  185. Transform(
  186. GpMatrix* matrix
  187. )
  188. {
  189. DpcTransformPath(this, matrix);
  190. }
  191. BOOL
  192. virtual IsRectangle(
  193. const GpMatrix * matrix,
  194. GpRectF * transformedBounds
  195. ) const;
  196. // Debug only.
  197. #if DBG
  198. void DisplayPath();
  199. #endif
  200. class SubpathInfo
  201. {
  202. public:
  203. INT StartIndex;
  204. INT Count;
  205. BOOL IsClosed;
  206. };
  207. protected: // GDI+ INTERNAL
  208. DpPath()
  209. {
  210. InitDefaultState(FillModeAlternate);
  211. SetValid(TRUE);
  212. }
  213. DpPath(
  214. const GpPointF *points,
  215. INT count,
  216. GpPointF *stackPoints,
  217. BYTE *stackTypes,
  218. INT stackCount,
  219. GpFillMode fillMode = FillModeAlternate,
  220. DpPathFlags flags = PossiblyNonConvex
  221. );
  222. DpPath(const DpPath *path);
  223. virtual VOID InitDefaultState(GpFillMode fillMode);
  224. virtual DynArray<SubpathInfo> *GetSubpathInformation() const = 0;
  225. protected:
  226. VOID SetValid(BOOL valid)
  227. {
  228. GpObject::SetValid(valid ? ObjectTagPath : ObjectTagInvalid);
  229. }
  230. protected:
  231. BOOL HasBezier; // does path have Bezier segments?
  232. DynArrayIA<BYTE, 16> Types;
  233. DynArrayIA<GpPointF, 16> Points;
  234. GpFillMode FillMode;
  235. DpPathFlags Flags;
  236. BOOL IsSubpathActive; // whether there is an active subpath
  237. INT SubpathCount; // number of subpaths
  238. };
  239. #endif