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.

174 lines
6.0 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * Line.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Definition of the classes used for drawing one-pixel-wide lines.
  12. *
  13. * History:
  14. *
  15. * 3/31/1999 AMatos
  16. * Created it
  17. * 9/17/1999 AGodfrey
  18. * Separated aliased from antialiased
  19. *
  20. \**************************************************************************/
  21. #ifndef LINE_HPP
  22. #define LINE_HPP
  23. // If line coordinate rounding is NOT to be dependent on line direction,
  24. // then define the following (see Office 10 bug 281816). The original
  25. // behavior of the DDA is to have rounding dependent on line direction,
  26. // so don't define the following if you want that behavior.
  27. #define LINEADJUST281816
  28. // This class implements drawing of solid one-pixel wide lines.
  29. // The lines can be aliased or anti-aliased and supports clipping.
  30. // The class keeps all the DDA state as member variables. Note that
  31. // currently it must be declared on the stack because of the Real
  32. // member (!!!Take this out)
  33. class OnePixelLineDDAAliased
  34. {
  35. public:
  36. // General members, used by aliased and anti-aliased
  37. // drawing.
  38. BOOL IsXMajor;
  39. BOOL Flipped; // Set when the end-points are switched
  40. INT DMajor, DMinor; // Deltas
  41. INT MinorDir; // 1 if minor is increasing and -1 if not.
  42. INT MajorStart, MajorEnd; // Major limits.
  43. INT MinorStart, MinorEnd; // Minor limits.
  44. REAL Slope; // Slope and its inverse.
  45. REAL InvSlope;
  46. ARGB Color; // The solid color in ARGB format.
  47. INT ErrorUp; // Increase in the error
  48. INT ErrorDown; // Decrease when steping
  49. BOOL IsEndExclusive;
  50. // Aliased specific
  51. INT Error; // The current error for aliased lines.
  52. // Used for clipping
  53. INT MajorIn; // The limits of the clipping rectangle.
  54. INT MajorOut;
  55. INT MinorIn;
  56. INT MinorOut;
  57. // Index of the drawing function to be used.
  58. INT DrawFuncIndex;
  59. // Maximum width of the clipping rectangle in pixels.
  60. INT MaximumWidth;
  61. public:
  62. // Public Functions
  63. BOOL SetupAliased();
  64. BOOL SetupCommon( GpPointF *point1, GpPointF *point2, BOOL drawLast, INT width );
  65. VOID DrawXMajor(DpScanBuffer *scan);
  66. VOID DrawYMajor(DpScanBuffer *scan);
  67. VOID DrawXMajorClip(DpScanBuffer *scan);
  68. VOID DrawYMajorClip(DpScanBuffer *scan);
  69. BOOL IsInDiamond( INT xFrac, INT yFrac, BOOL slopeIsOne,
  70. BOOL slopeIsPosOne );
  71. BOOL ClipRectangle(const GpRect* clipRect);
  72. BOOL StepUpAliasedClip();
  73. };
  74. // Antialiased lines are usually drawn using aarasterizer.cpp
  75. // rather than aaline.cpp. If aaline.cpp is to be used, define
  76. // AAONEPIXELLINE_SUPPORT
  77. #ifdef AAONEPIXELLINE_SUPPORT
  78. class OnePixelLineDDAAntiAliased
  79. {
  80. public:
  81. // General members, used by aliased and anti-aliased
  82. // drawing.
  83. BOOL IsXMajor;
  84. BOOL Flipped; // Set when the end-points are switched
  85. INT DMajor, DMinor; // Deltas
  86. INT MinorDir; // 1 if minor is increasing and -1 if not.
  87. INT MajorStart, MajorEnd; // Major limits.
  88. INT MinorStart, MinorEnd; // Minor limits.
  89. REAL Slope; // Slope and its inverse.
  90. REAL InvSlope;
  91. ARGB Color; // The solid color in ARGB format.
  92. INT ErrorUp; // Increase in the error
  93. INT ErrorDown; // Decrease when steping
  94. BOOL IsEndExclusive;
  95. // AntiAliased specific
  96. REAL InvDelta; // The inverse of the major delta, needed
  97. // to calculate the 4 end points of the
  98. // aa line.
  99. REAL LineLength;
  100. // An antialised line is drawed as 2 or three common lines. The dda state
  101. // must be kept for each. All variables that end with First refer to the
  102. // first one of this line, and all that end with Last refers to the last.
  103. INT ErrorFirst; // The DDA error.
  104. INT ErrorLast;
  105. INT FracStart; // The fraction of the start and end
  106. INT FracEnd; // points that are covered due to the cap.
  107. INT MinorFirst; // The minor position of each DDA.
  108. INT MinorLast;
  109. INT MajorFirst; // The major position of each DDA
  110. INT MajorLast;
  111. INT SwitchFirstLast; // Specifies if the first and last DDAs
  112. // should be switched, which is simpler in
  113. // some cases for the x-major line.
  114. INT AlphaFirst; // The currently calculated coverage for
  115. INT AlphaLast; // each DDA.
  116. INT AlphaMid;
  117. INT AlphaBiasFirst; // Bias for calculating the coverage.
  118. INT AlphaBiasLast;
  119. // Used for clipping
  120. INT MajorIn; // The limits of the clipping rectangle.
  121. INT MajorOut;
  122. INT MinorIn;
  123. INT MinorOut;
  124. // Index of the drawing function to be used.
  125. INT DrawFuncIndex;
  126. public:
  127. // Public Functions
  128. BOOL SetupAntiAliased();
  129. BOOL SetupCommon( GpPointF *point1, GpPointF *point2, BOOL drawLast );
  130. VOID DrawXMajor(DpScanBuffer *scan);
  131. VOID DrawYMajor(DpScanBuffer *scan);
  132. VOID DrawXMajorClip(DpScanBuffer *scan);
  133. VOID DrawYMajorClip(DpScanBuffer *scan);
  134. BOOL ClipRectangle(const GpRect* clipRect);
  135. };
  136. #endif // AAONEPIXELLINE_SUPPORT
  137. #endif // LINE_HPP