void _cairo_clip_init_deep_copy (cairo_clip_t *clip, cairo_clip_t *other, cairo_surface_t *target) { _cairo_clip_init (clip, target); if (other->mode != clip->mode) { /* We should reapply the original clip path in this case, and let * whatever the right handling is happen */ } else { if (other->region) { clip->region = pixman_region_create (); pixman_region_copy (clip->region, other->region); } if (other->surface) { _cairo_surface_clone_similar (target, other->surface, &clip->surface); clip->surface_rect = other->surface_rect; } if (other->path) { _cairo_clip_path_reapply_clip_path (clip, other->path); } } }
static cairo_status_t _test_fallback16_surface_clone_similar (void *abstract_surface, cairo_surface_t *src, cairo_content_t content, int src_x, int src_y, int width, int height, int *clone_offset_x, int *clone_offset_y, cairo_surface_t **clone_out) { test_fallback16_surface_t *surface = abstract_surface; if (src->backend == surface->base.backend) { *clone_offset_x = 0; *clone_offset_y = 0; *clone_out = cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } else { return _cairo_surface_clone_similar (surface->backing, src, content, src_x, src_y, width, height, clone_offset_x, clone_offset_y, clone_out); } }
cairo_status_t _cairo_clip_init_deep_copy (cairo_clip_t *clip, cairo_clip_t *other, cairo_surface_t *target) { cairo_status_t status; _cairo_clip_init (clip, target); if (other->mode != clip->mode) { /* We should reapply the original clip path in this case, and let * whatever the right handling is happen */ } else { if (other->has_region) { status = _cairo_region_copy (&clip->region, &other->region); if (unlikely (status)) goto BAIL; clip->has_region = TRUE; } if (other->surface) { int dx, dy; status = _cairo_surface_clone_similar (target, other->surface, 0, 0, other->surface_rect.width, other->surface_rect.height, &dx, &dy, &clip->surface); if (unlikely (status)) goto BAIL; clip->surface_rect = other->surface_rect; /* src offset was 0, so we expect an exact replica of the surface */ assert (dx == 0); assert (dy == 0); } if (other->path) { status = _cairo_clip_path_reapply_clip_path (clip, other->path); if (_cairo_status_is_error (status)) goto BAIL; } } return CAIRO_STATUS_SUCCESS; BAIL: if (clip->has_region) _cairo_region_fini (&clip->region); if (clip->surface) cairo_surface_destroy (clip->surface); return status; }
cairo_status_t _cairo_clip_init_deep_copy (cairo_clip_t *clip, cairo_clip_t *other, cairo_surface_t *target) { cairo_status_t status; _cairo_clip_init (clip, target); if (other->mode != clip->mode) { /* We should reapply the original clip path in this case, and let * whatever the right handling is happen */ } else { if (other->has_region) { status = _cairo_region_copy (&clip->region, &other->region); if (status) goto BAIL; clip->has_region = TRUE; } if (other->surface) { status = _cairo_surface_clone_similar (target, other->surface, other->surface_rect.x, other->surface_rect.y, other->surface_rect.width, other->surface_rect.height, &clip->surface); if (status) goto BAIL; clip->surface_rect = other->surface_rect; } if (other->path) { status = _cairo_clip_path_reapply_clip_path (clip, other->path); if (status && status != CAIRO_INT_STATUS_UNSUPPORTED) goto BAIL; } } return CAIRO_STATUS_SUCCESS; BAIL: if (clip->has_region) _cairo_region_fini (&clip->region); if (clip->surface) cairo_surface_destroy (clip->surface); return status; }