gzcpath.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Copyright (C) 1994, 1996, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: gzcpath.h,v 1.2 2000/09/19 19:00:40 lpd Exp $ */
  16. /* Structure definitions for clipping paths */
  17. /* Requires gzpath.h. */
  18. #ifndef gzcpath_INCLUDED
  19. # define gzcpath_INCLUDED
  20. #include "gxcpath.h"
  21. /*
  22. * The reference counting considerations for clip paths are the same as
  23. * for paths. We need a separate reference count for the clip list,
  24. * since its existence and lifetime are not necessarily the same as
  25. * those of the path.
  26. */
  27. typedef struct gx_clip_rect_list_s {
  28. rc_header rc;
  29. gx_clip_list list;
  30. } gx_clip_rect_list;
  31. #define private_st_clip_rect_list() /* in gxcpath.c */\
  32. gs_private_st_ptrs_add0(st_clip_rect_list, gx_clip_rect_list,\
  33. "gx_clip_rect_list", clip_rect_list_enum_ptrs, clip_rect_list_reloc_ptrs,\
  34. st_clip_list, list)
  35. /* gx_clip_path is a 'subclass' of gx_path. */
  36. struct gx_clip_path_s {
  37. gx_path path;
  38. gx_clip_rect_list local_list;
  39. int rule; /* rule for insideness of path */
  40. /* Anything within the inner_box is guaranteed to fall */
  41. /* entirely within the clipping path. */
  42. gs_fixed_rect inner_box;
  43. /* Anything outside the outer_box is guaranteed to fall */
  44. /* entirely outside the clipping path. This is the same */
  45. /* as the path bounding box, widened to pixel boundaries. */
  46. gs_fixed_rect outer_box;
  47. gx_clip_rect_list *rect_list;
  48. bool path_valid; /* path representation is valid */
  49. /* The id changes whenever the clipping region changes. */
  50. gs_id id;
  51. };
  52. extern_st(st_clip_path);
  53. #define public_st_clip_path() /* in gxcpath.c */\
  54. gs_public_st_composite(st_clip_path, gx_clip_path, "clip_path",\
  55. clip_path_enum_ptrs, clip_path_reloc_ptrs)
  56. #define st_clip_path_max_ptrs (st_path_max_ptrs + 1)
  57. /* Inline accessors. */
  58. #define gx_cpath_is_shared(pcpath)\
  59. ((pcpath)->rect_list->rc.ref_count > 1)
  60. /* Define the structure for enumerating a clipping list. */
  61. typedef enum {
  62. visit_left = 1,
  63. visit_right = 2
  64. } cpe_visit_t;
  65. typedef enum {
  66. cpe_scan, cpe_left, cpe_right, cpe_close, cpe_done
  67. } cpe_state_t;
  68. struct gs_cpath_enum_s {
  69. gs_path_enum path_enum; /* used iff clipping path exists as a path, */
  70. /* must be first for subclassing */
  71. bool using_path;
  72. gx_clip_rect *visit; /* scan pointer for finding next start */
  73. gx_clip_rect *rp; /* scan pointer for current rectangle */
  74. cpe_visit_t first_visit;
  75. cpe_state_t state;
  76. bool have_line;
  77. gs_int_point line_end;
  78. bool any_rectangles;
  79. };
  80. #define private_st_cpath_enum() /* in gxcpath.c */\
  81. gs_private_st_suffix_add2(st_cpath_enum, gs_cpath_enum, "gs_cpath_enum",\
  82. cpath_enum_enum_ptrs, cpath_enum_reloc_ptrs, st_path_enum,\
  83. visit, rp)
  84. #endif /* gzcpath_INCLUDED */