LCOV - code coverage report
Current view: directory - home/even/poppler-git/install/include/poppler - SplashOutputDev.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 7 3 42.9 %
Date: 2013-03-30 Functions: 6 3 50.0 %

       1                 : //========================================================================
       2                 : //
       3                 : // SplashOutputDev.h
       4                 : //
       5                 : // Copyright 2003 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) 2005 Takashi Iwai <tiwai@suse.de>
      17                 : // Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
      18                 : // Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
      19                 : // Copyright (C) 2010 Christian Feuersänger <cfeuersaenger@googlemail.com>
      20                 : // Copyright (C) 2011 Andreas Hartmetz <ahartmetz@gmail.com>
      21                 : // Copyright (C) 2011 Andrea Canciani <ranma42@gmail.com>
      22                 : // Copyright (C) 2011 Adrian Johnson <ajohnson@redneon.com>
      23                 : // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
      24                 : //
      25                 : // To see a description of the changes please see the Changelog file that
      26                 : // came with your tarball or type make ChangeLog if you are building from git
      27                 : //
      28                 : //========================================================================
      29                 : 
      30                 : #ifndef SPLASHOUTPUTDEV_H
      31                 : #define SPLASHOUTPUTDEV_H
      32                 : 
      33                 : #ifdef USE_GCC_PRAGMAS
      34                 : #pragma interface
      35                 : #endif
      36                 : 
      37                 : #include "goo/gtypes.h"
      38                 : #include "splash/SplashTypes.h"
      39                 : #include "splash/SplashPattern.h"
      40                 : #include "poppler-config.h"
      41                 : #include "OutputDev.h"
      42                 : #include "GfxState.h"
      43                 : 
      44                 : class PDFDoc;
      45                 : class Gfx8BitFont;
      46                 : class SplashBitmap;
      47                 : class Splash;
      48                 : class SplashPath;
      49                 : class SplashFontEngine;
      50                 : class SplashFont;
      51                 : class T3FontCache;
      52                 : struct T3FontCacheTag;
      53                 : struct T3GlyphStack;
      54                 : struct SplashTransparencyGroup;
      55                 : 
      56                 : //------------------------------------------------------------------------
      57                 : // Splash dynamic pattern
      58                 : //------------------------------------------------------------------------
      59                 : 
      60                 : class SplashUnivariatePattern: public SplashPattern {
      61                 : public:
      62                 : 
      63                 :   SplashUnivariatePattern(SplashColorMode colorMode, GfxState *state, GfxUnivariateShading *shading);
      64                 : 
      65                 :   virtual ~SplashUnivariatePattern();
      66                 : 
      67                 :   virtual GBool getColor(int x, int y, SplashColorPtr c);
      68                 : 
      69                 :   virtual GBool testPosition(int x, int y);
      70                 : 
      71                 :   virtual GBool isStatic() { return gFalse; }
      72                 : 
      73                 :   virtual GBool getParameter(double xs, double ys, double *t) = 0;
      74                 : 
      75                 :   virtual GfxUnivariateShading *getShading() { return shading; }
      76                 : 
      77                 : protected:
      78                 :   Matrix ictm;
      79                 :   double t0, t1, dt;
      80                 :   GfxUnivariateShading *shading;
      81                 :   GfxState *state;
      82                 :   SplashColorMode colorMode;
      83                 : };
      84                 : 
      85                 : class SplashAxialPattern: public SplashUnivariatePattern {
      86                 : public:
      87                 : 
      88                 :   SplashAxialPattern(SplashColorMode colorMode, GfxState *state, GfxAxialShading *shading);
      89                 : 
      90                 :   virtual SplashPattern *copy() { return new SplashAxialPattern(colorMode, state, (GfxAxialShading *) shading); }
      91                 : 
      92                 :   virtual ~SplashAxialPattern();
      93                 : 
      94                 :   virtual GBool getParameter(double xs, double ys, double *t);
      95                 : 
      96                 : private:
      97                 :   double x0, y0, x1, y1;
      98                 :   double dx, dy, mul;
      99                 : };
     100                 : 
     101                 : // see GfxState.h, GfxGouraudTriangleShading
     102                 : class SplashGouraudPattern: public SplashGouraudColor {
     103                 : public:
     104                 : 
     105                 :   SplashGouraudPattern(GBool bDirectColorTranslation, GfxState *state, GfxGouraudTriangleShading *shading, SplashColorMode mode);
     106                 : 
     107                 :   virtual SplashPattern *copy() { return new SplashGouraudPattern(bDirectColorTranslation, state, shading, mode); }
     108                 : 
     109                 :   virtual ~SplashGouraudPattern();
     110                 : 
     111                 :   virtual GBool getColor(int x, int y, SplashColorPtr c) { return gFalse; }
     112                 : 
     113                 :   virtual GBool testPosition(int x, int y) { return gFalse; }
     114                 : 
     115                 :   virtual GBool isStatic() { return gFalse; }
     116                 : 
     117                 :   virtual GBool isParameterized() { return shading->isParameterized(); }
     118                 :   virtual int getNTriangles() { return shading->getNTriangles(); }
     119                 :   virtual  void getTriangle(int i, double *x0, double *y0, double *color0,
     120                 :                             double *x1, double *y1, double *color1,
     121                 :                             double *x2, double *y2, double *color2)
     122                 :   { return shading->getTriangle(i, x0, y0, color0, x1, y1, color1, x2, y2, color2); }
     123                 : 
     124                 :   virtual void getParameterizedColor(double t, SplashColorMode mode, SplashColorPtr c);
     125                 : 
     126                 : private:
     127                 :   GfxGouraudTriangleShading *shading;
     128                 :   GfxState *state;
     129                 :   GBool bDirectColorTranslation;
     130                 :   SplashColorMode mode;
     131                 : };
     132                 : 
     133                 : // see GfxState.h, GfxRadialShading
     134                 : class SplashRadialPattern: public SplashUnivariatePattern {
     135                 : public:
     136                 : 
     137                 :   SplashRadialPattern(SplashColorMode colorMode, GfxState *state, GfxRadialShading *shading);
     138                 : 
     139                 :   virtual SplashPattern *copy() { return new SplashRadialPattern(colorMode, state, (GfxRadialShading *) shading); }
     140                 : 
     141                 :   virtual ~SplashRadialPattern();
     142                 : 
     143                 :   virtual GBool getParameter(double xs, double ys, double *t);
     144                 : 
     145                 : private:
     146                 :   double x0, y0, r0, dx, dy, dr;
     147                 :   double a, inva;
     148                 : };
     149                 : 
     150                 : //------------------------------------------------------------------------
     151                 : 
     152                 : // number of Type 3 fonts to cache
     153                 : #define splashOutT3FontCacheSize 8
     154                 : 
     155                 : //------------------------------------------------------------------------
     156                 : // SplashOutputDev
     157                 : //------------------------------------------------------------------------
     158                 : 
     159                 : class SplashOutputDev: public OutputDev {
     160                 : public:
     161                 : 
     162                 :   // Constructor.
     163                 :   SplashOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
     164                 :       GBool reverseVideoA, SplashColorPtr paperColorA,
     165                 :       GBool bitmapTopDownA = gTrue,
     166                 :       GBool allowAntialiasA = gTrue);
     167                 : 
     168                 :   // Destructor.
     169                 :   virtual ~SplashOutputDev();
     170                 : 
     171                 :   //----- get info about output device
     172                 : 
     173                 :   // Does this device use tilingPatternFill()?  If this returns false,
     174                 :   // tiling pattern fills will be reduced to a series of other drawing
     175                 :   // operations.
     176               0 :   virtual GBool useTilingPatternFill() { return gTrue; }
     177                 : 
     178                 :   // Does this device use functionShadedFill(), axialShadedFill(), and
     179                 :   // radialShadedFill()?  If this returns false, these shaded fills
     180                 :   // will be reduced to a series of other drawing operations.
     181               0 :   virtual GBool useShadedFills(int type)
     182               0 :   { return (type >= 2 && type <= 5) ? gTrue : gFalse; }
     183                 : 
     184                 :   // Does this device use upside-down coordinates?
     185                 :   // (Upside-down means (0,0) is the top left corner of the page.)
     186              96 :   virtual GBool upsideDown() { return bitmapTopDown ^ bitmapUpsideDown; }
     187                 : 
     188                 :   // Does this device use drawChar() or drawString()?
     189           15027 :   virtual GBool useDrawChar() { return gTrue; }
     190                 : 
     191                 :   // Does this device use beginType3Char/endType3Char?  Otherwise,
     192                 :   // text in Type 3 fonts will be drawn with drawChar/drawString.
     193               0 :   virtual GBool interpretType3Chars() { return gTrue; }
     194                 : 
     195                 :   //----- initialization and control
     196                 : 
     197                 :   // Start a page.
     198                 :   virtual void startPage(int pageNum, GfxState *state, XRef *xref);
     199                 : 
     200                 :   // End a page.
     201                 :   virtual void endPage();
     202                 : 
     203                 :   //----- save/restore graphics state
     204                 :   virtual void saveState(GfxState *state);
     205                 :   virtual void restoreState(GfxState *state);
     206                 : 
     207                 :   //----- update graphics state
     208                 :   virtual void updateAll(GfxState *state);
     209                 :   virtual void updateCTM(GfxState *state, double m11, double m12,
     210                 :        double m21, double m22, double m31, double m32);
     211                 :   virtual void updateLineDash(GfxState *state);
     212                 :   virtual void updateFlatness(GfxState *state);
     213                 :   virtual void updateLineJoin(GfxState *state);
     214                 :   virtual void updateLineCap(GfxState *state);
     215                 :   virtual void updateMiterLimit(GfxState *state);
     216                 :   virtual void updateLineWidth(GfxState *state);
     217                 :   virtual void updateStrokeAdjust(GfxState *state);
     218                 :   virtual void updateFillColorSpace(GfxState *state);
     219                 :   virtual void updateStrokeColorSpace(GfxState *state);
     220                 :   virtual void updateFillColor(GfxState *state);
     221                 :   virtual void updateStrokeColor(GfxState *state);
     222                 :   virtual void updateBlendMode(GfxState *state);
     223                 :   virtual void updateFillOpacity(GfxState *state);
     224                 :   virtual void updateStrokeOpacity(GfxState *state);
     225                 :   virtual void updateFillOverprint(GfxState *state);
     226                 :   virtual void updateStrokeOverprint(GfxState *state);
     227                 :   virtual void updateOverprintMode(GfxState *state);
     228                 :   virtual void updateTransfer(GfxState *state);
     229                 : 
     230                 :   //----- update text state
     231                 :   virtual void updateFont(GfxState *state);
     232                 : 
     233                 :   //----- path painting
     234                 :   virtual void stroke(GfxState *state);
     235                 :   virtual void fill(GfxState *state);
     236                 :   virtual void eoFill(GfxState *state);
     237                 :   virtual GBool tilingPatternFill(GfxState *state, Gfx *gfx, Catalog *catalog, Object *str,
     238                 :           double *pmat, int paintType, int tilingType, Dict *resDict,
     239                 :           double *mat, double *bbox,
     240                 :           int x0, int y0, int x1, int y1,
     241                 :           double xStep, double yStep);
     242                 :   virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
     243                 :   virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double tMin, double tMax);
     244                 :   virtual GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading);
     245                 : 
     246                 :   //----- path clipping
     247                 :   virtual void clip(GfxState *state);
     248                 :   virtual void eoClip(GfxState *state);
     249                 :   virtual void clipToStrokePath(GfxState *state);
     250                 : 
     251                 :   //----- text drawing
     252                 :   virtual void drawChar(GfxState *state, double x, double y,
     253                 :       double dx, double dy,
     254                 :       double originX, double originY,
     255                 :       CharCode code, int nBytes, Unicode *u, int uLen);
     256                 :   virtual GBool beginType3Char(GfxState *state, double x, double y,
     257                 :              double dx, double dy,
     258                 :              CharCode code, Unicode *u, int uLen);
     259                 :   virtual void endType3Char(GfxState *state);
     260                 :   virtual void beginTextObject(GfxState *state);
     261                 :   virtual void endTextObject(GfxState *state);
     262                 : 
     263                 :   //----- image drawing
     264                 :   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
     265                 :            int width, int height, GBool invert,
     266                 :            GBool interpolate, GBool inlineImg);
     267                 :   virtual void setSoftMaskFromImageMask(GfxState *state,
     268                 :           Object *ref, Stream *str,
     269                 :           int width, int height, GBool invert,
     270                 :           GBool inlineImg, double *baseMatrix);
     271                 :   virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix);
     272                 :   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
     273                 :        int width, int height, GfxImageColorMap *colorMap,
     274                 :        GBool interpolate, int *maskColors, GBool inlineImg);
     275                 :   virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
     276                 :              int width, int height,
     277                 :              GfxImageColorMap *colorMap,
     278                 :              GBool interpolate,
     279                 :              Stream *maskStr, int maskWidth, int maskHeight,
     280                 :              GBool maskInvert, GBool maskInterpolate);
     281                 :   virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
     282                 :            int width, int height,
     283                 :            GfxImageColorMap *colorMap,
     284                 :            GBool interpolate,
     285                 :            Stream *maskStr,
     286                 :            int maskWidth, int maskHeight,
     287                 :            GfxImageColorMap *maskColorMap,
     288                 :            GBool maskInterpolate);
     289                 : 
     290                 :   //----- Type 3 font operators
     291                 :   virtual void type3D0(GfxState *state, double wx, double wy);
     292                 :   virtual void type3D1(GfxState *state, double wx, double wy,
     293                 :            double llx, double lly, double urx, double ury);
     294                 : 
     295                 :   //----- transparency groups and soft masks
     296                 :   virtual GBool checkTransparencyGroup(GfxState *state, GBool knockout);
     297                 :   virtual void beginTransparencyGroup(GfxState *state, double *bbox,
     298                 :               GfxColorSpace *blendingColorSpace,
     299                 :               GBool isolated, GBool knockout,
     300                 :               GBool forSoftMask);
     301                 :   virtual void endTransparencyGroup(GfxState *state);
     302                 :   virtual void paintTransparencyGroup(GfxState *state, double *bbox);
     303                 :   virtual void setSoftMask(GfxState *state, double *bbox, GBool alpha,
     304                 :          Function *transferFunc, GfxColor *backdropColor);
     305                 :   virtual void clearSoftMask(GfxState *state);
     306                 : 
     307                 :   //----- special access
     308                 : 
     309                 :   // Called to indicate that a new PDF document has been loaded.
     310                 :   void startDoc(PDFDoc *docA);
     311                 :  
     312                 :   void setPaperColor(SplashColorPtr paperColorA);
     313                 : 
     314                 :   GBool isReverseVideo() { return reverseVideo; }
     315                 :   void setReverseVideo(GBool reverseVideoA) { reverseVideo = reverseVideoA; }
     316                 : 
     317                 :   // Get the bitmap and its size.
     318              96 :   SplashBitmap *getBitmap() { return bitmap; }
     319                 :   int getBitmapWidth();
     320                 :   int getBitmapHeight();
     321                 : 
     322                 :   // Returns the last rasterized bitmap, transferring ownership to the
     323                 :   // caller.
     324                 :   SplashBitmap *takeBitmap();
     325                 : 
     326                 :   // Set this flag to true to generate an upside-down bitmap (useful
     327                 :   // for Windows BMP files).
     328                 :   void setBitmapUpsideDown(GBool f) { bitmapUpsideDown = f; }
     329                 : 
     330                 :   // Get the Splash object.
     331                 :   Splash *getSplash() { return splash; }
     332                 : 
     333                 :   // Get the modified region.
     334                 :   void getModRegion(int *xMin, int *yMin, int *xMax, int *yMax);
     335                 : 
     336                 :   // Clear the modified region.
     337                 :   void clearModRegion();
     338                 : 
     339                 :   SplashFont *getCurrentFont() { return font; }
     340                 : 
     341                 :   // If <skipTextA> is true, don't draw horizontal text.
     342                 :   // If <skipRotatedTextA> is true, don't draw rotated (non-horizontal) text.
     343                 :   void setSkipText(GBool skipHorizTextA, GBool skipRotatedTextA)
     344                 :     { skipHorizText = skipHorizTextA; skipRotatedText = skipRotatedTextA; }
     345                 : 
     346                 :   int getNestCount() { return nestCount; }
     347                 : 
     348                 : #if 1 //~tmp: turn off anti-aliasing temporarily
     349                 :   virtual GBool getVectorAntialias();
     350                 :   virtual void setVectorAntialias(GBool vaa);
     351                 : #endif
     352                 : 
     353                 :   void setFreeTypeHinting(GBool enable, GBool enableSlightHinting);
     354                 : 
     355                 : protected:
     356                 :   void doUpdateFont(GfxState *state);
     357                 : 
     358                 : private:
     359                 :   GBool univariateShadedFill(GfxState *state, SplashUnivariatePattern *pattern, double tMin, double tMax);
     360                 : 
     361                 :   void setupScreenParams(double hDPI, double vDPI);
     362                 :   SplashPattern *getColor(GfxGray gray);
     363                 :   SplashPattern *getColor(GfxRGB *rgb);
     364                 : #if SPLASH_CMYK
     365                 :   SplashPattern *getColor(GfxCMYK *cmyk);
     366                 :   SplashPattern *getColor(GfxColor *deviceN);
     367                 : #endif
     368                 :   void setOverprintMask(GfxColorSpace *colorSpace, GBool overprintFlag,
     369                 :       int overprintMode, GfxColor *singleColor, GBool grayIndexed = gFalse);
     370                 :   SplashPath *convertPath(GfxState *state, GfxPath *path,
     371                 :         GBool dropEmptySubpaths);
     372                 :   void drawType3Glyph(GfxState *state, T3FontCache *t3Font,
     373                 :           T3FontCacheTag *tag, Guchar *data);
     374                 :   static GBool imageMaskSrc(void *data, SplashColorPtr line);
     375                 :   static GBool imageSrc(void *data, SplashColorPtr colorLine,
     376                 :       Guchar *alphaLine);
     377                 :   static GBool alphaImageSrc(void *data, SplashColorPtr line,
     378                 :            Guchar *alphaLine);
     379                 :   static GBool maskedImageSrc(void *data, SplashColorPtr line,
     380                 :             Guchar *alphaLine);
     381                 :   static GBool tilingBitmapSrc(void *data, SplashColorPtr line,
     382                 :            Guchar *alphaLine);
     383                 : 
     384                 :   GBool keepAlphaChannel; // don't fill with paper color, keep alpha channel
     385                 : 
     386                 :   SplashColorMode colorMode;
     387                 :   int bitmapRowPad;
     388                 :   GBool bitmapTopDown;
     389                 :   GBool bitmapUpsideDown;
     390                 :   GBool allowAntialias;
     391                 :   GBool vectorAntialias;
     392                 :   GBool enableFreeTypeHinting;
     393                 :   GBool enableSlightHinting;
     394                 :   GBool reverseVideo;   // reverse video mode
     395                 :   SplashColor paperColor; // paper color
     396                 :   SplashScreenParams screenParams;
     397                 :   GBool skipHorizText;
     398                 :   GBool skipRotatedText;
     399                 : 
     400                 :   PDFDoc *doc;      // the current document
     401                 :   XRef *xref;       // the xref of the current document
     402                 : 
     403                 :   SplashBitmap *bitmap;
     404                 :   Splash *splash;
     405                 :   SplashFontEngine *fontEngine;
     406                 : 
     407                 :   T3FontCache *     // Type 3 font cache
     408                 :     t3FontCache[splashOutT3FontCacheSize];
     409                 :   int nT3Fonts;     // number of valid entries in t3FontCache
     410                 :   T3GlyphStack *t3GlyphStack; // Type 3 glyph context stack
     411                 :   GBool haveT3Dx;   // set after seeing a d0/d1 operator
     412                 : 
     413                 :   SplashFont *font;   // current font
     414                 :   GBool needFontUpdate;   // set when the font needs to be updated
     415                 :   SplashPath *textClipPath; // clipping path built with text object
     416                 : 
     417                 :   SplashTransparencyGroup * // transparency group stack
     418                 :     transpGroupStack;
     419                 :   SplashBitmap *maskBitmap; // for image masks in pattern colorspace
     420                 :   int nestCount;
     421                 : };
     422                 : 
     423                 : #endif

Generated by: LCOV version 1.7