CairoOutputDev.h 19.5 KB
Newer Older
Kristian Høgsberg's avatar
Kristian Høgsberg committed
1 2 3 4 5 6 7 8 9
//========================================================================
//
// CairoOutputDev.h
//
// Copyright 2003 Glyph & Cog, LLC
// Copyright 2004 Red Hat, INC
//
//========================================================================

10 11 12 13
//========================================================================
//
// Modified under the Poppler project - http://poppler.freedesktop.org
//
14 15 16
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
//
17 18 19
// Copyright (C) 2005-2008 Jeff Muizelaar <jeff@infidigm.net>
// Copyright (C) 2005, 2006 Kristian Høgsberg <krh@redhat.com>
// Copyright (C) 2005 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
Albert Astals Cid's avatar
Albert Astals Cid committed
20
// Copyright (C) 2006-2011, 2013 Carlos Garcia Campos <carlosgc@gnome.org>
Albert Astals Cid's avatar
Albert Astals Cid committed
21
// Copyright (C) 2008, 2009, 2011-2017 Adrian Johnson <ajohnson@redneon.com>
22
// Copyright (C) 2008 Michael Vrable <mvrable@cs.ucsd.edu>
Thomas Freitag's avatar
Thomas Freitag committed
23
// Copyright (C) 2010-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
Albert Astals Cid's avatar
Albert Astals Cid committed
24
// Copyright (C) 2015 Suzuki Toshiya <mpsuzuki@hiroshima-u.ac.jp>
Albert Astals Cid's avatar
Albert Astals Cid committed
25
// Copyright (C) 2016 Jason Crain <jason@aquaticape.us>
26
// Copyright (C) 2018 Albert Astals Cid <aacid@kde.org>
27
// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <info@kdab.com>. Work sponsored by the LiMux project of the city of Munich
28 29 30 31 32 33
//
// 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
34 35 36 37 38 39 40 41
#ifndef CAIROOUTPUTDEV_H
#define CAIROOUTPUTDEV_H

#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif

#include "goo/gtypes.h"
42
#include <cairo-ft.h>
Kristian Høgsberg's avatar
Kristian Høgsberg committed
43
#include "OutputDev.h"
44
#include "TextOutputDev.h"
Kristian Høgsberg's avatar
Kristian Høgsberg committed
45 46
#include "GfxState.h"

47
class PDFDoc;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
48 49 50 51 52 53 54 55 56
class GfxState;
class GfxPath;
class Gfx8BitFont;
struct GfxRGB;
class CairoFontEngine;
class CairoFont;

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

57 58 59 60 61 62
//------------------------------------------------------------------------
// CairoImage
//------------------------------------------------------------------------
class CairoImage {
public:
  // Constructor.
63
  CairoImage (double x1, double y1, double x2, double y2);
64 65 66 67

  // Destructor.
  ~CairoImage ();

68 69 70
  CairoImage(const CairoImage &) = delete;
  CairoImage& operator=(const CairoImage &) = delete;

71 72 73
  // Set the image cairo surface
  void setImage (cairo_surface_t *image);
  
74 75 76 77 78 79 80 81 82 83 84 85 86 87
  // Get the image cairo surface
  cairo_surface_t *getImage () const { return image; }

  // Get the image rectangle
  void getRect (double *xa1, double *ya1, double *xa2, double *ya2)
	  { *xa1 = x1; *ya1 = y1; *xa2 = x2; *ya2 = y2; }
  
private:
  cairo_surface_t *image;  // image cairo surface
  double x1, y1;          // upper left corner
  double x2, y2;          // lower right corner
};


Kristian Høgsberg's avatar
Kristian Høgsberg committed
88 89 90 91 92 93 94 95
//------------------------------------------------------------------------
// CairoOutputDev
//------------------------------------------------------------------------

class CairoOutputDev: public OutputDev {
public:

  // Constructor.
96
  CairoOutputDev();
Kristian Høgsberg's avatar
Kristian Høgsberg committed
97 98 99 100 101 102 103 104

  // Destructor.
  virtual ~CairoOutputDev();

