SplashTypes.h 6.3 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4 5 6
//========================================================================
//
// SplashTypes.h
//
//========================================================================

7 8 9 10
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
11 12 13
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
14
// Copyright (C) 2006, 2010 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>
Stefan Thomas's avatar
Stefan Thomas committed
17
// Copyright (C) 2009 Stefan Thomas <thomas@eload24.com>
18
// Copyright (C) 2010 William Bader <williambader@hotmail.com>
19 20 21 22 23 24
//
// 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
//
//========================================================================

Kristian Høgsberg's avatar
Kristian Høgsberg committed
25 26 27 28 29 30 31 32 33
#ifndef SPLASHTYPES_H
#define SPLASHTYPES_H

#include "goo/gtypes.h"

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

34
#if defined(USE_FIXEDPOINT)
35
#include "goo/FixedPoint.h"
36
typedef FixedPoint SplashCoord;
37
#elif defined(USE_FLOAT)
38
typedef float SplashCoord;
39
#else
Kristian Høgsberg's avatar
Kristian Høgsberg committed
40
typedef double SplashCoord;
41
#endif
Kristian Høgsberg's avatar
Kristian Høgsberg committed
42

43 44 45 46 47 48
//------------------------------------------------------------------------
// antialiasing
//------------------------------------------------------------------------

#define splashAASize 4

49 50 51 52
#ifndef SPOT_NCOMPS
#define SPOT_NCOMPS 4
#endif

Kristian Høgsberg's avatar
Kristian Høgsberg committed
53 54 55 56 57
//------------------------------------------------------------------------
// colors
//------------------------------------------------------------------------

enum SplashColorMode {
58 59 60 61 62 63 64
  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...
65
  splashModeXBGR8		// 1 byte per component, 4 bytes per pixel:
66
				//   XBGRXBGR...
67
#ifdef SPLASH_CMYK
68
  ,
69
  splashModeCMYK8,	// 1 byte per component, 4 bytes per pixel:
70
				//   CMYKCMYK...
71 72 73
  splashModeDeviceN8		// 1 byte per component, 
                        // 4 bytes + n bytes spot colors per pixel:
				                // CMYKSSSSCMYKSSSS...
74
#endif
Kristian Høgsberg's avatar
Kristian Høgsberg committed
75 76
};

77 78 79 80 81 82
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
};
83 84 85 86
// number of components in each color mode
// (defined in SplashState.cc)
extern int splashColorModeNComps[];

Kristian Høgsberg's avatar
Kristian Høgsberg committed
87
// max number of components in any SplashColor
88
#ifdef SPLASH_CMYK
89 90
#define splashMaxColorComps SPOT_NCOMPS+4
#else
91
#define splashMaxColorComps 4
92
#endif
Kristian Høgsberg's avatar
Kristian Høgsberg committed
93

94 95 96 97 98 99 100 101 102 103 104 105 106
typedef Guchar SplashColor[splashMaxColorComps];
typedef Guchar *SplashColorPtr;

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

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

107
#ifdef SPLASH_CMYK
108 109 110 111 112
// CMYK8
static inline Guchar splashCMYK8C(SplashColorPtr cmyk8) { return cmyk8[0]; }
static inline Guchar splashCMYK8M(SplashColorPtr cmyk8) { return cmyk8[1]; }
static inline Guchar splashCMYK8Y(SplashColorPtr cmyk8) { return cmyk8[2]; }
static inline Guchar splashCMYK8K(SplashColorPtr cmyk8) { return cmyk8[3]; }
113 114 115 116 117 118 119

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

122 123 124 125
static inline void splashClearColor(SplashColorPtr dest) {
  dest[0] = 0;
  dest[1] = 0;
  dest[2] = 0;
126
#ifdef SPLASH_CMYK
127
  dest[3] = 0;
128 129
  for (int i = SPOT_NCOMPS; i < SPOT_NCOMPS + 4; i++)
    dest[i] = 0;
130 131 132
#endif
}

133 134 135 136
static inline void splashColorCopy(SplashColorPtr dest, SplashColorPtr src) {
  dest[0] = src[0];
  dest[1] = src[1];
  dest[2] = src[2];
137
#ifdef SPLASH_CMYK
138
  dest[3] = src[3];
139 140
  for (int i = SPOT_NCOMPS; i < SPOT_NCOMPS + 4; i++)
    dest[i] = src[i];
141 142 143 144 145 146 147
#endif
}

static inline void splashColorXor(SplashColorPtr dest, SplashColorPtr src) {
  dest[0] ^= src[0];
  dest[1] ^= src[1];
  dest[2] ^= src[2];
148
#ifdef SPLASH_CMYK
149
  dest[3] ^= src[3];
150 151
  for (int i = SPOT_NCOMPS; i < SPOT_NCOMPS + 4; i++)
    dest[i] ^= src[i];
152 153 154 155 156 157 158 159 160
#endif
}

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

typedef void (*SplashBlendFunc)(SplashColorPtr src, SplashColorPtr dest,
				SplashColorPtr blend, SplashColorMode cm);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
161

162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
//------------------------------------------------------------------------
// screen parameters
//------------------------------------------------------------------------

enum SplashScreenType {
  splashScreenDispersed,
  splashScreenClustered,
  splashScreenStochasticClustered
};

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

Kristian Høgsberg's avatar
Kristian Høgsberg committed
181 182 183 184 185 186
//------------------------------------------------------------------------
// error results
//------------------------------------------------------------------------

typedef int SplashError;

Stefan Thomas's avatar
Stefan Thomas committed
187 188 189 190 191 192 193

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

enum SplashImageFileFormat {
  splashFormatJpeg,
194
  splashFormatPng,
195 196
  splashFormatTiff,
  splashFormatJpegCMYK
Stefan Thomas's avatar
Stefan Thomas committed
197 198
};

Kristian Høgsberg's avatar
Kristian Høgsberg committed
199
#endif