Commit a28be53c authored by Caleb Michael Moore's avatar Caleb Michael Moore

more cairo pattern stuff

parent d6038ad5
...@@ -192,24 +192,27 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx, ...@@ -192,24 +192,27 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx,
cairo_surface_t *surface; cairo_surface_t *surface;
cairo_matrix_t matrix; cairo_matrix_t matrix;
int i; int i;
double affine[6], caffine[6], width, height; double affine[6], caffine[6], wscale, hscale;
rsvg_pattern = &local_pattern; rsvg_pattern = &local_pattern;
rsvg_pattern_fix_fallback(rsvg_pattern); rsvg_pattern_fix_fallback(rsvg_pattern);
cr_render = render->cr; cr_render = render->cr;
/* Work out the size of the rectangle so it takes into account the object bounding box */ /* Work out the size of the rectangle so it takes into account the object bounding box */
if (rsvg_pattern->obj_bbox){ if (rsvg_pattern->obj_bbox){
width = rsvg_pattern->width * bbox.w; wscale = bbox.w;
height = rsvg_pattern->height * bbox.h; hscale = bbox.h;
} else { } else {
width = rsvg_pattern->width; wscale = 1.0;
height = rsvg_pattern->height; hscale = 1.0;
} }
surface = cairo_surface_create_similar(cairo_get_target (cr_render), surface = cairo_surface_create_similar(cairo_get_target (cr_render),
CAIRO_CONTENT_COLOR_ALPHA, CAIRO_CONTENT_COLOR_ALPHA,
width, height); rsvg_pattern->width * wscale,
rsvg_pattern->height * hscale);
cr_pattern = cairo_create(surface); cr_pattern = cairo_create(surface);
/* Create the pattern coordinate system */ /* Create the pattern coordinate system */
...@@ -219,16 +222,16 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx, ...@@ -219,16 +222,16 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx,
affine[2] = 0.; affine[2] = 0.;
affine[3] = 1; affine[3] = 1;
/* subtract the pattern origin */ /* subtract the pattern origin */
affine[4] = bbox.x - rsvg_pattern->x * bbox.w; affine[4] = bbox.x + rsvg_pattern->x * bbox.w;
affine[5] = bbox.y - rsvg_pattern->y * bbox.h; affine[5] = bbox.y + rsvg_pattern->y * bbox.h;
} else { } else {
affine[0] = 1; affine[0] = 1;
affine[1] = 0.; affine[1] = 0.;
affine[2] = 0.; affine[2] = 0.;
affine[3] = 1; affine[3] = 1;
/* subtract the pattern origin */ /* subtract the pattern origin */
affine[4] = -rsvg_pattern->x; affine[4] = rsvg_pattern->x;
affine[5] = -rsvg_pattern->y; affine[5] = rsvg_pattern->y;
} }
/* Apply the pattern transform */ /* Apply the pattern transform */
_rsvg_affine_multiply(affine, affine, rsvg_pattern->affine); _rsvg_affine_multiply(affine, affine, rsvg_pattern->affine);
...@@ -237,23 +240,23 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx, ...@@ -237,23 +240,23 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx,
if (rsvg_pattern->vbox) { if (rsvg_pattern->vbox) {
/* If there is a vbox, use that */ /* If there is a vbox, use that */
double w, h, x, y; double w, h, x, y;
w = rsvg_pattern->width; w = rsvg_pattern->width * wscale;
h = rsvg_pattern->height; h = rsvg_pattern->height * hscale;
x = 0; x = 0;
y = 0; y = 0;
rsvg_preserve_aspect_ratio(rsvg_pattern->preserve_aspect_ratio, rsvg_preserve_aspect_ratio(rsvg_pattern->preserve_aspect_ratio,
rsvg_pattern->vbw, rsvg_pattern->vbh, rsvg_pattern->vbw, rsvg_pattern->vbh,
&w, &h, &x, &y); &w, &h, &x, &y);
x -= rsvg_pattern->vbx * w / rsvg_pattern->vbw; x += rsvg_pattern->vbx * w / rsvg_pattern->vbw;
y -= rsvg_pattern->vby * h / rsvg_pattern->vbh; y += rsvg_pattern->vby * h / rsvg_pattern->vbh;
caffine[0] = w / rsvg_pattern->vbw; caffine[0] = w / rsvg_pattern->vbw;
caffine[1] = 0.; caffine[1] = 0.;
caffine[2] = 0.; caffine[2] = 0.;
caffine[3] = h / rsvg_pattern->vbh; caffine[3] = h / rsvg_pattern->vbh;
caffine[4] = x; caffine[4] = -x;
caffine[5] = y; caffine[5] = -y;
} }
else if (rsvg_pattern->obj_cbbox) { else if (rsvg_pattern->obj_cbbox) {
/* If coords are in terms of the bounding box, use them */ /* If coords are in terms of the bounding box, use them */
...@@ -302,6 +305,7 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx, ...@@ -302,6 +305,7 @@ _set_source_rsvg_pattern (RsvgDrawingCtx *ctx,
cairo_matrix_invert (&matrix); cairo_matrix_invert (&matrix);
cairo_pattern_set_matrix (pattern, &matrix); cairo_pattern_set_matrix (pattern, &matrix);
cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST);
cairo_set_source (cr_render, pattern); cairo_set_source (cr_render, pattern);
......
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