  //----- 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
105
  GBool upsideDown() override { return gTrue; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
106 107

  // Does this device use drawChar() or drawString()?
Albert Astals Cid's avatar
Albert Astals Cid committed
108
  GBool useDrawChar() override { return gTrue; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
109

110 111 112
  // 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
113
  GBool useTilingPatternFill() override { return gTrue; }
114

115 116 117
  // 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.
118
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
Albert Astals Cid's avatar
Albert Astals Cid committed
119
  GBool useShadedFills(int type) override { return type <= 7; }
120
#else
Albert Astals Cid's avatar
Albert Astals Cid committed
121
  GBool useShadedFills(int type) override { return type > 1 && type < 4; }
122
#endif
123 124

  // Does this device use FillColorStop()?
Albert Astals Cid's avatar
Albert Astals Cid committed
125
  GBool useFillColorStop() override { return gTrue; }
126

Kristian Høgsberg's avatar
Kristian Høgsberg committed
127 128
  // 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
129
  GBool interpretType3Chars() override { return gFalse; }
Kristian Høgsberg's avatar
Kristian Høgsberg committed
130

Adrian Johnson's avatar
Adrian Johnson committed
131 132
  // Does this device need to clip pages to the crop box even when the
  // box is the crop box?
Albert Astals Cid's avatar
Albert Astals Cid committed
133
  GBool needClipToCropBox() override { return gTrue; }
Adrian Johnson's avatar
Adrian Johnson committed
134

Kristian Høgsberg's avatar
Kristian Høgsberg committed
135 136 137
  //----- initialization and control

  // Start a page.
Albert Astals Cid's avatar
Albert Astals Cid committed
138
  void startPage(int pageNum, GfxState *state, XRef *xref) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
139 140

  // End a page.
Albert Astals Cid's avatar
Albert Astals Cid committed
141
  void endPage() override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
142 143

  //----- save/restore graphics state
Albert Astals Cid's avatar
Albert Astals Cid committed
144 145
  void saveState(GfxState *state) override;
  void restoreState(GfxState *state) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
146 147

  //----- update graphics state
Albert Astals Cid's avatar
Albert Astals Cid committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
  void updateAll(GfxState *state) override;
  void setDefaultCTM(double *ctm) override;
  void updateCTM(GfxState *state, double m11, double m12,
		 double m21, double m22, double m31, double m32) override;
  void updateLineDash(GfxState *state) override;
  void updateFlatness(GfxState *state) override;
  void updateLineJoin(GfxState *state) override;
  void updateLineCap(GfxState *state) override;
  void updateMiterLimit(GfxState *state) override;
  void updateLineWidth(GfxState *state) override;
  void updateFillColor(GfxState *state) override;
  void updateStrokeColor(GfxState *state) override;
  void updateFillOpacity(GfxState *state) override;
  void updateStrokeOpacity(GfxState *state) override;
  void updateFillColorStop(GfxState *state, double offset) override;
  void updateBlendMode(GfxState *state) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
164 165

  //----- update text state
Albert Astals Cid's avatar
Albert Astals Cid committed
166
  void updateFont(GfxState *state) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
167 168

  //----- path painting
Albert Astals Cid's avatar
Albert Astals Cid committed
169 170 171 172 173 174 175 176 177
  void stroke(GfxState *state) override;
  void fill(GfxState *state) override;
  void eoFill(GfxState *state) override;
  void clipToStrokePath(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;
178
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
Albert Astals Cid's avatar
Albert Astals Cid committed
179
  GBool functionShadedFill(GfxState *state, GfxFunctionShading *shading) override;
180
#endif
Albert Astals Cid's avatar
Albert Astals Cid committed
181 182 183 184
  GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) override;
  GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading) override;
  GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax) override;
  GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading) override;
185
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
Albert Astals Cid's avatar
Albert Astals Cid committed
186 187
  GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading) override;
  GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading) override;
188
#endif
Kristian Høgsberg's avatar
Kristian Høgsberg committed
189 190

  //----- path clipping
Albert Astals Cid's avatar
Albert Astals Cid committed
191 192
  void clip(GfxState *state) override;
  void eoClip(GfxState *state) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
193 194

  //----- text drawing
195
  void beginString(GfxState *state, const GooString *s) override;
Albert Astals Cid's avatar
Albert Astals Cid committed
196
  void endString(GfxState *state) override;
197 198 199
  void drawChar(GfxState *state, double x, double y,
		double dx, double dy,
		double originX, double originY,
Albert Astals Cid's avatar
Albert Astals Cid committed
200
		CharCode code, int nBytes, Unicode *u, int uLen) override;
201
  void beginActualText(GfxState *state, const GooString *text) override;
Albert Astals Cid's avatar
Albert Astals Cid committed
202
  void endActualText(GfxState *state) override;
203

