Source code of Windows XP (NT5)
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.

201 lines
7.8 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: lines.h
  3. *
  4. * Line drawing constants and structures.
  5. *
  6. * NOTE: This file mirrors LINES.INC. Changes here must be reflected in
  7. * the .inc file!
  8. *
  9. * Copyright (c) 1992-1994 Microsoft Corporation
  10. \**************************************************************************/
  11. typedef struct _PDEV PDEV; // Handy forward declaration
  12. //
  13. // These constants are used for the W32p line drawing algorithm
  14. //
  15. // method 1
  16. #define NO_X_FLIP 0
  17. #define NO_Y_FLIP 0
  18. #define X_FLIP 1
  19. #define Y_FLIP 1
  20. #define X_MAJOR 1
  21. #define Y_MAJOR 0
  22. // method 2
  23. #define LINE_DRAW 0x80
  24. #define LINE_USE_ERROR_TERM 0x20
  25. #define LINE_X_NEG 0x01
  26. #define LINE_Y_NEG 0x12
  27. #define LINE_X_MAJOR 0x04
  28. // We have to be careful that we don't overflow any registers when using
  29. // the hardware to draw lines (as opposed to going through the strips
  30. // routines, which will never overflow). We accomplish this by simply
  31. // checking the bounds of the path; if it is so large that any of the
  32. // hardware terms may overflow, we punt the entire path to the strips
  33. // code (should be pretty rare).
  34. #define MAX_INTEGER_BOUND (1535) // W32's line length term is limited to
  35. #define MIN_INTEGER_BOUND (-512) // a maximum value of 2047
  36. // We have special strip routines when all strips have at most this many
  37. // pixels:
  38. #define MAX_SHORT_STROKE_LENGTH 15
  39. // # of strip drawers in every group:
  40. #define NUM_STRIP_DRAW_DIRECTIONS 4
  41. // # of strip drawers for doing either solid lines or styled lines:
  42. #define NUM_STRIP_DRAW_STYLES 8
  43. typedef LONG STYLEPOS;
  44. #define STYLE_MAX_COUNT 16
  45. #define STYLE_MAX_VALUE 0x3fffL
  46. #define RUN_MAX 20
  47. #define STRIP_MAX 100
  48. #define STYLE_DENSITY 3
  49. // Flip and round flags:
  50. #define FL_H_ROUND_DOWN 0x00000080L // .... .... 1... ....
  51. #define FL_V_ROUND_DOWN 0x00008000L // 1... .... .... ....
  52. #define FL_FLIP_D 0x00000005L // .... .... .... .1.1
  53. #define FL_FLIP_V 0x00000008L // .... .... .... 1...
  54. #define FL_FLIP_SLOPE_ONE 0x00000010L // .... .... ...1 ....
  55. #define FL_FLIP_HALF 0x00000002L // .... .... .... ..1.
  56. #define FL_FLIP_H 0x00000200L // .... ..1. .... ....
  57. #define FL_ROUND_MASK 0x0000001CL // .... .... ...1 11..
  58. #define FL_ROUND_SHIFT 2
  59. #define FL_RECTLCLIP_MASK 0x0000000CL // .... .... .... 11..
  60. #define FL_RECTLCLIP_SHIFT 2
  61. #define FL_STRIP_MASK 0x00000003L // .... .... .... ..11
  62. #define FL_STRIP_SHIFT 0
  63. #define FL_SIMPLE_CLIP 0x00000020 // .... .... ..1. ....
  64. #define FL_COMPLEX_CLIP 0x00000040 // .... .... .1.. ....
  65. #define FL_CLIP (FL_SIMPLE_CLIP | FL_COMPLEX_CLIP)
  66. #define FL_STYLED 0x00000400L // .... .1.. .... ....
  67. #define FL_ALTERNATESTYLED 0x00001000L // ...1 .... .... ....
  68. #define FL_STYLE_MASK 0x00000400L
  69. #define FL_STYLE_SHIFT 10
  70. #define FL_LAST_PEL_INCLUSIVE 0x00002000L // ..1. .... .... ....
  71. // Miscellaneous DDA defines:
  72. #define LROUND(x, flRoundDown) (((x) + F/2 - ((flRoundDown) > 0)) >> 4)
  73. #define F 16
  74. #define FLOG2 4
  75. #define LFLOOR(x) ((x) >> 4)
  76. #define FXFRAC(x) ((x) & (F - 1))
  77. ////////////////////////////////////////////////////////////////////////////
  78. // NOTE: The following structures must exactly match those declared in
  79. // lines.inc!
  80. typedef struct _STRIP {
  81. LONG cStrips; // # of strips in array
  82. LONG flFlips; // Indicates if line goes up or down
  83. POINTL ptlStart; // first point
  84. LONG alStrips[STRIP_MAX]; // Array of strips
  85. } STRIP;
  86. typedef struct _LINESTATE {
  87. STYLEPOS* pspStart; // Pointer to start of style array
  88. STYLEPOS* pspEnd; // Pointer to end of style array
  89. STYLEPOS* psp; // Pointer to current style entry
  90. STYLEPOS spRemaining; // To go in current style
  91. STYLEPOS spTotal; // Sum of style array
  92. STYLEPOS spTotal2; // Twice sum of style array
  93. STYLEPOS spNext; // Style state at start of next line
  94. STYLEPOS spComplex; // Style state at start of complex clip line
  95. STYLEPOS* aspRtoL; // Style array in right-to-left order
  96. STYLEPOS* aspLtoR; // Style array in left-to-right order
  97. ULONG ulStyleMask; // Are we working on a gap in the style?
  98. // 0xff if yes, 0x0 if not
  99. ULONG xyDensity; // Density of style
  100. ULONG cStyle; // Size of style array
  101. ULONG ulStyleMaskLtoR;// Original style mask, left-to-right order
  102. ULONG ulStyleMaskRtoL;// Original style mask, right-to-left order
  103. BOOL ulStartMask; // Determines if first element in style
  104. // array is for a gap or a dash
  105. } LINESTATE; /* ls */
  106. // Strip drawer prototype:
  107. typedef VOID (*PFNSTRIP)(PDEV*, STRIP*, LINESTATE*);
  108. extern PFNSTRIP gapfnStripP[];
  109. // Strip drawers:
  110. VOID vssSolidHorizontal(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  111. VOID vssSolidVertical(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  112. VOID vssSolidDiagonalHorizontal(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  113. VOID vssSolidDiagonalVertical(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  114. VOID vrlSolidHorizontal(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  115. VOID vrlSolidVertical(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  116. VOID vrlSolidDiagonalHorizontal(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  117. VOID vrlSolidDiagonalVertical(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  118. VOID vStripStyledHorizontal(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  119. VOID vStripStyledVertical(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  120. VOID vrlSolidHorizontalP(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  121. VOID vrlSolidVerticalP(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  122. VOID vrlSolidDiagonalHorizontalP(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  123. VOID vrlSolidDiagonalVerticalP(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  124. VOID vStripStyledHorizontalP(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  125. VOID vStripStyledVerticalP(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  126. // External calls:
  127. BOOL bLines(PDEV*, POINTFIX*, POINTFIX*, RUN* prun, ULONG,
  128. LINESTATE*, RECTL*, PFNSTRIP apfn[], FLONG);
  129. //
  130. // axis must be a constant
  131. //
  132. #define SETUP_DRAW_LINE(pjBase,dx,dy,axis,cBpp) \
  133. { \
  134. WAIT_FOR_EMPTY_ACL_QUEUE(ppdev, pjBase); \
  135. \
  136. if (axis == 1) \
  137. { \
  138. /* X major */ \
  139. CP_XCNT(ppdev, pjBase, ((dx - 1) * cBpp)); \
  140. CP_YCNT(ppdev, pjBase, 0xfff); \
  141. CP_DELTA_MINOR(ppdev, pjBase, dy); \
  142. CP_DELTA_MAJOR(ppdev, pjBase, dx); \
  143. } \
  144. else /*if (axis == 0)*/ \
  145. { \
  146. /* Y major */ \
  147. CP_XCNT(ppdev, pjBase, 0xfff); \
  148. CP_YCNT(ppdev, pjBase, (dy - 1)); \
  149. CP_DELTA_MINOR(ppdev, pjBase, dx); \
  150. CP_DELTA_MAJOR(ppdev, pjBase, dy); \
  151. } \
  152. }