summaryrefslogtreecommitdiff
path: root/psi/zcolor3.c
blob: 2ae0b2035692e22fd408ecf64c4d266f76ecfb0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* Copyright (C) 2001-2023 Artifex Software, Inc.
   All Rights Reserved.

   This software is provided AS-IS with no warranty, either express or
   implied.

   This software is distributed under license and may not be copied,
   modified or distributed except as expressly authorized under the terms
   of the license contained in the file LICENSE in this distribution.

   Refer to licensing information at http://www.artifex.com or contact
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
   CA 94129, USA, for further information.
*/


/* Level 3 color operators */
#include "ghost.h"
#include "oper.h"
#include "igstate.h"
#include "store.h"

/*
 *  <bool>   .setuseciecolor  -
 *
 * Set the use_cie_color parameter for the interpreter state, which
 * corresponds to the UseCIEColor page device parameter. This parameter
 * may be read at all language levels, but it may be set only for
 * language level 3. The parameter is handled separately from the page
 * device dictionary primarily for performance reasons (it may need to
 * be checked frequently), but also to ensure proper language level
 * specific behavior.
 *
 * This operator is accessible only during initialization and is called
 * only under controlled conditions. Hence, it does not do any operand
 * checking.
 */
static int
zsetuseciecolor(i_ctx_t * i_ctx_p)
{
    os_ptr  op = osp;
    check_type(*op, t_boolean);

    istate->use_cie_color = *op;
    pop(1);
    return 0;
}

/* - .currentrenderingintent <int> */
static int
zcurrentrenderingintent(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;

    push(1);
    make_int(op, gs_currentrenderingintent(igs));
    return 0;
}

/* <int> .setrenderingintent -
 * See the comment in gsstate.c about the argumet interepretation.
 */
static int
zsetrenderingintent(i_ctx_t * i_ctx_p)
{
    os_ptr op = osp;
    int param;
    int code = int_param(op, max_int, &param);

    if (code < 0 || (code = gs_setrenderingintent(igs, param)) < 0)
        return code;
    pop(1);
    return 0;
}

/* - .currentblackptcomp <int> */
static int
zcurrentblackptcomp(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;

    push(1);
    make_int(op, gs_currentblackptcomp(igs));
    return 0;
}

/* <int> .setblackptcomp */
static int
zsetblackptcomp(i_ctx_t * i_ctx_p)
{
    os_ptr op = osp;
    int param;
    int code = int_param(op, max_int, &param);

    if (code < 0 || (code = gs_setblackptcomp(igs, param)) < 0)
        return code;
    pop(1);
    return 0;
}

/*
 * Initialization procedure
 */

const op_def    zcolor3_l3_op_defs[] = {
    op_def_begin_ll3(),
    { "1.setuseciecolor", zsetuseciecolor },
    { "0.currentrenderintent", zcurrentrenderingintent },
    { "1.setrenderingintent", zsetrenderingintent },
    { "0.currentblackptcomp", zcurrentblackptcomp },
    { "1.setblackptcomp", zsetblackptcomp },
    op_def_end(0)
};