Albert Astals Cid's avatar
Albert Astals Cid committed
204 205 206 207 208 209
  GBool beginType3Char(GfxState *state, double x, double y,
		       double dx, double dy,
		       CharCode code, Unicode *u, int uLen) override;
  void endType3Char(GfxState *state) override;
  void beginTextObject(GfxState *state) override;
  void endTextObject(GfxState *state) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
210 211

  //----- image drawing
Albert Astals Cid's avatar
Albert Astals Cid committed
212 213 214 215 216 217 218 219
  void drawImageMask(GfxState *state, Object *ref, Stream *str,
		     int width, int height, GBool invert, GBool interpolate,
		     GBool inlineImg) override;
  void setSoftMaskFromImageMask(GfxState *state,
				Object *ref, Stream *str,
				int width, int height, GBool invert,
				GBool inlineImg, double *baseMatrix) override;
  void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override;
220
  void drawImageMaskPrescaled(GfxState *state, Object *ref, Stream *str,
221 222
			      int width, int height, GBool invert, GBool interpolate,
			      GBool inlineImg);
223
  void drawImageMaskRegular(GfxState *state, Object *ref, Stream *str,
224 225
			    int width, int height, GBool invert, GBool interpolate,
			    GBool inlineImg);
226

Albert Astals Cid's avatar
Albert Astals Cid committed
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
  void drawImage(GfxState *state, Object *ref, Stream *str,
		 int width, int height, GfxImageColorMap *colorMap,
		 GBool interpolate, int *maskColors, GBool inlineImg) 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;

  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;
246

247
  //----- transparency groups and soft masks
Albert Astals Cid's avatar
Albert Astals Cid committed
248
  void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
249 250
                                      GfxColorSpace * /*blendingColorSpace*/,
                                      GBool /*isolated*/, GBool /*knockout*/,
Albert Astals Cid's avatar
Albert Astals Cid committed
251 252
                                      GBool /*forSoftMask*/) override;
  void endTransparencyGroup(GfxState * /*state*/) override;
253
  void popTransparencyGroup();
Albert Astals Cid's avatar
Albert Astals Cid committed
254 255 256 257
  void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) override;
  void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
		   Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override;
  void clearSoftMask(GfxState * /*state*/) override;
258

Kristian Høgsberg's avatar
Kristian Høgsberg committed
259
  //----- Type 3 font operators
Albert Astals Cid's avatar
Albert Astals Cid committed
260 261 262
  void type3D0(GfxState *state, double wx, double wy) override;
  void type3D1(GfxState *state, double wx, double wy,
	       double llx, double lly, double urx, double ury) override;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
263 264

  //----- special access
265
  
Kristian Høgsberg's avatar
Kristian Høgsberg committed
266
  // Called to indicate that a new PDF document has been loaded.
267
  void startDoc(PDFDoc *docA, CairoFontEngine *fontEngine = NULL);
Kristian Høgsberg's avatar
Kristian Høgsberg committed
268 269 270
 
  GBool isReverseVideo() { return gFalse; }
  
271
  void setCairo (cairo_t *cr);
272
  void setTextPage (TextPage *text);
273
  void setPrinting (GBool printingA) { printing = printingA; needFontUpdate = gTrue; }
274
  void setAntialias(cairo_antialias_t antialias);
275

276
  void setInType3Char(GBool inType3CharA) { inType3Char = inType3CharA; }
277 278 279 280
  void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
  GBool hasType3GlyphBBox () { return t3_glyph_has_bbox; }
  double *getType3GlyphBBox () { return t3_glyph_bbox; }

Kristian Høgsberg's avatar
Kristian Høgsberg committed
281
protected:
282
  void doPath(cairo_t *cairo, GfxState *state, GfxPath *path);
283
  cairo_surface_t *downscaleSurface(cairo_surface_t *orig_surface);
284 285
  void getScaledSize(const cairo_matrix_t *matrix,
                     int orig_width, int orig_height,
286
		     int *scaledWidth, int *scaledHeight);
287 288
  cairo_filter_t getFilterForSurface(cairo_surface_t *image,
				     GBool interpolate);
289
  GBool getStreamData (Stream *str, char **buffer, int *length);
290
  void setMimeData(GfxState *state, Stream *str, Object *ref,
291
		   GfxImageColorMap *colorMap, cairo_surface_t *image, int height);
292
  void fillToStrokePathClip(GfxState *state);
293
  void alignStrokeCoords(GfxSubpath *subpath, int i, double *x, double *y);
