Commit 9faa9b05 authored by Adrian Johnson's avatar Adrian Johnson

Fix tiling patterns with BBox with non-zero x,y

parent 500fb06a
......@@ -900,6 +900,7 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
cairo_t *old_cairo;
double xMin, yMin, xMax, yMax;
double width, height;
double scaleX, scaleY;
int surface_width, surface_height;
StrokePathClip *strokePathTmp;
GBool adjusted_stroke_width_tmp;
......@@ -924,6 +925,8 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
double heightX = 0, heightY = height;
cairo_matrix_transform_distance (&matrix, &heightX, &heightY);
surface_height = ceil (sqrt (heightX * heightX + heightY * heightY));
scaleX = surface_width / width;
scaleY = surface_height / height;
surface = cairo_surface_create_similar (cairo_get_target (cairo),
CAIRO_CONTENT_COLOR_ALPHA,
......@@ -935,10 +938,12 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
cairo = cairo_create (surface);
cairo_surface_destroy (surface);
setContextAntialias(cairo, antialias);
cairo_scale (cairo, surface_width / width, surface_height / height);
box.x1 = bbox[0]; box.y1 = bbox[1];
box.x2 = bbox[2]; box.y2 = bbox[3];
cairo_scale (cairo, scaleX, scaleY);
cairo_translate (cairo, -box.x1, -box.y1);
strokePathTmp = strokePathClip;
strokePathClip = NULL;
adjusted_stroke_width_tmp = adjusted_stroke_width;
......@@ -964,7 +969,8 @@ GBool CairoOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat
state->getUserClipBBox(&xMin, &yMin, &xMax, &yMax);
cairo_rectangle (cairo, xMin, yMin, xMax - xMin, yMax - yMin);
cairo_matrix_init_scale (&matrix, surface_width / width, surface_height / height);
cairo_matrix_init_scale (&matrix, scaleX, scaleY);
cairo_matrix_translate (&matrix, -box.x1, -box.y1);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_transform (cairo, &pattern_matrix);
......
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