SplashOutputDev.h 9.14 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4 5 6 7 8
//========================================================================
//
// SplashOutputDev.h
//
// Copyright 2003 Glyph & Cog, LLC
//
//========================================================================

9 10 11 12
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
13 14 15
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
16
// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de>
17
// Copyright (C) 2009 Thomas Freitag <Thomas.Freitag@alfa.de>
18 19 20 21 22 23
//
// 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
24 25 26 27 28 29 30 31 32 33 34
#ifndef SPLASHOUTPUTDEV_H
#define SPLASHOUTPUTDEV_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "goo/gtypes.h"
#include "splash/SplashTypes.h"
#include "poppler-config.h"
#include "OutputDev.h"
35
#include "GfxState.h"
Kristian Høgsberg's avatar
Kristian Høgsberg committed
36 37 38 39 40 41 42 43 44 45 46

class Gfx8BitFont;
class SplashBitmap;
class Splash;
class SplashPath;
class SplashPattern;
class SplashFontEngine;
class SplashFont;
class T3FontCache;
struct T3FontCacheTag;
struct T3GlyphStack;
47
struct SplashTransparencyGroup;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61

//------------------------------------------------------------------------

// number of Type 3 fonts to cache
#define splashOutT3FontCacheSize 8

//------------------------------------------------------------------------
// SplashOutputDev
//------------------------------------------------------------------------

class SplashOutputDev: public OutputDev {
public:

  // Constructor.
62 63 64 65
  SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
		  GBool reverseVideoA, SplashColorPtr paperColorA,
		  GBool bitmapTopDownA = gTrue,
		  GBool allowAntialiasA = gTrue);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

  // Destructor.
  virtual ~SplashOutputDev();

  //----- get info about output device

  // Does this device use upside-down coordinates?
  // (Upside-down means (0,0) is the top left corner of the page.)
  virtual GBool upsideDown() { return gTrue; }

  // Does this device use drawChar() or drawString()?
  virtual GBool useDrawChar() { return gTrue; }

  // Does this device use beginType3Char/endType3Char?  Otherwise,
  // text in Type 3 fonts will be drawn with drawChar/drawString.
  virtual GBool interpretType3Chars() { return gTrue; }

83 84 85 86
  // This device now supports text in pattern colorspace!
  virtual GBool supportTextCSPattern(GfxState *state)
  	{ return state->getFillColorSpace()->getMode() == csPattern; }

Kristian Høgsberg's avatar
Kristian Høgsberg committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
  //----- initialization and control

  // Start a page.
  virtual void startPage(int pageNum, GfxState *state);

  // End a page.
  virtual void endPage();

  //----- save/restore graphics state
  virtual void saveState(GfxState *state);
  virtual void restoreState(GfxState *state);

  //----- update graphics state
  virtual void updateAll(GfxState *state);
  virtual void updateCTM(GfxState *state, double m11, double m12,
			 double m21, double m22, double m31, double m32);
  virtual void updateLineDash(GfxState *state);
  virtual void updateFlatness(GfxState *state);
  virtual void updateLineJoin(GfxState *state);
  virtual void updateLineCap(GfxState *state);
  virtual void updateMiterLimit(GfxState *state);
  virtual void updateLineWidth(GfxState *state);
109
  virtual void updateStrokeAdjust(GfxState *state);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
110 111
  virtual void updateFillColor(GfxState *state);
  virtual void updateStrokeColor(GfxState *state);
112 113 114
  virtual void updateBlendMode(GfxState *state);
  virtual void updateFillOpacity(GfxState *state);
  virtual void updateStrokeOpacity(GfxState *state);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
115 116 117

  //----- update text state
  virtual void updateFont(GfxState *state);
118
  virtual void updateRender(GfxState *state);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
119 120 121 122 123 124 125 126 127

  //----- path painting
  virtual void stroke(GfxState *state);
  virtual void fill(GfxState *state);
  virtual void eoFill(GfxState *state);

  //----- path clipping
  virtual void clip(GfxState *state);
  virtual void eoClip(GfxState *state);
128
  virtual void clipToStrokePath(GfxState *state);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
129 130 131 132 133

  //----- text drawing
  virtual void drawChar(GfxState *state, double x, double y,
			double dx, double dy,
			double originX, double originY,
134
			CharCode code, int nBytes, Unicode *u, int uLen);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
135 136 137 138
  virtual GBool beginType3Char(GfxState *state, double x, double y,
			       double dx, double dy,
			       CharCode code, Unicode *u, int uLen);
  virtual void endType3Char(GfxState *state);
139 140
  virtual void beginTextObject(GfxState *state);
  virtual GBool deviceHasTextClip(GfxState *state) { return textClipPath && haveCSPattern; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
141 142 143 144 145 146 147 148 149
  virtual void endTextObject(GfxState *state);

  //----- image drawing
  virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
			     int width, int height, GBool invert,
			     GBool inlineImg);
  virtual void drawImage(GfxState *state, Object *ref, Stream *str,
			 int width, int height, GfxImageColorMap *colorMap,
			 int *maskColors, GBool inlineImg);
150 151 152 153 154 155 156 157 158 159 160
  virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
			       int width, int height,
			       GfxImageColorMap *colorMap,
			       Stream *maskStr, int maskWidth, int maskHeight,
			       GBool maskInvert);
  virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
				   int width, int height,
				   GfxImageColorMap *colorMap,
				   Stream *maskStr,
				   int maskWidth, int maskHeight,
				   GfxImageColorMap *maskColorMap);
