Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/psi/zcsindex.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
/* Indexed color space support */
18
#include "memory_.h"
19
#include "ghost.h"
20
#include "oper.h"
21
#include "gsstruct.h"
22
#include "gscolor.h"
23
#include "gsmatrix.h"   /* for gxcolor2.h */
24
#include "gxcspace.h"
25
#include "gxfixed.h"    /* ditto */
26
#include "gxcolor2.h"
27
#include "estack.h"
28
#include "ialloc.h"
29
#include "icsmap.h"
30
#include "igstate.h"
31
#include "ivmspace.h"
32
#include "store.h"
33
34
/* ------ Internal routines ------ */
35
36
/* Allocate, and prepare to load, the index or tint map. */
37
int
38
zcs_begin_map(i_ctx_t *i_ctx_p, gs_color_space *pcs, gs_indexed_map ** pmap, const ref * pproc,
39
              int num_entries,  const gs_color_space * base_space,
40
              op_proc_t map1)
41
0
{
42
0
    gs_memory_t *mem = gs_gstate_memory(igs);
43
0
    int space = imemory_space((gs_ref_memory_t *)mem);
44
0
    int num_components = cs_num_components(base_space);
45
0
    int num_values = num_entries * num_components;
46
0
    gs_indexed_map *map;
47
0
    int code = alloc_indexed_map(&map, num_values, mem,
48
0
                                 "setcolorspace(mapped)");
49
0
    es_ptr ep;
50
51
0
    if (code < 0)
52
0
        return code;
53
0
    *pmap = map;
54
    /* Map the entire set of color indices.  Since the */
55
    /* o-stack may not be able to hold N*4096 values, we have */
56
    /* to load them into the cache as they are generated. */
57
0
    check_estack(num_csme + 1); /* 1 extra for map1 proc */
58
0
    ep = esp += num_csme;
59
0
    make_int(ep + csme_num_components, num_components);
60
0
    make_struct(ep + csme_cspace, space, pcs);
61
0
    rc_increment_cs(pcs);
62
0
    ep[csme_proc] = *pproc;
63
0
    make_int(ep + csme_hival, num_entries - 1);
64
0
    make_int(ep + csme_index, -1);
65
0
    push_op_estack(map1);
66
0
    return o_push_estack;
67
0
}