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.

170 lines
3.5 KiB

  1. #include "precomp.hpp"
  2. GpStatus
  3. GpPath::MoveTo(const GpPointF point)
  4. {
  5. INT origCount = GetPointCount();
  6. GpPointF* pointbuf = Points.AddMultiple(1);
  7. BYTE* typebuf = Types.AddMultiple(1);
  8. if (pointbuf == NULL || typebuf == NULL)
  9. {
  10. Points.SetCount(origCount);
  11. Types.SetCount(origCount);
  12. return OutOfMemory;
  13. }
  14. *typebuf = PathPointTypeStart;
  15. SubpathCount++; // start a new subpath
  16. GpMemcpy(pointbuf, (PVOID)&point, sizeof(GpPointF));
  17. IsSubpathActive = TRUE;
  18. return Ok;
  19. }
  20. BOOL APIENTRY PATHOBJ_bMoveTo(
  21. PVOID *ppo,
  22. POINTFIX ptfx
  23. )
  24. {
  25. GpPointF point(FIX4TOREAL(ptfx.x), FIX4TOREAL(ptfx.y));
  26. GpPath *path = (GpPath*)ppo;
  27. return (path->MoveTo(point) == Ok ? TRUE : FALSE);
  28. }
  29. GpStatus
  30. GpPath::AddPoints(
  31. const GpPointF *points,
  32. ULONG count,
  33. PathPointType pointType)
  34. {
  35. if (pointType != PathPointTypeLine && pointType != PathPointTypeBezier)
  36. return InvalidParameter;
  37. INT origCount = GetPointCount();
  38. GpPointF* pointbuf = Points.AddMultiple(count);
  39. BYTE* typebuf = Types.AddMultiple(count);
  40. if(pointbuf == NULL || typebuf == NULL)
  41. {
  42. // Resize the original size.
  43. Points.SetCount(origCount);
  44. Types.SetCount(origCount);
  45. return OutOfMemory;
  46. }
  47. // Copy path point data
  48. GpMemcpy(pointbuf, points, count*sizeof(GpPointF));
  49. GpMemset(typebuf, pointType, count);
  50. return Ok;
  51. }
  52. #define POINTS_BUFFER_SIZE 3*6
  53. BOOL APIENTRY PATHOBJ_bPolyLineTo(
  54. PVOID *ppo,
  55. POINTFIX *pptfx,
  56. ULONG cptfx
  57. )
  58. {
  59. GpPath *path = (GpPath*)ppo;
  60. GpPointF *points = NULL, apoint[POINTS_BUFFER_SIZE];
  61. BOOL ret = FALSE;
  62. if (!path->IsValid() || !pptfx || cptfx == 0)
  63. return FALSE;
  64. if (cptfx > POINTS_BUFFER_SIZE)
  65. {
  66. points = new GpPointF[cptfx];
  67. if (points == NULL)
  68. return FALSE;
  69. }
  70. else
  71. points = apoint;
  72. // convert FIX4 to REAL
  73. for (ULONG i = 0; i < cptfx; i++)
  74. {
  75. points[i].X = FIX4TOREAL(pptfx[i].x);
  76. points[i].Y = FIX4TOREAL(pptfx[i].y);
  77. }
  78. if (path->AddPoints(points, cptfx, PathPointTypeLine) == Ok)
  79. ret = TRUE;
  80. if (points != apoint)
  81. delete [] points;
  82. return ret;
  83. }
  84. BOOL APIENTRY PATHOBJ_bPolyBezierTo(
  85. PVOID *ppo,
  86. POINTFIX *pptfx,
  87. ULONG cptfx
  88. )
  89. {
  90. GpPath *path = (GpPath*)ppo;
  91. GpPointF *points = NULL, apoint[POINTS_BUFFER_SIZE];
  92. BOOL ret = FALSE;
  93. ASSERT(cptfx % 3 == 0);
  94. if (!path->IsValid() || pptfx == NULL || cptfx == 0 || (cptfx % 3 != 0))
  95. return FALSE;
  96. if (cptfx > POINTS_BUFFER_SIZE)
  97. {
  98. points = new GpPointF[cptfx];
  99. if (points == NULL)
  100. return FALSE;
  101. }
  102. else
  103. points = apoint;
  104. // convert FIX4 to REAL
  105. for (ULONG i = 0; i < cptfx; i++)
  106. {
  107. points[i].X = FIX4TOREAL(pptfx[i].x);
  108. points[i].Y = FIX4TOREAL(pptfx[i].y);
  109. }
  110. if (path->AddPoints(points, cptfx, PathPointTypeBezier) == Ok)
  111. {
  112. path->SetHasBezier(TRUE);
  113. ret = TRUE;
  114. }
  115. if (points != apoint)
  116. delete [] points;
  117. return ret;
  118. }
  119. BOOL APIENTRY PATHOBJ_bCloseFigure(
  120. PVOID *ppo
  121. )
  122. {
  123. ((GpPath*)ppo)->CloseFigure();
  124. return TRUE;
  125. }