File: SplashTypes.h

package info (click to toggle)
poppler 20.09.0-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 16,092 kB
  • sloc: cpp: 151,577; ansic: 30,155; python: 367; makefile: 42; sh: 36
file content (243 lines) | stat: -rw-r--r-- 6,894 bytes parent folder | download | duplicates (2)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
//========================================================================
//
// SplashTypes.h
//
//========================================================================

//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
// Copyright (C) 2006, 2010, 2019, 2020 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
// Copyright (C) 2009, 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
// Copyright (C) 2010 William Bader <williambader@hotmail.com>
// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2018 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
//
// To see a description of the changes please see the Changelog file that
// came with your tarball or type make ChangeLog if you are building from git
//
//========================================================================

#ifndef SPLASHTYPES_H
#define SPLASHTYPES_H

#include <cstddef>

//------------------------------------------------------------------------
// coordinates
//------------------------------------------------------------------------

#if defined(USE_FLOAT)
typedef float SplashCoord;
#else
typedef double SplashCoord;
#endif

//------------------------------------------------------------------------
// antialiasing
//------------------------------------------------------------------------

#define splashAASize 4

#ifndef SPOT_NCOMPS
#    define SPOT_NCOMPS 4
#endif

//------------------------------------------------------------------------
// colors
//------------------------------------------------------------------------

enum SplashColorMode
{
    splashModeMono1, // 1 bit per component, 8 pixels per byte,
                     //   MSbit is on the left
    splashModeMono8, // 1 byte per component, 1 byte per pixel
    splashModeRGB8, // 1 byte per component, 3 bytes per pixel:
                    //   RGBRGB...
    splashModeBGR8, // 1 byte per component, 3 bytes per pixel:
                    //   BGRBGR...
    splashModeXBGR8, // 1 byte per component, 4 bytes per pixel:
                     //   XBGRXBGR...
    splashModeCMYK8, // 1 byte per component, 4 bytes per pixel:
                     //   CMYKCMYK...
    splashModeDeviceN8 // 1 byte per component,
                       // 4 bytes + n bytes spot colors per pixel:
                       // CMYKSSSSCMYKSSSS...
};

enum SplashThinLineMode
{
    splashThinLineDefault, // if SA on: draw solid if requested line width, transformed into
                           // device space, is less than half a pixel and a shaped line else
    splashThinLineSolid, // draw line solid at least with 1 pixel
    splashThinLineShape // draw line shaped at least with 1 pixel
};
// number of components in each color mode
// (defined in SplashState.cc)
extern int splashColorModeNComps[];

// max number of components in any SplashColor
constexpr std::size_t splashMaxColorComps = SPOT_NCOMPS + 4;

typedef unsigned char SplashColor[splashMaxColorComps];
typedef unsigned char *SplashColorPtr;
typedef const unsigned char *SplashColorConstPtr;

// RGB8
static inline unsigned char splashRGB8R(SplashColorPtr rgb8)
{
    return rgb8[0];
}
static inline unsigned char splashRGB8G(SplashColorPtr rgb8)
{
    return rgb8[1];
}
static inline unsigned char splashRGB8B(SplashColorPtr rgb8)
{
    return rgb8[2];
}

// BGR8
static inline unsigned char splashBGR8R(SplashColorPtr bgr8)
{
    return bgr8[2];
}
static inline unsigned char splashBGR8G(SplashColorPtr bgr8)
{
    return bgr8[1];
}
static inline unsigned char splashBGR8B(SplashColorPtr bgr8)
{
    return bgr8[0];
}

// CMYK8
static inline unsigned char splashCMYK8C(SplashColorPtr cmyk8)
{
    return cmyk8[0];
}
static inline unsigned char splashCMYK8M(SplashColorPtr cmyk8)
{
    return cmyk8[1];
}
static inline unsigned char splashCMYK8Y(SplashColorPtr cmyk8)
{
    return cmyk8[2];
}
static inline unsigned char splashCMYK8K(SplashColorPtr cmyk8)
{
    return cmyk8[3];
}

// DEVICEN8
static inline unsigned char splashDeviceN8C(SplashColorPtr deviceN8)
{
    return deviceN8[0];
}
static inline unsigned char splashDeviceN8M(SplashColorPtr deviceN8)
{
    return deviceN8[1];
}
static inline unsigned char splashDeviceN8Y(SplashColorPtr deviceN8)
{
    return deviceN8[2];
}
static inline unsigned char splashDeviceN8K(SplashColorPtr deviceN8)
{
    return deviceN8[3];
}
static inline unsigned char splashDeviceN8S(SplashColorPtr deviceN8, int nSpot)
{
    return deviceN8[4 + nSpot];
}

static inline void splashClearColor(SplashColorPtr dest)
{
    dest[0] = 0;
    dest[1] = 0;
    dest[2] = 0;
    dest[3] = 0;
    for (int i = 4; i < SPOT_NCOMPS + 4; i++)
        dest[i] = 0;
}

static inline void splashColorCopy(SplashColorPtr dest, SplashColorConstPtr src)
{
    dest[0] = src[0];
    dest[1] = src[1];
    dest[2] = src[2];
    dest[3] = src[3];
    for (int i = 4; i < SPOT_NCOMPS + 4; i++)
        dest[i] = src[i];
}

static inline bool splashColorEqual(SplashColorConstPtr dest, SplashColorConstPtr src)
{
    for (int i = 0; i < SPOT_NCOMPS + 4; i++)
        if (dest[i] != src[i])
            return false;
    return true;
}

static inline void splashColorXor(SplashColorPtr dest, SplashColorConstPtr src)
{
    dest[0] ^= src[0];
    dest[1] ^= src[1];
    dest[2] ^= src[2];
    dest[3] ^= src[3];
    for (int i = 4; i < SPOT_NCOMPS + 4; i++)
        dest[i] ^= src[i];
}

//------------------------------------------------------------------------
// blend functions
//------------------------------------------------------------------------

typedef void (*SplashBlendFunc)(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm);

//------------------------------------------------------------------------
// screen parameters
//------------------------------------------------------------------------

enum SplashScreenType
{
    splashScreenDispersed,
    splashScreenClustered,
    splashScreenStochasticClustered
};

struct SplashScreenParams
{
    SplashScreenType type;
    int size;
    int dotRadius;
    SplashCoord gamma;
    SplashCoord blackThreshold;
    SplashCoord whiteThreshold;
};

//------------------------------------------------------------------------
// error results
//------------------------------------------------------------------------

typedef int SplashError;

//------------------------------------------------------------------------
// image file formats
//------------------------------------------------------------------------

enum SplashImageFileFormat
{
    splashFormatJpeg,
    splashFormatPng,
    splashFormatTiff,
    splashFormatJpegCMYK
};

#endif