1 //======================================================================== 2 // 3 // PreScanOutputDev.h 4 // 5 // Copyright 2005 Glyph & Cog, LLC 6 // 7 //======================================================================== 8 9 //======================================================================== 10 // 11 // Modified under the Poppler project - http://poppler.freedesktop.org 12 // 13 // All changes made under the Poppler project to this file are licensed 14 // under GPL version 2 or later 15 // 16 // 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> 19 // Copyright (C) 2011, 2013 Thomas Freitag <Thomas.Freitag@alfa.de> 20 // Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com> 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 PRESCANOUTPUTDEV_H 28 #define PRESCANOUTPUTDEV_H 29 30 #ifdef USE_GCC_PRAGMAS 31 #pragma interface 32 #endif 33 34 #include "goo/gtypes.h" 35 #include "Object.h" 36 #include "GfxState.h" 37 #include "GlobalParams.h" 38 #include "OutputDev.h" 39 40 //------------------------------------------------------------------------ 41 // PreScanOutputDev 42 //------------------------------------------------------------------------ 43 44 class PreScanOutputDev: public OutputDev { 45 public: 46 47 // Constructor. 48 PreScanOutputDev(PDFDoc *docA); 49 50 // Destructor. 51 virtual ~PreScanOutputDev(); 52 53 //----- get info about output device 54 55 // Does this device use upside-down coordinates? 56 // (Upside-down means (0,0) is the top left corner of the page.) upsideDown()57 virtual GBool upsideDown() { return gTrue; } 58 59 // Does this device use drawChar() or drawString()? useDrawChar()60 virtual GBool useDrawChar() { return gTrue; } 61 62 // Does this device use tilingPatternFill()? If this returns false, 63 // tiling pattern fills will be reduced to a series of other drawing 64 // operations. useTilingPatternFill()65 virtual GBool useTilingPatternFill() { return gTrue; } 66 67 // Does this device use functionShadedFill(), axialShadedFill(), and 68 // radialShadedFill()? If this returns false, these shaded fills 69 // will be reduced to a series of other drawing operations. useShadedFills(int type)70 virtual GBool useShadedFills(int type) { return gTrue; } 71 72 // Does this device use beginType3Char/endType3Char? Otherwise, 73 // text in Type 3 fonts will be drawn with drawChar/drawString. interpretType3Chars()74 virtual GBool interpretType3Chars() { return gTrue; } 75 76 //----- initialization and control 77 78 // Start a page. 79 virtual void startPage(int pageNum, GfxState *state, XRef *xref); 80 81 // End a page. 82 virtual void endPage(); 83 84 //----- path painting 85 virtual void stroke(GfxState *state); 86 virtual void fill(GfxState *state); 87 virtual void eoFill(GfxState *state); 88 virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *cat, Object *str, 89 double *pmat, int paintType, int tilingType, Dict *resDict, 90 double *mat, double *bbox, 91 int x0, int y0, int x1, int y1, 92 double xStep, double yStep); 93 virtual GBool functionShadedFill(GfxState *state, 94 GfxFunctionShading *shading); 95 virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); 96 virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax); 97 98 //----- path clipping 99 virtual void clip(GfxState *state); 100 virtual void eoClip(GfxState *state); 101 102 //----- text drawing 103 virtual void beginStringOp(GfxState *state); 104 virtual void endStringOp(GfxState *state); 105 virtual GBool beginType3Char(GfxState *state, double x, double y, 106 double dx, double dy, 107 CharCode code, Unicode *u, int uLen); 108 virtual void endType3Char(GfxState *state); 109 110 //----- image drawing 111 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str, 112 int width, int height, GBool invert, 113 GBool interpolate, GBool inlineImg); 114 virtual void drawImage(GfxState *state, Object *ref, Stream *str, 115 int width, int height, GfxImageColorMap *colorMap, 116 GBool interpolate, int *maskColors, GBool inlineImg); 117 virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str, 118 int width, int height, 119 GfxImageColorMap *colorMap, 120 GBool interpolate, 121 Stream *maskStr, int maskWidth, int maskHeight, 122 GBool maskInvert, GBool maskInterpolate); 123 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, 124 int width, int height, 125 GfxImageColorMap *colorMap, 126 GBool interpolate, 127 Stream *maskStr, 128 int maskWidth, int maskHeight, 129 GfxImageColorMap *maskColorMap, 130 GBool maskInterpolate); 131 132 //----- transparency groups and soft masks 133 virtual void beginTransparencyGroup(GfxState *state, double *bbox, 134 GfxColorSpace *blendingColorSpace, 135 GBool isolated, GBool knockout, 136 GBool forSoftMask); 137 virtual void paintTransparencyGroup(GfxState *state, double *bbox); 138 virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha, 139 Function *transferFunc, GfxColor *backdropColor); 140 141 //----- special access 142 143 // Returns true if the operations performed since the last call to 144 // clearStats() are all monochrome (black or white). isMonochrome()145 GBool isMonochrome() { return mono; } 146 147 // Returns true if the operations performed since the last call to 148 // clearStats() are all gray. isGray()149 GBool isGray() { return gray; } 150 151 // Returns true if the operations performed since the last call to 152 // clearStats() included any transparency. usesTransparency()153 GBool usesTransparency() { return transparency; } 154 155 // Returns true if the operations performed since the last call to 156 // clearStats() are all rasterizable by GDI calls in GDIOutputDev. isAllGDI()157 GBool isAllGDI() { return gdi; } 158 159 // Returns true if the operations performed since the last call to 160 // clearStats() included any image mask fills with a pattern color 161 // space. (only level1!) usesPatternImageMask()162 GBool usesPatternImageMask() { return patternImgMask; } 163 164 // Clear the stats used by the above functions. 165 void clearStats(); 166 167 private: 168 169 void check(GfxColorSpace *colorSpace, GfxColor *color, 170 double opacity, GfxBlendMode blendMode); 171 172 PDFDoc *doc; 173 GBool mono; 174 GBool gray; 175 GBool transparency; 176 GBool gdi; 177 PSLevel level; // PostScript level (1, 2, separation) 178 GBool patternImgMask; 179 int inTilingPatternFill; 180 }; 181 182 #endif 183