PreScanOutputDev.h 6.33 KB
Newer Older
1 2 3 4 5 6 7 8
//========================================================================
//
// PreScanOutputDev.h
//
// Copyright 2005 Glyph & Cog, LLC
//
//========================================================================

9 10 11 12 13 14 15 16
//========================================================================
//
// 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) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
17
// Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
18
// Copyright (C) 2011, 2014 William Bader <williambader@hotmail.com>
Thomas Freitag's avatar
Thomas Freitag committed
19
// Copyright (C) 2011, 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
Albert Astals Cid's avatar
Albert Astals Cid committed
20
// Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com>
21 22 23 24 25 26
//
// 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
//
//========================================================================

27 28 29 30 31 32 33
#ifndef PRESCANOUTPUTDEV_H
#define PRESCANOUTPUTDEV_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

34
#include "goo/gtypes.h"
35
#include "Object.h"
36
#include "GfxState.h"
37
#include "GlobalParams.h"
38 39 40 41 42 43 44 45 46 47
#include "OutputDev.h"

//------------------------------------------------------------------------
// PreScanOutputDev
//------------------------------------------------------------------------

class PreScanOutputDev: public OutputDev {
public:

  // Constructor.
48
  PreScanOutputDev(PDFDoc *docA);
49 50

  // Destructor.
Albert Astals Cid's avatar
Albert Astals Cid committed
51
  ~PreScanOutputDev();
52 53 54 55 56

  //----- 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.)
Albert Astals Cid's avatar
Albert Astals Cid committed
57
  GBool upsideDown() override { return gTrue; }
58 59

  // Does this device use drawChar() or drawString()?
Albert Astals Cid's avatar
Albert Astals Cid committed
60
  GBool useDrawChar() override { return gTrue; }
61

62 63 64
  // Does this device use tilingPatternFill()?  If this returns false,
  // tiling pattern fills will be reduced to a series of other drawing
  // operations.
Albert Astals Cid's avatar
Albert Astals Cid committed
65
  GBool useTilingPatternFill() override { return gTrue; }
66

67 68 69
  // Does this device use functionShadedFill(), axialShadedFill(), and
  // radialShadedFill()?  If this returns false, these shaded fills
  // will be reduced to a series of other drawing operations.
Albert Astals Cid's avatar
Albert Astals Cid committed
70
  GBool useShadedFills(int type) override { return gTrue; }
71

72 73
  // Does this device use beginType3Char/endType3Char?  Otherwise,
  // text in Type 3 fonts will be drawn with drawChar/drawString.
Albert Astals Cid's avatar
Albert Astals Cid committed
74
  GBool interpretType3Chars() override { return gTrue; }
75 76 77 78

  //----- initialization and control

  // Start a page.
Albert Astals Cid's avatar
Albert Astals Cid committed
79
  void startPage(int pageNum, GfxState *state, XRef *xref) override;
80 81

  // End a page.
Albert Astals Cid's avatar
Albert Astals Cid committed
82
  void endPage() override;
83 84

  //----- path painting
Albert Astals Cid's avatar
Albert Astals Cid committed
85 86 87 88 89 90 91 92 93 94 95 96
  void stroke(GfxState *state) override;
  void fill(GfxState *state) override;
  void eoFill(GfxState *state) override;
  GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str,
			  double *pmat, int paintType, int tilingType, Dict *resDict,
			  double *mat, double *bbox,
			  int x0, int y0, int x1, int y1,
			  double xStep, double yStep) override;
  GBool functionShadedFill(GfxState *state,
			   GfxFunctionShading *shading) override;
  GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override;
  GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax) override;
97 98

  //----- path clipping
Albert Astals Cid's avatar
Albert Astals Cid committed
99 100
  void clip(GfxState *state) override;
  void eoClip(GfxState *state) override;
101 102

  //----- text drawing
Albert Astals Cid's avatar
Albert Astals Cid committed
103 104 105 106 107 108
  void beginStringOp(GfxState *state) override;
  void endStringOp(GfxState *state) override;
  GBool beginType3Char(GfxState *state, double x, double y,
		       double dx, double dy,
		       CharCode code, Unicode *u, int uLen) override;
  void endType3Char(GfxState *state) override;
109 110

  //----- image drawing
Albert Astals Cid's avatar
Albert Astals Cid committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
  void drawImageMask(GfxState *state, Object *ref, Stream *str,
		     int width, int height, GBool invert,
		     GBool interpolate, GBool inlineImg) override;
  void drawImage(GfxState *state, Object *ref, Stream *str,
		 int width, int height, GfxImageColorMap *colorMap,
		 GBool interpolate, int *maskColors, GBool inlineImg) override;
  void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
		      int width, int height,
		      GfxImageColorMap *colorMap,
		      GBool interpolate,
		      Stream *maskStr, int maskWidth, int maskHeight,
		      GBool maskInvert, GBool maskInterpolate) override;
  void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
			   int width, int height,
			   GfxImageColorMap *colorMap,
			   GBool interpolate,
			   Stream *maskStr,
			   int maskWidth, int maskHeight,
			   GfxImageColorMap *maskColorMap,
			   GBool maskInterpolate) override;
131 132

  //----- transparency groups and soft masks
Albert Astals Cid's avatar
Albert Astals Cid committed
133 134 135 136 137 138 139
  void beginTransparencyGroup(GfxState *state, double *bbox,
			      GfxColorSpace *blendingColorSpace,
			      GBool isolated, GBool knockout,
			      GBool forSoftMask) override;
  void paintTransparencyGroup(GfxState *state, double *bbox) override;
  void setSoftMask(GfxState *state, double *bbox, GBool alpha,
		   Function *transferFunc, GfxColor *backdropColor) override;
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158

  //----- special access

  // Returns true if the operations performed since the last call to
  // clearStats() are all monochrome (black or white).
  GBool isMonochrome() { return mono; }

  // Returns true if the operations performed since the last call to
  // clearStats() are all gray.
  GBool isGray() { return gray; }

  // Returns true if the operations performed since the last call to
  // clearStats() included any transparency.
  GBool usesTransparency() { return transparency; }

  // Returns true if the operations performed since the last call to
  // clearStats() are all rasterizable by GDI calls in GDIOutputDev.
  GBool isAllGDI() { return gdi; }

159
  // Returns true if the operations performed since the last call to
160 161 162
  // clearStats() included any image mask fills with a pattern color
  // space. (only level1!)
  GBool usesPatternImageMask() { return patternImgMask; }
163

164 165 166 167 168 169 170 171
  // Clear the stats used by the above functions.
  void clearStats();

private:

  void check(GfxColorSpace *colorSpace, GfxColor *color,
	     double opacity, GfxBlendMode blendMode);

172
  PDFDoc *doc;
173 174 175 176
  GBool mono;
  GBool gray;
  GBool transparency;
  GBool gdi;
177
  PSLevel level;		// PostScript level (1, 2, separation)
178
  GBool patternImgMask;		
179
  int inTilingPatternFill;
180 181 182
};

#endif