Skip to content

Commit

Permalink
pdf: fix subsurface recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Johnson committed Oct 17, 2015
1 parent 2215b4e commit 094f0e0
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/cairo-pdf-surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,21 +1249,22 @@ _get_source_surface_size (cairo_surface_t *source,
unsigned long mime_data_length;

if (source->type == CAIRO_SURFACE_TYPE_RECORDING) {
cairo_surface_t *free_me = NULL;

if (_cairo_surface_is_snapshot (source))
free_me = source = _cairo_surface_snapshot_get_target (source);

if (source->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
cairo_surface_subsurface_t *sub = (cairo_surface_subsurface_t *) source;
cairo_surface_subsurface_t *sub = (cairo_surface_subsurface_t *) source;

*extents = sub->extents;
*width = extents->width;
*height = extents->height;
*extents = sub->extents;
*width = extents->width;
*height = extents->height;
} else {
cairo_surface_t *free_me = NULL;
cairo_rectangle_int_t surf_extents;
cairo_box_t box;
cairo_bool_t bounded;

if (_cairo_surface_is_snapshot (source))
free_me = source = _cairo_surface_snapshot_get_target (source);

status = _cairo_recording_surface_get_ink_bbox ((cairo_recording_surface_t *)source,
&box, NULL);
if (unlikely (status)) {
Expand All @@ -1272,13 +1273,13 @@ _get_source_surface_size (cairo_surface_t *source,
}

bounded = _cairo_surface_get_extents (source, &surf_extents);
cairo_surface_destroy (free_me);

*width = surf_extents.width;
*height = surf_extents.height;

_cairo_box_round_to_rectangle (&box, extents);
}
cairo_surface_destroy (free_me);

return CAIRO_STATUS_SUCCESS;
}
Expand Down Expand Up @@ -3010,9 +3011,10 @@ _cairo_pdf_surface_emit_recording_surface (cairo_pdf_surface_t *surface,
height = pdf_source->hash_entry->height;
is_subsurface = FALSE;
source = pdf_source->surface;
if (_cairo_surface_is_snapshot (source)) {
if (_cairo_surface_is_snapshot (source))
free_me = source = _cairo_surface_snapshot_get_target (source);
} else if (source->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {

if (source->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
cairo_surface_subsurface_t *sub = (cairo_surface_subsurface_t *) source;

source = sub->target;
Expand Down Expand Up @@ -3040,7 +3042,14 @@ _cairo_pdf_surface_emit_recording_surface (cairo_pdf_surface_t *surface,
*/
surface->paginated_mode = CAIRO_PAGINATED_MODE_RENDER;
_cairo_pdf_group_resources_clear (&surface->resources);
_get_bbox_from_extents (height, extents, &bbox);
if (is_subsurface) {
bbox.p1.x = 0;
bbox.p1.y = 0;
bbox.p2.x = extents->width;
bbox.p2.y = extents->height;
} else {
_get_bbox_from_extents (height, extents, &bbox);
}

/* We can optimize away the transparency group allowing the viewer
* to replay the group in place when all operators are OVER and the
Expand Down

0 comments on commit 094f0e0

Please sign in to comment.