1//========================================================================
2//
3// SplashTypes.h
4//
5//========================================================================
6
7//========================================================================
8//
9// Modified under the Poppler project - http://poppler.freedesktop.org
10//
11// All changes made under the Poppler project to this file are licensed
12// under GPL version 2 or later
13//
14// Copyright (C) 2006, 2010, 2019, 2020 Albert Astals Cid <aacid@kde.org>
15// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
16// Copyright (C) 2009, 2011-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
17// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
18// Copyright (C) 2010 William Bader <williambader@hotmail.com>
19// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
20// Copyright (C) 2018 Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de>
21//
22// To see a description of the changes please see the Changelog file that
23// came with your tarball or type make ChangeLog if you are building from git
24//
25//========================================================================
26
27#ifndef SPLASHTYPES_H
28#define SPLASHTYPES_H
29
30#include <cstddef>
31
32//------------------------------------------------------------------------
33// coordinates
34//------------------------------------------------------------------------
35
36#if defined(USE_FLOAT)
37typedef float SplashCoord;
38#else
39typedef double SplashCoord;
40#endif
41
42//------------------------------------------------------------------------
43// antialiasing
44//------------------------------------------------------------------------
45
46#define splashAASize 4
47
48#ifndef SPOT_NCOMPS
49# define SPOT_NCOMPS 4
50#endif
51
52//------------------------------------------------------------------------
53// colors
54//------------------------------------------------------------------------
55
56enum SplashColorMode
57{
58 splashModeMono1, // 1 bit per component, 8 pixels per byte,
59 // MSbit is on the left
60 splashModeMono8, // 1 byte per component, 1 byte per pixel
61 splashModeRGB8, // 1 byte per component, 3 bytes per pixel:
62 // RGBRGB...
63 splashModeBGR8, // 1 byte per component, 3 bytes per pixel:
64 // BGRBGR...
65 splashModeXBGR8, // 1 byte per component, 4 bytes per pixel:
66 // XBGRXBGR...
67 splashModeCMYK8, // 1 byte per component, 4 bytes per pixel:
68 // CMYKCMYK...
69 splashModeDeviceN8 // 1 byte per component,
70 // 4 bytes + n bytes spot colors per pixel:
71 // CMYKSSSSCMYKSSSS...
72};
73
74enum SplashThinLineMode
75{
76 splashThinLineDefault, // if SA on: draw solid if requested line width, transformed into
77 // device space, is less than half a pixel and a shaped line else
78 splashThinLineSolid, // draw line solid at least with 1 pixel
79 splashThinLineShape // draw line shaped at least with 1 pixel
80};
81// number of components in each color mode
82// (defined in SplashState.cc)
83extern int splashColorModeNComps[];
84
85// max number of components in any SplashColor
86constexpr std::size_t splashMaxColorComps = SPOT_NCOMPS + 4;
87
88typedef unsigned char SplashColor[splashMaxColorComps];
89typedef unsigned char *SplashColorPtr;
90typedef const unsigned char *SplashColorConstPtr;
91
92// RGB8
93static inline unsigned char splashRGB8R(SplashColorPtr rgb8)
94{
95 return rgb8[0];
96}
97static inline unsigned char splashRGB8G(SplashColorPtr rgb8)
98{
99 return rgb8[1];
100}
101static inline unsigned char splashRGB8B(SplashColorPtr rgb8)
102{
103 return rgb8[2];
104}
105
106// BGR8
107static inline unsigned char splashBGR8R(SplashColorPtr bgr8)
108{
109 return bgr8[2];
110}
111static inline unsigned char splashBGR8G(SplashColorPtr bgr8)
112{
113 return bgr8[1];
114}
115static inline unsigned char splashBGR8B(SplashColorPtr bgr8)
116{
117 return bgr8[0];
118}
119
120// CMYK8
121static inline unsigned char splashCMYK8C(SplashColorPtr cmyk8)
122{
123 return cmyk8[0];
124}
125static inline unsigned char splashCMYK8M(SplashColorPtr cmyk8)
126{
127 return cmyk8[1];
128}
129static inline unsigned char splashCMYK8Y(SplashColorPtr cmyk8)
130{
131 return cmyk8[2];
132}
133static inline unsigned char splashCMYK8K(SplashColorPtr cmyk8)
134{
135 return cmyk8[3];
136}
137
138// DEVICEN8
139static inline unsigned char splashDeviceN8C(SplashColorPtr deviceN8)
140{
141 return deviceN8[0];
142}
143static inline unsigned char splashDeviceN8M(SplashColorPtr deviceN8)
144{
145 return deviceN8[1];
146}
147static inline unsigned char splashDeviceN8Y(SplashColorPtr deviceN8)
148{
149 return deviceN8[2];
150}
151static inline unsigned char splashDeviceN8K(SplashColorPtr deviceN8)
152{
153 return deviceN8[3];
154}
155static inline unsigned char splashDeviceN8S(SplashColorPtr deviceN8, int nSpot)
156{
157 return deviceN8[4 + nSpot];
158}
159
160static inline void splashClearColor(SplashColorPtr dest)
161{
162 dest[0] = 0;
163 dest[1] = 0;
164 dest[2] = 0;
165 dest[3] = 0;
166 for (int i = 4; i < SPOT_NCOMPS + 4; i++) {
167 dest[i] = 0;
168 }
169}
170
171static inline void splashColorCopy(SplashColorPtr dest, SplashColorConstPtr src)
172{
173 dest[0] = src[0];
174 dest[1] = src[1];
175 dest[2] = src[2];
176 dest[3] = src[3];
177 for (int i = 4; i < SPOT_NCOMPS + 4; i++) {
178 dest[i] = src[i];
179 }
180}
181
182static inline bool splashColorEqual(SplashColorConstPtr dest, SplashColorConstPtr src)
183{
184 for (int i = 0; i < SPOT_NCOMPS + 4; i++) {
185 if (dest[i] != src[i]) {
186 return false;
187 }
188 }
189 return true;
190}
191
192static inline void splashColorXor(SplashColorPtr dest, SplashColorConstPtr src)
193{
194 dest[0] ^= src[0];
195 dest[1] ^= src[1];
196 dest[2] ^= src[2];
197 dest[3] ^= src[3];
198 for (int i = 4; i < SPOT_NCOMPS + 4; i++) {
199 dest[i] ^= src[i];
200 }
201}
202
203//------------------------------------------------------------------------
204// blend functions
205//------------------------------------------------------------------------
206
207typedef void (*SplashBlendFunc)(SplashColorPtr src, SplashColorPtr dest, SplashColorPtr blend, SplashColorMode cm);
208
209//------------------------------------------------------------------------
210// screen parameters
211//------------------------------------------------------------------------
212
213enum SplashScreenType
214{
215 splashScreenDispersed,
216 splashScreenClustered,
217 splashScreenStochasticClustered
218};
219
220struct SplashScreenParams
221{
222 SplashScreenType type;
223 int size;
224 int dotRadius;
225 SplashCoord gamma;
226 SplashCoord blackThreshold;
227 SplashCoord whiteThreshold;
228};
229
230//------------------------------------------------------------------------
231// error results
232//------------------------------------------------------------------------
233
234typedef int SplashError;
235
236//------------------------------------------------------------------------
237// image file formats
238//------------------------------------------------------------------------
239
240enum SplashImageFileFormat
241{
242 splashFormatJpeg,
243 splashFormatPng,
244 splashFormatTiff,
245 splashFormatJpegCMYK
246};
247
248#endif
249

source code of poppler/splash/SplashTypes.h