image: peek through a snapshot to the recording surface behind

Fixes record-* after the recent overhaul.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2011-08-14 00:43:09 +01:00
parent 8a90b22897
commit 6b3d53646e
8 changed files with 21 additions and 11 deletions

View file

@ -120,7 +120,7 @@ _analyze_recording_surface_pattern (cairo_analysis_surface_t *surface,
surface->has_ctm = ! _cairo_matrix_is_identity (&surface->ctm);
source = surface_pattern->surface;
if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
if (_cairo_surface_is_snapshot (source))
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;

View file

@ -1406,8 +1406,8 @@ _pixman_image_for_surface (const cairo_surface_pattern_t *pattern,
cairo_image_surface_t *source = (cairo_image_surface_t *) pattern->surface;
cairo_surface_type_t type;
if (source->base.backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
source = (cairo_image_surface_t *) ((cairo_surface_snapshot_t *) pattern->surface)->target;
if (_cairo_surface_is_snapshot (&source->base))
source = (cairo_image_surface_t *) _cairo_surface_snapshot_get_target (&source->base);
type = source->base.backend->type;
if (type == CAIRO_SURFACE_TYPE_IMAGE) {
@ -2963,6 +2963,8 @@ is_recording_pattern (const cairo_pattern_t *pattern)
surface = ((const cairo_surface_pattern_t *) pattern)->surface;
if (_cairo_surface_is_paginated (surface))
surface = _cairo_paginated_surface_get_recording (surface);
if (_cairo_surface_is_snapshot (surface))
surface = _cairo_surface_snapshot_get_target (surface);
return _cairo_surface_is_recording (surface);
}
@ -2974,6 +2976,8 @@ recording_pattern_get_surface (const cairo_pattern_t *pattern)
surface = ((const cairo_surface_pattern_t *) pattern)->surface;
if (_cairo_surface_is_paginated (surface))
surface = _cairo_paginated_surface_get_recording (surface);
if (_cairo_surface_is_snapshot (surface))
surface = _cairo_surface_snapshot_get_target (surface);
return surface;
}

View file

@ -1114,7 +1114,7 @@ _get_source_surface_size (cairo_surface_t *source,
cairo_recording_surface_t *recording_surface;
cairo_box_t bbox;
if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
if (_cairo_surface_is_snapshot (source))
source = _cairo_surface_snapshot_get_target (source);
recording_surface = (cairo_recording_surface_t *) source;
@ -2381,7 +2381,7 @@ _cairo_pdf_surface_emit_recording_surface (cairo_pdf_surface_t *surface,
cairo_int_status_t status;
int alpha = 0;
if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
if (_cairo_surface_is_snapshot (source))
source = _cairo_surface_snapshot_get_target (source);
is_bounded = _cairo_surface_get_extents (source,
@ -5957,7 +5957,7 @@ _cairo_pdf_surface_mask (void *abstract_surface,
cairo_status_t source_status, mask_status;
status = _cairo_pdf_surface_analyze_operation (surface, op, source, &extents.bounded);
if (_cairo_status_is_error (status))
if (_cairo_int_status_is_error (status))
goto cleanup;
source_status = status;
@ -5965,7 +5965,7 @@ _cairo_pdf_surface_mask (void *abstract_surface,
status = CAIRO_INT_STATUS_UNSUPPORTED;
} else {
status = _cairo_pdf_surface_analyze_operation (surface, op, mask, &extents.bounded);
if (_cairo_status_is_error (status))
if (_cairo_int_status_is_error (status))
goto cleanup;
}
mask_status = status;

View file

@ -1570,7 +1570,7 @@ _emit_surface_pattern (cairo_script_surface_t *surface,
surface_pattern = (cairo_surface_pattern_t *) pattern;
source = surface_pattern->surface;
if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT) {
if (_cairo_surface_is_snapshot (source)) {
snapshot = _cairo_surface_has_snapshot (source, &script_snapshot_backend);
if (snapshot) {
_cairo_output_stream_printf (ctx->stream,

View file

@ -57,4 +57,10 @@ _cairo_surface_snapshot_get_target (cairo_surface_t *surface)
return ((cairo_surface_snapshot_t *) surface)->target;
}
static inline cairo_bool_t
_cairo_surface_is_snapshot (cairo_surface_t *surface)
{
return surface->backend->type == (cairo_surface_type_t)CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT;
}
#endif /* CAIRO_SURFACE_SNAPSHOT_PRIVATE_H */

View file

@ -316,7 +316,7 @@ _cairo_surface_subsurface_acquire_source_image (void *abstrac
}
meta = surface->target;
if (surface->target->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT)
if (_cairo_surface_is_snapshot (meta))
meta = _cairo_surface_snapshot_get_target (meta);
if (! _cairo_surface_has_snapshot (meta, &_cairo_image_surface_backend)) {

View file

@ -1084,7 +1084,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
picture->width = rect.width;
picture->height = rect.height;
}
} else if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT) {
} else if (_cairo_surface_is_snapshot (source)) {
cairo_surface_snapshot_t *snap = (cairo_surface_snapshot_t *) source;
cairo_xcb_surface_t *xcb = (cairo_xcb_surface_t *) snap->target;

View file

@ -2412,7 +2412,7 @@ _cairo_xlib_surface_upload(cairo_xlib_surface_t *surface,
return CAIRO_INT_STATUS_UNSUPPORTED;
if (image->base.backend->type != CAIRO_SURFACE_TYPE_IMAGE) {
if (image->base.backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT) {
if (_cairo_surface_is_snapshot (&image->base)) {
image = (cairo_image_surface_t *) ((cairo_surface_snapshot_t *) image)->target;
extents.x = extents.y = 0;
extents.width = image->width;