294 295
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
  GBool setMimeDataForJBIG2Globals (Stream *str, cairo_surface_t *image);
296 297 298
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 15, 10)
  GBool setMimeDataForCCITTParams(Stream  *str, cairo_surface_t *image, int height);
299
#endif
300
  static void setContextAntialias(cairo_t *cr, cairo_antialias_t antialias);
Adrian Johnson's avatar
Adrian Johnson committed
301

302
  GfxRGB fill_color, stroke_color;
303
  cairo_pattern_t *fill_pattern, *stroke_pattern;
304 305
  double fill_opacity;
  double stroke_opacity;
306
  GBool stroke_adjust;
307 308
  GBool adjusted_stroke_width;
  GBool align_stroke_coords;
Kristian Høgsberg's avatar
Kristian Høgsberg committed
309
  CairoFont *currentFont;
Thomas Freitag's avatar
Thomas Freitag committed
310
  XRef *xref;
Adrian Johnson's avatar
Adrian Johnson committed
311 312

  struct StrokePathClip {
313
    GfxPath *path;
Adrian Johnson's avatar
Adrian Johnson committed
314 315 316 317 318 319 320 321
    cairo_matrix_t ctm;
    double line_width;
    double *dashes;
    int dash_count;
    double dash_offset;
    cairo_line_cap_t cap;
    cairo_line_join_t join;
    double miter;
322
    int ref_count;
Adrian Johnson's avatar
Adrian Johnson committed
323 324
  } *strokePathClip;

325
  PDFDoc *doc;			// the current document
Kristian Høgsberg's avatar
Kristian Høgsberg committed
326

327 328 329
  static FT_Library ft_lib;
  static GBool ft_lib_initialized;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
330
  CairoFontEngine *fontEngine;
331 332
  GBool fontEngine_owner;

Kristian Høgsberg's avatar
Kristian Høgsberg committed
333
  cairo_t *cairo;
334
  cairo_matrix_t orig_matrix;
335
  GBool needFontUpdate;                // set when the font needs to be updated
336
  GBool printing;
337
  GBool use_show_text_glyphs;
338
  GBool text_matrix_valid;
339 340
  cairo_glyph_t *glyphs;
  int glyphCount;
341 342 343 344 345
  cairo_text_cluster_t *clusters;
  int clusterCount;
  char *utf8;
  int utf8Count;
  int utf8Max;
346
  cairo_path_t *textClipPath;
347
  GBool inUncoloredPattern;     // inside a uncolored pattern (PaintType = 2)
348
  GBool inType3Char;		// inside a Type 3 CharProc
349 350 351
  double t3_glyph_wx, t3_glyph_wy;
  GBool t3_glyph_has_bbox;
  double t3_glyph_bbox[4];
352
  cairo_antialias_t antialias;
353 354
  GBool prescaleImages;

355
  TextPage *text;		// text for the current page
356
  ActualText *actualText;
357

358
  cairo_pattern_t *group;
359
  cairo_pattern_t *shape;
360
  cairo_pattern_t *mask;
Adrian Johnson's avatar
Adrian Johnson committed
361
  cairo_matrix_t mask_matrix;
362 363
  cairo_t *cairo_shape;
  int knockoutCount;
364
  struct ColorSpaceStack {
365
    GBool knockout;
366
    GfxColorSpace *cs;
367
    cairo_matrix_t group_matrix;
368 369
    struct ColorSpaceStack *next;
  } * groupColorSpaceStack;
370 371

  struct MaskStack {
Adrian Johnson's avatar
Adrian Johnson committed
372 373 374
    cairo_pattern_t *mask;
    cairo_matrix_t mask_matrix;
    struct MaskStack *next;
375
  } *maskStack;
376

Kristian Høgsberg's avatar
Kristian Høgsberg committed
377 378
};

379 380 381 382
//------------------------------------------------------------------------
// CairoImageOutputDev
//------------------------------------------------------------------------

383
//XXX: this should ideally not inherit from CairoOutputDev but use it instead perhaps
384 385 386 387 388 389 390 391 392 393 394 395 396
class CairoImageOutputDev: public CairoOutputDev {
public:

  // Constructor.
  CairoImageOutputDev();

  // Destructor.
  virtual ~CairoImageOutputDev();

  //----- 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
397
  GBool upsideDown() override { return gTrue; }
398 399

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

402 403 404
  // 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
405
  GBool useTilingPatternFill() override { return gTrue; }
406 407 408 409

