Commit d20d6511 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[cairo] Implement tiling patterns in cairo backend

Fixes bug #13518 for the cairo backend.
parent e965d068
......@@ -45,8 +45,10 @@
#include "GlobalParams.h"
#include "Error.h"
#include "Object.h"
#include "Gfx.h"
#include "GfxState.h"
#include "GfxFont.h"
#include "Page.h"
#include "Link.h"
#include "CharCodeToUnicode.h"
#include "FontEncodingTables.h"
......@@ -657,6 +659,60 @@ void CairoOutputDev::eoFill(GfxState *state) {
}
GBool CairoOutputDev::tilingPatternFill(GfxState *state, Object *str,
int paintType, Dict *resDict,
double *mat, double *bbox,
int x0, int y0, int x1, int y1,
double xStep, double yStep)
{
PDFRectangle box;
Gfx *gfx;
cairo_pattern_t *pattern;
cairo_surface_t *surface;
cairo_matrix_t matrix;
cairo_t *old_cairo;
double xMin, yMin, xMax, yMax;
if (xStep != bbox[2] || yStep != bbox[3])
return gFalse;
/* TODO: implement the other cases here too */
surface = cairo_surface_create_similar (cairo_get_target (cairo),
CAIRO_CONTENT_COLOR_ALPHA,
bbox[2], bbox[3]);
if (cairo_surface_status (surface))
return gFalse;
old_cairo = cairo;
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
gfx = new Gfx(xref, this, resDict, catalog, &box, NULL);
gfx->display(str);
delete gfx;
pattern = cairo_pattern_create_for_surface (cairo_get_target (cairo));
cairo_destroy (cairo);
cairo = old_cairo;
if (cairo_pattern_status (pattern))
return gFalse;
state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax);
cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
cairo_matrix_init (&matrix, mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
cairo_transform (cairo, &matrix);
cairo_set_source (cairo, pattern);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_fill (cairo);
cairo_pattern_destroy (pattern);
return gTrue;
}
GBool CairoOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) {
double x0, y0, x1, y1;
double dx, dy;
......
......@@ -98,6 +98,11 @@ public:
// Does this device use drawChar() or drawString()?
virtual GBool useDrawChar() { return gTrue; }
// Does this device use tilingPatternFill()? If this returns false,
// tiling pattern fills will be reduced to a series of other drawing
// operations.
virtual GBool useTilingPatternFill() { return gTrue; }
// 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.
......@@ -151,6 +156,11 @@ public:
virtual void stroke(GfxState *state);
virtual void fill(GfxState *state);
virtual void eoFill(GfxState *state);
virtual GBool tilingPatternFill(GfxState *state, Object *str,
int paintType, Dict *resDict,
double *mat, double *bbox,
int x0, int y0, int x1, int y1,
double xStep, double yStep);
virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
virtual GBool axialShadedSupportExtend(GfxState *state, GfxAxialShading *shading);
virtual GBool radialShadedFill(GfxState *state, GfxRadialShading *shading, double sMin, double sMax);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment