~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/poppler/poppler/Gfx.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// Gfx.h
 
4
//
 
5
// Copyright 1996-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 Jonathan Blandford <jrb@redhat.com>
 
17
// Copyright (C) 2007 IƱigo MartĆ­nez <inigomartinez@gmail.com>
 
18
// Copyright (C) 2008 Brad Hards <bradh@kde.org>
 
19
// Copyright (C) 2008, 2010 Carlos Garcia Campos <carlosgc@gnome.org>
 
20
// Copyright (C) 2009, 2010 Albert Astals Cid <aacid@kde.org>
 
21
// Copyright (C) 2009, 2010 Thomas Freitag <Thomas.Freitag@alfa.de>
 
22
// Copyright (C) 2010 David Benjamin <davidben@mit.edu>
 
23
// Copyright (C) 2010 Christian FeuersƤnger <cfeuersaenger@googlemail.com>
 
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 GFX_H
 
31
#define GFX_H
 
32
 
 
33
#ifdef USE_GCC_PRAGMAS
 
34
#pragma interface
 
35
#endif
 
36
 
 
37
#include "goo/gtypes.h"
 
38
#include "goo/GooList.h"
 
39
#include "GfxState.h"
 
40
#include "Object.h"
 
41
#include "PopplerCache.h"
 
42
 
 
43
#include <vector>
 
44
 
 
45
class GooString;
 
46
class XRef;
 
47
class Array;
 
48
class Stream;
 
49
class Parser;
 
50
class Dict;
 
51
class Function;
 
52
class OutputDev;
 
53
class GfxFontDict;
 
54
class GfxFont;
 
55
class GfxPattern;
 
56
class GfxTilingPattern;
 
57
class GfxShadingPattern;
 
58
class GfxShading;
 
59
class GfxFunctionShading;
 
60
class GfxAxialShading;
 
61
class GfxRadialShading;
 
62
class GfxGouraudTriangleShading;
 
63
class GfxPatchMeshShading;
 
64
struct GfxPatch;
 
65
class GfxState;
 
66
struct GfxColor;
 
67
class GfxColorSpace;
 
68
class Gfx;
 
69
class PDFRectangle;
 
70
class AnnotBorder;
 
71
class AnnotColor;
 
72
class Catalog;
 
73
struct MarkedContentStack;
 
74
 
 
75
//------------------------------------------------------------------------
 
76
 
 
77
enum GfxClipType {
 
78
  clipNone,
 
79
  clipNormal,
 
80
  clipEO
 
81
};
 
82
 
 
83
enum TchkType {
 
84
  tchkBool,                     // boolean
 
85
  tchkInt,                      // integer
 
86
  tchkNum,                      // number (integer or real)
 
87
  tchkString,                   // string
 
88
  tchkName,                     // name
 
89
  tchkArray,                    // array
 
90
  tchkProps,                    // properties (dictionary or name)
 
91
  tchkSCN,                      // scn/SCN args (number of name)
 
92
  tchkNone                      // used to avoid empty initializer lists
 
93
};
 
94
 
 
95
#define maxArgs 33
 
96
 
 
97
struct Operator {
 
98
  char name[4];
 
99
  int numArgs;
 
100
  TchkType tchk[maxArgs];
 
101
  void (Gfx::*func)(Object args[], int numArgs);
 
102
};
 
103
 
 
104
//------------------------------------------------------------------------
 
105
 
 
106
class GfxResources {
 
107
public:
 
108
 
 
109
  GfxResources(XRef *xref, Dict *resDict, GfxResources *nextA);
 
110
  ~GfxResources();
 
111
 
 
112
  GfxFont *lookupFont(char *name);
 
113
  GBool lookupXObject(char *name, Object *obj);
 
114
  GBool lookupXObjectNF(char *name, Object *obj);
 
115
  GBool lookupMarkedContentNF(char *name, Object *obj);
 
116
  void lookupColorSpace(char *name, Object *obj);
 
117
  GfxPattern *lookupPattern(char *name, Gfx *gfx);
 
118
  GfxShading *lookupShading(char *name, Gfx *gfx);
 
119
  GBool lookupGState(char *name, Object *obj);
 
120
  GBool lookupGStateNF(char *name, Object *obj);
 
121
 
 
122
  GfxResources *getNext() { return next; }
 
123
 
 
124
private:
 
125
 
 
126
  GfxFontDict *fonts;
 
127
  Object xObjDict;
 
128
  Object colorSpaceDict;
 
129
  Object patternDict;
 
130
  Object shadingDict;
 
131
  Object gStateDict;
 
132
  PopplerObjectCache gStateCache;
 
133
  Object propertiesDict;
 
134
  GfxResources *next;
 
135
};
 
