2 |
- |
1 |
/* Copyright (C) 2000 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: gstrans.h,v 1.15 2005/08/30 17:08:55 igor Exp $ */
|
|
|
18 |
/* Transparency definitions and interface */
|
|
|
19 |
|
|
|
20 |
#ifndef gstrans_INCLUDED
|
|
|
21 |
# define gstrans_INCLUDED
|
|
|
22 |
|
|
|
23 |
#include "gstparam.h"
|
|
|
24 |
#include "gxcomp.h"
|
|
|
25 |
|
|
|
26 |
/*
|
|
|
27 |
* Define the operations for the PDF 1.4 transparency compositor.
|
|
|
28 |
*/
|
|
|
29 |
typedef enum {
|
|
|
30 |
PDF14_PUSH_DEVICE,
|
|
|
31 |
PDF14_POP_DEVICE,
|
|
|
32 |
PDF14_BEGIN_TRANS_GROUP,
|
|
|
33 |
PDF14_END_TRANS_GROUP,
|
|
|
34 |
PDF14_INIT_TRANS_MASK,
|
|
|
35 |
PDF14_BEGIN_TRANS_MASK,
|
|
|
36 |
PDF14_END_TRANS_MASK,
|
|
|
37 |
PDF14_SET_BLEND_PARAMS
|
|
|
38 |
} pdf14_compositor_operations;
|
|
|
39 |
|
|
|
40 |
#define PDF14_OPCODE_NAMES \
|
|
|
41 |
{\
|
|
|
42 |
"PDF14_PUSH_DEVICE ",\
|
|
|
43 |
"PDF14_POP_DEVICE ",\
|
|
|
44 |
"PDF14_BEGIN_TRANS_GROUP",\
|
|
|
45 |
"PDF14_END_TRANS_GROUP ",\
|
|
|
46 |
"PDF14_INIT_TRANS_MASK ",\
|
|
|
47 |
"PDF14_BEGIN_TRANS_MASK ",\
|
|
|
48 |
"PDF14_END_TRANS_MASK ",\
|
|
|
49 |
"PDF14_SET_BLEND_PARAMS "\
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/* Bit definitions for serializing PDF 1.4 parameters */
|
|
|
53 |
#define PDF14_SET_BLEND_MODE (1 << 0)
|
|
|
54 |
#define PDF14_SET_TEXT_KNOCKOUT (1 << 1)
|
|
|
55 |
#define PDF14_SET_SHAPE_ALPHA (1 << 2)
|
|
|
56 |
#define PDF14_SET_OPACITY_ALPHA (1 << 3)
|
|
|
57 |
|
|
|
58 |
#ifndef gs_function_DEFINED
|
|
|
59 |
typedef struct gs_function_s gs_function_t;
|
|
|
60 |
# define gs_function_DEFINED
|
|
|
61 |
#endif
|
|
|
62 |
|
|
|
63 |
typedef struct gs_transparency_source_s {
|
|
|
64 |
float alpha; /* constant alpha */
|
|
|
65 |
gs_transparency_mask_t *mask;
|
|
|
66 |
} gs_transparency_source_t;
|
|
|
67 |
|
|
|
68 |
struct gs_pdf14trans_params_s {
|
|
|
69 |
/* The type of trasnparency operation */
|
|
|
70 |
pdf14_compositor_operations pdf14_op;
|
|
|
71 |
/* Changed parameters flag */
|
|
|
72 |
int changed;
|
|
|
73 |
/* Parameters from the gs_transparency_group_params_t structure */
|
|
|
74 |
bool Isolated;
|
|
|
75 |
bool Knockout;
|
|
|
76 |
gs_rect bbox;
|
|
|
77 |
/*The transparency channel selector */
|
|
|
78 |
gs_transparency_channel_selector_t csel;
|
|
|
79 |
/* Parameters from the gx_transparency_mask_params_t structure */
|
|
|
80 |
gs_transparency_mask_subtype_t subtype;
|
|
|
81 |
int Background_components;
|
|
|
82 |
bool function_is_identity;
|
|
|
83 |
float Background[GS_CLIENT_COLOR_MAX_COMPONENTS];
|
|
|
84 |
float GrayBackground;
|
|
|
85 |
gs_function_t *transfer_function;
|
|
|
86 |
byte transfer_fn[MASK_TRANSFER_FUNCTION_SIZE];
|
|
|
87 |
/* Individual transparency parameters */
|
|
|
88 |
gs_blend_mode_t blend_mode;
|
|
|
89 |
bool text_knockout;
|
|
|
90 |
gs_transparency_source_t opacity;
|
|
|
91 |
gs_transparency_source_t shape;
|
|
|
92 |
bool mask_is_image;
|
|
|
93 |
};
|
|
|
94 |
|
|
|
95 |
typedef struct gs_pdf14trans_params_s gs_pdf14trans_params_t;
|
|
|
96 |
|
|
|
97 |
/*
|
|
|
98 |
* The PDF 1.4 transparency compositor structure. This is exactly analogous to
|
|
|
99 |
* other compositor structures, consisting of a the compositor common elements
|
|
|
100 |
* and the PDF 1.4 transparency specific parameters.
|
|
|
101 |
*/
|
|
|
102 |
typedef struct gs_pdf14trans_s {
|
|
|
103 |
gs_composite_common;
|
|
|
104 |
gs_pdf14trans_params_t params;
|
|
|
105 |
} gs_pdf14trans_t;
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
/* Access transparency-related graphics state elements. */
|
|
|
109 |
int gs_setblendmode(gs_state *, gs_blend_mode_t);
|
|
|
110 |
gs_blend_mode_t gs_currentblendmode(const gs_state *);
|
|
|
111 |
int gs_setopacityalpha(gs_state *, floatp);
|
|
|
112 |
float gs_currentopacityalpha(const gs_state *);
|
|
|
113 |
int gs_setshapealpha(gs_state *, floatp);
|
|
|
114 |
float gs_currentshapealpha(const gs_state *);
|
|
|
115 |
int gs_settextknockout(gs_state *, bool);
|
|
|
116 |
bool gs_currenttextknockout(const gs_state *);
|
|
|
117 |
|
|
|
118 |
/*
|
|
|
119 |
* Manage transparency group and mask rendering. Eventually these will be
|
|
|
120 |
* driver procedures, taking dev + pis instead of pgs.
|
|
|
121 |
*/
|
|
|
122 |
|
|
|
123 |
gs_transparency_state_type_t
|
|
|
124 |
gs_current_transparency_type(const gs_state *pgs);
|
|
|
125 |
|
|
|
126 |
/*
|
|
|
127 |
* We have to abbreviate the procedure name because procedure names are
|
|
|
128 |
* only unique to 23 characters on VMS.
|
|
|
129 |
*/
|
|
|
130 |
int gs_push_pdf14trans_device(gs_state * pgs);
|
|
|
131 |
|
|
|
132 |
int gs_pop_pdf14trans_device(gs_state * pgs);
|
|
|
133 |
|
|
|
134 |
void gs_trans_group_params_init(gs_transparency_group_params_t *ptgp);
|
|
|
135 |
|
|
|
136 |
int gs_begin_transparency_group(gs_state * pgs,
|
|
|
137 |
const gs_transparency_group_params_t *ptgp,
|
|
|
138 |
const gs_rect *pbbox);
|
|
|
139 |
|
|
|
140 |
int gs_end_transparency_group(gs_state *pgs);
|
|
|
141 |
|
|
|
142 |
void gs_trans_mask_params_init(gs_transparency_mask_params_t *ptmp,
|
|
|
143 |
gs_transparency_mask_subtype_t subtype);
|
|
|
144 |
|
|
|
145 |
int gs_begin_transparency_mask(gs_state *pgs,
|
|
|
146 |
const gs_transparency_mask_params_t *ptmp,
|
|
|
147 |
const gs_rect *pbbox, bool mask_is_image);
|
|
|
148 |
|
|
|
149 |
int gs_end_transparency_mask(gs_state *pgs,
|
|
|
150 |
gs_transparency_channel_selector_t csel);
|
|
|
151 |
|
|
|
152 |
int gs_init_transparency_mask(gs_state *pgs,
|
|
|
153 |
gs_transparency_channel_selector_t csel);
|
|
|
154 |
|
|
|
155 |
int gs_discard_transparency_layer(gs_state *pgs);
|
|
|
156 |
|
|
|
157 |
/*
|
|
|
158 |
* Imager level routines for the PDF 1.4 transparency operations.
|
|
|
159 |
*/
|
|
|
160 |
int gx_begin_transparency_group(gs_imager_state * pis, gx_device * pdev,
|
|
|
161 |
const gs_pdf14trans_params_t * pparams);
|
|
|
162 |
|
|
|
163 |
int gx_end_transparency_group(gs_imager_state * pis, gx_device * pdev);
|
|
|
164 |
|
|
|
165 |
int gx_init_transparency_mask(gs_imager_state * pis,
|
|
|
166 |
const gs_pdf14trans_params_t * pparams);
|
|
|
167 |
|
|
|
168 |
int gx_begin_transparency_mask(gs_imager_state * pis, gx_device * pdev,
|
|
|
169 |
const gs_pdf14trans_params_t * pparams);
|
|
|
170 |
|
|
|
171 |
int gx_end_transparency_mask(gs_imager_state * pis, gx_device * pdev,
|
|
|
172 |
const gs_pdf14trans_params_t * pparams);
|
|
|
173 |
|
|
|
174 |
int gx_discard_transparency_layer(gs_imager_state *pis);
|
|
|
175 |
|
|
|
176 |
/*
|
|
|
177 |
* Verify that a compositor data structure is for the PDF 1.4 compositor.
|
|
|
178 |
*/
|
|
|
179 |
int gs_is_pdf14trans_compositor(const gs_composite_t * pct);
|
|
|
180 |
|
|
|
181 |
/*
|
|
|
182 |
* Estimate the amount of space that will be required by the PDF 1.4
|
|
|
183 |
* transparency buffers for doing the blending operations. These buffers
|
|
|
184 |
* use 8 bits per component plus one or two 8 bit alpha component values.
|
|
|
185 |
* In theory there can be a large number of these buffers required. However
|
|
|
186 |
* we do not know the required number of buffers, the required numbe of
|
|
|
187 |
* alpha chanels, or the number of components for the blending operations.
|
|
|
188 |
* (This information is determined later as the data streams are parsed.)
|
|
|
189 |
* For now we are simply assuming that we will have three buffers with five
|
|
|
190 |
* eight bit values. This is a hack but not too unreasonable. However
|
|
|
191 |
* since it is a hack, we may exceed our desired buffer space while
|
|
|
192 |
* processing the file.
|
|
|
193 |
*/
|
|
|
194 |
#define NUM_PDF14_BUFFERS 3
|
|
|
195 |
#define NUM_ALPHA_CHANNELS 1
|
|
|
196 |
#define NUM_COLOR_CHANNELS 4
|
|
|
197 |
#define BITS_PER_CHANNEL 8
|
|
|
198 |
/* The estimated size of an individual PDF 1.4 buffer row (in bits) */
|
|
|
199 |
#define ESTIMATED_PDF14_ROW_SIZE(width) ((width) * BITS_PER_CHANNEL\
|
|
|
200 |
* (NUM_ALPHA_CHANNELS + NUM_COLOR_CHANNELS))
|
|
|
201 |
/* The estimated size of one row in all PDF 1.4 buffers (in bits) */
|
|
|
202 |
#define ESTIMATED_PDF14_ROW_SPACE(width) \
|
|
|
203 |
(NUM_PDF14_BUFFERS * ESTIMATED_PDF14_ROW_SIZE(width))
|
|
|
204 |
|
|
|
205 |
#endif /* gstrans_INCLUDED */
|