1 /* Copyright (C) 1997 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: gxcomp.h,v 1.7 2005/03/14 18:08:36 dan Exp $ */ 18 /* Definitions for implementing compositing functions */ 19 20 #ifndef gxcomp_INCLUDED 21 # define gxcomp_INCLUDED 22 23 #include "gscompt.h" 24 #include "gsrefct.h" 25 #include "gxbitfmt.h" 26 27 /* 28 * Because compositor information is passed through the command list, 29 * individual compositors must be identified by some means that is 30 * independent of address space. The address of the compositor method 31 * array, gs_composite_type_t (see below), cannot be used, as it is 32 * meaningful only within a single address space. 33 * 34 * In addition, it is desirable the keep the compositor identifier 35 * size as small as possible, as this identifier must be passed through 36 * the command list for all bands whenever the compositor is invoked. 37 * Fortunately, compositor invocation is not so frequent as to warrant 38 * byte-sharing techniques, which most likely would store the identifier 39 * in some unused bits of a command code byte. Hence, the smallest 40 * reasonable size for the identifier is one byte. This allows for up 41 * to 255 compositors, which should be ample (as of this writing, there 42 * are only two compositors, only one of which can be passed through 43 * the command list). 44 * 45 * The following list is intended to enumerate all compositors. We 46 * use definitions rather than an encoding to ensure a one-byte size. 47 */ 48 #define GX_COMPOSITOR_ALPHA 0x01 /* DPS/Next alpha compositor */ 49 #define GX_COMPOSITOR_OVERPRINT 0x02 /* overprint/overprintmode compositor */ 50 #define GX_COMPOSITOR_PDF14_TRANS 0x03 /* PDF 1.4 transparency compositor */ 51 52 53 /* 54 * Define the abstract superclass for all compositing function types. 55 */ 56 /*typedef struct gs_composite_s gs_composite_t; *//* in gscompt.h */ 57 58 #ifndef gs_imager_state_DEFINED 59 # define gs_imager_state_DEFINED 60 typedef struct gs_imager_state_s gs_imager_state; 61 62 #endif 63 64 #ifndef gx_device_DEFINED 65 # define gx_device_DEFINED 66 typedef struct gx_device_s gx_device; 67 68 #endif 69 70 typedef struct gs_composite_type_procs_s { 71 72 /* 73 * Create the default compositor for a compositing function. 74 */ 75 #define composite_create_default_compositor_proc(proc)\ 76 int proc(const gs_composite_t *pcte, gx_device **pcdev,\ 77 gx_device *dev, gs_imager_state *pis, gs_memory_t *mem) 78 composite_create_default_compositor_proc((*create_default_compositor)); 79 80 /* 81 * Test whether this function is equal to another one. 82 */ 83 #define composite_equal_proc(proc)\ 84 bool proc(const gs_composite_t *pcte, const gs_composite_t *pcte2) 85 composite_equal_proc((*equal)); 86 87 /* 88 * Convert the representation of this function to a string 89 * for writing in a command list. *psize is the amount of space 90 * available. If it is large enough, the procedure sets *psize 91 * to the amount used and returns 0; if it is not large enough, 92 * the procedure sets *psize to the amount needed and returns a 93 * rangecheck error; in the case of any other error, *psize is 94 * not changed. 95 */ 96 #define composite_write_proc(proc)\ 97 int proc(const gs_composite_t *pcte, byte *data, uint *psize) 98 composite_write_proc((*write)); 99 100 /* 101 * Convert the string representation of a function back to 102 * a structure, allocating the structure. Return the number of 103 * bytes read, or < 0 in the event of an error. 104 */ 105 #define composite_read_proc(proc)\ 106 int proc(gs_composite_t **ppcte, const byte *data, uint size,\ 107 gs_memory_t *mem) 108 composite_read_proc((*read)); 109 110 /* 111 * Update the clist write device when a compositor device is created. 112 */ 113 #define composite_clist_write_update(proc)\ 114 int proc(const gs_composite_t * pcte, gx_device * dev, gx_device ** pcdev,\ 115 gs_imager_state * pis, gs_memory_t * mem) 116 composite_clist_write_update((*clist_compositor_write_update)); 117 118 /* 119 * Update the clist read device when a compositor device is created. 120 */ 121 #define composite_clist_read_update(proc)\ 122 int proc(gs_composite_t * pcte, gx_device * cdev, gx_device * tdev,\ 123 gs_imager_state * pis, gs_memory_t * mem) 124 composite_clist_read_update((*clist_compositor_read_update)); 125 126 } gs_composite_type_procs_t; 127 128 typedef struct gs_composite_type_s { 129 byte comp_id; /* to identify compositor passed through command list */ 130 gs_composite_type_procs_t procs; 131 } gs_composite_type_t; 132 133 /* 134 * Default implementation for creating a compositor for clist writing. 135 * The default does nothing. 136 */ 137 composite_clist_write_update(gx_default_composite_clist_write_update); 138 139 /* 140 * Default implementation for adjusting the clist reader when a compositor 141 * device is added. The default does nothing. 142 */ 143 composite_clist_read_update(gx_default_composite_clist_read_update); 144 145 /* 146 * Compositing objects are reference-counted, because graphics states will 147 * eventually reference them. Note that the common part has no 148 * garbage-collectible pointers and is never actually instantiated, so no 149 * structure type is needed for it. 150 */ 151 #define gs_composite_common\ 152 const gs_composite_type_t *type;\ 153 gs_id id; /* see gscompt.h */\ 154 rc_header rc 155 struct gs_composite_s { 156 gs_composite_common; 157 }; 158 159 /* Replace a procedure with a macro. */ 160 #define gs_composite_id(pcte) ((pcte)->id) 161 162 #endif /* gxcomp_INCLUDED */ 163