summaryrefslogtreecommitdiff
path: root/src/graphics_state.h
blob: e5cc2bf134c02f5df21e325f2ce99884915f9ba8 (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
/*
 * Copyright 2018 Vincent Sanders <vince@netsurf-browser.org>
 *
 * This file is part of libnspdf.
 *
 * Licensed under the MIT License,
 *                http://www.opensource.org/licenses/mit-license.php
 */

/**
 * \file
 * NetSurf PDF library graphics state
 */

#ifndef NSPDF__GRAPHICS_STATE_H_
#define NSPDF__GRAPHICS_STATE_H_

/**
 * colourspaces
 * \todo extend this with full list from section 4.5.2
 */
enum graphics_state_colorspace {
    GSDeviceGray = 0, /* Default */
    GSDeviceRGB,
    GSDeviceCMYK,
};

struct graphics_state_color {
    enum graphics_state_colorspace space;
    union {
        float gray; /* default is 0 - black */
        struct {
            float r;
            float g;
            float b;
        } rgb;
        struct {
            float c;
            float m;
            float y;
            float k;
        } cmyk;
    } u;
};

struct graphics_state_param {
    float ctm[6]; /* current transform matrix */
    /* clipping path */
    struct {
        struct graphics_state_color colour;
    } stroke;
    struct {
        struct graphics_state_color colour;
    } other;
    /* text state */
    float line_width;
    unsigned int line_cap;
    unsigned int line_join;
    float miter_limit;
    /* dash pattern */
    /* rendering intent RelativeColorimetric */
    bool stroke_adjustment;
    /* blend mode: Normal */
    /* soft mask */
    /* alpha constant */
    /* alpha source */

    /* device dependant */
    bool overprint;
    float overprint_mode;
    /* black generation */
    /* undercolor removal */
    /* transfer */
    /* halftone */
    float flatness;
    float smoothness;
};

struct graphics_state {
    float *path; /* current path */
    unsigned int path_idx; /* current index into path */
    unsigned int path_alloc; /* current number of path elements allocated */

    struct graphics_state_param *param_stack; /* parameter stack */
    unsigned int param_stack_idx;
    unsigned int param_stack_alloc;
};

#endif