  // 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.
410
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)
Albert Astals Cid's avatar
Albert Astals Cid committed
411
  GBool useShadedFills(int type) override { return type <= 7; }
412
#else
Albert Astals Cid's avatar
Albert Astals Cid committed
413
  GBool useShadedFills(int type) override { return type < 4; }
414
#endif
415 416

  // Does this device use FillColorStop()?
Albert Astals Cid's avatar
Albert Astals Cid committed
417
  GBool useFillColorStop() override { return gFalse; }
418

419 420
  // 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
421
  GBool interpretType3Chars() override { return gFalse; }
422 423

  // Does this device need non-text content?
Albert Astals Cid's avatar
Albert Astals Cid committed
424
  GBool needNonText() override { return gTrue; }
425 426

  //----- save/restore graphics state
Albert Astals Cid's avatar
Albert Astals Cid committed
427 428
  void saveState(GfxState *state) override { }
  void restoreState(GfxState *state) override { }
429 430

  //----- update graphics state
Albert Astals Cid's avatar
Albert Astals Cid committed
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
  void updateAll(GfxState *state) override { }
  void setDefaultCTM(double *ctm) override { }
  void updateCTM(GfxState *state, double m11, double m12,
		 double m21, double m22, double m31, double m32) override { }
  void updateLineDash(GfxState *state) override { }
  void updateFlatness(GfxState *state) override { }
  void updateLineJoin(GfxState *state) override { }
  void updateLineCap(GfxState *state) override { }
  void updateMiterLimit(GfxState *state) override { }
  void updateLineWidth(GfxState *state) override { }
  void updateFillColor(GfxState *state) override { }
  void updateStrokeColor(GfxState *state) override { }
  void updateFillOpacity(GfxState *state) override { }
  void updateStrokeOpacity(GfxState *state) override { }
  void updateBlendMode(GfxState *state) override { }
446 447

  //----- update text state
Albert Astals Cid's avatar
Albert Astals Cid committed
448
  void updateFont(GfxState *state) override { }
449 450

  //----- path painting
Albert Astals Cid's avatar
Albert Astals Cid committed
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
  void stroke(GfxState *state) override { }
  void fill(GfxState *state) override { }
  void eoFill(GfxState *state) override { }
  void clipToStrokePath(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 { return gTrue; }
  GBool axialShadedFill(GfxState *state,
			GfxAxialShading *shading,
			double tMin, double tMax) override { return gTrue; }
  GBool radialShadedFill(GfxState *state,
			 GfxRadialShading *shading,
			 double sMin, double sMax) override { return gTrue; }
466 467

  //----- path clipping
Albert Astals Cid's avatar
Albert Astals Cid committed
468 469
  void clip(GfxState *state) override { }
  void eoClip(GfxState *state) override { }
470 471

  //----- image drawing
Albert Astals Cid's avatar
Albert Astals Cid committed
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
  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 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;
  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 setSoftMaskFromImageMask(GfxState *state, Object *ref, Stream *str,
				int width, int height, GBool invert,
				GBool inlineImg, double *baseMatrix) override;
  void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix) override {}
497

498

499
  //----- transparency groups and soft masks
Albert Astals Cid's avatar
Albert Astals Cid committed
500 501 502 503 504 505 506 507 508
  void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
			      GfxColorSpace * /*blendingColorSpace*/,
			      GBool /*isolated*/, GBool /*knockout*/,
			      GBool /*forSoftMask*/) override {}
  void endTransparencyGroup(GfxState * /*state*/) override {}
  void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) override {}
  void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
		   Function * /*transferFunc*/, GfxColor * /*backdropColor*/) override {}
  void clearSoftMask(GfxState * /*state*/) override {}
509

510
  //----- Image list
511 512 513
  // By default images are not rendred
  void setImageDrawDecideCbk(GBool (*cbk)(int img_id, void *data),
			     void *data) { imgDrawCbk = cbk; imgDrawCbkData = data; }
514 515 516 517 518 519
  // Iterate through list of images.
  int getNumImages() const { return numImages; }
  CairoImage *getImage(int i) const { return images[i]; }

private:
  void saveImage(CairoImage *image);
520 521
  void getBBox(GfxState *state, int width, int height,
               double *x1, double *y1, double *x2, double *y2);
522
  
523 524 525
  CairoImage **images;
  int numImages;
  int size;
526 527
  GBool (*imgDrawCbk)(int img_id, void *data);
  void *imgDrawCbkData;
528 529
};

Kristian Høgsberg's avatar
Kristian Høgsberg committed
530
#endif