gspcolor.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* Copyright (C) 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: gspcolor.h,v 1.2 2000/09/19 19:00:31 lpd Exp $ */
  16. /* Client interface to Pattern color */
  17. #ifndef gspcolor_INCLUDED
  18. # define gspcolor_INCLUDED
  19. #include "gsccolor.h"
  20. #include "gsrefct.h"
  21. #include "gsuid.h"
  22. /* ---------------- Types and structures ---------------- */
  23. /*
  24. * We originally defined the gs_client_pattern structure before we
  25. * realized that we would have to accommodate multiple PatternTypes.
  26. * In version 5.68, we bit the bullet and made an incompatible change
  27. * to this structure so that multiple PatternTypes could be supported.
  28. * In order to make this work:
  29. *
  30. * Clients creating instances of any Pattern template structure
  31. * (gs_patternN_template_t) must call gs_patternN_init to
  32. * initialize all the members, before filling in any of the
  33. * members themselves.
  34. *
  35. * This is a non-backward-compatible requirement relative to previous
  36. * versions, but it was unavoidable.
  37. */
  38. /*
  39. * Define the abstract pattern template (called "prototype pattern" in Red
  40. * Book).
  41. */
  42. #ifndef gs_pattern_type_DEFINED
  43. # define gs_pattern_type_DEFINED
  44. typedef struct gs_pattern_type_s gs_pattern_type_t;
  45. #endif
  46. #define gs_pattern_template_common\
  47. const gs_pattern_type_t *type;\
  48. int PatternType; /* copied from the type structure */\
  49. gs_uid uid;\
  50. void *client_data /* additional data for rendering */
  51. typedef struct gs_pattern_template_s {
  52. gs_pattern_template_common;
  53. } gs_pattern_template_t;
  54. /* The descriptor is public for subclassing. */
  55. extern_st(st_pattern_template);
  56. #define public_st_pattern_template() /* in gspcolor.c */\
  57. gs_public_st_ptrs2(st_pattern_template, gs_pattern_template_t,\
  58. "gs_pattern_template_t", pattern_template_enum_ptrs,\
  59. pattern_template_reloc_ptrs, uid.xvalues, client_data)
  60. #define st_pattern_template_max_ptrs 2
  61. /* Definition of Pattern instances. */
  62. #ifndef gs_pattern_instance_DEFINED
  63. # define gs_pattern_instance_DEFINED
  64. typedef struct gs_pattern_instance_s gs_pattern_instance_t;
  65. #endif
  66. #define gs_pattern_instance_common\
  67. rc_header rc;\
  68. /* Following are set by makepattern */\
  69. const gs_pattern_type_t *type; /* from template */\
  70. gs_state *saved
  71. struct gs_pattern_instance_s {
  72. gs_pattern_instance_common;
  73. };
  74. /* The following is public for subclassing. */
  75. extern_st(st_pattern_instance);
  76. #define public_st_pattern_instance() /* in gspcolor.c */\
  77. gs_public_st_ptrs1(st_pattern_instance, gs_pattern_instance_t,\
  78. "gs_pattern_instance_t", pattern_instance_enum_ptrs,\
  79. pattern_instance_reloc_ptrs, saved)
  80. #define st_pattern_instance_max_ptrs 1
  81. /* ---------------- Procedures ---------------- */
  82. /* Set a Pattern color or a Pattern color space. */
  83. int gs_setpattern(P2(gs_state *, const gs_client_color *));
  84. int gs_setpatternspace(P1(gs_state *));
  85. /*
  86. * Construct a Pattern color of any PatternType.
  87. * The gs_memory_t argument for gs_make_pattern may be NULL, meaning use the
  88. * same allocator as for the gs_state argument. Note that gs_make_pattern
  89. * uses rc_alloc_struct_1 to allocate pattern instances.
  90. */
  91. int gs_make_pattern(P5(gs_client_color *, const gs_pattern_template_t *,
  92. const gs_matrix *, gs_state *, gs_memory_t *));
  93. const gs_pattern_template_t *gs_get_pattern(P1(const gs_client_color *));
  94. /*
  95. * Adjust the reference count of a pattern. This is intended to support
  96. * applications (such as PCL) which maintain client colors outside of the
  97. * graphic state. Since the pattern instance structure is opaque to these
  98. * applications, they need some way to release or retain the instances as
  99. * needed.
  100. */
  101. void gs_pattern_reference(P2(gs_client_color * pcc, int delta));
  102. #endif /* gspcolor_INCLUDED */