xref: /plan9/sys/src/cmd/gs/src/gstparam.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
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: gstparam.h,v 1.15 2005/08/30 16:49:34 igor Exp $ */
18 /* Transparency parameter definitions */
19 
20 #ifndef gstparam_INCLUDED
21 #  define gstparam_INCLUDED
22 
23 #include "gsccolor.h"
24 #include "gsrefct.h"
25 
26 /* Define the names of the known blend modes. */
27 typedef enum {
28     BLEND_MODE_Compatible,
29     BLEND_MODE_Normal,
30     BLEND_MODE_Multiply,
31     BLEND_MODE_Screen,
32     BLEND_MODE_Difference,
33     BLEND_MODE_Darken,
34     BLEND_MODE_Lighten,
35     BLEND_MODE_ColorDodge,
36     BLEND_MODE_ColorBurn,
37     BLEND_MODE_Exclusion,
38     BLEND_MODE_HardLight,
39     BLEND_MODE_Overlay,
40     BLEND_MODE_SoftLight,
41     BLEND_MODE_Luminosity,
42     BLEND_MODE_Hue,
43     BLEND_MODE_Saturation,
44     BLEND_MODE_Color
45 #define MAX_BLEND_MODE BLEND_MODE_Color
46 } gs_blend_mode_t;
47 #define GS_BLEND_MODE_NAMES\
48   "Compatible", "Normal", "Multiply", "Screen", "Difference",\
49   "Darken", "Lighten", "ColorDodge", "ColorBurn", "Exclusion",\
50   "HardLight", "Overlay", "SoftLight", "Luminosity", "Hue",\
51   "Saturation", "Color"
52 
53 /* Define the common part for a transparency stack state. */
54 typedef enum {
55     TRANSPARENCY_STATE_Group = 1,	/* must not be 0 */
56     TRANSPARENCY_STATE_Mask
57 } gs_transparency_state_type_t;
58 #define GS_TRANSPARENCY_STATE_COMMON\
59     gs_transparency_state_t *saved;\
60     gs_transparency_state_type_t type
61 typedef struct gs_transparency_state_s gs_transparency_state_t;
62 struct gs_transparency_state_s {
63     GS_TRANSPARENCY_STATE_COMMON;
64 };
65 
66 /* Define the common part for a cached transparency mask. */
67 #define GS_TRANSPARENCY_MASK_COMMON\
68     rc_header rc
69 typedef struct gs_transparency_mask_s {
70     GS_TRANSPARENCY_MASK_COMMON;
71 } gs_transparency_mask_t;
72 
73 /* Define the parameter structure for a transparency group. */
74 #ifndef gs_color_space_DEFINED
75 #  define gs_color_space_DEFINED
76 typedef struct gs_color_space_s gs_color_space;
77 #endif
78 #ifndef gs_function_DEFINED
79 typedef struct gs_function_s gs_function_t;
80 #  define gs_function_DEFINED
81 #endif
82 
83 /* (Update gs_trans_group_params_init if these change.) */
84 typedef struct gs_transparency_group_params_s {
85     const gs_color_space *ColorSpace;
86     bool Isolated;
87     bool Knockout;
88 } gs_transparency_group_params_t;
89 
90 /* Define the parameter structure for a transparency mask. */
91 typedef enum {
92     TRANSPARENCY_MASK_Alpha,
93     TRANSPARENCY_MASK_Luminosity
94 } gs_transparency_mask_subtype_t;
95 
96 #define GS_TRANSPARENCY_MASK_SUBTYPE_NAMES\
97   "Alpha", "Luminosity"
98 
99 /* See the gx_transparency_mask_params_t type below */
100 /* (Update gs_trans_mask_params_init if these change.) */
101 typedef struct gs_transparency_mask_params_s {
102     gs_transparency_mask_subtype_t subtype;
103     int Background_components;
104     float Background[GS_CLIENT_COLOR_MAX_COMPONENTS];
105     float GrayBackground;
106     int (*TransferFunction)(floatp in, float *out, void *proc_data);
107     gs_function_t *TransferFunction_data;
108 } gs_transparency_mask_params_t;
109 
110 #define MASK_TRANSFER_FUNCTION_SIZE 256
111 
112 /* The post clist version of transparency mask parameters */
113 typedef struct gx_transparency_mask_params_s {
114     gs_transparency_mask_subtype_t subtype;
115     int Background_components;
116     float Background[GS_CLIENT_COLOR_MAX_COMPONENTS];
117     float GrayBackground;
118     bool function_is_identity;
119     byte transfer_fn[MASK_TRANSFER_FUNCTION_SIZE];
120 } gx_transparency_mask_params_t;
121 
122 /* Select the opacity or shape parameters. */
123 typedef enum {
124     TRANSPARENCY_CHANNEL_Opacity = 0,
125     TRANSPARENCY_CHANNEL_Shape = 1
126 } gs_transparency_channel_selector_t;
127 
128 #endif /* gstparam_INCLUDED */
129