161 162 163 164 165 166
  // If current colorspace ist pattern,
  // need this device special handling for masks in pattern colorspace?
  // Default is false
  virtual GBool fillMaskCSPattern(GfxState * state)
  	{ return state->getFillColorSpace()->getMode() == csPattern; }
  virtual void endMaskClip(GfxState * /*state*/);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
167 168 169 170 171 172

  //----- Type 3 font operators
  virtual void type3D0(GfxState *state, double wx, double wy);
  virtual void type3D1(GfxState *state, double wx, double wy,
		       double llx, double lly, double urx, double ury);

173 174 175 176 177 178 179 180 181 182 183
  //----- transparency groups and soft masks
  virtual void beginTransparencyGroup(GfxState *state, double *bbox,
				      GfxColorSpace *blendingColorSpace,
				      GBool isolated, GBool knockout,
				      GBool forSoftMask);
  virtual void endTransparencyGroup(GfxState *state);
  virtual void paintTransparencyGroup(GfxState *state, double *bbox);
  virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha,
			   Function *transferFunc, GfxColor *backdropColor);
  virtual void clearSoftMask(GfxState *state);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
184 185 186 187 188
  //----- special access

  // Called to indicate that a new PDF document has been loaded.
  void startDoc(XRef *xrefA);
 
189 190
  void setPaperColor(SplashColorPtr paperColorA);

Kristian Høgsberg's avatar
Kristian Høgsberg committed
191
  GBool isReverseVideo() { return reverseVideo; }
192
  void setReverseVideo(GBool reverseVideoA) { reverseVideo = reverseVideoA; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
193 194 195 196 197 198

  // Get the bitmap and its size.
  SplashBitmap *getBitmap() { return bitmap; }
  int getBitmapWidth();
  int getBitmapHeight();

199 200 201 202
  // Returns the last rasterized bitmap, transferring ownership to the
  // caller.
  SplashBitmap *takeBitmap();

Kristian Høgsberg's avatar
Kristian Høgsberg committed
203 204 205
  // Get the Splash object.
  Splash *getSplash() { return splash; }

206 207 208 209 210
  // Get the modified region.
  void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax);

  // Clear the modified region.
  void clearModRegion();
Kristian Høgsberg's avatar
Kristian Høgsberg committed
211 212 213 214

  // Set the Splash fill color.
  void setFillColor(int r, int g, int b);

215
  SplashFont *getCurrentFont() { return font; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
216

217 218 219 220 221
#if 1 //~tmp: turn off anti-aliasing temporarily
  virtual GBool getVectorAntialias();
  virtual void setVectorAntialias(GBool vaa);
#endif

Kristian Høgsberg's avatar
Kristian Høgsberg committed
222 223
private:

224
  void setupScreenParams(double hDPI, double vDPI);
225 226 227 228 229
#if SPLASH_CMYK
  SplashPattern *getColor(GfxGray gray, GfxRGB *rgb, GfxCMYK *cmyk);
#else
  SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
#endif
Kristian Høgsberg's avatar
Kristian Høgsberg committed
230
  SplashPath *convertPath(GfxState *state, GfxPath *path);
231
  void doUpdateFont(GfxState *state);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
232
  void drawType3Glyph(T3FontCache *t3Font,
233
		      T3FontCacheTag *tag, Guchar *data);
234
  static GBool imageMaskSrc(void *data, SplashColorPtr line);
235 236 237 238 239 240
  static GBool imageSrc(void *data, SplashColorPtr colorLine,
			Guchar *alphaLine);
  static GBool alphaImageSrc(void *data, SplashColorPtr line,
			     Guchar *alphaLine);
  static GBool maskedImageSrc(void *data, SplashColorPtr line,
			      Guchar *alphaLine);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
241

242 243 244 245 246
  GBool haveCSPattern;		// set if text has been drawn with a
				//   clipping render mode because of pattern colorspace
  int savedRender;		// use if pattern colorspace
  GBool keepAlphaChannel;	// don't fill with paper color, keep alpha channel

Kristian Høgsberg's avatar
Kristian Høgsberg committed
247
  SplashColorMode colorMode;
248 249 250
  int bitmapRowPad;
  GBool bitmapTopDown;
  GBool allowAntialias;
251
  GBool vectorAntialias;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
252 253
  GBool reverseVideo;		// reverse video mode
  SplashColor paperColor;	// paper color
254
  SplashScreenParams screenParams;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269

  XRef *xref;			// xref table for current document

  SplashBitmap *bitmap;
  Splash *splash;
  SplashFontEngine *fontEngine;

  T3FontCache *			// Type 3 font cache
    t3FontCache[splashOutT3FontCacheSize];
  int nT3Fonts;			// number of valid entries in t3FontCache
  T3GlyphStack *t3GlyphStack;	// Type 3 glyph context stack

  SplashFont *font;		// current font
  GBool needFontUpdate;		// set when the font needs to be updated
  SplashPath *textClipPath;	// clipping path built with text object
270 271 272

  SplashTransparencyGroup *	// transparency group stack
    transpGroupStack;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
273 274 275
};

#endif