summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-01 20:25:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-01 20:25:53 +0100
commit6ddab64025eacd5000fa295c86c0fddc469bdc5f (patch)
tree2de982a9b952d0a81b4891ff8bfd9bb02e71c266
parent665f5829541703b29e33f80bebf579a17f47a892 (diff)
[ps] Clip meta-surface to desired extents.
Ensure that the meta surface does not extend beyond the operation by forcing a clip to the extents of the operation. Fixes test/device-offset and test/device-offset-positive
-rw-r--r--src/cairo-ps-surface.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 49d962ba..26bba176 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2317,9 +2317,11 @@ _cairo_ps_surface_emit_meta_surface (cairo_ps_surface_t *surface,
if (cairo_surface_get_content (meta_surface) == CAIRO_CONTENT_COLOR) {
surface->content = CAIRO_CONTENT_COLOR;
_cairo_output_stream_printf (surface->stream,
- " 0 g 0 0 %f %f rectfill\n",
- surface->width,
- surface->height);
+ " 0 g %d %d %d %d rectfill\n",
+ surface->page_bbox.x,
+ surface->page_bbox.y,
+ surface->page_bbox.width,
+ surface->page_bbox.height);
}
status = _cairo_meta_surface_replay_region (meta_surface, &surface->base,
@@ -2527,6 +2529,35 @@ _cairo_ps_surface_release_surface (cairo_ps_surface_t *surface,
surface->image = NULL;
}
+static void
+_path_fixed_init_rectangle (cairo_path_fixed_t *path,
+ cairo_rectangle_int_t *rect)
+{
+ cairo_status_t status;
+
+ _cairo_path_fixed_init (path);
+
+ status = _cairo_path_fixed_move_to (path,
+ _cairo_fixed_from_int (rect->x),
+ _cairo_fixed_from_int (rect->y));
+ assert (status == CAIRO_STATUS_SUCCESS);
+ status = _cairo_path_fixed_rel_line_to (path,
+ _cairo_fixed_from_int (rect->width),
+ _cairo_fixed_from_int (0));
+ assert (status == CAIRO_STATUS_SUCCESS);
+ status = _cairo_path_fixed_rel_line_to (path,
+ _cairo_fixed_from_int (0),
+ _cairo_fixed_from_int (rect->height));
+ assert (status == CAIRO_STATUS_SUCCESS);
+ status = _cairo_path_fixed_rel_line_to (path,
+ _cairo_fixed_from_int (-rect->width),
+ _cairo_fixed_from_int (0));
+ assert (status == CAIRO_STATUS_SUCCESS);
+
+ status = _cairo_path_fixed_close_path (path);
+ assert (status == CAIRO_STATUS_SUCCESS);
+}
+
static cairo_status_t
_cairo_ps_surface_paint_surface (cairo_ps_surface_t *surface,
cairo_surface_pattern_t *pattern,
@@ -2536,6 +2567,7 @@ _cairo_ps_surface_paint_surface (cairo_ps_surface_t *surface,
cairo_status_t status;
int width, height;
cairo_matrix_t cairo_p2d, ps_p2d;
+ cairo_path_fixed_t path;
int origin_x = 0;
int origin_y = 0;
@@ -2547,6 +2579,14 @@ _cairo_ps_surface_paint_surface (cairo_ps_surface_t *surface,
if (unlikely (status))
return status;
+ _path_fixed_init_rectangle (&path, extents);
+ status = _cairo_pdf_operators_clip (&surface->pdf_operators,
+ &path,
+ CAIRO_FILL_RULE_WINDING);
+ _cairo_path_fixed_fini (&path);
+ if (unlikely (status))
+ return status;
+
cairo_p2d = pattern->base.matrix;
if (surface->paginated_mode == CAIRO_PAGINATED_MODE_FALLBACK) {