/* Redirect @gstate rendering to a "child" target. The original "parent" target with which the gstate was created will not be affected. See _cairo_gstate_get_target().  */
cairo_status_t _cairo_gstate_redirect_target(cairo_gstate_t *gstate, cairo_surface_t *child)
/* Redirect @gstate rendering to a "child" target. The original "parent" target with which the gstate was created will not be affected. See _cairo_gstate_get_target().  */
cairo_status_t _cairo_gstate_redirect_target(cairo_gstate_t *gstate, cairo_surface_t *child)
{
    assert (gstate->parent_target == NULL);
    gstate->parent_target = gstate->target;
    gstate->target = cairo_surface_reference (child);
    gstate->is_identity &= _cairo_matrix_is_identity (&child->device_transform);
    cairo_list_move (&gstate->device_transform_observer.link,
		     &gstate->target->device_transform_observers);
    _cairo_clip_destroy (gstate->clip);
    gstate->clip = _cairo_clip_copy_with_translation (gstate->next->clip,
						      child->device_transform.x0 - gstate->parent_target->device_transform.x0,
						      child->device_transform.y0 - gstate->parent_target->device_transform.y0);
    return CAIRO_STATUS_SUCCESS;
}