home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / oslib / oslib_1 / OSLib / User / h / draw < prev    next >
Encoding:
Text File  |  1995-08-21  |  12.4 KB  |  366 lines

  1. #ifndef draw_H
  2. #define draw_H
  3.  
  4. /* C header file for Draw
  5.  * written by DefMod (Jul 24 1995) on Mon Aug 21 11:57:28 1995
  6.  * Jonathan Coxhead, Acorn Computers Ltd
  7.  */
  8.  
  9. #ifndef types_H
  10. #include "types.h"
  11. #endif
  12.  
  13. #ifndef os_H
  14. #include "os.h"
  15. #endif
  16.  
  17. /**********************************
  18.  * SWI names and SWI reason codes *
  19.  **********************************/
  20. #undef  Draw_ProcessPath
  21. #define Draw_ProcessPath                        0x40700
  22. #undef  XDraw_ProcessPath
  23. #define XDraw_ProcessPath                       0x60700
  24. #undef  Draw_Fill
  25. #define Draw_Fill                               0x40702
  26. #undef  XDraw_Fill
  27. #define XDraw_Fill                              0x60702
  28. #undef  Draw_Stroke
  29. #define Draw_Stroke                             0x40704
  30. #undef  XDraw_Stroke
  31. #define XDraw_Stroke                            0x60704
  32. #undef  Draw_StrokePath
  33. #define Draw_StrokePath                         0x40706
  34. #undef  XDraw_StrokePath
  35. #define XDraw_StrokePath                        0x60706
  36. #undef  Draw_FlattenPath
  37. #define Draw_FlattenPath                        0x40708
  38. #undef  XDraw_FlattenPath
  39. #define XDraw_FlattenPath                       0x60708
  40. #undef  Draw_TransformPath
  41. #define Draw_TransformPath                      0x4070A
  42. #undef  XDraw_TransformPath
  43. #define XDraw_TransformPath                     0x6070A
  44. #undef  DrawV
  45. #define DrawV                                   0x20
  46.  
  47. /************************************
  48.  * Structure and union declarations *
  49.  ************************************/
  50. typedef struct draw_path_element                draw_path_element;
  51. typedef struct draw_line_style                  draw_line_style;
  52. typedef struct draw_dash_pattern                draw_dash_pattern;
  53. typedef struct draw_path                        draw_path;
  54.  
  55. /********************
  56.  * Type definitions *
  57.  ********************/
  58. typedef byte draw_tag;
  59.  
  60. typedef bits draw_fill_style;
  61.  
  62. typedef byte draw_join_style;
  63.  
  64. typedef byte draw_cap_style;
  65.  
  66. typedef draw_path *draw_output_path;
  67.  
  68. struct draw_path_element
  69.    {  draw_tag tag;
  70.       byte reserved [3];
  71.       union
  72.       {  int end_path;
  73.          draw_path_element *continuation;
  74.          os_coord move_to;
  75.          os_coord special_move_to;
  76.          os_coord bezier_to [3];
  77.          os_coord gap_to;
  78.          os_coord line_to;
  79.          byte reserved [24];
  80.       }
  81.       data;
  82.    };
  83.  
  84. struct draw_line_style
  85.    {  draw_join_style join_style;
  86.       draw_cap_style end_cap_style;
  87.       draw_cap_style start_cap_style;
  88.       byte reserved;
  89.       int mitre_limit;
  90.       short start_cap_width;
  91.       short start_cap_length;
  92.       short end_cap_width;
  93.       short end_cap_length;
  94.    };
  95.  
  96. struct draw_dash_pattern
  97.    {  int start;
  98.       int element_count;
  99.       int elements [UNKNOWN];
  100.    };
  101.  
  102. #define draw_DASH_PATTERN(N) \
  103.    struct \
  104.       {  int start; \
  105.          int element_count; \
  106.          int elements [N]; \
  107.       }
  108.  
  109. #define draw_SIZEOF_DASH_PATTERN(N) \
  110.    (offsetof (draw_dash_pattern, elements) + \
  111.          (N)*sizeof ((draw_dash_pattern *) NULL)->elements)
  112.  
  113. struct draw_path
  114.    {  draw_path_element elements [UNKNOWN];
  115.    };
  116.  
  117. /************************
  118.  * Constant definitions *
  119.  ************************/
  120. #define draw_OS_UNIT                            256
  121.       /*1 O S unit in draw units*/
  122. #define draw_INCH                               46080
  123.       /*1in in draw units*/
  124. #define draw_POINT                              640
  125.       /*1pt in draw units*/
  126. #define draw_END_PATH                           ((draw_tag) 0x0u)
  127. #define draw_CONTINUATION                       ((draw_tag) 0x1u)
  128. #define draw_MOVE_TO                            ((draw_tag) 0x2u)
  129. #define draw_SPECIAL_MOVE_TO                    ((draw_tag) 0x3u)
  130. #define draw_CLOSE_GAP                          ((draw_tag) 0x4u)
  131. #define draw_CLOSE_LINE                         ((draw_tag) 0x5u)
  132. #define draw_BEZIER_TO                          ((draw_tag) 0x6u)
  133. #define draw_GAP_TO                             ((draw_tag) 0x7u)
  134. #define draw_LINE_TO                            ((draw_tag) 0x8u)
  135. #define draw_FILL_NONZERO                       ((draw_fill_style) 0x0u)
  136. #define draw_FILL_NEGATIVE                      ((draw_fill_style) 0x1u)
  137. #define draw_FILL_EVEN_ODD                      ((draw_fill_style) 0x2u)
  138. #define draw_FILL_POSITIVE                      ((draw_fill_style) 0x3u)
  139. #define draw_FILL_WINDING_RULE_SHIFT            0
  140. #define draw_FILL_WINDING_RULE                  ((draw_fill_style) 0x3u)
  141. #define draw_FILL_FULL_EXTERIOR                 ((draw_fill_style) 0x4u)
  142. #define draw_FILL_EXTERIOR_BOUNDARY             ((draw_fill_style) 0x8u)
  143. #define draw_FILL_INTERIOR_BOUNDARY             ((draw_fill_style) 0x10u)
  144. #define draw_FILL_FULL_INTERIOR                 ((draw_fill_style) 0x20u)
  145. #define draw_FILL_CLOSE_OPEN_SUBPATHS           ((draw_fill_style) 0x8000000u)
  146. #define draw_FILL_FLATTEN                       ((draw_fill_style) 0x10000000u)
  147. #define draw_FILL_THICKEN                       ((draw_fill_style) 0x20000000u)
  148. #define draw_FILL_REFLATTEN                     ((draw_fill_style) 0x40000000u)
  149. #define draw_FILL_FLOAT                         ((draw_fill_style) 0x80000000u)
  150. #define draw_JOIN_MITRED                        ((draw_join_style) 0x0u)
  151. #define draw_JOIN_ROUND                         ((draw_join_style) 0x1u)
  152. #define draw_JOIN_BEVELLED                      ((draw_join_style) 0x2u)
  153. #define draw_CAP_BUTT                           ((draw_cap_style) 0x0u)
  154. #define draw_CAP_ROUND                          ((draw_cap_style) 0x1u)
  155. #define draw_CAP_SQUARE                         ((draw_cap_style) 0x2u)
  156. #define draw_CAP_TRIANGULAR                     ((draw_cap_style) 0x3u)
  157. #define draw_SPECIAL_IN_SITU                    ((draw_output_path) 0x0u)
  158. #define draw_SPECIAL_FILL                       ((draw_output_path) 0x1u)
  159. #define draw_SPECIAL_FILL_BY_SUBPATHS           ((draw_output_path) 0x2u)
  160. #define draw_SPECIAL_COUNT                      ((draw_output_path) 0x3u)
  161. #define draw_SPECIAL_BBOX                       ((draw_output_path) 0x80000000u)
  162. #define error_DRAW_NO_DRAW_IN_IRQ_MODE          0x980u
  163. #define error_DRAW_BAD_DRAW_REASON_CODE         0x981u
  164. #define error_DRAW_RESERVED_DRAW_BITS           0x982u
  165. #define error_DRAW_INVALID_DRAW_ADDRESS         0x983u
  166. #define error_DRAW_BAD_PATH_ELEMENT             0x984u
  167. #define error_DRAW_BAD_PATH_SEQUENCE            0x985u
  168. #define error_DRAW_MAY_EXPAND_PATH              0x986u
  169. #define error_DRAW_PATH_FULL                    0x987u
  170. #define error_DRAW_PATH_NOT_FLAT                0x988u
  171. #define error_DRAW_BAD_CAPS_OR_JOINS            0x989u
  172. #define error_DRAW_TRANSFORM_OVERFLOW           0x98Au
  173. #define error_DRAW_DRAW_NEEDS_GRAPHICS_MODE     0x98Bu
  174. #define error_DRAW_UNIMPLEMENTED_DRAW           0x9FFu
  175.  
  176. /*************************
  177.  * Function declarations *
  178.  *************************/
  179.  
  180. #ifdef __cplusplus
  181.    extern "C" {
  182. #endif
  183.  
  184. /* ------------------------------------------------------------------------
  185.  * Function:      draw_process_path()
  186.  *
  187.  * Description:   Main Draw SWI
  188.  *
  189.  * Input:         path - value of R0 on entry
  190.  *                fill_style - value of R1 on entry
  191.  *                trfm - value of R2 on entry
  192.  *                flatness - value of R3 on entry
  193.  *                thickness - value of R4 on entry
  194.  *                line_style - value of R5 on entry
  195.  *                dash_pattern - value of R6 on entry
  196.  *                processed_path - value of R7 on entry
  197.  *
  198.  * Output:        end_or_used - value of R0 on exit (X version only)
  199.  *
  200.  * Returns:       R0 (non-X version only)
  201.  *
  202.  * Other notes:   Calls SWI 0x40700.
  203.  */
  204.  
  205. extern os_error *xdraw_process_path (draw_path const *path,
  206.       draw_fill_style fill_style,
  207.       os_trfm const *trfm,
  208.       int flatness,
  209.       int thickness,
  210.       draw_line_style const *line_style,
  211.       draw_dash_pattern const *dash_pattern,
  212.       draw_output_path processed_path,
  213.       byte **end_or_used);
  214. extern byte *draw_process_path (draw_path const *path,
  215.       draw_fill_style fill_style,
  216.       os_trfm const *trfm,
  217.       int flatness,
  218.       int thickness,
  219.       draw_line_style const *line_style,
  220.       draw_dash_pattern const *dash_pattern,
  221.       draw_output_path processed_path);
  222.  
  223. /* ------------------------------------------------------------------------
  224.  * Function:      draw_fill()
  225.  *
  226.  * Description:   Processes a path and sends it to the VDU, filling the
  227.  *                interior portion
  228.  *
  229.  * Input:         path - value of R0 on entry
  230.  *                fill_style - value of R1 on entry
  231.  *                trfm - value of R2 on entry
  232.  *                flatness - value of R3 on entry
  233.  *
  234.  * Other notes:   Calls SWI 0x40702.
  235.  */
  236.  
  237. extern os_error *xdraw_fill (draw_path const *path,
  238.       draw_fill_style fill_style,
  239.       os_trfm const *trfm,
  240.       int flatness);
  241. __swi (0x40702) void draw_fill (draw_path const *path,
  242.       draw_fill_style fill_style,
  243.       os_trfm const *trfm,
  244.       int flatness);
  245.  
  246. /* ------------------------------------------------------------------------
  247.  * Function:      draw_stroke()
  248.  *
  249.  * Description:   Processes a path and sends it to the VDU
  250.  *
  251.  * Input:         path - value of R0 on entry
  252.  *                fill_style - value of R1 on entry
  253.  *                trfm - value of R2 on entry
  254.  *                flatness - value of R3 on entry
  255.  *                thickness - value of R4 on entry
  256.  *                line_style - value of R5 on entry
  257.  *                dash_pattern - value of R6 on entry
  258.  *
  259.  * Other notes:   Calls SWI 0x40704.
  260.  */
  261.  
  262. extern os_error *xdraw_stroke (draw_path const *path,
  263.       draw_fill_style fill_style,
  264.       os_trfm const *trfm,
  265.       int flatness,
  266.       int thickness,
  267.       draw_line_style const *line_style,
  268.       draw_dash_pattern const *dash_pattern);
  269. extern void draw_stroke (draw_path const *path,
  270.       draw_fill_style fill_style,
  271.       os_trfm const *trfm,
  272.       int flatness,
  273.       int thickness,
  274.       draw_line_style const *line_style,
  275.       draw_dash_pattern const *dash_pattern);
  276.  
  277. /* ------------------------------------------------------------------------
  278.  * Function:      draw_stroke_path()
  279.  *
  280.  * Description:   Processes a path and writes its output to another path
  281.  *
  282.  * Input:         path - value of R0 on entry
  283.  *                stroked_path - value of R1 on entry
  284.  *                trfm - value of R2 on entry
  285.  *                flatness - value of R3 on entry
  286.  *                thickness - value of R4 on entry
  287.  *                line_style - value of R5 on entry
  288.  *                dash_pattern - value of R6 on entry
  289.  *
  290.  * Output:        end_or_used - value of R0 on exit (X version only)
  291.  *
  292.  * Returns:       R0 (non-X version only)
  293.  *
  294.  * Other notes:   Calls SWI 0x40706.
  295.  */
  296.  
  297. extern os_error *xdraw_stroke_path (draw_path const *path,
  298.       draw_path *stroked_path,
  299.       os_trfm const *trfm,
  300.       int flatness,
  301.       int thickness,
  302.       draw_line_style const *line_style,
  303.       draw_dash_pattern const *dash_pattern,
  304.       byte **end_or_used);
  305. extern byte *draw_stroke_path (draw_path const *path,
  306.       draw_path *stroked_path,
  307.       os_trfm const *trfm,
  308.       int flatness,
  309.       int thickness,
  310.       draw_line_style const *line_style,
  311.       draw_dash_pattern const *dash_pattern);
  312.  
  313. /* ------------------------------------------------------------------------
  314.  * Function:      draw_flatten_path()
  315.  *
  316.  * Description:   Flattens a path and writes its output to another path
  317.  *
  318.  * Input:         path - value of R0 on entry
  319.  *                flattened_path - value of R1 on entry
  320.  *                flatness - value of R2 on entry
  321.  *
  322.  * Output:        end_or_used - value of R0 on exit (X version only)
  323.  *
  324.  * Returns:       R0 (non-X version only)
  325.  *
  326.  * Other notes:   Calls SWI 0x40708.
  327.  */
  328.  
  329. extern os_error *xdraw_flatten_path (draw_path const *path,
  330.       draw_path *flattened_path,
  331.       int flatness,
  332.       byte **end_or_used);
  333. __swi (0x40708) byte *draw_flatten_path (draw_path const *path,
  334.       draw_path *flattened_path,
  335.       int flatness);
  336.  
  337. /* ------------------------------------------------------------------------
  338.  * Function:      draw_transform_path()
  339.  *
  340.  * Description:   Transforms a path and writes its output to another path
  341.  *
  342.  * Input:         path - value of R0 on entry
  343.  *                transformed_path - value of R1 on entry
  344.  *                trfm - value of R2 on entry
  345.  *
  346.  * Output:        end_or_used - value of R0 on exit (X version only)
  347.  *
  348.  * Returns:       R0 (non-X version only)
  349.  *
  350.  * Other notes:   Calls SWI 0x4070A with R3 = 0x0.
  351.  */
  352.  
  353. extern os_error *xdraw_transform_path (draw_path const *path,
  354.       draw_path *transformed_path,
  355.       os_trfm const *trfm,
  356.       byte **end_or_used);
  357. extern byte *draw_transform_path (draw_path const *path,
  358.       draw_path *transformed_path,
  359.       os_trfm const *trfm);
  360.  
  361. #ifdef __cplusplus
  362.    }
  363. #endif
  364.  
  365. #endif
  366.