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.

150 lines
6.1 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: lines.h
  8. *
  9. * Content: Line drawing constants and structures.
  10. *
  11. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  13. \*****************************************************************************/
  14. typedef struct _PDEV PDEV; // Handy forward declaration
  15. // We have to be careful that we don't overflow any registers when using
  16. // the hardware to draw lines (as opposed to going through the strips
  17. // routines, which will never overflow). We accomplish this by simply
  18. // checking the bounds of the path; if it is so large that any of the
  19. // hardware terms may overflow, we punt the entire path to the strips
  20. // code (should be pretty rare).
  21. #define MAX_INTEGER_BOUND (1535) // S3's line length term is limited to
  22. #define MIN_INTEGER_BOUND (-512) // a maximum value of 2047
  23. // We have special strip routines when all strips have at most this many
  24. // pixels:
  25. #define MAX_SHORT_STROKE_LENGTH 15
  26. // # of strip drawers in every group:
  27. #define NUM_STRIP_DRAW_DIRECTIONS 4
  28. // # of strip drawers for doing either solid lines or styled lines:
  29. #define NUM_STRIP_DRAW_STYLES 8
  30. typedef LONG STYLEPOS;
  31. #define STYLE_MAX_COUNT 16
  32. #define STYLE_MAX_VALUE 0x3fffL
  33. #define RUN_MAX 20
  34. #define STRIP_MAX 100
  35. #define STYLE_DENSITY 3
  36. // Flip and round flags:
  37. #define FL_H_ROUND_DOWN 0x00000080L // .... .... 1... ....
  38. #define FL_V_ROUND_DOWN 0x00000100L // .... ...1 .... ....
  39. #define FL_FLIP_D 0x00000005L // .... .... .... .1.1
  40. #define FL_FLIP_V 0x00000008L // .... .... .... 1...
  41. #define FL_FLIP_SLOPE_ONE 0x00000010L // .... .... ...1 ....
  42. #define FL_FLIP_HALF 0x00000002L // .... .... .... ..1.
  43. #define FL_FLIP_H 0x00000200L // .... ..1. .... ....
  44. #define FL_ROUND_MASK 0x0000001CL // .... .... ...1 11..
  45. #define FL_ROUND_SHIFT 2
  46. #define FL_RECTLCLIP_MASK 0x0000000CL // .... .... .... 11..
  47. #define FL_RECTLCLIP_SHIFT 2
  48. #define FL_STRIP_MASK 0x00000003L // .... .... .... ..11
  49. #define FL_STRIP_SHIFT 0
  50. #define FL_SIMPLE_CLIP 0x00000020 // .... .... ..1. ....
  51. #define FL_COMPLEX_CLIP 0x00000040 // .... .... .1.. ....
  52. #define FL_CLIP (FL_SIMPLE_CLIP | FL_COMPLEX_CLIP)
  53. #define FL_ARBITRARYSTYLED 0x00000400L // .... .1.. .... ....
  54. #define FL_MASKSTYLED 0x00000800L // .... 1... .... ....
  55. #define FL_STYLED (FL_ARBITRARYSTYLED | FL_MASKSTYLED)
  56. #define FL_ALTERNATESTYLED 0x00001000L // ...1 .... .... ....
  57. #define FL_STYLE_MASK 0x00000C00L
  58. #define FL_STYLE_SHIFT 10
  59. // Simpler flag bits in high byte:
  60. #define FL_DONT_DO_HALF_FLIP 0x00002000L // ..1. .... .... ....
  61. #define FL_PHYSICAL_DEVICE 0x00004000L // .1.. .... .... ....
  62. // Logical operation which requires a read (for GLINT)
  63. #define FL_READ 0x00008000L // 1... .... .... ....
  64. // Miscellaneous DDA defines:
  65. #define LROUND(x, flRoundDown) (((x) + F/2 - ((flRoundDown) > 0)) >> 4)
  66. #define F 16
  67. #define FLOG2 4
  68. #define LFLOOR(x) ((x) >> 4)
  69. #define FXFRAC(x) ((x) & (F - 1))
  70. ////////////////////////////////////////////////////////////////////////////
  71. // NOTE: The following structures must exactly match those declared in
  72. // lines.inc!
  73. typedef struct _STRIP {
  74. LONG cStrips; // # of strips in array
  75. LONG flFlips; // Indicates if line goes up or down
  76. POINTL ptlStart; // first point
  77. LONG alStrips[STRIP_MAX]; // Array of strips
  78. } STRIP;
  79. typedef struct _LINESTATE {
  80. STYLEPOS* pspStart; // Pointer to start of style array
  81. STYLEPOS* pspEnd; // Pointer to end of style array
  82. STYLEPOS* psp; // Pointer to current style entry
  83. STYLEPOS spRemaining; // To go in current style
  84. STYLEPOS spTotal; // Sum of style array
  85. STYLEPOS spTotal2; // Twice sum of style array
  86. STYLEPOS spNext; // Style state at start of next line
  87. STYLEPOS spComplex; // Style state at start of complex clip line
  88. STYLEPOS* aspRtoL; // Style array in right-to-left order
  89. STYLEPOS* aspLtoR; // Style array in left-to-right order
  90. ULONG ulStyleMask; // Are we working on a gap in the style?
  91. // 0xff if yes, 0x0 if not
  92. ULONG xyDensity; // Density of style
  93. ULONG cStyle; // Size of style array
  94. ULONG ulStyleMaskLtoR;// Original style mask, left-to-right order
  95. ULONG ulStyleMaskRtoL;// Original style mask, right-to-left order
  96. BOOL ulStartMask; // Determines if first element in style
  97. // array is for a gap or a dash
  98. } LINESTATE; /* ls */
  99. // Strip drawer prototype:
  100. typedef VOID (*PFNSTRIP)(PDEV*, STRIP*, LINESTATE*);
  101. // Strip drawers (P3RX):
  102. VOID vPXRXSolidHorizontalLine(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  103. VOID vPXRXSolidVerticalLine(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  104. VOID vPXRXSolidDiagonalHorizontalLine(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  105. VOID vPXRXSolidDiagonalVerticalLine(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  106. VOID vPXRXStyledHorizontalLine(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  107. VOID vPXRXStyledVerticalLine(PDEV* ppdev, STRIP *pStrip, LINESTATE *pLineState);
  108. // External calls:
  109. BOOL bLines(PDEV*, POINTFIX*, POINTFIX*, RUN* prun, ULONG,
  110. LINESTATE*, RECTL*, PFNSTRIP*, FLONG);