Coverage Report

Created: 2025-06-10 07:27

/src/ghostpdl/pdf/pdf_colour.h
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2018-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
/* colour operations for the PDF interpreter */
17
18
#ifndef PDF_COLOUR_OPERATORS
19
#define PDF_COLOUR_OPERATORS
20
21
#include "gscolor1.h"
22
#include "gscspace.h"
23
#include "pdf_stack.h"  /* for pdfi_countup/countdown */
24
#include "pdf_misc.h"   /* for pdf_name_cmp */
25
26
static inline void pdfi_set_colourspace_name(pdf_context *ctx, gs_color_space *pcs, pdf_name *n)
27
178k
{
28
178k
    if (pcs->interpreter_data != NULL) {
29
178k
        pdf_obj *o = (pdf_obj *)(pcs->interpreter_data);
30
178k
        if (o != NULL && pdfi_type_of(o) == PDF_NAME) {
31
116k
            pdfi_countdown(o);
32
116k
            pcs->interpreter_data = NULL;
33
116k
        }
34
178k
    }
35
36
178k
    if (n != NULL) {
37
178k
        pcs->interpreter_data = n;
38
178k
        pdfi_countup(n);
39
178k
    } else {
40
0
        if (pcs->interpreter_data == NULL)
41
0
            pcs->interpreter_data = ctx;
42
0
    }
43
178k
}
Unexecuted instantiation: ghostpdf.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_int.c:pdfi_set_colourspace_name
pdf_colour.c:pdfi_set_colourspace_name
Line
Count
Source
27
178k
{
28
178k
    if (pcs->interpreter_data != NULL) {
29
178k
        pdf_obj *o = (pdf_obj *)(pcs->interpreter_data);
30
178k
        if (o != NULL && pdfi_type_of(o) == PDF_NAME) {
31
116k
            pdfi_countdown(o);
32
116k
            pcs->interpreter_data = NULL;
33
116k
        }
34
178k
    }
35
36
178k
    if (n != NULL) {
37
178k
        pcs->interpreter_data = n;
38
178k
        pdfi_countup(n);
39
178k
    } else {
40
0
        if (pcs->interpreter_data == NULL)
41
0
            pcs->interpreter_data = ctx;
42
0
    }
43
178k
}
Unexecuted instantiation: pdf_pattern.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_gstate.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_image.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_page.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_annot.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_text.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_shading.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_trans.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_check.c:pdfi_set_colourspace_name
Unexecuted instantiation: pdf_doc.c:pdfi_set_colourspace_name
44
45
static inline void pdfi_set_colour_callback(gs_color_space *pcs, pdf_context *ctx, gs_cspace_free_proc_t pdfi_cspace_free_callback)
46
2.15M
{
47
2.15M
    if (pcs->interpreter_data == NULL)
48
1.81M
        pcs->interpreter_data = ctx;
49
2.15M
    pcs->interpreter_free_cspace_proc = pdfi_cspace_free_callback;
50
2.15M
}
Unexecuted instantiation: ghostpdf.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_int.c:pdfi_set_colour_callback
pdf_colour.c:pdfi_set_colour_callback
Line
Count
Source
46
2.15M
{
47
2.15M
    if (pcs->interpreter_data == NULL)
48
1.81M
        pcs->interpreter_data = ctx;
49
2.15M
    pcs->interpreter_free_cspace_proc = pdfi_cspace_free_callback;
50
2.15M
}
Unexecuted instantiation: pdf_pattern.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_gstate.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_image.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_page.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_annot.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_text.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_shading.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_trans.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_check.c:pdfi_set_colour_callback
Unexecuted instantiation: pdf_doc.c:pdfi_set_colour_callback
51
52
static inline int check_same_current_space(pdf_context *ctx, pdf_name *n)
53
328k
{
54
328k
    pdf_obj *o = (pdf_obj *)(ctx->pgs->color[0].color_space->interpreter_data);
55
56
328k
    if (o == NULL || pdfi_type_of(o) != PDF_NAME)
57
162k
        return 0;
58
59
165k
    if (pdfi_name_cmp(n, (pdf_name *)o) == 0) {
60
94.9k
        if (n->object_num == o->object_num && n->indirect_num == o->indirect_num)
61
94.0k
            return 1;
62
94.9k
    }
63
71.1k
    return 0;
64
165k
}
Unexecuted instantiation: ghostpdf.c:check_same_current_space
Unexecuted instantiation: pdf_int.c:check_same_current_space
pdf_colour.c:check_same_current_space
Line
Count
Source
53
328k
{
54
328k
    pdf_obj *o = (pdf_obj *)(ctx->pgs->color[0].color_space->interpreter_data);
55
56
328k
    if (o == NULL || pdfi_type_of(o) != PDF_NAME)
57
162k
        return 0;
58
59
165k
    if (pdfi_name_cmp(n, (pdf_name *)o) == 0) {
60
94.9k
        if (n->object_num == o->object_num && n->indirect_num == o->indirect_num)
61
94.0k
            return 1;
62
94.9k
    }
63
71.1k
    return 0;
64
165k
}
Unexecuted instantiation: pdf_pattern.c:check_same_current_space
Unexecuted instantiation: pdf_gstate.c:check_same_current_space
Unexecuted instantiation: pdf_image.c:check_same_current_space
Unexecuted instantiation: pdf_page.c:check_same_current_space
Unexecuted instantiation: pdf_annot.c:check_same_current_space
Unexecuted instantiation: pdf_text.c:check_same_current_space
Unexecuted instantiation: pdf_shading.c:check_same_current_space
Unexecuted instantiation: pdf_trans.c:check_same_current_space
Unexecuted instantiation: pdf_check.c:check_same_current_space
Unexecuted instantiation: pdf_doc.c:check_same_current_space
65
66
int pdfi_setgraystroke(pdf_context *ctx);
67
int pdfi_setgrayfill(pdf_context *ctx);
68
int pdfi_setrgbstroke(pdf_context *ctx);
69
int pdfi_setrgbfill(pdf_context *ctx);
70
int pdfi_setrgbfill_array(pdf_context *ctx);
71
int pdfi_setcmykstroke(pdf_context *ctx);
72
int pdfi_setcmykfill(pdf_context *ctx);
73
int pdfi_setstrokecolor_space(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict);
74
int pdfi_setfillcolor_space(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict);
75
int pdfi_setstrokecolor(pdf_context *ctx);
76
int pdfi_setfillcolor(pdf_context *ctx);
77
int pdfi_setcolorN(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict, bool is_fill);
78
int pdfi_ri(pdf_context *ctx);
79
80
int pdfi_setcolor_from_array(pdf_context *ctx, pdf_array *array);
81
int pdfi_gs_setgray(pdf_context *ctx, double d);
82
int pdfi_gs_setrgbcolor(pdf_context *ctx, double r, double g, double b);
83
84
/* For potential use by other types of object (images etc) */
85
int pdfi_gs_setcolorspace(pdf_context *ctx, gs_color_space *pcs);
86
int pdfi_setcolorspace(pdf_context *ctx, pdf_obj *space, pdf_dict *stream_dict, pdf_dict *page_dict);
87
int pdfi_create_colorspace(pdf_context *ctx, pdf_obj *space, pdf_dict *stream_dict, pdf_dict *page_dict, gs_color_space **ppcs, bool inline_image);
88
int pdfi_create_icc_colorspace_from_stream(pdf_context *ctx, pdf_c_stream *stream, gs_offset_t offset,
89
                                           unsigned int length, int comps, int *icc_N, ulong dictkey, gs_color_space **ppcs);
90
91
/* Page level spot colour detection and enumeration */
92
int pdfi_check_ColorSpace_for_spots(pdf_context *ctx, pdf_obj *space, pdf_dict *parent_dict, pdf_dict *page_dict, pdf_dict *spot_dict);
93
94
int pdfi_color_setoutputintent(pdf_context *ctx, pdf_dict *intent_dict, pdf_stream *profile);
95
96
/* Sets up the DefaultRGB, DefaultCMYK and DefaultGray colour spaces if present */
97
int pdfi_setup_DefaultSpaces(pdf_context *ctx, pdf_dict *source_dict);
98
99
#endif