1 /* Copyright (C) 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: gspcolor.h,v 1.6 2003/03/25 21:18:06 igor Exp $ */ 18 /* Client interface to Pattern color */ 19 20 #ifndef gspcolor_INCLUDED 21 # define gspcolor_INCLUDED 22 23 #include "gsccolor.h" 24 #include "gsrefct.h" 25 #include "gsuid.h" 26 27 /* ---------------- Types and structures ---------------- */ 28 29 /* 30 * We originally defined the gs_client_pattern structure before we 31 * realized that we would have to accommodate multiple PatternTypes. 32 * In version 5.68, we bit the bullet and made an incompatible change 33 * to this structure so that multiple PatternTypes could be supported. 34 * In order to make this work: 35 * 36 * Clients creating instances of any Pattern template structure 37 * (gs_patternN_template_t) must call gs_patternN_init to 38 * initialize all the members, before filling in any of the 39 * members themselves. 40 * 41 * This is a non-backward-compatible requirement relative to previous 42 * versions, but it was unavoidable. 43 */ 44 45 /* 46 * Define the abstract pattern template (called "prototype pattern" in Red 47 * Book). 48 */ 49 50 #ifndef gs_pattern_type_DEFINED 51 # define gs_pattern_type_DEFINED 52 typedef struct gs_pattern_type_s gs_pattern_type_t; 53 #endif 54 55 #define gs_pattern_template_common\ 56 const gs_pattern_type_t *type;\ 57 int PatternType; /* copied from the type structure */\ 58 gs_uid uid;\ 59 void *client_data /* additional data for rendering */ 60 61 typedef struct gs_pattern_template_s { 62 gs_pattern_template_common; 63 } gs_pattern_template_t; 64 65 /* The descriptor is public for subclassing. */ 66 extern_st(st_pattern_template); 67 #define public_st_pattern_template() /* in gspcolor.c */\ 68 gs_public_st_ptrs2(st_pattern_template, gs_pattern_template_t,\ 69 "gs_pattern_template_t", pattern_template_enum_ptrs,\ 70 pattern_template_reloc_ptrs, uid.xvalues, client_data) 71 #define st_pattern_template_max_ptrs 2 72 73 /* Definition of Pattern instances. */ 74 #ifndef gs_pattern_instance_DEFINED 75 # define gs_pattern_instance_DEFINED 76 typedef struct gs_pattern_instance_s gs_pattern_instance_t; 77 #endif 78 79 #define gs_pattern_instance_common\ 80 rc_header rc;\ 81 /* Following are set by makepattern */\ 82 const gs_pattern_type_t *type; /* from template */\ 83 gs_state *saved;\ 84 gs_id pattern_id 85 struct gs_pattern_instance_s { 86 gs_pattern_instance_common; 87 }; 88 89 /* The following is public for subclassing. */ 90 extern_st(st_pattern_instance); 91 #define public_st_pattern_instance() /* in gspcolor.c */\ 92 gs_public_st_ptrs1(st_pattern_instance, gs_pattern_instance_t,\ 93 "gs_pattern_instance_t", pattern_instance_enum_ptrs,\ 94 pattern_instance_reloc_ptrs, saved) 95 #define st_pattern_instance_max_ptrs 1 96 97 /* ---------------- Procedures ---------------- */ 98 99 /* Set a Pattern color or a Pattern color space. */ 100 int gs_setpattern(gs_state *, const gs_client_color *); 101 int gs_setpatternspace(gs_state *); 102 103 /* 104 * Construct a Pattern color of any PatternType. 105 * The gs_memory_t argument for gs_make_pattern may be NULL, meaning use the 106 * same allocator as for the gs_state argument. Note that gs_make_pattern 107 * uses rc_alloc_struct_1 to allocate pattern instances. 108 */ 109 int gs_make_pattern(gs_client_color *, const gs_pattern_template_t *, 110 const gs_matrix *, gs_state *, gs_memory_t *); 111 const gs_pattern_template_t *gs_get_pattern(const gs_client_color *); 112 113 /* 114 * Adjust the reference count of a pattern. This is intended to support 115 * applications (such as PCL) which maintain client colors outside of the 116 * graphic state. Since the pattern instance structure is opaque to these 117 * applications, they need some way to release or retain the instances as 118 * needed. 119 */ 120 void gs_pattern_reference(gs_client_color * pcc, int delta); 121 122 #endif /* gspcolor_INCLUDED */ 123