136
 
 
137
//------------------------------------------------------------------------
 
138
// Gfx
 
139
//------------------------------------------------------------------------
 
140
 
 
141
class Gfx {
 
142
public:
 
143
 
 
144
  // Constructor for regular output.
 
145
  Gfx(XRef *xrefA, OutputDev *outA, int pageNum, Dict *resDict, Catalog *catalog,
 
146
      double hDPI, double vDPI, PDFRectangle *box,
 
147
      PDFRectangle *cropBox, int rotate,
 
148
      GBool (*abortCheckCbkA)(void *data) = NULL,
 
149
      void *abortCheckCbkDataA = NULL);
 
150
 
 
151
  // Constructor for a sub-page object.
 
152
  Gfx(XRef *xrefA, OutputDev *outA, Dict *resDict, Catalog *catalog,
 
153
      PDFRectangle *box, PDFRectangle *cropBox,
 
154
      GBool (*abortCheckCbkA)(void *data) = NULL,
 
155
      void *abortCheckCbkDataA = NULL);
 
156
 
 
157
  ~Gfx();
 
158
 
 
159
  // Interpret a stream or array of streams.
 
160
  void display(Object *obj, GBool topLevel = gTrue);
 
161
 
 
162
  // Display an annotation, given its appearance (a Form XObject),
 
163
  // border style, and bounding box (in default user space).
 
164
  void drawAnnot(Object *str, AnnotBorder *border, AnnotColor *aColor,
 
165
                 double xMin, double yMin, double xMax, double yMax);
 
166
 
 
167
  // Save graphics state.
 
168
  void saveState();
 
169
 
 
170
  // Push a new state guard
 
171
  void pushStateGuard();
 
172
 
 
173
  // Restore graphics state.
 
174
  void restoreState();
 
175
 
 
176
  // Pop to state guard and pop guard
 
177
  void popStateGuard();
 
178
 
 
179
  // Get the current graphics state object.
 
180
  GfxState *getState() { return state; }
 
181
 
 
182
  void pushResources(Dict *resDict);
 
183
  void popResources();
 
184
  
 
185
#ifdef USE_CMS
 
186
  PopplerCache *getIccColorSpaceCache();
 
187
#endif
 
188
 
 
189
private:
 
190
 
 
191
  XRef *xref;                   // the xref table for this PDF file
 
192
  Catalog *catalog;             // the Catalog for this PDF file  
 
193
  OutputDev *out;               // output device
 
194
  GBool subPage;                // is this a sub-page object?
 
195
  GBool printCommands;          // print the drawing commands (for debugging)
 
196
  GBool profileCommands;        // profile the drawing commands (for debugging)
 
197
  GBool textHaveCSPattern;      // in text drawing and text has pattern colorspace
 
198
  GBool drawText;               // in text drawing
 
199
  GBool maskHaveCSPattern;      // in mask drawing and mask has pattern colorspace
 
200
  GBool commandAborted;         // did the previous command abort the drawing?
 
201
  GfxResources *res;            // resource stack
 
202
  int updateLevel;
 
203
 
 
204
  GfxState *state;              // current graphics state
 
205
  int stackHeight;              // the height of the current graphics stack
 
206
  std::vector<int> stateGuards;   // a stack of state limits; to guard against unmatched pops
 
207
  GBool fontChanged;            // set if font or text matrix has changed
 
208
  GfxClipType clip;             // do a clip?
 
209
  int ignoreUndef;              // current BX/EX nesting level
 
210
  double baseMatrix[6];         // default matrix for most recent
 
211
                                //   page/form/pattern
 
212
  int formDepth;
 
213
 
 
214
  MarkedContentStack *mcStack;  // current BMC/EMC stack
 
215
 
 
216
  Parser *parser;               // parser for page content stream(s)
 
217
 
 
218
#ifdef USE_CMS
 
219
  PopplerCache iccColorSpaceCache;
 
220
#endif
 
221
 
 
222
  GBool                         // callback to check for an abort
 
223
    (*abortCheckCbk)(void *data);
 
224
  void *abortCheckCbkData;
 
225
 
 
226
  static Operator opTab[];      // table of operators
 
227
 
 
228
  void go(GBool topLevel);
 
229
  void execOp(Object *cmd, Object args[], int numArgs);
 
230
  Operator *findOp(char *name);
 
231
  GBool checkArg(Object *arg, TchkType type);
 
232
  int getPos();
 
233
 
 
234
  int bottomGuard();
 
235
 
 
236
  // graphics state operators
 
237
  void opSave(Object args[], int numArgs);
 
238
  void opRestore(Object args[], int numArgs);
 
239
  void opConcat(Object args[], int numArgs);
 
240
  void opSetDash(Object args[], int numArgs);
 
241
  void opSetFlat(Object args[], int numArgs);
 
242
  void opSetLineJoin(Object args[], int numArgs);
 
243
  void opSetLineCap(Object args[], int numArgs);
 
244
  void opSetMiterLimit(Object args[], int numArgs);
 
245
  void opSetLineWidth(Object args[], int numArgs);
 
246
  void opSetExtGState(Object args[], int numArgs);
 
247
  void doSoftMask(Object *str, GBool alpha,
 
248
                  GfxColorSpace *blendingColorSpace,
 
249
                  GBool isolated, GBool knockout,
 
250
                  Function *transferFunc, GfxColor *backdropColor);
 
251
  void opSetRenderingIntent(Object args[], int numArgs);
 
252
 
 
253
  // color operators
 
254
  void opSetFillGray(Object args[], int numArgs);
 
255
  void opSetStrokeGray(Object args[], int numArgs);
 
256
  void opSetFillCMYKColor(Object args[], int numArgs);
 
257
  void opSetStrokeCMYKColor(Object args[], int numArgs);
 
258
  void opSetFillRGBColor(Object args[], int numArgs);
 
259
  void opSetStrokeRGBColor(Object args[], int numArgs);
 
260
  void opSetFillColorSpace(Object args[], int numArgs);
 
261
  void opSetStrokeColorSpace(Object args[], int numArgs);
 
262
  void opSetFillColor(Object args[], int numArgs);
 
263
  void opSetStrokeColor(Object args[], int numArgs);
 
264
  void opSetFillColorN(Object args[], int numArgs);
 
265
  void opSetStrokeColorN(Object args[], int numArgs);
 
266
 
 
267
  // path segment operators
 
268
  void opMoveTo(Object args[], int numArgs);
 
269
  void opLineTo(Object args[], int numArgs);
 
270
  void opCurveTo(Object args[], int numArgs);
 
271
  void opCurveTo1(Object args[], int numArgs);
 
272
  void opCurveTo2(Object args[], int numArgs);
 
273
  void opRectangle(Object args[], int numArgs);
 
274
  void opClosePath(Object args[], int numArgs);
 
275
 
 
276
  // path painting operators
 
277
  void opEndPath(Object args[], int numArgs);
 
278
  void opStroke(Object args[], int numArgs);
 
279
  void opCloseStroke(Object args[], int numArgs);
 
280
  void opFill(Object args[], int numArgs);
 
281
  void opEOFill(Object args[], int numArgs);
 
282
  void opFillStroke(Object args[], int numArgs);
 
283
  void opCloseFillStroke(Object args[], int numArgs);
 
284
  void opEOFillStroke(Object args[], int numArgs);
 
285
  void opCloseEOFillStroke(Object args[], int numArgs);
 
286
  void doPatternFill(GBool eoFill);
 
287
  void doPatternStroke();
 
288
  void doTilingPatternFill(GfxTilingPattern *tPat,
 
289
                           GBool stroke, GBool eoFill);
 
290
  void doShadingPatternFill(GfxShadingPattern *sPat,
 
291
                            GBool stroke, GBool eoFill);
 
292
  void opShFill(Object args[], int numArgs);
 
293
  void doFunctionShFill(GfxFunctionShading *shading);
 
294
  void doFunctionShFill1(GfxFunctionShading *shading,
 
295
                         double x0, double y0,
 
296
                         double x1, double y1,
 
297
                         GfxColor *colors, int depth);
 
298
  void doAxialShFill(GfxAxialShading *shading);
 
299
  void doRadialShFill(GfxRadialShading *shading);
 
300
  void doGouraudTriangleShFill(GfxGouraudTriangleShading *shading);
 
301
  void gouraudFillTriangle(double x0, double y0, GfxColor *color0,
 
302
                           double x1, double y1, GfxColor *color1,
 
303
                           double x2, double y2, GfxColor *color2,
 
304
                           int nComps, int depth, GfxState::ReusablePathIterator *path);
 
305
  void gouraudFillTriangle(double x0, double y0, double color0,
 
306
                           double x1, double y1, double color1,
 
307
                           double x2, double y2, double color2,
 
308
                           double refineColorThreshold, int depth, GfxGouraudTriangleShading *shading, GfxState::ReusablePathIterator *path);
 
309
  void doPatchMeshShFill(GfxPatchMeshShading *shading);
 
310
  void fillPatch(GfxPatch *patch, int colorComps, int patchColorComps, double refineColorThreshold, int depth, GfxPatchMeshShading *shading);
 
311
  void doEndPath();
 
312
 
 
313
  // path clipping operators
 
314
  void opClip(Object args[], int numArgs);
 
315
  void opEOClip(Object args[], int numArgs);
 
316
 
 
317
  // text object operators
 
318
  void opBeginText(Object args[], int numArgs);
 
319
  void opEndText(Object args[], int numArgs);
 
320
 
 
321
  // text state operators
 
322
  void opSetCharSpacing(Object args[], int numArgs);
 
323
  void opSetFont(Object args[], int numArgs);
 
324
  void opSetTextLeading(Object args[], int numArgs);
 
325
  void opSetTextRender(Object args[], int numArgs);
 
326
  void opSetTextRise(Object args[], int numArgs);
 
327
  void opSetWordSpacing(Object args[], int numArgs);
 
328
  void opSetHorizScaling(Object args[], int numArgs);
 
329
 
 
330
  // text positioning operators
 
331
  void opTextMove(Object args[], int numArgs);
 
332
  void opTextMoveSet(Object args[], int numArgs);
 
333
  void opSetTextMatrix(Object args[], int numArgs);
 
334
  void opTextNextLine(Object args[], int numArgs);
 
335
 
 
336
  // text string operators
 
337
  void opShowText(Object args[], int numArgs);
 
338
  void opMoveShowText(Object args[], int numArgs);
 
339
  void opMoveSetShowText(Object args[], int numArgs);
 
340
  void opShowSpaceText(Object args[], int numArgs);
 
341
  void doShowText(GooString *s);
 
342
 
 
343
  // XObject operators
 
344
  void opXObject(Object args[], int numArgs);
 
345
  void doImage(Object *ref, Stream *str, GBool inlineImg);
 
346
  void doForm(Object *str);
 
347
  void doForm1(Object *str, Dict *resDict, double *matrix, double *bbox,
 
348
               GBool transpGroup = gFalse, GBool softMask = gFalse,
 
349
               GfxColorSpace *blendingColorSpace = NULL,
 
350
               GBool isolated = gFalse, GBool knockout = gFalse,
 
351
               GBool alpha = gFalse, Function *transferFunc = NULL,
 
352
               GfxColor *backdropColor = NULL);
 
353
 
 
354
  // in-line image operators
 
355
  void opBeginImage(Object args[], int numArgs);
 
356
  Stream *buildImageStream();
 
357
  void opImageData(Object args[], int numArgs);
 
358
  void opEndImage(Object args[], int numArgs);
 
359
 
 
360
  // type 3 font operators
 
361
  void opSetCharWidth(Object args[], int numArgs);
 
362
  void opSetCacheDevice(Object args[], int numArgs);
 
363
 
 
364
  // compatibility operators
 
365
  void opBeginIgnoreUndef(Object args[], int numArgs);
 
366
  void opEndIgnoreUndef(Object args[], int numArgs);
 
367
 
 
368
  // marked content operators
 
369
  void opBeginMarkedContent(Object args[], int numArgs);
 
370
  void opEndMarkedContent(Object args[], int numArgs);
 
371
  void opMarkPoint(Object args[], int numArgs);
 
372
  GBool contentIsHidden();
 
373
  void pushMarkedContent();
 
374
  void popMarkedContent();
 
375
};
 
376
 
 
377
#endif