diff options
author | Andrea Canciani <ranma42@gmail.com> | 2011-07-05 21:20:34 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2011-07-07 00:07:44 +0200 |
commit | bb2ea59dc7945a536fb232705fe183375ac4883c (patch) | |
tree | 694167d09331944baec460305003ca59d613ae8b | |
parent | dab2d5378b323262d49cd2cd7d73dc663cbcbe77 (diff) |
object: surfacewip/objectify3
48 files changed, 888 insertions, 942 deletions
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c index 01428b49f..9adbd19b2 100644 --- a/src/cairo-analysis-surface.c +++ b/src/cairo-analysis-surface.c @@ -687,7 +687,7 @@ _cairo_analysis_surface_create (cairo_surface_t *target) cairo_analysis_surface_t *surface; cairo_status_t status; - status = target->status; + status = _cairo_surface_status (target); if (unlikely (status)) return _cairo_surface_create_in_error (status); @@ -705,7 +705,7 @@ _cairo_analysis_surface_create (cairo_surface_t *target) cairo_matrix_init_identity (&surface->ctm); surface->has_ctm = FALSE; - surface->target = cairo_surface_reference (target); + surface->target = _cairo_surface_reference (target); surface->first_op = TRUE; surface->has_supported = FALSE; surface->has_unsupported = FALSE; @@ -727,7 +727,7 @@ _cairo_analysis_surface_set_ctm (cairo_surface_t *abstract_surface, { cairo_analysis_surface_t *surface; - if (abstract_surface->status) + if (unlikely (_cairo_surface_status (abstract_surface))) return; surface = (cairo_analysis_surface_t *) abstract_surface; diff --git a/src/cairo-clip.c b/src/cairo-clip.c index 2d6ac152d..975ab08b3 100644 --- a/src/cairo-clip.c +++ b/src/cairo-clip.c @@ -450,7 +450,7 @@ _cairo_clip_path_reapply_clip_path_translate (cairo_clip_t *clip, cairo_region_translate (clip_path->region, tx, ty); } - clip_path->surface = cairo_surface_reference (other_path->surface); + clip_path->surface = _cairo_surface_reference (other_path->surface); clip_path->extents = other_path->extents; clip_path->extents.x += tx; @@ -980,7 +980,7 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path, clip_extents->width, clip_extents->height); } - if (unlikely (surface->status)) + if (unlikely (_cairo_surface_status (surface))) return surface; need_translate = clip_extents->x | clip_extents->y; @@ -1066,7 +1066,7 @@ _cairo_clip_path_get_surface (cairo_clip_path_t *clip_path, int prev_tx, prev_ty; prev_surface = _cairo_clip_path_get_surface (prev, target, &prev_tx, &prev_ty); - status = prev_surface->status; + status = _cairo_surface_status (prev_surface); if (unlikely (status)) goto BAIL; diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c index 75a9e5c72..84104f2c1 100644 --- a/src/cairo-directfb-surface.c +++ b/src/cairo-directfb-surface.c @@ -491,8 +491,8 @@ _directfb_acquire_surface (cairo_directfb_surface_t *surface, image = _cairo_image_surface_create_for_pixman_image (pixman_image, pixman_format); - status = image->status; - if (status) + status = _cairo_surface_status (image); + if (unlikely (status)) goto ERROR; if (image_rect_out) { @@ -725,7 +725,7 @@ _cairo_directfb_surface_clone_similar (void *abstract_surface, if (src->backend == surface->base.backend) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } else if (_cairo_surface_is_image (src)) { @@ -735,6 +735,7 @@ _cairo_directfb_surface_clone_similar (void *abstract_surface, pixman_image_t *pixman_image; void *data; int pitch; + cairo_status_t status; format = _directfb_from_pixman_format (image_src->pixman_format); if (format == 0) @@ -744,8 +745,9 @@ _cairo_directfb_surface_clone_similar (void *abstract_surface, _cairo_directfb_surface_create_internal (surface->dfb, format, image_src->base.content, width, height); - if (unlikely (clone->base.status)) - return clone->base.status; + status = _cairo_surface_status (&clone->base); + if (unlikely (status)) + return status; ret = clone->dfbsurface->Lock (clone->dfbsurface, DSLF_WRITE, (void *)&data, &pitch); diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 7292f8593..683efcc38 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -1107,14 +1107,15 @@ _get_bitmap_surface (FT_Bitmap *bitmap, unsigned char *data; int format = CAIRO_FORMAT_A8; cairo_image_surface_t *image; + cairo_status_t status; width = bitmap->width; height = bitmap->rows; if (width == 0 || height == 0) { - *surface = (cairo_image_surface_t *) + *surface = image = (cairo_image_surface_t *) cairo_image_surface_create_for_data (NULL, format, 0, 0, 0); - return (*surface)->base.status; + return _cairo_surface_status (&image->base); } switch (bitmap->pixel_mode) { @@ -1202,9 +1203,10 @@ _get_bitmap_surface (FT_Bitmap *bitmap, cairo_image_surface_create_for_data (data, format, width, height, stride); - if (image->base.status) { + status = _cairo_surface_status (&image->base); + if (unlikely (status)) { free (data); - return (*surface)->base.status; + return status; } if (format == CAIRO_FORMAT_ARGB32) @@ -1322,8 +1324,9 @@ _render_glyph_outline (FT_Face face, (*surface) = (cairo_image_surface_t *) cairo_image_surface_create_for_data (NULL, format, 0, 0, 0); - if ((*surface)->base.status) - return (*surface)->base.status; + status = _cairo_surface_status (&(*surface)->base); + if (unlikely (status)) + return status; } else { int bitmap_size; @@ -1512,8 +1515,9 @@ _transform_glyph_bitmap (cairo_matrix_t * shape, return status; image = cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); - if (unlikely (image->status)) - return image->status; + status = _cairo_surface_status (image); + if (unlikely (status)) + return status; /* Draw the original bitmap transformed into the new bitmap */ diff --git a/src/cairo-gl-glyphs.c b/src/cairo-gl-glyphs.c index 1f2741259..7cbadbd5c 100644 --- a/src/cairo-gl-glyphs.c +++ b/src/cairo-gl-glyphs.c @@ -155,12 +155,13 @@ cairo_gl_context_get_glyph_cache (cairo_gl_context_t *ctx, if (unlikely (cache->pattern.surface == NULL)) { cairo_surface_t *surface; + cairo_status_t status; surface = cairo_gl_surface_create (&ctx->base, content, GLYPH_CACHE_WIDTH, GLYPH_CACHE_HEIGHT); - if (unlikely (surface->status)) { - cairo_status_t status = surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) { cairo_surface_destroy (surface); return status; } @@ -389,8 +390,9 @@ _cairo_gl_surface_show_glyphs_via_mask (cairo_gl_surface_t *dst, CAIRO_CONTENT_COLOR_ALPHA, glyph_extents->width, glyph_extents->height); - if (unlikely (mask->status)) - return mask->status; + status = _cairo_surface_status (mask); + if (unlikely (status)) + return status; for (i = 0; i < num_glyphs; i++) { glyphs[i].x -= glyph_extents->x; diff --git a/src/cairo-gl-surface.c b/src/cairo-gl-surface.c index ad47d5a42..3f6b84784 100644 --- a/src/cairo-gl-surface.c +++ b/src/cairo-gl-surface.c @@ -420,7 +420,7 @@ _cairo_gl_surface_create_scratch (cairo_gl_context_t *ctx, surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch_for_texture (ctx, content, tex, width, height); - if (unlikely (surface->base.status)) + if (unlikely (_cairo_surface_status (&surface->base))) return &surface->base; surface->owns_tex = TRUE; @@ -524,8 +524,9 @@ cairo_gl_surface_create (cairo_device_t *abstract_device, surface = (cairo_gl_surface_t *) _cairo_gl_surface_create_scratch (ctx, content, width, height); - if (unlikely (surface->base.status)) { - status = _cairo_gl_context_release (ctx, surface->base.status); + status = _cairo_surface_status (&surface->base); + if (unlikely (status)) { + status = _cairo_gl_context_release (ctx, status); cairo_surface_destroy (&surface->base); return _cairo_surface_create_in_error (status); } @@ -615,7 +616,7 @@ cairo_gl_surface_set_size (cairo_surface_t *abstract_surface, cairo_gl_surface_t *surface = (cairo_gl_surface_t *) abstract_surface; cairo_status_t status; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { status = _cairo_surface_set_error (abstract_surface, @@ -665,7 +666,7 @@ cairo_gl_surface_swapbuffers (cairo_surface_t *abstract_surface) cairo_gl_surface_t *surface = (cairo_gl_surface_t *) abstract_surface; cairo_status_t status; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { status = _cairo_surface_set_error (abstract_surface, @@ -763,7 +764,8 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, cairo_bool_t is_supported; clone = _cairo_image_surface_coerce (src); - if (unlikely (status = clone->base.status)) + status = _cairo_surface_status (&clone->base); + if (unlikely (status)) goto FAIL; is_supported = @@ -856,7 +858,7 @@ _cairo_gl_surface_draw_image (cairo_gl_surface_t *dst, tmp = _cairo_gl_surface_create_scratch (ctx, dst->base.content, width, height); - if (unlikely (tmp->status)) { + if (unlikely (_cairo_surface_status (tmp))) { cairo_surface_destroy (tmp); goto FAIL; } @@ -967,8 +969,9 @@ _cairo_gl_surface_get_image (cairo_gl_surface_t *surface, interest->width, interest->height, -1); - if (unlikely (image->base.status)) - return _cairo_gl_context_release (ctx, image->base.status); + status = _cairo_surface_status (&image->base); + if (unlikely (status)) + return _cairo_gl_context_release (ctx, status); /* This is inefficient, as we'd rather just read the thing without making * it the destination. But then, this is the fallback path, so let's not @@ -1108,7 +1111,7 @@ _cairo_gl_surface_clone_similar (void *abstract_surface, _cairo_gl_surface_is_texture ((cairo_gl_surface_t *) src)) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } else if (_cairo_surface_is_image (src)) { @@ -1122,8 +1125,9 @@ _cairo_gl_surface_clone_similar (void *abstract_surface, width, height); if (clone == NULL) return UNSUPPORTED ("create_similar failed"); - if (clone->base.status) - return clone->base.status; + status = _cairo_surface_status (&clone->base); + if (unlikely (status)) + return status; status = _cairo_gl_surface_draw_image (clone, image_src, src_x, src_y, @@ -1158,6 +1162,7 @@ _cairo_gl_get_traps_pattern (cairo_gl_surface_t *dst, pixman_image_t *image; cairo_surface_t *surface; int i; + cairo_status_t status; pixman_format = antialias != CAIRO_ANTIALIAS_NONE ? PIXMAN_a8 : PIXMAN_a1, image = pixman_image_create_bits (pixman_format, width, height, NULL, 0); @@ -1185,9 +1190,10 @@ _cairo_gl_get_traps_pattern (cairo_gl_surface_t *dst, surface = _cairo_image_surface_create_for_pixman_image (image, pixman_format); - if (unlikely (surface->status)) { + status = _cairo_surface_status (surface); + if (unlikely (status)) { pixman_image_unref (image); - return surface->status; + return status; } _cairo_pattern_init_for_surface (pattern, surface); diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c index f60f49575..0a0e24f2f 100644 --- a/src/cairo-gstate.c +++ b/src/cairo-gstate.c @@ -113,9 +113,9 @@ _cairo_gstate_init (cairo_gstate_t *gstate, _cairo_clip_init (&gstate->clip); - gstate->target = cairo_surface_reference (target); + gstate->target = _cairo_surface_reference (target); gstate->parent_target = NULL; - gstate->original_target = cairo_surface_reference (target); + gstate->original_target = _cairo_surface_reference (target); gstate->device_transform_observer.callback = _cairo_gstate_update_device_transform; cairo_list_add (&gstate->device_transform_observer.link, @@ -131,7 +131,7 @@ _cairo_gstate_init (cairo_gstate_t *gstate, /* Now that the gstate is fully initialized and ready for the eventual * _cairo_gstate_fini(), we can check for errors (and not worry about * the resource deallocation). */ - status = target->status; + status = _cairo_surface_status (target); if (unlikely (status)) return status; @@ -174,10 +174,10 @@ _cairo_gstate_init_copy (cairo_gstate_t *gstate, cairo_gstate_t *other) _cairo_clip_init_copy (&gstate->clip, &other->clip); - gstate->target = cairo_surface_reference (other->target); + gstate->target = _cairo_surface_reference (other->target); /* parent_target is always set to NULL; it's only ever set by redirect_target */ gstate->parent_target = NULL; - gstate->original_target = cairo_surface_reference (other->original_target); + gstate->original_target = _cairo_surface_reference (other->original_target); gstate->device_transform_observer.callback = _cairo_gstate_update_device_transform; cairo_list_add (&gstate->device_transform_observer.link, @@ -316,7 +316,7 @@ _cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child) /* Now set up our new target; we overwrite gstate->target directly, * since its ref is now owned by gstate->parent_target */ - gstate->target = cairo_surface_reference (child); + 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); @@ -1355,14 +1355,14 @@ cairo_status_t _cairo_gstate_copy_page (cairo_gstate_t *gstate) { cairo_surface_copy_page (gstate->target); - return cairo_surface_status (gstate->target); + return _cairo_surface_status (gstate->target); } cairo_status_t _cairo_gstate_show_page (cairo_gstate_t *gstate) { cairo_surface_show_page (gstate->target); - return cairo_surface_status (gstate->target); + return _cairo_surface_status (gstate->target); } static void diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 7fc1f391a..c12e95286 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -339,7 +339,7 @@ _cairo_image_surface_create_with_pixman_format (unsigned char *data, surface = _cairo_image_surface_create_for_pixman_image (pixman_image, pixman_format); - if (unlikely (surface->status)) { + if (unlikely (_cairo_surface_status (surface))) { pixman_image_unref (pixman_image); return surface; } @@ -1634,7 +1634,7 @@ _pixman_image_for_pattern (const cairo_pattern_t *pattern, height = extents->height; image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); - if (unlikely (image->status)) + if (unlikely (_cairo_surface_status (image))) return NULL; stride = cairo_image_surface_get_stride (image); @@ -1663,8 +1663,8 @@ _cairo_image_surface_fixup_unbounded (cairo_image_surface_t *dst, int clip_x, clip_y; clip_surface = _cairo_clip_get_surface (clip, &dst->base, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) - return clip_surface->status; + if (unlikely (_cairo_surface_status (clip_surface))) + return _cairo_surface_status (clip_surface); mask = ((cairo_image_surface_t *) clip_surface)->pixman_image; mask_x = -clip_x; @@ -1946,7 +1946,7 @@ _create_composite_mask_pattern (cairo_clip_t *clip, cairo_surface_t *tmp; tmp = _cairo_image_surface_create_for_pixman_image (mask, PIXMAN_a8); - if (unlikely (tmp->status)) { + if (unlikely (_cairo_surface_status (tmp))) { pixman_image_unref (mask); return NULL; } @@ -2085,7 +2085,7 @@ _clip_and_composite_combine (cairo_clip_t *clip, assert (clip->path != NULL); clip_surface = _cairo_clip_get_surface (clip, &dst->base, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) + if (unlikely (_cairo_surface_status (clip_surface))) goto CLEANUP_SURFACE; if (! dst->base.is_clear) { @@ -2956,8 +2956,8 @@ _composite_boxes (cairo_image_surface_t *dst, int clip_x, clip_y; clip_surface = _cairo_clip_get_surface (clip, &dst->base, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) - return clip_surface->status; + if (unlikely (_cairo_surface_status (clip_surface))) + return _cairo_surface_status (clip_surface); mask_x = -clip_x; mask_y = -clip_y; @@ -4160,7 +4160,7 @@ _cairo_image_surface_clone_similar (void *abstract_surface, if (src->backend == surface->base.backend) { *clone_offset_x = *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } @@ -4652,16 +4652,16 @@ _cairo_image_surface_coerce_to_format (cairo_image_surface_t *surface, cairo_image_surface_t *clone; cairo_status_t status; - status = surface->base.status; + status = _cairo_surface_status (&surface->base); if (unlikely (status)) return (cairo_image_surface_t *)_cairo_surface_create_in_error (status); if (surface->format == format) - return (cairo_image_surface_t *)cairo_surface_reference(&surface->base); + return (cairo_image_surface_t *)_cairo_surface_reference (&surface->base); clone = (cairo_image_surface_t *) cairo_image_surface_create (format, surface->width, surface->height); - if (unlikely (clone->base.status)) + if (unlikely (_cairo_surface_status (&clone->base))) return clone; pixman_image_composite32 (PIXMAN_OP_SRC, diff --git a/src/cairo-object-wrappers-private.h b/src/cairo-object-wrappers-private.h index 0fd57fd9a..7202a8e33 100644 --- a/src/cairo-object-wrappers-private.h +++ b/src/cairo-object-wrappers-private.h @@ -40,7 +40,7 @@ #define CAIRO_OBJECT_CHECK_TYPES #ifdef CAIRO_OBJECT_CHECK_TYPES -#include "cairoint.h" +//#include "cairoint.h" #define CAIRO_OBJECT_BASE_WRAPPERS(opt, type, prefix, c) \ opt type * \ diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 884c43e5f..417ee0788 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -111,13 +111,13 @@ _cairo_paginated_surface_create (cairo_surface_t *target, * evidence of the paginated wrapper out to the user. */ surface->base.type = target->type; - surface->target = cairo_surface_reference (target); + surface->target = _cairo_surface_reference (target); surface->content = content; surface->backend = backend; surface->recording_surface = _create_recording_surface_for_target (target, content); - status = surface->recording_surface->status; + status = _cairo_surface_status (surface->recording_surface); if (unlikely (status)) goto FAIL_CLEANUP_SURFACE; @@ -172,11 +172,11 @@ _cairo_paginated_surface_set_size (cairo_surface_t *surface, cairo_surface_destroy (paginated_surface->recording_surface); paginated_surface->recording_surface = cairo_recording_surface_create (paginated_surface->content, &recording_extents); - status = paginated_surface->recording_surface->status; + status = _cairo_surface_status (paginated_surface->recording_surface); if (unlikely (status)) - return _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); - return CAIRO_STATUS_SUCCESS; + return status; } static cairo_status_t @@ -197,15 +197,15 @@ _cairo_paginated_surface_finish (void *abstract_surface) * and check the status afterwards. However, we can only call finish() * on the target, if we own it. */ - if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->target->ref_count) == 1) + if (_cairo_surface_get_reference_count (surface->target) == 1) cairo_surface_finish (surface->target); if (status == CAIRO_STATUS_SUCCESS) - status = cairo_surface_status (surface->target); + status = _cairo_surface_status (surface->target); cairo_surface_destroy (surface->target); cairo_surface_finish (surface->recording_surface); if (status == CAIRO_STATUS_SUCCESS) - status = cairo_surface_status (surface->recording_surface); + status = _cairo_surface_status (surface->recording_surface); cairo_surface_destroy (surface->recording_surface); return status; @@ -328,22 +328,27 @@ _paint_page (cairo_paginated_surface_t *surface) cairo_status_t status; cairo_bool_t has_supported, has_page_fallback, has_finegrained_fallback; - if (unlikely (surface->target->status)) - return surface->target->status; + status = _cairo_surface_status (surface->target); + if (unlikely (status)) + return status; analysis = _cairo_analysis_surface_create (surface->target); - if (unlikely (analysis->status)) - return _cairo_surface_set_error (surface->target, analysis->status); + status = _cairo_surface_status (analysis); + if (unlikely (status)) { + _cairo_surface_set_error (surface->target, status); + return status; + } surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE); status = _cairo_recording_surface_replay_and_create_regions (surface->recording_surface, analysis); - if (status || analysis->status) { - if (status == CAIRO_STATUS_SUCCESS) - status = analysis->status; + if (unlikely (status)) + goto FAIL; + + status = _cairo_surface_status (analysis); + if (unlikely (status)) goto FAIL; - } if (surface->backend->set_bounding_box) { cairo_box_t bbox; @@ -438,20 +443,28 @@ _paint_page (cairo_paginated_surface_t *surface) FAIL: cairo_surface_destroy (analysis); - return _cairo_surface_set_error (surface->target, status); + if (unlikely (status)) + _cairo_surface_set_error (surface->target, status); + + return status; } static cairo_status_t _start_page (cairo_paginated_surface_t *surface) { - if (surface->target->status) - return surface->target->status; + cairo_status_t status; - if (! surface->backend->start_page) - return CAIRO_STATUS_SUCCESS; + status = _cairo_surface_status (surface->target); + if (unlikely (status)) + return status; - return _cairo_surface_set_error (surface->target, - surface->backend->start_page (surface->target)); + if (surface->backend->start_page) { + status = surface->backend->start_page (surface->target); + if (unlikely (status)) + _cairo_surface_set_error (surface->target, status); + } + + return status; } static cairo_int_status_t @@ -478,7 +491,7 @@ _cairo_paginated_surface_copy_page (void *abstract_surface) * the recording-surface. */ cairo_surface_show_page (surface->target); - return cairo_surface_status (surface->target); + return _cairo_surface_status (surface->target); } static cairo_int_status_t @@ -496,11 +509,11 @@ _cairo_paginated_surface_show_page (void *abstract_surface) return status; cairo_surface_show_page (surface->target); - status = surface->target->status; + status = _cairo_surface_status (surface->target); if (unlikely (status)) return status; - status = surface->recording_surface->status; + status = _cairo_surface_status (surface->recording_surface); if (unlikely (status)) return status; @@ -509,7 +522,7 @@ _cairo_paginated_surface_show_page (void *abstract_surface) surface->recording_surface = _create_recording_surface_for_target (surface->target, surface->content); - status = surface->recording_surface->status; + status = _cairo_surface_status (surface->recording_surface); if (unlikely (status)) return status; diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index 35ad781a6..6cff613a4 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -207,7 +207,7 @@ _cairo_pattern_init_copy (cairo_pattern_t *pattern, VG (VALGRIND_MAKE_MEM_UNDEFINED (pattern, sizeof (cairo_surface_pattern_t))); *dst = *src; - cairo_surface_reference (dst->surface); + _cairo_surface_reference (dst->surface); } break; case CAIRO_PATTERN_TYPE_LINEAR: case CAIRO_PATTERN_TYPE_RADIAL: { @@ -301,11 +301,10 @@ _cairo_pattern_init_snapshot (cairo_pattern_t *pattern, cairo_surface_destroy (surface); - if (surface_pattern->surface->status) - return surface_pattern->surface->status; + status = _cairo_surface_status (surface_pattern->surface); } - return CAIRO_STATUS_SUCCESS; + return status; } void @@ -416,16 +415,17 @@ void _cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern, cairo_surface_t *surface) { - if (surface->status) { + cairo_status_t status; + + status = _cairo_surface_status (surface); + if (unlikely (status)) { /* Force to solid to simplify the pattern_fini process. */ _cairo_pattern_init (&pattern->base, CAIRO_PATTERN_TYPE_SOLID); - _cairo_pattern_set_error (&pattern->base, surface->status); - return; + _cairo_pattern_set_error (&pattern->base, status); + } else { + _cairo_pattern_init (&pattern->base, CAIRO_PATTERN_TYPE_SURFACE); + pattern->surface = _cairo_surface_reference (surface); } - - _cairo_pattern_init (&pattern->base, CAIRO_PATTERN_TYPE_SURFACE); - - pattern->surface = cairo_surface_reference (surface); } static void @@ -571,12 +571,14 @@ cairo_pattern_t * cairo_pattern_create_for_surface (cairo_surface_t *surface) { cairo_surface_pattern_t *pattern; + cairo_status_t status; if (unlikely (surface == NULL)) return _cairo_pattern_create_in_error (CAIRO_ERROR_NULL_POINTER); - if (surface->status) - return _cairo_pattern_create_in_error (surface->status); + status = _cairo_surface_status (surface); + if (unlikely (status)) + return _cairo_pattern_create_in_error (status); pattern = _freed_pool_get (&freed_pattern_pool[CAIRO_PATTERN_TYPE_SURFACE]); @@ -2021,10 +2023,10 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat image = (cairo_image_surface_t *) _cairo_image_surface_create_for_pixman_image (pixman_image, PIXMAN_a8r8g8b8); - if (image->base.status) - { + status = _cairo_surface_status (&image->base); + if (unlikely (status)) { pixman_image_unref (pixman_image); - return image->base.status; + return status; } attr->x_offset = attr->y_offset = 0; @@ -2071,9 +2073,10 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat image = (cairo_image_surface_t *) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); - if (image->base.status) { + status = _cairo_surface_status (&image->base); + if (unlikely (status)) { pixman_image_unref (pixman_image); - return image->base.status; + return status; } ix = x; @@ -2156,8 +2159,9 @@ _cairo_pattern_acquire_surface_for_mesh (const cairo_mesh_pattern_t *pattern, int stride; image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); - if (unlikely (image->status)) - return image->status; + status = _cairo_surface_status (image); + if (unlikely (status)) + return status; stride = cairo_image_surface_get_stride (image); data = cairo_image_surface_get_data (image); @@ -2207,7 +2211,7 @@ _cairo_pattern_solid_surface_matches ( if (cairo_surface_get_content (cache->surface) != _cairo_color_get_content (&pattern->color)) return FALSE; - if (CAIRO_REFERENCE_COUNT_GET_VALUE (&cache->surface->ref_count) != 1) + if (_cairo_surface_get_reference_count (cache->surface) != 1) return FALSE; if (! _cairo_surface_is_similar (cache->surface, dst)) @@ -2278,7 +2282,7 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt if (unlikely (status)) goto EVICT; - cairo_surface_reference (surface); + _cairo_surface_reference (surface); } else { @@ -2294,10 +2298,9 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt status = CAIRO_INT_STATUS_UNSUPPORTED; goto UNLOCK; } - if (unlikely (surface->status)) { - status = surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) goto UNLOCK; - } if (unlikely (! _cairo_surface_is_similar (surface, dst))) { @@ -2317,7 +2320,7 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt solid_surface_cache.cache[i].color = pattern->color; DONE: - *out = cairo_surface_reference (solid_surface_cache.cache[i].surface); + *out = _cairo_surface_reference (solid_surface_cache.cache[i].surface); NOCACHE: attribs->x_offset = attribs->y_offset = 0; @@ -3618,7 +3621,7 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat cairo_bool_t is_bounded; cairo_int_status_t status; - surface = cairo_surface_reference (pattern->surface); + surface = _cairo_surface_reference (pattern->surface); is_identity = FALSE; attr->matrix = pattern->base.matrix; @@ -3714,9 +3717,10 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat FALSE); if (surface == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; - if (unlikely (surface->status)) { + status = _cairo_surface_status (surface); + if (unlikely (status)) { cairo_surface_destroy (src); - return surface->status; + return status; } surface->device_transform = pattern->surface->device_transform; diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index d4cffe6f1..15da4d6f3 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -400,7 +400,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *output, CAIRO_CONTENT_COLOR_ALPHA, &cairo_pdf_surface_paginated_backend); - status = surface->paginated_surface->status; + status = _cairo_surface_status (surface->paginated_surface); if (status == CAIRO_STATUS_SUCCESS) { /* paginated keeps the only reference to surface now, drop ours */ cairo_surface_destroy (&surface->base); @@ -514,37 +514,33 @@ _extract_pdf_surface (cairo_surface_t *surface, cairo_pdf_surface_t **pdf_surface) { cairo_surface_t *target; - cairo_status_t status_ignored; + cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) + return FALSE; + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return FALSE; - if (surface->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); - return FALSE; } - if (! _cairo_surface_is_paginated (surface)) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_paginated (surface))) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return FALSE; } target = _cairo_paginated_surface_get_target (surface); - if (target->status) { - status_ignored = _cairo_surface_set_error (surface, - target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); return FALSE; } - if (target->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (target->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return FALSE; } - if (! _cairo_surface_is_pdf (target)) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_pdf (target))) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return FALSE; } @@ -659,8 +655,8 @@ cairo_pdf_surface_set_size (cairo_surface_t *surface, status = _cairo_paginated_surface_set_size (pdf_surface->paginated_surface, width_in_points, height_in_points); - if (status) - status = _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); } static void @@ -1217,7 +1213,7 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface, _cairo_pdf_source_surface_init_key (surface_entry); src_surface.hash_entry = surface_entry; - src_surface.surface = cairo_surface_reference (source); + src_surface.surface = _cairo_surface_reference (source); surface_entry->surface_res = _cairo_pdf_surface_new_object (surface); if (surface_entry->surface_res.id == 0) { cairo_surface_destroy (source); @@ -1671,7 +1667,7 @@ _cairo_pdf_surface_finish (void *abstract_surface) cairo_pdf_resource_t info, catalog; cairo_status_t status, status2; - status = surface->base.status; + status = _cairo_surface_status (abstract_surface); if (status == CAIRO_STATUS_SUCCESS) status = _cairo_pdf_surface_emit_font_subsets (surface); @@ -2144,8 +2140,9 @@ _cairo_pdf_surface_emit_jpeg_image (cairo_pdf_surface_t *surface, cairo_surface_get_mime_data (source, CAIRO_MIME_TYPE_JPEG, &mime_data, &mime_data_length); - if (unlikely (source->status)) - return source->status; + status = _cairo_surface_status (source); + if (unlikely (status)) + return status; if (mime_data == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; @@ -2251,10 +2248,9 @@ _cairo_pdf_surface_emit_padded_image_surface (cairo_pdf_surface_t *surface, pad_image = _cairo_image_surface_create_with_content (pattern->surface->content, rect.width, rect.height); - if (pad_image->status) { - status = pad_image->status; - goto BAIL; - } + status = _cairo_surface_status (pad_image); + if (unlikely (status)) + goto BAIL; _cairo_pattern_init_for_surface (&pad_pattern, &image->base); cairo_matrix_init_translate (&pad_pattern.base.matrix, -x, -y); @@ -4756,9 +4752,10 @@ _cairo_pdf_surface_analyze_user_font_subset (cairo_scaled_font_subset_t *font_su null_stream, _cairo_pdf_emit_imagemask, surface->font_subsets); - if (unlikely (type3_surface->status)) { + status = _cairo_surface_status (type3_surface); + if (unlikely (status)) { status2 = _cairo_output_stream_destroy (null_stream); - return type3_surface->status; + return status; } _cairo_type3_glyph_surface_set_font_subsets_callback (type3_surface, @@ -4817,10 +4814,11 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t *surface, NULL, _cairo_pdf_emit_imagemask, surface->font_subsets); - if (unlikely (type3_surface->status)) { + status = _cairo_surface_status (type3_surface); + if (unlikely (status)) { free (glyphs); free (widths); - return type3_surface->status; + return status; } _cairo_type3_glyph_surface_set_font_subsets_callback (type3_surface, @@ -5477,8 +5475,9 @@ _cairo_pdf_surface_analyze_surface_pattern_transparency (cairo_pdf_surface_t if (unlikely (status)) return status; - if (image->base.status) - return image->base.status; + status = _cairo_surface_status (&image->base); + if (unlikely (status)) + return status; transparency = _cairo_image_analyze_transparency (image); if (transparency == CAIRO_IMAGE_IS_OPAQUE) @@ -5703,8 +5702,9 @@ _cairo_pdf_surface_emit_stencil_mask (cairo_pdf_surface_t *surface, if (unlikely (status)) return status; - if (image->base.status) - return image->base.status; + status = _cairo_surface_status (&image->base); + if (unlikely (status)) + return status; if (image->format != CAIRO_FORMAT_A1) { status = CAIRO_INT_STATUS_UNSUPPORTED; diff --git a/src/cairo-png.c b/src/cairo-png.c index 0e2f4b0f5..359f94d9a 100644 --- a/src/cairo-png.c +++ b/src/cairo-png.c @@ -199,7 +199,7 @@ write_png (cairo_surface_t *surface, * by coercing them to a simpler format using pixman. */ clone = _cairo_image_surface_coerce (image); - status = clone->base.status; + status = _cairo_surface_status (&clone->base); if (unlikely (status)) goto BAIL1; @@ -355,8 +355,9 @@ cairo_surface_write_to_png (cairo_surface_t *surface, FILE *fp; cairo_status_t status; - if (surface->status) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; if (surface->finished) return CAIRO_ERROR_SURFACE_FINISHED; @@ -420,9 +421,11 @@ cairo_surface_write_to_png_stream (cairo_surface_t *surface, void *closure) { struct png_write_closure_t png_closure; + cairo_status_t status; - if (surface->status) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; if (surface->finished) return CAIRO_ERROR_SURFACE_FINISHED; @@ -677,7 +680,7 @@ read_png (struct png_read_closure_t *png_closure) surface = cairo_image_surface_create_for_data (data, format, png_width, png_height, stride); - if (surface->status) + if (_cairo_surface_status (surface)) goto BAIL; _cairo_image_surface_assume_ownership_of_data ((cairo_image_surface_t*)surface); diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 10a740283..bd5e46980 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -612,7 +612,7 @@ _cairo_ps_surface_emit_type3_font_subset (cairo_ps_surface_t *surface, NULL, _cairo_ps_emit_imagemask, surface->font_subsets); - status = type3_surface->status; + status = _cairo_surface_status (type3_surface); if (unlikely (status)) return status; @@ -1020,7 +1020,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream, &surface->base, CAIRO_CONTENT_COLOR_ALPHA, &cairo_ps_surface_paginated_backend); - status = surface->paginated_surface->status; + status = _cairo_surface_status (surface->paginated_surface); if (status == CAIRO_STATUS_SUCCESS) { /* paginated keeps the only reference to surface now, drop ours */ cairo_surface_destroy (&surface->base); @@ -1144,41 +1144,38 @@ _extract_ps_surface (cairo_surface_t *surface, cairo_ps_surface_t **ps_surface) { cairo_surface_t *target; - cairo_status_t status_ignored; + cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return FALSE; - if (surface->finished) { - if (set_error_on_failure) - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + if (set_error_on_failure) + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return FALSE; } - if (! _cairo_surface_is_paginated (surface)) { - if (set_error_on_failure) - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_paginated (surface))) { + if (set_error_on_failure) + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return FALSE; } target = _cairo_paginated_surface_get_target (surface); - if (target->status) { - if (set_error_on_failure) - status_ignored = _cairo_surface_set_error (surface, target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) { + if (set_error_on_failure) + _cairo_surface_set_error (surface, status); return FALSE; } - if (target->finished) { - if (set_error_on_failure) - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (target->finished)) { + if (set_error_on_failure) + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return FALSE; } - if (! _cairo_surface_is_ps (target)) { - if (set_error_on_failure) - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_ps (target))) { + if (set_error_on_failure) + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return FALSE; } @@ -1342,8 +1339,8 @@ cairo_ps_surface_set_size (cairo_surface_t *surface, status = _cairo_paginated_surface_set_size (ps_surface->paginated_surface, width_in_points, height_in_points); - if (status) - status = _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); } /** @@ -1447,27 +1444,27 @@ cairo_ps_surface_dsc_comment (cairo_surface_t *surface, return; /* A couple of sanity checks on the comment value. */ - if (comment == NULL) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_NULL_POINTER); + if (unlikely (comment == NULL)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_NULL_POINTER); return; } - if (comment[0] != '%' || strlen (comment) > 255) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_INVALID_DSC_COMMENT); + if (unlikely (comment[0] != '%' || strlen (comment) > 255)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_INVALID_DSC_COMMENT); return; } /* Then, copy the comment and store it in the appropriate array. */ comment_copy = strdup (comment); if (unlikely (comment_copy == NULL)) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_NO_MEMORY); + _cairo_surface_set_error (surface, CAIRO_ERROR_NO_MEMORY); return; } status = _cairo_array_append (ps_surface->dsc_comment_target, &comment_copy); if (unlikely (status)) { free (comment_copy); - status = _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); return; } } @@ -1540,7 +1537,7 @@ _cairo_ps_surface_finish (void *abstract_surface) int i, num_comments; char **comments; - status = surface->base.status; + status = _cairo_surface_status (&surface->base); if (unlikely (status)) goto CLEANUP; @@ -1671,8 +1668,9 @@ _cairo_ps_surface_analyze_surface_pattern_transparency (cairo_ps_surface_t if (unlikely (status)) return status; - if (image->base.status) - return image->base.status; + status = _cairo_surface_status (&image->base); + if (unlikely (status)) + return status; transparency = _cairo_image_analyze_transparency (image); switch (transparency) { @@ -2007,8 +2005,9 @@ _cairo_ps_surface_flatten_image_transparency (cairo_ps_surface_t *surface, opaque = cairo_image_surface_create (CAIRO_FORMAT_RGB24, image->width, image->height); - if (unlikely (opaque->status)) - return opaque->status; + status = _cairo_surface_status (opaque); + if (unlikely (status)) + return status; if (surface->content == CAIRO_CONTENT_COLOR_ALPHA) { status = _cairo_surface_paint (opaque, @@ -2090,8 +2089,9 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface, int bit; const char *interpolate; - if (image->base.status) - return image->base.status; + status = _cairo_surface_status (&image->base); + if (unlikely (status)) + return status; switch (filter) { default: @@ -2338,8 +2338,9 @@ _cairo_ps_surface_emit_jpeg_image (cairo_ps_surface_t *surface, cairo_surface_get_mime_data (source, CAIRO_MIME_TYPE_JPEG, &mime_data, &mime_data_length); - if (unlikely (source->status)) - return source->status; + status = _cairo_surface_status (source); + if (unlikely (status)) + return status; if (mime_data == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; @@ -2671,10 +2672,9 @@ _cairo_ps_surface_acquire_surface (cairo_ps_surface_t *surface, surface->acquired_image->pixman_format, rect.width, rect.height, 0); - if (pad_image->status) { - status = pad_image->status; + status = _cairo_surface_status (pad_image); + if (unlikely (status)) goto BAIL; - } _cairo_pattern_init_for_surface (&pad_pattern, &surface->acquired_image->base); cairo_matrix_init_translate (&pad_pattern.base.matrix, -x, -y); diff --git a/src/cairo-qt-surface.cpp b/src/cairo-qt-surface.cpp index 1740df3da..39b3ea22d 100644 --- a/src/cairo-qt-surface.cpp +++ b/src/cairo-qt-surface.cpp @@ -509,7 +509,7 @@ _cairo_qt_surface_acquire_source_image (void *abstract_surface, if (qs->image_equiv) { *image_out = (cairo_image_surface_t*) - cairo_surface_reference (qs->image_equiv); + _cairo_surface_reference (qs->image_equiv); return CAIRO_STATUS_SUCCESS; } @@ -524,10 +524,10 @@ _cairo_qt_surface_acquire_source_image (void *abstract_surface, qimg->width(), qimg->height(), qimg->bytesPerLine()); - status = _cairo_user_data_array_set_data (&image->user_data, - (const cairo_user_data_key_t *)&_qimg_destroy, - qimg, - _qimg_destroy); + status = _cairo_surface_set_user_data (image, + (const cairo_user_data_key_t *)&_qimg_destroy, + qimg, + _qimg_destroy); if (status) { cairo_surface_destroy (image); return status; @@ -568,7 +568,7 @@ _cairo_qt_surface_acquire_dest_image (void *abstract_surface, if (qs->image_equiv) { *image_out = (cairo_image_surface_t*) - cairo_surface_reference (qs->image_equiv); + _cairo_surface_reference (qs->image_equiv); image_rect->x = qs->window.x(); image_rect->y = qs->window.y(); @@ -664,7 +664,7 @@ _cairo_qt_surface_clone_similar (void *abstract_surface, if (src->backend == qs->base.backend) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c index f0c07f976..7372fc043 100644 --- a/src/cairo-quartz-font.c +++ b/src/cairo-quartz-font.c @@ -604,7 +604,7 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font, */ if (glyph == INVALID_GLYPH) { surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2); - status = cairo_surface_status ((cairo_surface_t *) surface); + status = _cairo_surface_status ((cairo_surface_t *) surface); if (status) return status; diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c index bc0d7addd..49f593655 100644 --- a/src/cairo-quartz-image-surface.c +++ b/src/cairo-quartz-image-surface.c @@ -139,7 +139,7 @@ _cairo_quartz_image_surface_flush (void *asurface) CGImageRef newImage = NULL; /* To be released by the ReleaseCallback */ - cairo_surface_reference ((cairo_surface_t*) surface->imageSurface); + _cairo_surface_reference ((cairo_surface_t*) surface->imageSurface); newImage = _cairo_quartz_create_cgimage (surface->imageSurface->format, surface->imageSurface->width, @@ -248,7 +248,7 @@ cairo_quartz_image_surface_create (cairo_surface_t *surface) * be released via the callback (which will be called in * case of failure.) */ - cairo_surface_reference (surface); + _cairo_surface_reference (surface); image = _cairo_quartz_create_cgimage (format, width, height, diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index a43eca99e..57a9f411c 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -1401,7 +1401,7 @@ _cairo_quartz_get_image (cairo_quartz_surface_t *surface, } if (surface->imageSurfaceEquiv) { - *image_out = (cairo_image_surface_t*) cairo_surface_reference (surface->imageSurfaceEquiv); + *image_out = (cairo_image_surface_t*) _cairo_surface_reference (surface->imageSurfaceEquiv); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c index b0a3ffb22..85a3d86bc 100644 --- a/src/cairo-recording-surface.c +++ b/src/cairo-recording-surface.c @@ -263,7 +263,7 @@ _cairo_recording_surface_acquire_source_image_transformed (void *abstract_s image = _cairo_surface_has_snapshot (&surface->base, &_cairo_image_surface_backend); if (image != NULL) { - *image_out = (cairo_image_surface_t *) cairo_surface_reference (image); + *image_out = (cairo_image_surface_t *) _cairo_surface_reference (image); *image_extra = NULL; return CAIRO_STATUS_SUCCESS; } @@ -272,8 +272,9 @@ _cairo_recording_surface_acquire_source_image_transformed (void *abstract_s height = surface->extents.height * device_transform->yy; image = _cairo_image_surface_create_with_content (surface->content, width, height); - if (unlikely (image->status)) - return image->status; + status = _cairo_surface_status (image); + if (unlikely (status)) + return status; cairo_surface_set_device_offset (image, -surface->extents.x, @@ -761,8 +762,9 @@ _cairo_recording_surface_get_path (cairo_surface_t *surface, int i, num_elements; cairo_int_status_t status; - if (surface->status) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; recording_surface = (cairo_recording_surface_t *) surface; status = CAIRO_STATUS_SUCCESS; @@ -822,7 +824,10 @@ _cairo_recording_surface_get_path (cairo_surface_t *surface, break; } - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } #define _clip(c) ((c)->header.clip.path ? &(c)->header.clip : NULL) @@ -839,11 +844,13 @@ _cairo_recording_surface_replay_internal (cairo_surface_t *surface, cairo_int_status_t status; cairo_surface_wrapper_t wrapper; - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; - if (unlikely (target->status)) - return target->status; + status = _cairo_surface_status (target); + if (unlikely (status)) + return status; if (unlikely (surface->finished)) return CAIRO_ERROR_SURFACE_FINISHED; @@ -1009,7 +1016,10 @@ _cairo_recording_surface_replay_internal (cairo_surface_t *surface, _cairo_surface_wrapper_fini (&wrapper); - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } /** @@ -1075,7 +1085,7 @@ _recording_surface_get_ink_bbox (cairo_recording_surface_t *surface, analysis_surface = _cairo_analysis_surface_create (null_surface); cairo_surface_destroy (null_surface); - status = analysis_surface->status; + status = _cairo_surface_status (analysis_surface); if (unlikely (status)) return status; @@ -1124,7 +1134,7 @@ cairo_recording_surface_ink_extents (cairo_surface_t *surface, &bbox, NULL); if (unlikely (status)) - status = _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); DONE: if (x0) diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 0b52b08f5..0a891b470 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -2250,7 +2250,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font, if (mask == NULL) { mask_format = glyph_surface->format; mask = cairo_image_surface_create (mask_format, width, height); - status = mask->status; + status = _cairo_surface_status (mask); if (unlikely (status)) goto CLEANUP_MASK; } @@ -2280,7 +2280,7 @@ _cairo_scaled_font_show_glyphs (cairo_scaled_font_t *scaled_font, } new_mask = cairo_image_surface_create (mask_format, width, height); - status = new_mask->status; + status = _cairo_surface_status (new_mask); if (unlikely (status)) { cairo_surface_destroy (new_mask); goto CLEANUP_MASK; @@ -2430,7 +2430,7 @@ _trace_mask_to_path (cairo_image_surface_t *mask, cairo_status_t status; mask = _cairo_image_surface_coerce_to_format (mask, CAIRO_FORMAT_A1); - status = mask->base.status; + status = _cairo_surface_status (&mask->base); if (unlikely (status)) return status; diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c index 4901c00d5..dfe30865e 100644 --- a/src/cairo-script-surface.c +++ b/src/cairo-script-surface.c @@ -1058,8 +1058,9 @@ _emit_recording_surface_pattern (cairo_script_surface_t *surface, rect.width, rect.height, NULL); - if (unlikely (similar->base.status)) - return similar->base.status; + status = _cairo_surface_status (&similar->base); + if (unlikely (status)) + return status; cairo_surface_set_device_offset (&similar->base, -rect.x, -rect.y); similar->base.is_clear = TRUE; @@ -1263,7 +1264,7 @@ _emit_png_surface (cairo_script_surface_t *surface, struct def { cairo_script_context_t *ctx; - cairo_user_data_array_t *user_data; + cairo_image_surface_t *image; unsigned int tag; cairo_list_t link; }; @@ -1290,8 +1291,8 @@ _emit_image_surface (cairo_script_surface_t *surface, unsigned long mime_data_length; struct def *tag; - if (_cairo_user_data_array_get_data (&image->base.user_data, - (cairo_user_data_key_t *) ctx)) + if (_cairo_surface_get_user_data (&image->base, + (cairo_user_data_key_t *) ctx)) { _cairo_output_stream_printf (ctx->stream, "s%u ", @@ -1310,7 +1311,7 @@ _emit_image_surface (cairo_script_surface_t *surface, clone = _cairo_image_surface_coerce (image); } else { clone = (cairo_image_surface_t *) - cairo_surface_reference (&image->base); + _cairo_surface_reference (&image->base); } _cairo_output_stream_printf (ctx->stream, @@ -1385,11 +1386,11 @@ _emit_image_surface (cairo_script_surface_t *surface, tag->ctx = ctx; tag->tag = image->base.unique_id; - tag->user_data = &image->base.user_data; + tag->image = image; cairo_list_add (&tag->link, &ctx->defines); - status = _cairo_user_data_array_set_data (&image->base.user_data, - (cairo_user_data_key_t *) ctx, - tag, _undef); + status = _cairo_surface_set_user_data (&image->base, + (cairo_user_data_key_t *) ctx, + tag, _undef); if (unlikely (status)) { free (tag); return status; @@ -1869,7 +1870,7 @@ _cairo_script_surface_create_similar (void *abstract_surface, passthrough = _cairo_surface_wrapper_create_similar (&other->wrapper, content, width, height); - if (unlikely (passthrough->status)) { + if (unlikely (_cairo_surface_status (passthrough))) { cairo_device_release (&ctx->base); return passthrough; } @@ -1881,7 +1882,7 @@ _cairo_script_surface_create_similar (void *abstract_surface, passthrough); cairo_surface_destroy (passthrough); - if (unlikely (surface->base.status)) { + if (unlikely (_cairo_surface_status (&surface->base))) { cairo_device_release (&ctx->base); return &surface->base; } @@ -1931,9 +1932,9 @@ _device_destroy (void *abstract_device) struct def *def = cairo_list_first_entry (&ctx->defines, struct def, link); - status = _cairo_user_data_array_set_data (def->user_data, - (cairo_user_data_key_t *) ctx, - NULL, NULL); + status = _cairo_surface_set_user_data (&def->image->base, + (cairo_user_data_key_t *) ctx, + NULL, NULL); assert (status == CAIRO_STATUS_SUCCESS); } @@ -3640,6 +3641,7 @@ cairo_script_surface_create_for_target (cairo_device_t *device, cairo_surface_t *target) { cairo_rectangle_int_t extents; + cairo_status_t status; if (unlikely (device->backend->type != CAIRO_DEVICE_TYPE_SCRIPT)) return _cairo_surface_create_in_error (CAIRO_ERROR_DEVICE_TYPE_MISMATCH); @@ -3648,8 +3650,9 @@ cairo_script_surface_create_for_target (cairo_device_t *device, if (unlikely (status)) return _cairo_surface_create_in_error (status); - if (unlikely (target->status)) - return _cairo_surface_create_in_error (target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); if (! _cairo_surface_get_extents (target, &extents)) extents.width = extents.height = -1; @@ -3677,8 +3680,9 @@ cairo_script_from_recording_surface (cairo_device_t *device, if (unlikely (status)) return status; - if (unlikely (recording_surface->status)) - return recording_surface->status; + status = _cairo_surface_status (recording_surface); + if (unlikely (status)) + return status; if (unlikely (! _cairo_surface_is_recording (recording_surface))) return CAIRO_ERROR_SURFACE_TYPE_MISMATCH; @@ -3695,8 +3699,9 @@ cairo_script_from_recording_surface (cairo_device_t *device, extents.width, extents.height, NULL)->base; - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; cairo_surface_set_device_offset (surface, -extents.x, -extents.y); status = _cairo_recording_surface_replay (recording_surface, surface); diff --git a/src/cairo-skia-surface.cpp b/src/cairo-skia-surface.cpp index 05b4bceac..b3bb6f987 100644 --- a/src/cairo-skia-surface.cpp +++ b/src/cairo-skia-surface.cpp @@ -664,7 +664,7 @@ _cairo_skia_surface_clone_similar (void *asurface, if (src->type == CAIRO_SURFACE_TYPE_SKIA || _cairo_surface_is_image (src)) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c index 8a248d853..8b72d5b23 100644 --- a/src/cairo-surface-fallback.c +++ b/src/cairo-surface-fallback.c @@ -151,8 +151,9 @@ _create_composite_mask_pattern (cairo_surface_pattern_t *mask_pattern, extents->height, CAIRO_COLOR_TRANSPARENT, TRUE); - if (unlikely (mask->status)) - return mask->status; + status = _cairo_surface_status (mask); + if (unlikely (status)) + return status; if (clip_region && (extents->x || extents->y)) { fallback_region = cairo_region_copy (clip_region); @@ -257,8 +258,9 @@ _clip_and_composite_combine (cairo_clip_t *clip, extents->width, extents->width); } - if (unlikely (intermediate->status)) - return intermediate->status; + status = _cairo_surface_status (intermediate); + if (unlikely (status)) + return status; /* Initialize the intermediate surface from the destination surface */ _cairo_pattern_init_for_surface (&pattern, dst); @@ -283,7 +285,7 @@ _clip_and_composite_combine (cairo_clip_t *clip, assert (clip->path != NULL); clip_surface = _cairo_clip_get_surface (clip, dst, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) + if (unlikely (_cairo_surface_status (clip_surface))) goto CLEANUP_SURFACE; _cairo_pattern_init_for_surface (&clip_pattern, clip_surface); @@ -500,8 +502,9 @@ _composite_trap_region (cairo_clip_t *clip, int clip_x, clip_y; clip_surface = _cairo_clip_get_surface (clip, dst, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) - return clip_surface->status; + status = _cairo_surface_status (clip_surface); + if (unlikely (status)) + return status; if (op == CAIRO_OPERATOR_CLEAR) { src = &_cairo_pattern_white.base; @@ -1372,7 +1375,7 @@ _cairo_surface_fallback_snapshot (cairo_surface_t *surface) snapshot = cairo_image_surface_create (format, image->width, image->height); - if (cairo_surface_status (snapshot)) { + if (_cairo_surface_status (snapshot)) { _cairo_surface_release_source_image (surface, image, image_extra); return snapshot; } @@ -1614,8 +1617,9 @@ _cairo_surface_fallback_clone_similar (cairo_surface_t *surface, width, height); if (new_surface == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; - if (unlikely (new_surface->status)) - return new_surface->status; + status = _cairo_surface_status (new_surface); + if (unlikely (status)) + return status; /* We have to copy these here, so that the coordinate spaces are correct */ new_surface->device_transform = src->device_transform; diff --git a/src/cairo-surface-offset.c b/src/cairo-surface-offset.c index 4abc353e2..086c01f24 100644 --- a/src/cairo-surface-offset.c +++ b/src/cairo-surface-offset.c @@ -64,8 +64,9 @@ _cairo_surface_offset_paint (cairo_surface_t *target, cairo_clip_t clip_copy, *dev_clip = clip; cairo_pattern_union_t source_copy; - if (unlikely (target->status)) - return target->status; + status = _cairo_surface_status (target); + if (unlikely (status)) + return status; if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -109,8 +110,9 @@ _cairo_surface_offset_mask (cairo_surface_t *target, cairo_pattern_union_t source_copy; cairo_pattern_union_t mask_copy; - if (unlikely (target->status)) - return target->status; + status = _cairo_surface_status (target); + if (unlikely (status)) + return status; if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -165,8 +167,9 @@ _cairo_surface_offset_stroke (cairo_surface_t *surface, cairo_pattern_union_t source_copy; cairo_status_t status; - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -230,8 +233,9 @@ _cairo_surface_offset_fill (cairo_surface_t *surface, cairo_clip_t clip_copy, *dev_clip = clip; cairo_pattern_union_t source_copy; - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -292,8 +296,9 @@ _cairo_surface_offset_glyphs (cairo_surface_t *surface, cairo_glyph_t *dev_glyphs; int i; - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; diff --git a/src/cairo-surface-private.h b/src/cairo-surface-private.h index 31ddb8c7b..8c9137f27 100644 --- a/src/cairo-surface-private.h +++ b/src/cairo-surface-private.h @@ -42,12 +42,15 @@ #include "cairo-types-private.h" #include "cairo-list-private.h" -#include "cairo-reference-count-private.h" +#include "cairo-object-private.h" +#include "cairo-object-wrappers-private.h" #include "cairo-clip-private.h" typedef void (*cairo_surface_func_t) (cairo_surface_t *); struct _cairo_surface { + cairo_object_t base; + const cairo_surface_backend_t *backend; cairo_device_t *device; @@ -58,8 +61,6 @@ struct _cairo_surface { cairo_content_t content; - cairo_reference_count_t ref_count; - cairo_status_t status; unsigned int unique_id; unsigned finished : 1; @@ -67,7 +68,6 @@ struct _cairo_surface { unsigned has_font_options : 1; unsigned owns_device : 1; - cairo_user_data_array_t user_data; cairo_user_data_array_t mime_data; cairo_matrix_t device_transform; @@ -101,4 +101,6 @@ struct _cairo_surface { cairo_font_options_t font_options; }; +CAIRO_OBJECT_WRAPPERS(cairo_surface) + #endif /* CAIRO_SURFACE_PRIVATE_H */ diff --git a/src/cairo-surface-snapshot.c b/src/cairo-surface-snapshot.c index 2cc5aa824..2cdc31e2e 100644 --- a/src/cairo-surface-snapshot.c +++ b/src/cairo-surface-snapshot.c @@ -50,7 +50,7 @@ _cairo_surface_snapshot_finish (void *abstract_surface) if (surface->clone != NULL) { cairo_surface_finish (surface->clone); - status = surface->clone->status; + status = _cairo_surface_status (surface->clone); cairo_surface_destroy (surface->clone); } @@ -125,7 +125,7 @@ _cairo_surface_snapshot_copy_on_write (cairo_surface_t *surface) status = _cairo_surface_acquire_source_image (snapshot->target, &image, &extra); if (unlikely (status)) { snapshot->target = _cairo_surface_create_in_error (status); - status = _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); return; } @@ -135,7 +135,7 @@ _cairo_surface_snapshot_copy_on_write (cairo_surface_t *surface) image->width, image->height, 0); - if (likely (clone->base.status == CAIRO_STATUS_SUCCESS)) { + if (likely (_cairo_surface_status (&clone->base) == CAIRO_STATUS_SUCCESS)) { if (clone->stride == image->stride) { memcpy (clone->data, image->data, image->stride * image->height); } else { @@ -151,7 +151,7 @@ _cairo_surface_snapshot_copy_on_write (cairo_surface_t *surface) snapshot->clone = &clone->base; } else { snapshot->clone = &clone->base; - status = _cairo_surface_set_error (surface, clone->base.status); + _cairo_surface_set_error (surface, _cairo_surface_status (&clone->base)); } _cairo_surface_release_source_image (snapshot->target, image, extra); @@ -184,25 +184,26 @@ _cairo_surface_snapshot (cairo_surface_t *surface) cairo_surface_snapshot_t *snapshot; cairo_status_t status; - if (unlikely (surface->status)) - return _cairo_surface_create_in_error (surface->status); + status = _cairo_surface_status (surface); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); if (surface->finished) return _cairo_surface_create_in_error (CAIRO_ERROR_SURFACE_FINISHED); if (surface->snapshot_of != NULL) - return cairo_surface_reference (surface); + return _cairo_surface_reference (surface); if (surface->backend->snapshot != NULL) { cairo_surface_t *snap; snap = _cairo_surface_has_snapshot (surface, surface->backend); if (snap != NULL) - return cairo_surface_reference (snap); + return _cairo_surface_reference (snap); snap = surface->backend->snapshot (surface); if (snap != NULL) { - if (unlikely (snap->status)) + if (unlikely (_cairo_surface_status (snap))) return snap; status = _cairo_surface_copy_mime_data (snap, surface); @@ -223,7 +224,7 @@ _cairo_surface_snapshot (cairo_surface_t *surface) snapshot = (cairo_surface_snapshot_t *) _cairo_surface_has_snapshot (surface, &_cairo_surface_snapshot_backend); if (snapshot != NULL) - return cairo_surface_reference (&snapshot->base); + return _cairo_surface_reference (&snapshot->base); snapshot = malloc (sizeof (cairo_surface_snapshot_t)); if (unlikely (snapshot == NULL)) diff --git a/src/cairo-surface-subsurface.c b/src/cairo-surface-subsurface.c index ce069bdb6..dd9927f02 100644 --- a/src/cairo-surface-subsurface.c +++ b/src/cairo-surface-subsurface.c @@ -314,7 +314,7 @@ _cairo_surface_subsurface_acquire_source_image (void *abstrac snapshot = _cairo_surface_has_snapshot (&surface->base, &_cairo_image_surface_backend); if (snapshot != NULL) { - *image_out = (cairo_image_surface_t *) cairo_surface_reference (snapshot); + *image_out = (cairo_image_surface_t *) _cairo_surface_reference (snapshot); *extra_out = NULL; return CAIRO_STATUS_SUCCESS; } @@ -326,8 +326,9 @@ _cairo_surface_subsurface_acquire_source_image (void *abstrac _cairo_image_surface_create_with_content (meta->content, surface->extents.width, surface->extents.height); - if (unlikely (image->base.status)) - return image->base.status; + status = _cairo_surface_status (&image->base); + if (unlikely (status)) + return status; cairo_surface_paint_to_target (&image->base, surface); @@ -368,7 +369,8 @@ _cairo_surface_subsurface_acquire_source_image (void *abstrac surface->extents.width, surface->extents.height, extra->image->stride); - if (unlikely ((status = image->base.status))) + status = _cairo_surface_status (&image->base); + if (unlikely (status)) goto CLEANUP_IMAGE; image->base.is_clear = FALSE; @@ -379,7 +381,8 @@ _cairo_surface_subsurface_acquire_source_image (void *abstrac surface->extents.width, surface->extents.height, 0); - if (unlikely ((status = image->base.status))) + status = _cairo_surface_status (&image->base); + if (unlikely (status)) goto CLEANUP_IMAGE; cairo_surface_paint_to_target (&image->base, surface); @@ -418,6 +421,7 @@ _cairo_surface_subsurface_snapshot (void *abstract_surface) { cairo_surface_subsurface_t *surface = abstract_surface; cairo_surface_subsurface_t *snapshot; + cairo_status_t status; snapshot = malloc (sizeof (cairo_surface_subsurface_t)); if (unlikely (snapshot == NULL)) @@ -428,10 +432,8 @@ _cairo_surface_subsurface_snapshot (void *abstract_surface) NULL, /* device */ surface->target->content); snapshot->target = _cairo_surface_snapshot (surface->target); - if (unlikely (snapshot->target->status)) { - cairo_status_t status; - - status = snapshot->target->status; + status = _cairo_surface_status (snapshot->target); + if (unlikely (status)) { free (snapshot); return _cairo_surface_create_in_error (status); } @@ -512,9 +514,11 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target, double width, double height) { cairo_surface_subsurface_t *surface; + cairo_status_t status; - if (unlikely (target->status)) - return _cairo_surface_create_in_error (target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); if (unlikely (target->finished)) return _cairo_surface_create_in_error (CAIRO_ERROR_SURFACE_FINISHED); @@ -545,7 +549,7 @@ cairo_surface_create_for_rectangle (cairo_surface_t *target, target = sub->target; } - surface->target = cairo_surface_reference (target); + surface->target = _cairo_surface_reference (target); return &surface->base; } diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c index 785a97f8f..b998570fd 100644 --- a/src/cairo-surface-wrapper.c +++ b/src/cairo-surface-wrapper.c @@ -70,8 +70,11 @@ _cairo_surface_wrapper_acquire_source_image (cairo_surface_wrapper_t *wrapper, cairo_image_surface_t **image_out, void **image_extra) { - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + cairo_status_t status; + + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; return _cairo_surface_acquire_source_image (wrapper->target, image_out, image_extra); @@ -96,8 +99,9 @@ _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper, cairo_pattern_union_t source_copy; cairo_clip_t target_clip; - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; if (wrapper->has_extents) { _cairo_clip_init_copy (&target_clip, clip); @@ -164,8 +168,9 @@ _cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper, cairo_pattern_union_t mask_copy; cairo_clip_t target_clip; - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; if (wrapper->has_extents) { _cairo_clip_init_copy (&target_clip, clip); @@ -242,8 +247,9 @@ _cairo_surface_wrapper_stroke (cairo_surface_wrapper_t *wrapper, cairo_pattern_union_t source_copy; cairo_clip_t target_clip; - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; if (wrapper->has_extents) { _cairo_clip_init_copy (&target_clip, clip); @@ -347,8 +353,9 @@ _cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper, cairo_pattern_union_t fill_source_copy; cairo_clip_t target_clip; - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; if (wrapper->has_extents) { _cairo_clip_init_copy (&target_clip, clip); @@ -449,8 +456,9 @@ _cairo_surface_wrapper_fill (cairo_surface_wrapper_t *wrapper, cairo_pattern_union_t source_copy; cairo_clip_t target_clip; - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; if (wrapper->has_extents) { _cairo_clip_init_copy (&target_clip, clip); @@ -543,8 +551,9 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper, cairo_pattern_union_t source_copy; cairo_clip_t target_clip; - if (unlikely (wrapper->target->status)) - return wrapper->target->status; + status = _cairo_surface_status (wrapper->target); + if (unlikely (status)) + return status; if (glyphs == NULL || num_glyphs == 0) return CAIRO_STATUS_SUCCESS; @@ -689,7 +698,7 @@ void _cairo_surface_wrapper_init (cairo_surface_wrapper_t *wrapper, cairo_surface_t *target) { - wrapper->target = cairo_surface_reference (target); + wrapper->target = _cairo_surface_reference (target); wrapper->has_extents = FALSE; } diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 3146c8cab..90749882e 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -46,6 +46,8 @@ #include "cairo-region-private.h" #include "cairo-tee-surface-private.h" +CAIRO_OBJECT_PUBLIC_WRAPPERS (cairo_surface) + /** * SECTION:cairo-surface * @Title: cairo_surface_t @@ -93,93 +95,6 @@ * devices. */ -#define DEFINE_NIL_SURFACE(status, name) \ -const cairo_surface_t name = { \ - NULL, /* backend */ \ - NULL, /* device */ \ - CAIRO_SURFACE_TYPE_IMAGE, /* type */ \ - CAIRO_CONTENT_COLOR, /* content */ \ - CAIRO_REFERENCE_COUNT_INVALID, /* ref_count */ \ - status, /* status */ \ - 0, /* unique id */ \ - FALSE, /* finished */ \ - TRUE, /* is_clear */ \ - FALSE, /* has_font_options */ \ - FALSE, /* owns_device */ \ - { 0, 0, 0, NULL, }, /* user_data */ \ - { 0, 0, 0, NULL, }, /* mime_data */ \ - { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, /* device_transform */ \ - { 1.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, /* device_transform_inverse */ \ - { NULL, NULL }, /* device_transform_observers */ \ - 0.0, /* x_resolution */ \ - 0.0, /* y_resolution */ \ - 0.0, /* x_fallback_resolution */ \ - 0.0, /* y_fallback_resolution */ \ - NULL, /* snapshot_of */ \ - NULL, /* snapshot_detach */ \ - { NULL, NULL }, /* snapshots */ \ - { NULL, NULL }, /* snapshot */ \ - { CAIRO_ANTIALIAS_DEFAULT, /* antialias */ \ - CAIRO_SUBPIXEL_ORDER_DEFAULT, /* subpixel_order */ \ - CAIRO_LCD_FILTER_DEFAULT, /* lcd_filter */ \ - CAIRO_HINT_STYLE_DEFAULT, /* hint_style */ \ - CAIRO_HINT_METRICS_DEFAULT, /* hint_metrics */ \ - CAIRO_ROUND_GLYPH_POS_DEFAULT /* round_glyph_positions */ \ - } /* font_options */ \ -} - -/* XXX error object! */ - -static DEFINE_NIL_SURFACE(CAIRO_STATUS_NO_MEMORY, _cairo_surface_nil); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_SURFACE_TYPE_MISMATCH, _cairo_surface_nil_surface_type_mismatch); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_STATUS, _cairo_surface_nil_invalid_status); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_CONTENT, _cairo_surface_nil_invalid_content); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_FORMAT, _cairo_surface_nil_invalid_format); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_VISUAL, _cairo_surface_nil_invalid_visual); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_FILE_NOT_FOUND, _cairo_surface_nil_file_not_found); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_TEMP_FILE_ERROR, _cairo_surface_nil_temp_file_error); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_READ_ERROR, _cairo_surface_nil_read_error); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_WRITE_ERROR, _cairo_surface_nil_write_error); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_STRIDE, _cairo_surface_nil_invalid_stride); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_INVALID_SIZE, _cairo_surface_nil_invalid_size); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_DEVICE_TYPE_MISMATCH, _cairo_surface_nil_device_type_mismatch); -static DEFINE_NIL_SURFACE(CAIRO_STATUS_DEVICE_ERROR, _cairo_surface_nil_device_error); - -/** - * _cairo_surface_set_error: - * @surface: a surface - * @status: a status value indicating an error - * - * Atomically sets surface->status to @status and calls _cairo_error; - * Does nothing if status is %CAIRO_STATUS_SUCCESS or any of the internal - * status values. - * - * All assignments of an error status to surface->status should happen - * through _cairo_surface_set_error(). Note that due to the nature of - * the atomic operation, it is not safe to call this function on the - * nil objects. - * - * The purpose of this function is to allow the user to set a - * breakpoint in _cairo_error() to generate a stack trace for when the - * user causes cairo to detect an error. - * - * Return value: the error status. - **/ -cairo_status_t -_cairo_surface_set_error (cairo_surface_t *surface, - cairo_status_t status) -{ - if (status == CAIRO_STATUS_SUCCESS || - status == CAIRO_INT_STATUS_NOTHING_TO_DO) - return CAIRO_STATUS_SUCCESS; - - /* Don't overwrite an existing error. This preserves the first - * error, which is the most significant. */ - _cairo_status_set_error (&surface->status, status); - - return _cairo_error (status); -} - /** * cairo_surface_get_type: * @surface: a #cairo_surface_t @@ -233,12 +148,6 @@ slim_hidden_def(cairo_surface_get_content); * %CAIRO_STATUS_INVALID_CONTENT, %CAIRO_STATUS_INVALID_FORMAT, or * %CAIRO_STATUS_INVALID_VISUAL. **/ -cairo_status_t -cairo_surface_status (cairo_surface_t *surface) -{ - return surface->status; -} -slim_hidden_def (cairo_surface_status); static unsigned int _cairo_surface_allocate_unique_id (void) @@ -278,8 +187,8 @@ _cairo_surface_allocate_unique_id (void) cairo_device_t * cairo_surface_get_device (cairo_surface_t *surface) { - if (unlikely (surface->status)) - return _cairo_device_create_in_error (surface->status); + if (unlikely (_cairo_surface_status (surface))) + return _cairo_device_create_in_error (_cairo_surface_status (surface)); return surface->device; } @@ -338,7 +247,7 @@ _cairo_surface_attach_snapshot (cairo_surface_t *surface, assert (surface != snapshot); assert (snapshot->snapshot_of != surface); - cairo_surface_reference (snapshot); + _cairo_surface_reference (snapshot); if (snapshot->snapshot_of != NULL) _cairo_surface_detach_snapshot (snapshot); @@ -380,7 +289,7 @@ _cairo_surface_is_writable (cairo_surface_t *surface) static void _cairo_surface_begin_modification (cairo_surface_t *surface) { - assert (surface->status == CAIRO_STATUS_SUCCESS); + assert (_cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS); assert (! surface->finished); assert (surface->snapshot_of == NULL); @@ -396,6 +305,8 @@ _cairo_surface_init (cairo_surface_t *surface, { CAIRO_MUTEX_INITIALIZE (); + _cairo_object_init (&surface->base); + surface->backend = backend; if (device) @@ -405,14 +316,11 @@ _cairo_surface_init (cairo_surface_t *surface, surface->content = content; surface->type = backend->type; - CAIRO_REFERENCE_COUNT_INIT (&surface->ref_count, 1); - surface->status = CAIRO_STATUS_SUCCESS; surface->unique_id = _cairo_surface_allocate_unique_id (); surface->finished = FALSE; surface->is_clear = FALSE; surface->owns_device = (device != NULL); - _cairo_user_data_array_init (&surface->user_data); _cairo_user_data_array_init (&surface->mime_data); cairo_matrix_init_identity (&surface->device_transform); @@ -454,16 +362,18 @@ _cairo_surface_create_similar_scratch (cairo_surface_t *other, int height) { cairo_surface_t *surface; + cairo_status_t status; - if (unlikely (other->status)) - return _cairo_surface_create_in_error (other->status); + status = _cairo_surface_status (other); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); if (other->backend->create_similar == NULL) return NULL; surface = other->backend->create_similar (other, content, width, height); - if (surface == NULL || surface->status) + if (surface == NULL || _cairo_surface_status (surface)) return surface; _cairo_surface_copy_similar_properties (surface, other); @@ -502,8 +412,11 @@ cairo_surface_create_similar (cairo_surface_t *other, int width, int height) { - if (unlikely (other->status)) - return _cairo_surface_create_in_error (other->status); + cairo_status_t status; + + status = _cairo_surface_status (other); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); if (unlikely (other->finished)) return _cairo_surface_create_in_error (CAIRO_ERROR_SURFACE_FINISHED); if (unlikely (width < 0 || height < 0)) @@ -535,7 +448,7 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other, if (surface == NULL && allow_fallback) surface = _cairo_image_surface_create_with_content (content, width, height); - if (surface == NULL || surface->status) + if (surface == NULL || _cairo_surface_status (surface)) return surface; _cairo_pattern_init_solid (&pattern, color); @@ -609,20 +522,6 @@ _cairo_surface_repaint_solid_pattern_surface (cairo_surface_t *other, * * Return value: the referenced #cairo_surface_t. **/ -cairo_surface_t * -cairo_surface_reference (cairo_surface_t *surface) -{ - if (surface == NULL || - CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) - return surface; - - assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); - - _cairo_reference_count_inc (&surface->ref_count); - - return surface; -} -slim_hidden_def (cairo_surface_reference); /** * cairo_surface_destroy: @@ -635,13 +534,7 @@ slim_hidden_def (cairo_surface_reference); void cairo_surface_destroy (cairo_surface_t *surface) { - if (surface == NULL || - CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) - return; - - assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); - - if (! _cairo_reference_count_dec_and_test (&surface->ref_count)) + if (! _cairo_object_destroy (&surface->base)) return; assert (surface->snapshot_of == NULL); @@ -649,10 +542,6 @@ cairo_surface_destroy (cairo_surface_t *surface) if (! surface->finished) cairo_surface_finish (surface); - /* paranoid check that nobody took a reference whilst finishing */ - assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count)); - - _cairo_user_data_array_fini (&surface->user_data); _cairo_user_data_array_fini (&surface->mime_data); if (surface->owns_device) @@ -661,6 +550,8 @@ cairo_surface_destroy (cairo_surface_t *surface) assert (surface->snapshot_of == NULL); assert (!_cairo_surface_has_snapshots (surface)); + _cairo_object_fini (&surface->base); + free (surface); } slim_hidden_def(cairo_surface_destroy); @@ -676,15 +567,6 @@ slim_hidden_def(cairo_surface_destroy); * * Since: 1.4 **/ -unsigned int -cairo_surface_get_reference_count (cairo_surface_t *surface) -{ - if (surface == NULL || - CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) - return 0; - - return CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->ref_count); -} /** * cairo_surface_finish: @@ -713,10 +595,10 @@ cairo_surface_finish (cairo_surface_t *surface) if (surface == NULL) return; - if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) + if (unlikely (_cairo_object_is_static (&surface->base))) return; - if (surface->finished) + if (unlikely (surface->finished)) return; cairo_surface_flush (surface); @@ -732,7 +614,7 @@ cairo_surface_finish (cairo_surface_t *surface) if (surface->backend->finish) { status = surface->backend->finish (surface); if (unlikely (status)) - status = _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); } assert (surface->snapshot_of == NULL); @@ -773,13 +655,6 @@ _cairo_surface_release_device_reference (cairo_surface_t *surface) * * Return value: the user data previously attached or %NULL. **/ -void * -cairo_surface_get_user_data (cairo_surface_t *surface, - const cairo_user_data_key_t *key) -{ - return _cairo_user_data_array_get_data (&surface->user_data, - key); -} /** * cairo_surface_set_user_data: @@ -797,18 +672,6 @@ cairo_surface_get_user_data (cairo_surface_t *surface, * Return value: %CAIRO_STATUS_SUCCESS or %CAIRO_STATUS_NO_MEMORY if a * slot could not be allocated for the user data. **/ -cairo_status_t -cairo_surface_set_user_data (cairo_surface_t *surface, - const cairo_user_data_key_t *key, - void *user_data, - cairo_destroy_func_t destroy) -{ - if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count)) - return surface->status; - - return _cairo_user_data_array_set_data (&surface->user_data, - key, user_data, destroy); -} /** * cairo_surface_get_mime_data: @@ -834,7 +697,7 @@ cairo_surface_get_mime_data (cairo_surface_t *surface, *data = NULL; *length = 0; - if (unlikely (surface->status)) + if (unlikely (_cairo_surface_status (surface))) return; /* The number of mime-types attached to a surface is usually small, @@ -955,14 +818,17 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, cairo_status_t status; cairo_mime_data_t *mime_data; - if (unlikely (surface->status)) - return surface->status; - if (surface->finished) + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; + if (unlikely (surface->finished)) return _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); status = _cairo_intern_string (&mime_type, -1); - if (unlikely (status)) - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); + return status; + } if (data != NULL) { mime_data = malloc (sizeof (cairo_mime_data_t)); @@ -986,10 +852,10 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, if (mime_data != NULL) free (mime_data); - return _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); } - return CAIRO_STATUS_SUCCESS; + return status; } slim_hidden_def (cairo_surface_set_mime_data); @@ -1007,16 +873,22 @@ _cairo_surface_copy_mime_data (cairo_surface_t *dst, { cairo_status_t status; - if (dst->status) - return dst->status; + status = _cairo_surface_status (dst); + if (unlikely (status)) + return status; - if (src->status) - return _cairo_surface_set_error (dst, src->status); + status = _cairo_surface_status (src); + if (unlikely (status)) { + _cairo_surface_set_error (dst, status); + return status; + } /* first copy the mime-data, discarding any already set on dst */ status = _cairo_user_data_array_copy (&dst->mime_data, &src->mime_data); - if (unlikely (status)) - return _cairo_surface_set_error (dst, status); + if (unlikely (status)) { + _cairo_surface_set_error (dst, status); + return status; + } /* now increment the reference counters for the copies */ _cairo_user_data_array_foreach (&dst->mime_data, @@ -1045,16 +917,13 @@ void _cairo_surface_set_font_options (cairo_surface_t *surface, cairo_font_options_t *options) { - cairo_status_t status; - - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; assert (surface->snapshot_of == NULL); - if (surface->finished) { - status = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -1085,7 +954,7 @@ cairo_surface_get_font_options (cairo_surface_t *surface, if (cairo_font_options_status (options)) return; - if (surface->status) { + if (unlikely (_cairo_surface_status (surface))) { _cairo_font_options_init_default (options); return; } @@ -1120,10 +989,10 @@ cairo_surface_flush (cairo_surface_t *surface) { cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; - if (surface->finished) + if (unlikely (surface->finished)) return; /* update the current snapshots *before* the user updates the surface */ @@ -1132,7 +1001,7 @@ cairo_surface_flush (cairo_surface_t *surface) if (surface->backend->flush) { status = surface->backend->flush (surface); if (unlikely (status)) - status = _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); } } slim_hidden_def (cairo_surface_flush); @@ -1177,13 +1046,13 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, { cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; assert (surface->snapshot_of == NULL); - if (surface->finished) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -1207,7 +1076,7 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, width, height); if (unlikely (status)) - status = _cairo_surface_set_error (surface, status); + _cairo_surface_set_error (surface, status); } } slim_hidden_def (cairo_surface_mark_dirty_rectangle); @@ -1236,13 +1105,13 @@ _cairo_surface_set_device_scale (cairo_surface_t *surface, { cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; assert (surface->snapshot_of == NULL); - if (surface->finished) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -1286,13 +1155,13 @@ cairo_surface_set_device_offset (cairo_surface_t *surface, { cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; assert (surface->snapshot_of == NULL); - if (surface->finished) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -1371,15 +1240,13 @@ cairo_surface_set_fallback_resolution (cairo_surface_t *surface, double x_pixels_per_inch, double y_pixels_per_inch) { - cairo_status_t status; - - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; assert (surface->snapshot_of == NULL); - if (surface->finished) { - status = _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -1387,7 +1254,7 @@ cairo_surface_set_fallback_resolution (cairo_surface_t *surface, /* XXX Could delay raising the error until we fallback, but throwing * the error here means that we can catch the real culprit. */ - status = _cairo_surface_set_error (surface, CAIRO_ERROR_INVALID_MATRIX); + _cairo_surface_set_error (surface, CAIRO_ERROR_INVALID_MATRIX); return; } @@ -1451,8 +1318,8 @@ _cairo_surface_acquire_source_image (cairo_surface_t *surface, { cairo_status_t status; - if (surface->status) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); assert (!surface->finished); @@ -1461,8 +1328,10 @@ _cairo_surface_acquire_source_image (cairo_surface_t *surface, status = surface->backend->acquire_source_image (surface, image_out, image_extra); - if (unlikely (status)) - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); + return status; + } _cairo_debug_check_image_surface_is_defined (&(*image_out)->base); @@ -1477,8 +1346,8 @@ _cairo_surface_acquire_source_image_transformed (cairo_surface_t *surface, { cairo_status_t status; - if (surface->status) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); assert (!surface->finished); @@ -1488,8 +1357,10 @@ _cairo_surface_acquire_source_image_transformed (cairo_surface_t *surface, status = surface->backend->acquire_source_image_transformed (surface, device_transform, image_out, image_extra); - if (unlikely (status)) - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); + return status; + } _cairo_debug_check_image_surface_is_defined (&(*image_out)->base); @@ -1554,8 +1425,8 @@ _cairo_surface_acquire_dest_image (cairo_surface_t *surface, { cairo_status_t status; - if (surface->status) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); assert (_cairo_surface_is_writable (surface)); @@ -1567,8 +1438,10 @@ _cairo_surface_acquire_dest_image (cairo_surface_t *surface, image_out, image_rect, image_extra); - if (unlikely (status)) - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); + return status; + } _cairo_debug_check_image_surface_is_defined (&(*image_out)->base); @@ -1618,7 +1491,7 @@ _cairo_recording_surface_clone_similar (cairo_surface_t *surface, similar = _cairo_surface_has_snapshot (src, surface->backend); if (similar != NULL) { - *clone_out = cairo_surface_reference (similar); + *clone_out = _cairo_surface_reference (similar); *clone_offset_x = 0; *clone_offset_y = 0; return CAIRO_STATUS_SUCCESS; @@ -1634,8 +1507,9 @@ _cairo_recording_surface_clone_similar (cairo_surface_t *surface, FALSE); if (similar == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; - if (unlikely (similar->status)) - return similar->status; + status = _cairo_surface_status (similar); + if (unlikely (status)) + return status; cairo_surface_set_device_offset (similar, -src_x, -src_y); @@ -1651,8 +1525,9 @@ _cairo_recording_surface_clone_similar (cairo_surface_t *surface, recorder->extents.height); if (similar == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; - if (unlikely (similar->status)) - return similar->status; + status = _cairo_surface_status (similar); + if (unlikely (status)) + return status; status = _cairo_recording_surface_replay (src, similar); if (unlikely (status)) { @@ -1707,8 +1582,8 @@ _cairo_surface_clone_similar (cairo_surface_t *surface, cairo_image_surface_t *image; void *image_extra; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (unlikely (surface->finished)) return CAIRO_ERROR_SURFACE_FINISHED; @@ -1833,8 +1708,8 @@ _cairo_surface_composite (cairo_operator_t op, { cairo_int_status_t status; - if (unlikely (dst->status)) - return dst->status; + if (unlikely (_cairo_surface_status (dst))) + return _cairo_surface_status (dst); assert (_cairo_surface_is_writable (dst)); @@ -1853,18 +1728,23 @@ _cairo_surface_composite (cairo_operator_t op, dst_x, dst_y, width, height, clip_region); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) - return _cairo_surface_set_error (dst, status); + if (status != CAIRO_INT_STATUS_UNSUPPORTED) { + _cairo_surface_set_error (dst, status); + return status; + } } - return _cairo_surface_set_error (dst, - _cairo_surface_fallback_composite (op, - src, mask, dst, - src_x, src_y, - mask_x, mask_y, - dst_x, dst_y, - width, height, - clip_region)); + status = _cairo_surface_fallback_composite (op, + src, mask, dst, + src_x, src_y, + mask_x, mask_y, + dst_x, dst_y, + width, height, + clip_region); + if (unlikely (status)) + _cairo_surface_set_error (dst, status); + + return status; } /** @@ -1892,8 +1772,8 @@ _cairo_surface_fill_region (cairo_surface_t *surface, cairo_status_t status; int i; - if (surface->status) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); assert (_cairo_surface_is_writable (surface)); @@ -1912,10 +1792,8 @@ _cairo_surface_fill_region (cairo_surface_t *surface, if (num_rects > ARRAY_LENGTH (stack_rects)) { rects = _cairo_malloc_ab (num_rects, sizeof (cairo_rectangle_int_t)); - if (rects == NULL) { - return _cairo_surface_set_error (surface, - CAIRO_ERROR_NO_MEMORY); - } + if (unlikely (rects == NULL)) + return _cairo_surface_set_error (surface, CAIRO_ERROR_NO_MEMORY); } for (i = 0; i < num_rects; i++) @@ -1927,7 +1805,10 @@ _cairo_surface_fill_region (cairo_surface_t *surface, if (rects != stack_rects) free (rects); - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } /** @@ -1955,8 +1836,8 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface, { cairo_int_status_t status; - if (surface->status) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); assert (_cairo_surface_is_writable (surface)); @@ -1967,14 +1848,19 @@ _cairo_surface_fill_rectangles (cairo_surface_t *surface, status = surface->backend->fill_rectangles (surface, op, color, rects, num_rects); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) - return _cairo_surface_set_error (surface, status); + if (status != CAIRO_INT_STATUS_UNSUPPORTED) { + _cairo_surface_set_error (surface, status); + return status; + } } - return _cairo_surface_set_error (surface, - _cairo_surface_fallback_fill_rectangles (surface, - op, color, - rects, num_rects)); + status = _cairo_surface_fallback_fill_rectangles (surface, + op, color, + rects, num_rects); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } static cairo_status_t @@ -1991,8 +1877,8 @@ _pattern_has_error (const cairo_pattern_t *pattern) return CAIRO_STATUS_SUCCESS; spattern = (const cairo_surface_pattern_t *) pattern; - if (unlikely (spattern->surface->status)) - return spattern->surface->status; + if (unlikely (_cairo_surface_status (spattern->surface))) + return _cairo_surface_status (spattern->surface); if (unlikely (spattern->surface->finished)) return CAIRO_ERROR_SURFACE_FINISHED; @@ -2008,8 +1894,8 @@ _cairo_surface_paint (cairo_surface_t *surface, { cairo_status_t status; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -2041,7 +1927,10 @@ _cairo_surface_paint (cairo_surface_t *surface, if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) surface->is_clear = op == CAIRO_OPERATOR_CLEAR && clip == NULL; - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } cairo_status_t @@ -2053,8 +1942,8 @@ _cairo_surface_mask (cairo_surface_t *surface, { cairo_status_t status; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -2097,7 +1986,10 @@ _cairo_surface_mask (cairo_surface_t *surface, if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) surface->is_clear = FALSE; - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } cairo_status_t @@ -2119,8 +2011,8 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface, { cairo_status_t status; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -2177,7 +2069,10 @@ _cairo_surface_fill_stroke (cairo_surface_t *surface, if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) surface->is_clear = FALSE; - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } cairo_status_t @@ -2194,8 +2089,8 @@ _cairo_surface_stroke (cairo_surface_t *surface, { cairo_status_t status; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -2236,7 +2131,10 @@ _cairo_surface_stroke (cairo_surface_t *surface, if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) surface->is_clear = FALSE; - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } cairo_status_t @@ -2251,8 +2149,8 @@ _cairo_surface_fill (cairo_surface_t *surface, { cairo_status_t status; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (clip && clip->all_clipped) return CAIRO_STATUS_SUCCESS; @@ -2291,7 +2189,10 @@ _cairo_surface_fill (cairo_surface_t *surface, if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) surface->is_clear = FALSE; - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } cairo_status_t @@ -2311,8 +2212,8 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op, { cairo_int_status_t status; - if (dst->status) - return dst->status; + if (unlikely (_cairo_surface_status (dst))) + return _cairo_surface_status (dst); assert (_cairo_surface_is_writable (dst)); @@ -2330,18 +2231,23 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op, width, height, traps, num_traps, clip_region); - if (status != CAIRO_INT_STATUS_UNSUPPORTED) - return _cairo_surface_set_error (dst, status); + if (status != CAIRO_INT_STATUS_UNSUPPORTED) { + _cairo_surface_set_error (dst, status); + return status; + } } - return _cairo_surface_set_error (dst, - _cairo_surface_fallback_composite_trapezoids (op, pattern, dst, - antialias, - src_x, src_y, - dst_x, dst_y, - width, height, - traps, num_traps, - clip_region)); + status = _cairo_surface_fallback_composite_trapezoids (op, pattern, dst, + antialias, + src_x, src_y, + dst_x, dst_y, + width, height, + traps, num_traps, + clip_region); + if (unlikely (status)) + _cairo_surface_set_error (dst, status); + + return status; } cairo_span_renderer_t * @@ -2354,8 +2260,8 @@ _cairo_surface_create_span_renderer (cairo_operator_t op, { assert (dst->snapshot_of == NULL); - if (unlikely (dst->status)) - return _cairo_span_renderer_create_in_error (dst->status); + if (unlikely (_cairo_surface_status (dst))) + return _cairo_span_renderer_create_in_error (_cairo_surface_status (dst)); if (unlikely (dst->finished)) return _cairo_span_renderer_create_in_error (CAIRO_ERROR_SURFACE_FINISHED); @@ -2378,7 +2284,7 @@ _cairo_surface_check_span_renderer (cairo_operator_t op, cairo_antialias_t antialias) { assert (dst->snapshot_of == NULL); - assert (dst->status == CAIRO_STATUS_SUCCESS); + assert (_cairo_surface_status (dst) == CAIRO_STATUS_SUCCESS); assert (! dst->finished); /* XXX: Currently we have no mono span renderer */ @@ -2408,16 +2314,13 @@ _cairo_surface_check_span_renderer (cairo_operator_t op, void cairo_surface_copy_page (cairo_surface_t *surface) { - cairo_status_t status_ignored; - - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; assert (surface->snapshot_of == NULL); - if (surface->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -2425,8 +2328,7 @@ cairo_surface_copy_page (cairo_surface_t *surface) if (surface->backend->copy_page == NULL) return; - status_ignored = _cairo_surface_set_error (surface, - surface->backend->copy_page (surface)); + _cairo_surface_set_error (surface, surface->backend->copy_page (surface)); } slim_hidden_def (cairo_surface_copy_page); @@ -2445,14 +2347,11 @@ slim_hidden_def (cairo_surface_copy_page); void cairo_surface_show_page (cairo_surface_t *surface) { - cairo_status_t status_ignored; - - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; - if (surface->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return; } @@ -2462,8 +2361,7 @@ cairo_surface_show_page (cairo_surface_t *surface) if (surface->backend->show_page == NULL) return; - status_ignored = _cairo_surface_set_error (surface, - surface->backend->show_page (surface)); + _cairo_surface_set_error (surface, surface->backend->show_page (surface)); } slim_hidden_def (cairo_surface_show_page); @@ -2531,14 +2429,11 @@ _cairo_surface_get_extents (cairo_surface_t *surface, cairo_bool_t cairo_surface_has_show_text_glyphs (cairo_surface_t *surface) { - cairo_status_t status_ignored; - - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return FALSE; - if (surface->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return FALSE; } @@ -2581,8 +2476,8 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface, cairo_status_t status; cairo_scaled_font_t *dev_scaled_font = scaled_font; - if (unlikely (surface->status)) - return surface->status; + if (unlikely (_cairo_surface_status (surface))) + return _cairo_surface_status (surface); if (num_glyphs == 0 && utf8_len == 0) return CAIRO_STATUS_SUCCESS; @@ -2615,8 +2510,10 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface, &font_options); } status = cairo_scaled_font_status (dev_scaled_font); - if (unlikely (status)) - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); + return status; + } status = CAIRO_INT_STATUS_UNSUPPORTED; @@ -2696,7 +2593,10 @@ _cairo_surface_show_text_glyphs (cairo_surface_t *surface, if (status != CAIRO_INT_STATUS_NOTHING_TO_DO) surface->is_clear = FALSE; - return _cairo_surface_set_error (surface, status); + if (unlikely (status)) + _cairo_surface_set_error (surface, status); + + return status; } /* XXX: Previously, we had a function named _cairo_surface_show_glyphs @@ -2719,22 +2619,27 @@ _cairo_surface_old_show_glyphs (cairo_scaled_font_t *scaled_font, int num_glyphs, cairo_region_t *clip_region) { - if (unlikely (dst->status)) - return dst->status; + cairo_status_t status; + + if (unlikely (_cairo_surface_status (dst))) + return _cairo_surface_status (dst); assert (_cairo_surface_is_writable (dst)); if (dst->backend->old_show_glyphs == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; - return _cairo_surface_set_error - (dst, dst->backend->old_show_glyphs (scaled_font, - op, pattern, dst, - source_x, source_y, - dest_x, dest_y, - width, height, - glyphs, num_glyphs, - clip_region)); + status = dst->backend->old_show_glyphs (scaled_font, + op, pattern, dst, + source_x, source_y, + dest_x, dest_y, + width, height, + glyphs, num_glyphs, + clip_region); + if (unlikely (status)) + _cairo_surface_set_error (dst, status); + + return status; } static cairo_status_t @@ -2790,7 +2695,10 @@ _cairo_surface_composite_fixup_unbounded_internal (cairo_surface_t *dst, CLEANUP_REGIONS: _cairo_region_fini (&clear_region); - return _cairo_surface_set_error (dst, status); + if (unlikely (status)) + _cairo_surface_set_error (dst, status); + + return status; } /** @@ -2839,8 +2747,8 @@ _cairo_surface_composite_fixup_unbounded (cairo_surface_t *dst, cairo_rectangle_int_t *src_rectangle = NULL; cairo_rectangle_int_t *mask_rectangle = NULL; - if (unlikely (dst->status)) - return dst->status; + if (unlikely (_cairo_surface_status (dst))) + return _cairo_surface_status (dst); assert (_cairo_surface_is_writable (dst)); @@ -2918,8 +2826,8 @@ _cairo_surface_composite_shape_fixup_unbounded (cairo_surface_t *dst, cairo_rectangle_int_t src_tmp, *src= NULL; cairo_rectangle_int_t mask; - if (dst->status) - return dst->status; + if (unlikely (_cairo_surface_status (dst))) + return _cairo_surface_status (dst); assert (_cairo_surface_is_writable (dst)); @@ -2962,75 +2870,12 @@ _cairo_surface_set_resolution (cairo_surface_t *surface, double x_res, double y_res) { - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) return; surface->x_resolution = x_res; surface->y_resolution = y_res; } -cairo_surface_t * -_cairo_surface_create_in_error (cairo_status_t status) -{ - switch (status) { - case CAIRO_STATUS_NO_MEMORY: - return (cairo_surface_t *) &_cairo_surface_nil; - case CAIRO_STATUS_SURFACE_TYPE_MISMATCH: - return (cairo_surface_t *) &_cairo_surface_nil_surface_type_mismatch; - case CAIRO_STATUS_INVALID_STATUS: - return (cairo_surface_t *) &_cairo_surface_nil_invalid_status; - case CAIRO_STATUS_INVALID_CONTENT: - return (cairo_surface_t *) &_cairo_surface_nil_invalid_content; - case CAIRO_STATUS_INVALID_FORMAT: - return (cairo_surface_t *) &_cairo_surface_nil_invalid_format; - case CAIRO_STATUS_INVALID_VISUAL: - return (cairo_surface_t *) &_cairo_surface_nil_invalid_visual; - case CAIRO_STATUS_READ_ERROR: - return (cairo_surface_t *) &_cairo_surface_nil_read_error; - case CAIRO_STATUS_WRITE_ERROR: - return (cairo_surface_t *) &_cairo_surface_nil_write_error; - case CAIRO_STATUS_FILE_NOT_FOUND: - return (cairo_surface_t *) &_cairo_surface_nil_file_not_found; - case CAIRO_STATUS_TEMP_FILE_ERROR: - return (cairo_surface_t *) &_cairo_surface_nil_temp_file_error; - case CAIRO_STATUS_INVALID_STRIDE: - return (cairo_surface_t *) &_cairo_surface_nil_invalid_stride; - case CAIRO_STATUS_INVALID_SIZE: - return (cairo_surface_t *) &_cairo_surface_nil_invalid_size; - case CAIRO_STATUS_DEVICE_TYPE_MISMATCH: - return (cairo_surface_t *) &_cairo_surface_nil_device_type_mismatch; - case CAIRO_STATUS_DEVICE_ERROR: - return (cairo_surface_t *) &_cairo_surface_nil_device_error; - case CAIRO_STATUS_SUCCESS: - case CAIRO_STATUS_LAST_STATUS: - ASSERT_NOT_REACHED; - /* fall-through */ - case CAIRO_STATUS_INVALID_RESTORE: - case CAIRO_STATUS_INVALID_POP_GROUP: - case CAIRO_STATUS_NO_CURRENT_POINT: - case CAIRO_STATUS_INVALID_MATRIX: - case CAIRO_STATUS_NULL_POINTER: - case CAIRO_STATUS_INVALID_STRING: - case CAIRO_STATUS_INVALID_PATH_DATA: - case CAIRO_STATUS_SURFACE_FINISHED: - case CAIRO_STATUS_PATTERN_TYPE_MISMATCH: - case CAIRO_STATUS_INVALID_DASH: - case CAIRO_STATUS_INVALID_DSC_COMMENT: - case CAIRO_STATUS_INVALID_INDEX: - case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE: - case CAIRO_STATUS_FONT_TYPE_MISMATCH: - case CAIRO_STATUS_USER_FONT_IMMUTABLE: - case CAIRO_STATUS_USER_FONT_ERROR: - case CAIRO_STATUS_NEGATIVE_COUNT: - case CAIRO_STATUS_INVALID_CLUSTERS: - case CAIRO_STATUS_INVALID_SLANT: - case CAIRO_STATUS_INVALID_WEIGHT: - case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED: - case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION: - default: - return _cairo_surface_create_in_error (CAIRO_ERROR_NO_MEMORY); - } -} - /* LocalWords: rasterized */ diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c index 1585c750b..43407ad04 100644 --- a/src/cairo-svg-surface.c +++ b/src/cairo-svg-surface.c @@ -275,37 +275,33 @@ _extract_svg_surface (cairo_surface_t *surface, cairo_svg_surface_t **svg_surface) { cairo_surface_t *target; - cairo_status_t status_ignored; + cairo_status_t status; - if (surface->status) + if (unlikely (_cairo_surface_status (surface))) + return FALSE; + if (unlikely (surface->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); return FALSE; - if (surface->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); - return FALSE; } - if (! _cairo_surface_is_paginated (surface)) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_paginated (surface))) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return FALSE; } target = _cairo_paginated_surface_get_target (surface); - if (target->status) { - status_ignored = _cairo_surface_set_error (surface, - target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) { + _cairo_surface_set_error (surface, status); return FALSE; } - if (target->finished) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_FINISHED); - return FALSE; + if (unlikely (target->finished)) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_FINISHED); + return FALSE; } - if (! _cairo_surface_is_svg (target)) { - status_ignored = _cairo_surface_set_error (surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_svg (target))) { + _cairo_surface_set_error (surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return FALSE; } @@ -506,7 +502,7 @@ _cairo_svg_surface_create_for_document (cairo_svg_document_t *document, paginated = _cairo_paginated_surface_create (&surface->base, surface->content, &cairo_svg_surface_paginated_backend); - status = paginated->status; + status = _cairo_surface_status (paginated); if (status == CAIRO_STATUS_SUCCESS) { /* paginated keeps the only reference to surface now, drop ours */ cairo_surface_destroy (&surface->base); @@ -545,7 +541,7 @@ _cairo_svg_surface_create_for_stream_internal (cairo_output_stream_t *stream, surface = _cairo_svg_surface_create_for_document (document, CAIRO_CONTENT_COLOR_ALPHA, width, height); - if (surface->status) { + if (unlikely (_cairo_surface_status (surface))) { status = _cairo_svg_document_destroy (document); return surface; } @@ -785,7 +781,7 @@ _cairo_svg_document_emit_bitmap_glyph_data (cairo_svg_document_t *document, image = _cairo_image_surface_coerce_to_format (scaled_glyph->surface, CAIRO_FORMAT_A1); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) return status; @@ -1133,8 +1129,9 @@ _cairo_surface_base64_encode_png (cairo_surface_t *surface, cairo_surface_get_mime_data (surface, CAIRO_MIME_TYPE_PNG, &mime_data, &mime_data_length); - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; if (mime_data == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; @@ -1270,8 +1267,8 @@ _cairo_svg_surface_emit_surface (cairo_svg_document_t *document, const unsigned char *uri; unsigned long uri_len; - if (_cairo_user_data_array_get_data (&surface->user_data, - (cairo_user_data_key_t *) document)) + if (_cairo_surface_get_user_data (surface, + (cairo_user_data_key_t *) document)) { return CAIRO_STATUS_SUCCESS; } @@ -1301,9 +1298,9 @@ _cairo_svg_surface_emit_surface (cairo_svg_document_t *document, _cairo_output_stream_printf (document->xml_node_defs, "\"/>\n"); /* and tag it */ - return _cairo_user_data_array_set_data (&surface->user_data, - (cairo_user_data_key_t *) document, - document, NULL); + return _cairo_surface_set_user_data (surface, + (cairo_user_data_key_t *) document, + document, NULL); } static cairo_status_t @@ -1379,8 +1376,8 @@ _cairo_svg_surface_emit_recording_surface (cairo_svg_document_t *document, cairo_output_stream_t *contents; - if (_cairo_user_data_array_get_data (&source->base.user_data, - (cairo_user_data_key_t *) document)) + if (_cairo_surface_get_user_data (&source->base, + (cairo_user_data_key_t *) document)) { return CAIRO_STATUS_SUCCESS; } @@ -1389,8 +1386,9 @@ _cairo_svg_surface_emit_recording_surface (cairo_svg_document_t *document, source->content, source->extents_pixels.width, source->extents_pixels.height); - if (unlikely (paginated_surface->status)) - return paginated_surface->status; + status = _cairo_surface_status (paginated_surface); + if (unlikely (status)) + return status; svg_surface = (cairo_svg_surface_t *) _cairo_paginated_surface_get_target (paginated_surface); @@ -1408,7 +1406,7 @@ _cairo_svg_surface_emit_recording_surface (cairo_svg_document_t *document, } cairo_surface_show_page (paginated_surface); - status = cairo_surface_status (paginated_surface); + status = _cairo_surface_status (paginated_surface); if (unlikely (status)) { cairo_surface_destroy (paginated_surface); return status; @@ -1460,16 +1458,16 @@ _cairo_svg_surface_emit_recording_surface (cairo_svg_document_t *document, _cairo_output_stream_printf (document->xml_node_defs, "</g>\n"); - status = cairo_surface_status (paginated_surface); + status = _cairo_surface_status (paginated_surface); cairo_surface_destroy (paginated_surface); if (unlikely (status)) return status; /* and tag it */ - return _cairo_user_data_array_set_data (&source->base.user_data, - (cairo_user_data_key_t *) document, - document, NULL); + return _cairo_surface_set_user_data (&source->base, + (cairo_user_data_key_t *) document, + document, NULL); } static cairo_status_t diff --git a/src/cairo-tee-surface.c b/src/cairo-tee-surface.c index 37ac5fa70..6d262262e 100644 --- a/src/cairo-tee-surface.c +++ b/src/cairo-tee-surface.c @@ -68,12 +68,14 @@ _cairo_tee_surface_create_similar (void *abstract_surface, cairo_surface_t *surface; cairo_surface_wrapper_t *slaves; int n, num_slaves; + cairo_status_t status; similar = _cairo_surface_wrapper_create_similar (&other->master, content, width, height); surface = cairo_tee_surface_create (similar); cairo_surface_destroy (similar); - if (unlikely (surface->status)) + status = _cairo_surface_status (surface); + if (unlikely (status)) return surface; num_slaves = _cairo_array_num_elements (&other->slaves); @@ -87,8 +89,8 @@ _cairo_tee_surface_create_similar (void *abstract_surface, cairo_surface_destroy (similar); } - if (unlikely (surface->status)) { - cairo_status_t status = surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) { cairo_surface_destroy (surface); surface = _cairo_surface_create_in_error (status); } @@ -436,9 +438,11 @@ cairo_surface_t * cairo_tee_surface_create (cairo_surface_t *master) { cairo_tee_surface_t *surface; + cairo_status_t status; - if (unlikely (master->status)) - return _cairo_surface_create_in_error (master->status); + status = _cairo_surface_status (master); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); surface = malloc (sizeof (cairo_tee_surface_t)); if (unlikely (surface == NULL)) @@ -465,7 +469,7 @@ cairo_tee_surface_add (cairo_surface_t *abstract_surface, cairo_surface_wrapper_t slave; cairo_status_t status; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { status = _cairo_surface_set_error (abstract_surface, @@ -479,8 +483,9 @@ cairo_tee_surface_add (cairo_surface_t *abstract_surface, return; } - if (unlikely (target->status)) { - status = _cairo_surface_set_error (abstract_surface, target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) { + status = _cairo_surface_set_error (abstract_surface, status); return; } @@ -504,7 +509,7 @@ cairo_tee_surface_remove (cairo_surface_t *abstract_surface, int n, num_slaves; cairo_status_t status; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { status = _cairo_surface_set_error (abstract_surface, @@ -549,9 +554,11 @@ cairo_tee_surface_index (cairo_surface_t *abstract_surface, int index) { cairo_tee_surface_t *surface; + cairo_status_t status; - if (unlikely (abstract_surface->status)) - return _cairo_surface_create_in_error (abstract_surface->status); + status = _cairo_surface_status (abstract_surface); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); if (unlikely (abstract_surface->finished)) return _cairo_surface_create_in_error (CAIRO_ERROR_SURFACE_FINISHED); diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c index 324ab45ad..dae2a33a0 100644 --- a/src/cairo-type3-glyph-surface.c +++ b/src/cairo-type3-glyph-surface.c @@ -121,7 +121,7 @@ _cairo_type3_glyph_surface_emit_image (cairo_type3_glyph_surface_t *surface, /* The only image type supported by Type 3 fonts are 1-bit masks */ image = _cairo_image_surface_coerce_to_format (image, CAIRO_FORMAT_A1); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) return status; @@ -401,7 +401,7 @@ _cairo_type3_glyph_surface_set_font_subsets_callback (void *abstract { cairo_type3_glyph_surface_t *surface = abstract_surface; - if (unlikely (surface->base.status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; _cairo_pdf_operators_set_font_subsets_callback (&surface->pdf_operators, @@ -418,8 +418,9 @@ _cairo_type3_glyph_surface_analyze_glyph (void *abstract_surface, cairo_status_t status, status2; cairo_output_stream_t *null_stream; - if (unlikely (surface->base.status)) - return surface->base.status; + status = _cairo_surface_status (abstract_surface); + if (unlikely (status)) + return status; null_stream = _cairo_null_stream_create (); if (unlikely (null_stream->status)) @@ -473,8 +474,9 @@ _cairo_type3_glyph_surface_emit_glyph (void *abstract_surface, double x_advance, y_advance; cairo_matrix_t font_matrix_inverse; - if (unlikely (surface->base.status)) - return surface->base.status; + status = _cairo_surface_status (abstract_surface); + if (unlikely (status)) + return status; _cairo_type3_glyph_surface_set_stream (surface, stream); diff --git a/src/cairo-vg-surface.c b/src/cairo-vg-surface.c index 904c520e5..85330b762 100644 --- a/src/cairo-vg-surface.c +++ b/src/cairo-vg-surface.c @@ -425,8 +425,9 @@ _vg_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clipper, surface->width, surface->height); if (unlikely (mask == NULL)) return CAIRO_INT_STATUS_UNSUPPORTED; - if (unlikely (mask->base.status)) - return mask->base.status; + status = _cairo_surface_status (&mask->base); + if (unlikely (status)) + return status; status = _cairo_surface_fill (&mask->base, CAIRO_OPERATOR_SOURCE, @@ -919,7 +920,7 @@ _vg_clone_image_surface (cairo_vg_context_t *context, clone = (cairo_vg_surface_t *) _vg_surface_create_internal (context, vg_image, format, image->width, image->height); - if (unlikely (clone->base.status)) + if (unlikely (_cairo_surface_status (&clone->base))) return clone; vgImageSubData (clone->image, @@ -959,7 +960,7 @@ _vg_setup_surface_source (cairo_vg_context_t *context, snapshot = _cairo_surface_has_snapshot (spat->surface, &cairo_vg_surface_backend); if (snapshot != NULL) { - clone = (cairo_vg_surface_t *) cairo_surface_reference (snapshot); + clone = (cairo_vg_surface_t *) _cairo_surface_reference (snapshot); goto DONE; } @@ -969,8 +970,9 @@ _vg_setup_surface_source (cairo_vg_context_t *context, clone = _vg_clone_image_surface (context, spat->surface); if (clone == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; - if (unlikely (clone->base.status)) - return clone->base.status; + status = _cairo_surface_status (&clone->base); + if (unlikely (status)) + return status; clone->snapshot_cache_entry.hash = clone->base.unique_id; status = _cairo_cache_insert (&context->snapshot_cache, @@ -1387,6 +1389,7 @@ _vg_get_image (cairo_vg_surface_t *surface, pixman_image_t *pixman_image; pixman_format_code_t pixman_format; cairo_bool_t needs_premultiply; + cairo_status_t status; pixman_format = _vg_format_to_pixman (surface->format, &needs_premultiply); @@ -1411,9 +1414,10 @@ _vg_get_image (cairo_vg_surface_t *surface, image = (cairo_image_surface_t *) _cairo_image_surface_create_for_pixman_image (pixman_image, pixman_format); - if (unlikely (image->base.status)) { + status = _cairo_surface_status (&image->base); + if (unlikely (status)) { pixman_image_unref (pixman_image); - return image->base.status; + return status; } if (needs_premultiply) @@ -1667,7 +1671,7 @@ cairo_vg_surface_create (cairo_vg_context_t *context, surface = _vg_surface_create_internal (context, image, format, width, height); - if (unlikely (surface->status)) + if (unlikely (_cairo_surface_status (surface))) return surface; ((cairo_vg_surface_t *) surface)->own_image = TRUE; diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c index c7202fe1c..19a69165b 100644 --- a/src/cairo-win32-font.c +++ b/src/cairo-win32-font.c @@ -1336,7 +1336,7 @@ _compute_a8_mask (cairo_win32_surface_t *mask_surface) int i, j; if (image24->base.status) - return cairo_surface_reference (&image24->base); + return _cairo_surface_reference (&image24->base); image8 = (cairo_image_surface_t *)cairo_image_surface_create (CAIRO_FORMAT_A8, image24->width, image24->height); diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index 240af72c6..5b7a185c4 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -1990,7 +1990,7 @@ _cairo_win32_surface_span_renderer_finish (void *abstract_renderer) if (renderer->pattern == NULL || renderer->mask == NULL) return CAIRO_STATUS_SUCCESS; - status = cairo_surface_status (&renderer->mask->base); + status = _cairo_surface_status (&renderer->mask->base); if (status == CAIRO_STATUS_SUCCESS) { cairo_composite_rectangles_t *rects = &renderer->composite_rectangles; cairo_win32_surface_t *dst = renderer->dst; @@ -2075,7 +2075,7 @@ _cairo_win32_surface_create_span_renderer (cairo_operator_t op, cairo_image_surface_create (CAIRO_FORMAT_A8, width, height); - status = cairo_surface_status (&renderer->mask->base); + status = _cairo_surface_status (&renderer->mask->base); if (status != CAIRO_STATUS_SUCCESS) { _cairo_win32_surface_span_renderer_destroy (renderer); diff --git a/src/cairo-xcb-screen.c b/src/cairo-xcb-screen.c index 1934e3472..7e9d5e2ae 100644 --- a/src/cairo-xcb-screen.c +++ b/src/cairo-xcb-screen.c @@ -57,7 +57,7 @@ _cairo_xcb_screen_finish (cairo_xcb_screen_t *screen) cairo_xcb_surface_t, link)->base; - cairo_surface_reference (surface); + _cairo_surface_reference (surface); cairo_surface_finish (surface); cairo_surface_destroy (surface); } @@ -353,7 +353,7 @@ _cairo_xcb_screen_store_linear_picture (cairo_xcb_screen_t *screen, return status; } - entry->picture = cairo_surface_reference (picture); + entry->picture = _cairo_surface_reference (picture); entry->screen = screen; status = _cairo_cache_insert (&screen->linear_pattern_cache, @@ -382,7 +382,7 @@ _cairo_xcb_screen_lookup_linear_picture (cairo_xcb_screen_t *screen, entry = _cairo_cache_lookup (&screen->linear_pattern_cache, &tmpl.key); if (entry != NULL) - picture = cairo_surface_reference (entry->picture); + picture = _cairo_surface_reference (entry->picture); return picture; } @@ -410,7 +410,7 @@ _cairo_xcb_screen_store_radial_picture (cairo_xcb_screen_t *screen, return status; } - entry->picture = cairo_surface_reference (picture); + entry->picture = _cairo_surface_reference (picture); entry->screen = screen; status = _cairo_cache_insert (&screen->radial_pattern_cache, &entry->key); @@ -438,7 +438,7 @@ _cairo_xcb_screen_lookup_radial_picture (cairo_xcb_screen_t *screen, entry = _cairo_cache_lookup (&screen->radial_pattern_cache, &tmpl.key); if (entry != NULL) - picture = cairo_surface_reference (entry->picture); + picture = _cairo_surface_reference (entry->picture); return picture; } diff --git a/src/cairo-xcb-surface-core.c b/src/cairo-xcb-surface-core.c index 2479e82a1..63c04a9f6 100644 --- a/src/cairo-xcb-surface-core.c +++ b/src/cairo-xcb-surface-core.c @@ -130,7 +130,7 @@ _cairo_xcb_pixmap_copy (cairo_xcb_surface_t *target) surface->connection = target->connection; surface->screen = target->screen; surface->pixmap = target->drawable; - surface->owner = cairo_surface_reference (&target->base); + surface->owner = _cairo_surface_reference (&target->base); surface->width = target->width; surface->height = target->height; surface->depth = target->depth; @@ -170,16 +170,16 @@ _cairo_xcb_shm_image_create_shm (cairo_xcb_connection_t *connection, pixman_format, width, height, stride); - status = image->status; + status = _cairo_surface_status (image); if (unlikely (status)) { _cairo_xcb_shm_info_destroy (shm_info); return status; } - status = _cairo_user_data_array_set_data (&image->user_data, - (const cairo_user_data_key_t *) connection, - shm_info, - (cairo_destroy_func_t) _cairo_xcb_shm_info_destroy); + status = _cairo_surface_set_user_data (image, + (const cairo_user_data_key_t *) connection, + shm_info, + (cairo_destroy_func_t) _cairo_xcb_shm_info_destroy); if (unlikely (status)) { cairo_surface_destroy (image); @@ -226,7 +226,7 @@ _cairo_xcb_shm_image_create (cairo_xcb_connection_t *connection, pixman_format, width, height, 0); - status = image->status; + status = _cairo_surface_status (image); if (unlikely (status)) return status; @@ -249,7 +249,7 @@ _pixmap_from_image (cairo_xcb_surface_t *target, pixmap = _cairo_xcb_pixmap_create (target, image->width, image->height); - if (unlikely (pixmap->base.status)) + if (unlikely (_cairo_surface_status (&pixmap->base))) return pixmap; gc = _cairo_xcb_screen_get_gc (target->screen, pixmap->pixmap, image->depth); @@ -329,7 +329,7 @@ _render_to_pixmap (cairo_xcb_surface_t *target, pixmap = _pixmap_from_image (target, target->xrender_format, image, shm_info); cairo_surface_destroy (&image->base); - if (unlikely (pixmap->base.status)) + if (unlikely (_cairo_surface_status (&pixmap->base))) return pixmap; pixmap->x0 = -extents->x; @@ -348,7 +348,7 @@ _copy_to_pixmap (cairo_xcb_surface_t *source) */ if (source->owns_pixmap) { pixmap = _cairo_xcb_pixmap_copy (source); - if (unlikely (pixmap->base.status)) + if (unlikely (_cairo_surface_status (&pixmap->base))) return pixmap; } else { uint32_t values[1]; @@ -357,7 +357,7 @@ _copy_to_pixmap (cairo_xcb_surface_t *source) pixmap = _cairo_xcb_pixmap_create (source, source->width, source->height); - if (unlikely (pixmap->base.status)) + if (unlikely (_cairo_surface_status (&pixmap->base))) return pixmap; gc = _cairo_xcb_screen_get_gc (source->screen, @@ -400,7 +400,7 @@ _cairo_xcb_surface_pixmap (cairo_xcb_surface_t *target, pixmap = (cairo_xcb_pixmap_t *) _cairo_surface_has_snapshot (source, &_cairo_xcb_pixmap_backend); if (pixmap != NULL && pixmap->screen == target->screen) - return (cairo_xcb_pixmap_t *) cairo_surface_reference (&pixmap->base); + return (cairo_xcb_pixmap_t *) _cairo_surface_reference (&pixmap->base); if (source->type == CAIRO_SURFACE_TYPE_XCB && ((cairo_xcb_surface_t *) source)->screen == target->screen) @@ -433,7 +433,7 @@ _cairo_xcb_surface_pixmap (cairo_xcb_surface_t *target, pixmap = _render_to_pixmap (target, &pattern->base, &rect); } - if (unlikely (pixmap->base.status)) + if (unlikely (_cairo_surface_status (&pixmap->base))) return pixmap; _cairo_surface_attach_snapshot (source, &pixmap->base, NULL); @@ -506,7 +506,7 @@ _cairo_xcb_surface_core_copy_boxes (cairo_xcb_surface_t *dst, return status; src = _cairo_xcb_pixmap_for_pattern (dst, src_pattern, extents); - status = src->base.status; + status = _cairo_surface_status (&src->base); if (unlikely (status)) goto CLEANUP_CONNECTION; diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c index e7628f499..ceeb6d049 100644 --- a/src/cairo-xcb-surface-render.c +++ b/src/cairo-xcb-surface-render.c @@ -370,7 +370,7 @@ _picture_from_image (cairo_xcb_surface_t *target, picture = _cairo_xcb_picture_create (target->screen, image->pixman_format, format, image->width, image->height); - if (likely (picture->base.status == CAIRO_STATUS_SUCCESS)) { + if (likely (_cairo_surface_status (&picture->base) == CAIRO_STATUS_SUCCESS)) { _cairo_xcb_connection_render_create_picture (target->connection, picture->picture, pixmap, format, 0, 0); @@ -587,7 +587,7 @@ _solid_picture (cairo_xcb_surface_t *target, PIXMAN_a8r8g8b8, xrender_format, -1, -1); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; if (target->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS) { @@ -653,7 +653,7 @@ _cairo_xcb_transparent_picture (cairo_xcb_surface_t *target) target->screen->stock_colors[CAIRO_STOCK_TRANSPARENT] = &picture->base; } - return (cairo_xcb_picture_t *) cairo_surface_reference (&picture->base); + return (cairo_xcb_picture_t *) _cairo_surface_reference (&picture->base); } static cairo_xcb_picture_t * @@ -667,7 +667,7 @@ _cairo_xcb_black_picture (cairo_xcb_surface_t *target) target->screen->stock_colors[CAIRO_STOCK_BLACK] = &picture->base; } - return (cairo_xcb_picture_t *) cairo_surface_reference (&picture->base); + return (cairo_xcb_picture_t *) _cairo_surface_reference (&picture->base); } static cairo_xcb_picture_t * @@ -681,7 +681,7 @@ _cairo_xcb_white_picture (cairo_xcb_surface_t *target) target->screen->stock_colors[CAIRO_STOCK_WHITE] = &picture->base; } - return (cairo_xcb_picture_t *) cairo_surface_reference (&picture->base); + return (cairo_xcb_picture_t *) _cairo_surface_reference (&picture->base); } static cairo_xcb_picture_t * @@ -715,12 +715,12 @@ _cairo_xcb_solid_picture (cairo_xcb_surface_t *target, n_cached = screen->solid_cache_size; for (i = 0; i < n_cached; i++) { if (_cairo_color_equal (&screen->solid_cache[i].color, &pattern->color)) { - return (cairo_xcb_picture_t *) cairo_surface_reference (screen->solid_cache[i].picture); + return (cairo_xcb_picture_t *) _cairo_surface_reference (screen->solid_cache[i].picture); } } picture = _solid_picture (target, &pattern->color); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; if (screen->solid_cache_size < ARRAY_LENGTH (screen->solid_cache)) { @@ -729,7 +729,7 @@ _cairo_xcb_solid_picture (cairo_xcb_surface_t *target, i = hars_petruska_f54_1_random () % ARRAY_LENGTH (screen->solid_cache); cairo_surface_destroy (screen->solid_cache[i].picture); } - screen->solid_cache[i].picture = cairo_surface_reference (&picture->base); + screen->solid_cache[i].picture = _cairo_surface_reference (&picture->base); screen->solid_cache[i].color = pattern->color; return picture; @@ -775,7 +775,7 @@ _render_to_picture (cairo_xcb_surface_t *target, picture = _picture_from_image (target, xrender_format, image, shm_info); cairo_surface_destroy (&image->base); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; _cairo_xcb_picture_set_component_alpha (picture, pattern->has_component_alpha); @@ -866,7 +866,7 @@ _cairo_xcb_linear_picture (cairo_xcb_surface_t *target, target->screen->connection->standard_formats[CAIRO_FORMAT_ARGB32], PIXMAN_a8r8g8b8, -1, -1); - if (unlikely (picture->base.status)) { + if (unlikely (_cairo_surface_status (&picture->base))) { if (stops != (xcb_render_fixed_t *) buf) free (stops); return picture; @@ -941,7 +941,7 @@ _cairo_xcb_radial_picture (cairo_xcb_surface_t *target, target->screen->connection->standard_formats[CAIRO_FORMAT_ARGB32], PIXMAN_a8r8g8b8, -1, -1); - if (unlikely (picture->base.status)) { + if (unlikely (_cairo_surface_status (&picture->base))) { if (stops != (xcb_render_fixed_t *) buf) free (stops); return picture; @@ -1009,7 +1009,7 @@ _copy_to_picture (cairo_xcb_surface_t *source) source->pixman_format, source->width, source->height); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; _cairo_xcb_connection_render_create_picture (source->connection, @@ -1047,7 +1047,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, _cairo_surface_has_snapshot (source, &_cairo_xcb_picture_backend); if (picture != NULL) { if (picture->screen == target->screen) { - picture = (cairo_xcb_picture_t *) cairo_surface_reference (&picture->base); + picture = (cairo_xcb_picture_t *) _cairo_surface_reference (&picture->base); goto setup_picture; } picture = NULL; @@ -1058,7 +1058,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, if (source->backend->type == CAIRO_SURFACE_TYPE_XCB) { if (((cairo_xcb_surface_t *) source)->screen == target->screen) { picture = _copy_to_picture ((cairo_xcb_surface_t *) source); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; } } else if (source->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) { @@ -1070,7 +1070,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, xcb_rectangle_t rect; picture = _copy_to_picture (xcb); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; rect.x = sub->extents.x; @@ -1093,7 +1093,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, if (xcb->screen == target->screen) { picture = _copy_to_picture (xcb); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; } } @@ -1104,7 +1104,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, if (source->backend->type == CAIRO_SURFACE_TYPE_XLIB) { if (((cairo_xlib_xcb_surface_t *) source)->xcb->screen == target->screen) { picture = _copy_to_picture (((cairo_xlib_xcb_surface_t *) source)->xcb); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; } } else if (source->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) { @@ -1115,7 +1115,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, xcb_rectangle_t rect; picture = _copy_to_picture (xcb); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; rect.x = sub->extents.x; @@ -1138,7 +1138,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, if (xcb->screen == target->screen) { picture = _copy_to_picture (xcb); - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; } } @@ -1244,7 +1244,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, conv = _cairo_image_surface_coerce (image); _cairo_surface_release_source_image (source, image, image_extra); - if (unlikely (conv->base.status)) + if (unlikely (_cairo_surface_status (&conv->base))) return (cairo_xcb_picture_t *) conv; render_format = target->screen->connection->standard_formats[conv->format]; @@ -1252,7 +1252,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target, cairo_surface_destroy (&conv->base); } - if (unlikely (picture->base.status)) + if (unlikely (_cairo_surface_status (&picture->base))) return picture; } @@ -1417,7 +1417,7 @@ _render_composite_boxes (cairo_xcb_surface_t *dst, } src = _cairo_xcb_picture_for_pattern (dst, src_pattern, extents); - status = src->base.status; + status = _cairo_surface_status (&src->base); if (unlikely (status)) goto cleanup_boxes; @@ -1459,7 +1459,7 @@ _render_composite_boxes (cairo_xcb_surface_t *dst, if (mask_pattern != NULL) { mask = _cairo_xcb_picture_for_pattern (dst, mask_pattern, extents); - status = mask->base.status; + status = _cairo_surface_status (&mask->base); if (unlikely (status)) goto cleanup_clip; @@ -1567,10 +1567,12 @@ _composite_traps (void *closure, xcb_render_trapezoid_t *xtraps; int render_reference_x, render_reference_y; int i; + cairo_status_t status; src = _cairo_xcb_picture_for_pattern (dst, pattern, extents); - if (unlikely (src->base.status)) - return src->base.status; + status = _cairo_surface_status (&src->base); + if (unlikely (status)) + return status; if (info->antialias == CAIRO_ANTIALIAS_NONE) format = CAIRO_FORMAT_A1; @@ -1686,7 +1688,7 @@ _create_composite_mask (cairo_clip_t *clip, surface = (cairo_xcb_surface_t *) _cairo_xcb_surface_create_similar (dst, CAIRO_CONTENT_ALPHA, extents->width, extents->height); - if (unlikely (surface->base.status)) + if (unlikely (_cairo_surface_status (&surface->base))) return surface; _cairo_xcb_surface_ensure_picture (surface); @@ -1749,16 +1751,19 @@ _clip_and_composite_with_mask (cairo_clip_t *clip, { cairo_xcb_surface_t *mask; cairo_xcb_picture_t *src; + cairo_status_t status; mask = _create_composite_mask (clip, draw_func, draw_closure, dst, extents); - if (unlikely (mask->base.status)) - return mask->base.status; + status = _cairo_surface_status (&mask->base); + if (unlikely (status)) + return status; if (pattern != NULL || dst->base.content != CAIRO_CONTENT_ALPHA) { src = _cairo_xcb_picture_for_pattern (dst, pattern, extents); - if (unlikely (src->base.status)) { + status = _cairo_surface_status (&src->base); + if (unlikely (status)) { cairo_surface_destroy (&mask->base); - return src->base.status; + return status; } _cairo_xcb_connection_render_composite (dst->connection, @@ -1809,8 +1814,9 @@ _clip_and_composite_combine (cairo_clip_t *clip, tmp = (cairo_xcb_surface_t *) _cairo_xcb_surface_create_similar (dst, dst->base.content, extents->width, extents->height); - if (unlikely (tmp->base.status)) - return tmp->base.status; + status = _cairo_surface_status (&tmp->base); + if (unlikely (status)) + return status; _cairo_xcb_surface_ensure_picture (tmp); @@ -1862,7 +1868,8 @@ _clip_and_composite_combine (cairo_clip_t *clip, goto CLEANUP_SURFACE; clip_surface = _cairo_clip_get_surface (clip, &dst->base, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) + status = _cairo_surface_status (clip_surface); + if (unlikely (status)) goto CLEANUP_SURFACE; clip_picture = ((cairo_xcb_surface_t *) clip_surface)->picture; @@ -1917,16 +1924,19 @@ _clip_and_composite_source (cairo_clip_t *clip, { cairo_xcb_surface_t *mask; cairo_xcb_picture_t *src; + cairo_status_t status; /* Create a surface that is mask IN clip */ mask = _create_composite_mask (clip, draw_func, draw_closure, dst, extents); - if (unlikely (mask->base.status)) - return mask->base.status; + status = _cairo_surface_status (&mask->base); + if (unlikely (status)) + return status; src = _cairo_xcb_picture_for_pattern (dst, pattern, extents); - if (unlikely (src->base.status)) { + status = _cairo_surface_status (&src->base); + if (unlikely (status)) { cairo_surface_destroy (&mask->base); - return src->base.status; + return status; } if (dst->base.is_clear) { @@ -2063,10 +2073,12 @@ _cairo_xcb_surface_fixup_unbounded (cairo_xcb_surface_t *dst, } else { int i; cairo_xcb_picture_t *src; + cairo_status_t status; src = _cairo_xcb_transparent_picture (dst); - if (unlikely (src->base.status)) - return src->base.status; + status = _cairo_surface_status (&src->base); + if (unlikely (status)) + return status; for (i = 0; i < n; i++) { _cairo_xcb_connection_render_composite (dst->connection, @@ -2090,10 +2102,12 @@ _cairo_xcb_surface_fixup_unbounded_with_mask (cairo_xcb_surface_t *dst, { cairo_xcb_surface_t *mask; int mask_x, mask_y; + cairo_status_t status; mask = (cairo_xcb_surface_t *) _cairo_clip_get_surface (clip, &dst->base, &mask_x, &mask_y); - if (unlikely (mask->base.status)) - return mask->base.status; + status = _cairo_surface_status (&mask->base); + if (unlikely (status)) + return status; /* top */ if (rects->bounded.y != rects->unbounded.y) { @@ -2495,8 +2509,9 @@ _composite_boxes (cairo_xcb_surface_t *dst, int clip_x, clip_y; clip_surface = _cairo_clip_get_surface (clip, &dst->base, &clip_x, &clip_y); - if (unlikely (clip_surface->status)) - return clip_surface->status; + status = _cairo_surface_status (clip_surface); + if (unlikely (status)) + return status; _cairo_pattern_init_for_surface (&mask, clip_surface); mask.base.filter = CAIRO_FILTER_NEAREST; @@ -2813,16 +2828,19 @@ _composite_mask (void *closure, { const cairo_pattern_t *mask_pattern = closure; cairo_xcb_picture_t *src, *mask = NULL; + cairo_status_t status; if (src_pattern != NULL) { src = _cairo_xcb_picture_for_pattern (dst, src_pattern, extents); - if (unlikely (src->base.status)) - return src->base.status; + status = _cairo_surface_status (&src->base); + if (unlikely (status)) + return status; mask = _cairo_xcb_picture_for_pattern (dst, mask_pattern, extents); - if (unlikely (mask->base.status)) { + status = _cairo_surface_status (&mask->base); + if (unlikely (status)) { cairo_surface_destroy (&src->base); - return mask->base.status; + return status; } _cairo_xcb_connection_render_composite (dst->connection, @@ -2838,8 +2856,9 @@ _composite_mask (void *closure, cairo_surface_destroy (&src->base); } else { src = _cairo_xcb_picture_for_pattern (dst, mask_pattern, extents); - if (unlikely (src->base.status)) - return src->base.status; + status = _cairo_surface_status (&src->base); + if (unlikely (status)) + return status; _cairo_xcb_connection_render_composite (dst->connection, _render_operator (op), @@ -3180,8 +3199,9 @@ _cairo_xcb_surface_render_stroke_via_mask (cairo_xcb_surface_t *dst, image = _cairo_xcb_surface_create_similar_image (dst, CAIRO_CONTENT_ALPHA, extents->bounded.width, extents->bounded.height); - if (unlikely (image->status)) - return image->status; + status = _cairo_surface_status (image); + if (unlikely (status)) + return status; _clear_image (image); @@ -3365,8 +3385,9 @@ _cairo_xcb_surface_render_fill_via_mask (cairo_xcb_surface_t *dst, CAIRO_CONTENT_ALPHA, extents->bounded.width, extents->bounded.height); - if (unlikely (image->status)) - return image->status; + status = _cairo_surface_status (image); + if (unlikely (status)) + return status; _clear_image (image); @@ -3513,8 +3534,9 @@ _cairo_xcb_surface_render_glyphs_via_mask (cairo_xcb_surface_t *dst, image = _cairo_xcb_surface_create_similar_image (dst, content, extents->bounded.width, extents->bounded.height); - if (unlikely (image->status)) - return image->status; + status = _cairo_surface_status (image); + if (unlikely (status)) + return status; _clear_image (image); @@ -4015,7 +4037,7 @@ _cairo_xcb_surface_add_glyph (cairo_xcb_connection_t *connection, cairo_surface_t *tmp_surface; tmp_surface = cairo_image_surface_create (glyphset_info->format, 1, 1); - status = tmp_surface->status; + status = _cairo_surface_status (tmp_surface); if (unlikely (status)) goto BAIL; @@ -4032,7 +4054,7 @@ _cairo_xcb_surface_add_glyph (cairo_xcb_connection_t *connection, if (glyph_surface->format != glyphset_info->format) { glyph_surface = _cairo_image_surface_coerce_to_format (glyph_surface, glyphset_info->format); - status = glyph_surface->base.status; + status = _cairo_surface_status (&glyph_surface->base); if (unlikely (status)) goto BAIL; } @@ -4249,8 +4271,9 @@ _composite_glyphs (void *closure, int i; src = _cairo_xcb_picture_for_pattern (dst, pattern, extents); - if (unlikely (src->base.status)) - return src->base.status; + status = _cairo_surface_status (&src->base); + if (unlikely (status)) + return status; memset (glyph_cache, 0, sizeof (glyph_cache)); diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index 89b71f6bf..2e81fb2e5 100644 --- a/src/cairo-xcb-surface.c +++ b/src/cairo-xcb-surface.c @@ -107,16 +107,16 @@ _cairo_xcb_surface_create_similar_shm (cairo_xcb_surface_t *other, pixman_format, width, height, stride); - status = image->status; + status = _cairo_surface_status (image); if (unlikely (status)) { _cairo_xcb_shm_info_destroy (shm_info); return status; } - status = _cairo_user_data_array_set_data (&image->user_data, - (const cairo_user_data_key_t *) other->connection, - shm_info, - (cairo_destroy_func_t) _cairo_xcb_shm_info_destroy); + status = _cairo_surface_set_user_data (image, + (const cairo_user_data_key_t *) other->connection, + shm_info, + (cairo_destroy_func_t) _cairo_xcb_shm_info_destroy); if (unlikely (status)) { cairo_surface_destroy (image); _cairo_xcb_shm_info_destroy (shm_info); @@ -256,7 +256,7 @@ _cairo_xcb_surface_create_similar (void *abstract_other, width, height); } - if (unlikely (surface->base.status)) + if (unlikely (_cairo_surface_status (&surface->base))) _cairo_xcb_connection_free_pixmap (connection, pixmap); _cairo_xcb_connection_release (connection); @@ -343,16 +343,16 @@ _cairo_xcb_surface_create_shm_image (cairo_xcb_surface_t *target, target->width, target->height, stride); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) { _cairo_xcb_shm_info_destroy (shm_info); return status; } - status = _cairo_user_data_array_set_data (&image->base.user_data, - (const cairo_user_data_key_t *) target->connection, - shm_info, - (cairo_destroy_func_t) _cairo_xcb_shm_info_destroy); + status = _cairo_surface_set_user_data (&image->base, + (const cairo_user_data_key_t *) target->connection, + shm_info, + (cairo_destroy_func_t) _cairo_xcb_shm_info_destroy); if (unlikely (status)) { cairo_surface_destroy (&image->base); _cairo_xcb_shm_info_destroy (shm_info); @@ -417,7 +417,7 @@ _get_image (cairo_xcb_surface_t *surface, surface->height, 0); *image_out = image; - return image->base.status; + return _cairo_surface_status (&image->base); } connection = surface->connection; @@ -505,7 +505,7 @@ _get_image (cairo_xcb_surface_t *surface, surface->height, CAIRO_STRIDE_FOR_WIDTH_BPP (surface->width, PIXMAN_FORMAT_BPP (surface->pixman_format))); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) { free (reply); goto FAIL; @@ -543,7 +543,7 @@ _cairo_xcb_surface_acquire_source_image (void *abstract_surface, } if (surface->fallback != NULL) { - image = (cairo_image_surface_t *) cairo_surface_reference (surface->fallback); + image = (cairo_image_surface_t *) _cairo_surface_reference (surface->fallback); goto DONE; } @@ -551,7 +551,7 @@ _cairo_xcb_surface_acquire_source_image (void *abstract_surface, _cairo_surface_has_snapshot (&surface->base, &_cairo_image_surface_backend); if (image != NULL) { - image = (cairo_image_surface_t *) cairo_surface_reference (&image->base); + image = (cairo_image_surface_t *) _cairo_surface_reference (&image->base); goto DONE; } @@ -609,8 +609,8 @@ _put_shm_image (cairo_xcb_surface_t *surface, #if CAIRO_HAS_XCB_SHM_FUNCTIONS cairo_xcb_shm_info_t *shm_info; - shm_info = _cairo_user_data_array_get_data (&image->base.user_data, - (const cairo_user_data_key_t *) surface->connection); + shm_info = _cairo_surface_get_user_data (&image->base, + (const cairo_user_data_key_t *) surface->connection); if (shm_info == NULL) return CAIRO_INT_STATUS_UNSUPPORTED; @@ -693,9 +693,9 @@ _cairo_xcb_surface_flush (void *abstract_surface) return status; } - status = surface->base.status; + status = _cairo_surface_status (&surface->base); if (status == CAIRO_STATUS_SUCCESS && ! surface->base.finished) { - status = cairo_surface_status (surface->fallback); + status = _cairo_surface_status (surface->fallback); if (status == CAIRO_STATUS_SUCCESS) { status = _put_image (surface, @@ -1392,26 +1392,24 @@ cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface, int height) { cairo_xcb_surface_t *surface; - cairo_status_t status_ignored; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { - status_ignored = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_SURFACE_FINISHED); + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_SURFACE_FINISHED); return; } - if (abstract_surface->type != CAIRO_SURFACE_TYPE_XCB) { - status_ignored = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (abstract_surface->type != CAIRO_SURFACE_TYPE_XCB)) { + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return; } - if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) { - status_ignored = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_INVALID_SIZE); + if (unlikely (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || + width <= 0 || height <= 0)) + { + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_INVALID_SIZE); return; } diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 71f26397e..b2586d99a 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -438,7 +438,7 @@ _cairo_xlib_surface_create_similar (void *abstract_src, #endif } - if (unlikely (surface->base.status)) { + if (unlikely (_cairo_surface_status (&surface->base))) { XFreePixmap (display->display, pix); cairo_device_release (&display->base); return &surface->base; @@ -935,7 +935,7 @@ _get_image_surface (cairo_xlib_surface_t *surface, ximage->width, ximage->height, ximage->bytes_per_line); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) goto BAIL; @@ -1004,7 +1004,7 @@ _get_image_surface (cairo_xlib_surface_t *surface, image = (cairo_image_surface_t *) cairo_image_surface_create (format, ximage->width, ximage->height); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) goto BAIL; @@ -1455,7 +1455,7 @@ _cairo_xlib_surface_release_dest_image (void *abstract_surfac status = _draw_image_surface (surface, image, 0, 0, image->width, image->height, image_rect->x, image_rect->y); - status = _cairo_surface_set_error (&surface->base, status); + _cairo_surface_set_error (&surface->base, status); cairo_surface_destroy (&image->base); } @@ -1528,7 +1528,7 @@ fallback: width, height, xrender_format->depth); - if (unlikely (surface->base.status)) { + if (unlikely (_cairo_surface_status (&surface->base))) { XFreePixmap (display->display, pix); cairo_device_release (&display->base); return surface; @@ -1560,7 +1560,7 @@ _cairo_xlib_surface_clone_similar (void *abstract_surface, if (_cairo_xlib_surface_same_screen (surface, xlib_src)) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } @@ -1576,8 +1576,9 @@ _cairo_xlib_surface_clone_similar (void *abstract_surface, if (clone == NULL) return UNSUPPORTED ("unhandled image format, no similar surface"); - if (unlikely (clone->base.status)) - return clone->base.status; + status = _cairo_surface_status (&clone->base); + if (unlikely (status)) + return status; status = _draw_image_surface (clone, image_src, src_x, src_y, @@ -1627,7 +1628,7 @@ _cairo_xlib_surface_create_solid_pattern_surface (void *abstrac image = (cairo_image_surface_t *) _cairo_image_surface_create_with_content (_cairo_color_get_content (&solid_pattern->color), width, height); - status = image->base.status; + status = _cairo_surface_status (&image->base); if (unlikely (status)) goto BAIL; @@ -1648,7 +1649,7 @@ _cairo_xlib_surface_create_solid_pattern_surface (void *abstrac other->xrender_format, width, height, other->depth); - status = surface->base.status; + status = _cairo_surface_status (&surface->base); if (unlikely (status)) goto BAIL; @@ -2280,9 +2281,9 @@ _cairo_xlib_surface_acquire_pattern_surface (cairo_xlib_display_t *display, NULL, format, /* what could possibly go wrong? */ XLIB_COORD_MAX, XLIB_COORD_MAX, 32); - if (unlikely (surface->base.status)) { + if (unlikely (_cairo_surface_status (&surface->base))) { XRenderFreePicture (display->display, picture); - return surface->base.status; + return _cairo_surface_status (&surface->base); } surface->src_picture = picture; @@ -3596,25 +3597,23 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface, int height) { cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *) abstract_surface; - cairo_status_t status; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { - status = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_SURFACE_FINISHED); + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_SURFACE_FINISHED); return; } - if (! _cairo_surface_is_xlib (abstract_surface)) { - status = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_xlib (abstract_surface))) { + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return; } - if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) { - status = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_INVALID_SIZE); + if (unlikely (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || + width <= 0 || height <= 0)) + { + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_INVALID_SIZE); return; } @@ -3644,23 +3643,22 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface, cairo_xlib_surface_t *surface = (cairo_xlib_surface_t *)abstract_surface; cairo_status_t status; - if (unlikely (abstract_surface->status)) + if (unlikely (_cairo_surface_status (abstract_surface))) return; if (unlikely (abstract_surface->finished)) { - status = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_SURFACE_FINISHED); + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_SURFACE_FINISHED); return; } - if (! _cairo_surface_is_xlib (abstract_surface)) { - status = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_SURFACE_TYPE_MISMATCH); + if (unlikely (! _cairo_surface_is_xlib (abstract_surface))) { + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_SURFACE_TYPE_MISMATCH); return; } - if (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || width <= 0 || height <= 0) { - status = _cairo_surface_set_error (abstract_surface, - CAIRO_ERROR_INVALID_SIZE); + if (unlikely (width > XLIB_COORD_MAX || height > XLIB_COORD_MAX || + width <= 0 || height <= 0)) + { + _cairo_surface_set_error (abstract_surface, CAIRO_ERROR_INVALID_SIZE); return; } @@ -3683,7 +3681,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface, XRenderFreePicture, surface->dst_picture); if (unlikely (status)) { - status = _cairo_surface_set_error (&surface->base, status); + _cairo_surface_set_error (&surface->base, status); return; } @@ -3696,7 +3694,7 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface, XRenderFreePicture, surface->src_picture); if (unlikely (status)) { - status = _cairo_surface_set_error (&surface->base, status); + _cairo_surface_set_error (&surface->base, status); return; } @@ -4265,7 +4263,7 @@ _cairo_xlib_surface_add_glyph (cairo_xlib_display_t *display, cairo_surface_t *tmp_surface; tmp_surface = cairo_image_surface_create (glyphset_info->format, 1, 1); - status = tmp_surface->status; + status = _cairo_surface_status (tmp_surface); if (unlikely (status)) goto BAIL; @@ -4286,7 +4284,7 @@ _cairo_xlib_surface_add_glyph (cairo_xlib_display_t *display, tmp_surface = cairo_image_surface_create (glyphset_info->format, glyph_surface->width, glyph_surface->height); - status = tmp_surface->status; + status = _cairo_surface_status (tmp_surface); if (unlikely (status)) goto BAIL; diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c index e15e10332..6ff76af98 100644 --- a/src/cairo-xlib-xcb-surface.c +++ b/src/cairo-xlib-xcb-surface.c @@ -65,7 +65,7 @@ _cairo_xlib_xcb_surface_create_similar (void *abstract_other, cairo_surface_t *xcb; xcb = other->xcb->base.backend->create_similar (other->xcb, content, width, height); - if (unlikely (xcb == NULL || xcb->status)) + if (unlikely (xcb == NULL || _cairo_surface_status (xcb))) return xcb; return _cairo_xlib_xcb_surface_create (other->display, other->screen, NULL, NULL, xcb); @@ -78,7 +78,7 @@ _cairo_xlib_xcb_surface_finish (void *abstract_surface) cairo_status_t status; cairo_surface_finish (&surface->xcb->base); - status = surface->xcb->base.status; + status = _cairo_surface_status (&surface->xcb->base); cairo_surface_destroy (&surface->xcb->base); surface->xcb = NULL; @@ -211,7 +211,7 @@ _cairo_xlib_xcb_surface_mark_dirty (void *abstract_surface, { cairo_xlib_xcb_surface_t *surface = abstract_surface; cairo_surface_mark_dirty_rectangle (&surface->xcb->base, x, y, width, height); - return cairo_surface_status (&surface->xcb->base); + return _cairo_surface_status (&surface->xcb->base); } static const cairo_surface_backend_t _cairo_xlib_xcb_surface_backend = { @@ -254,7 +254,7 @@ _cairo_xlib_xcb_surface_create (void *dpy, { cairo_xlib_xcb_surface_t *surface; - if (unlikely (xcb->status)) + if (unlikely (_cairo_surface_status (xcb))) return xcb; surface = malloc (sizeof (*surface)); @@ -422,7 +422,8 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface, cairo_xlib_xcb_surface_t *surface = (cairo_xlib_xcb_surface_t *) abstract_surface; cairo_status_t status; - if (unlikely (abstract_surface->status)) + status = _cairo_surface_status (abstract_surface); + if (unlikely (status)) return; if (unlikely (abstract_surface->finished)) { status = _cairo_surface_set_error (abstract_surface, @@ -437,10 +438,9 @@ cairo_xlib_surface_set_size (cairo_surface_t *abstract_surface, } cairo_xcb_surface_set_size (&surface->xcb->base, width, height); - if (unlikely (surface->xcb->base.status)) { - status = _cairo_surface_set_error (abstract_surface, - surface->xcb->base.status); - } + status = _cairo_surface_status (&surface->xcb->base); + if (unlikely (status)) + _cairo_surface_set_error (abstract_surface, status); } void @@ -452,7 +452,8 @@ cairo_xlib_surface_set_drawable (cairo_surface_t *abstract_surface, cairo_xlib_xcb_surface_t *surface = (cairo_xlib_xcb_surface_t *)abstract_surface; cairo_status_t status; - if (unlikely (abstract_surface->status)) + status = _cairo_surface_status (abstract_surface); + if (unlikely (status)) return; if (unlikely (abstract_surface->finished)) { status = _cairo_surface_set_error (abstract_surface, diff --git a/src/cairo-xml-surface.c b/src/cairo-xml-surface.c index c4b7e17fe..706c4ff73 100644 --- a/src/cairo-xml-surface.c +++ b/src/cairo-xml-surface.c @@ -1107,8 +1107,9 @@ cairo_xml_for_recording_surface (cairo_device_t *device, if (unlikely (status)) return status; - if (unlikely (recording_surface->status)) - return recording_surface->status; + status = _cairo_surface_status (recording_surface); + if (unlikely (status)) + return status; if (unlikely (device->backend->type != CAIRO_DEVICE_TYPE_XML)) return CAIRO_ERROR_DEVICE_TYPE_MISMATCH; @@ -1126,8 +1127,9 @@ cairo_xml_for_recording_surface (cairo_device_t *device, recording_surface->content, extents.width, extents.height); - if (unlikely (surface->status)) - return surface->status; + status = _cairo_surface_status (surface); + if (unlikely (status)) + return status; xml = (cairo_xml_t *) device; diff --git a/src/cairo.c b/src/cairo.c index 4e32e7b0f..8bc5d111a 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -150,8 +150,9 @@ cairo_create (cairo_surface_t *target) if (unlikely (target == NULL)) return _cairo_create_in_error (CAIRO_ERROR_NULL_POINTER); - if (unlikely (target->status)) - return _cairo_create_in_error (target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) + return _cairo_create_in_error (status); cr = _freed_pool_get (&context_pool); if (unlikely (cr == NULL)) { @@ -409,7 +410,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) clip = _cairo_gstate_get_clip (cr->gstate); if (clip->all_clipped) { group_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0); - status = group_surface->status; + status = _cairo_surface_status (group_surface); if (unlikely (status)) goto bail; } else { @@ -433,7 +434,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content) extents.height, CAIRO_COLOR_TRANSPARENT, TRUE); - status = group_surface->status; + status = _cairo_surface_status (group_surface); if (unlikely (status)) goto bail; @@ -508,7 +509,7 @@ cairo_pop_group (cairo_t *cr) /* Get a reference to the active surface before restoring */ group_surface = _cairo_gstate_get_target (cr->gstate); - group_surface = cairo_surface_reference (group_surface); + group_surface = _cairo_surface_reference (group_surface); status = _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist); assert (status == CAIRO_STATUS_SUCCESS); diff --git a/src/cairoint.h b/src/cairoint.h index e46272b25..0fb4c31e1 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1544,17 +1544,10 @@ _cairo_stroke_style_dash_approximate (const cairo_stroke_style_t *style, /* cairo-surface.c */ -cairo_private cairo_surface_t * -_cairo_surface_create_in_error (cairo_status_t status); - cairo_private cairo_status_t _cairo_surface_copy_mime_data (cairo_surface_t *dst, cairo_surface_t *src); -cairo_private cairo_status_t -_cairo_surface_set_error (cairo_surface_t *surface, - cairo_status_t status); - cairo_private void _cairo_surface_set_resolution (cairo_surface_t *surface, double x_res, @@ -2503,12 +2496,10 @@ slim_hidden_proto (cairo_surface_get_type); slim_hidden_proto (cairo_surface_has_show_text_glyphs); slim_hidden_proto (cairo_surface_mark_dirty); slim_hidden_proto (cairo_surface_mark_dirty_rectangle); -slim_hidden_proto_no_warn (cairo_surface_reference); slim_hidden_proto (cairo_surface_set_device_offset); slim_hidden_proto (cairo_surface_set_fallback_resolution); slim_hidden_proto (cairo_surface_set_mime_data); slim_hidden_proto (cairo_surface_show_page); -slim_hidden_proto (cairo_surface_status); slim_hidden_proto (cairo_text_cluster_allocate); slim_hidden_proto (cairo_text_cluster_free); slim_hidden_proto (cairo_toy_font_face_create); diff --git a/src/test-fallback-surface.c b/src/test-fallback-surface.c index 001257774..b3f22673e 100644 --- a/src/test-fallback-surface.c +++ b/src/test-fallback-surface.c @@ -76,7 +76,7 @@ _cairo_test_fallback_surface_create (cairo_content_t content, cairo_surface_t *backing; backing = _cairo_image_surface_create_with_content (content, width, height); - if (cairo_surface_status (backing)) + if (_cairo_surface_status (backing)) return backing; surface = malloc (sizeof (test_fallback_surface_t)); @@ -188,7 +188,7 @@ _test_fallback_surface_clone_similar (void *abstract_surface, if (src->backend == surface->base.backend) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } diff --git a/src/test-fallback16-surface.c b/src/test-fallback16-surface.c index 953a73c03..2c28ec9b2 100644 --- a/src/test-fallback16-surface.c +++ b/src/test-fallback16-surface.c @@ -70,7 +70,7 @@ _cairo_test_fallback16_surface_create (cairo_content_t content, backing = _cairo_image_surface_create_with_pixman_format (NULL, format, width, height, -1); - if (cairo_surface_status (backing)) + if (_cairo_surface_status (backing)) return backing; surface = malloc (sizeof (test_fallback16_surface_t)); @@ -181,7 +181,7 @@ _test_fallback16_surface_clone_similar (void *abstract_surface, if (src->backend == surface->base.backend) { *clone_offset_x = 0; *clone_offset_y = 0; - *clone_out = cairo_surface_reference (src); + *clone_out = _cairo_surface_reference (src); return CAIRO_STATUS_SUCCESS; } else { diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c index 36491fcc6..c33bf3a9f 100644 --- a/src/test-paginated-surface.c +++ b/src/test-paginated-surface.c @@ -68,7 +68,7 @@ _cairo_test_paginated_surface_create (cairo_surface_t *target) cairo_surface_t *paginated; test_paginated_surface_t *surface; - status = cairo_surface_status (target); + status = _cairo_surface_status (target); if (unlikely (status)) return _cairo_surface_create_in_error (status); @@ -81,12 +81,12 @@ _cairo_test_paginated_surface_create (cairo_surface_t *target) NULL, /* device */ target->content); - surface->target = cairo_surface_reference (target); + surface->target = _cairo_surface_reference (target); paginated = _cairo_paginated_surface_create (&surface->base, target->content, &test_paginated_surface_paginated_backend); - status = paginated->status; + status = _cairo_surface_status (paginated); if (status == CAIRO_STATUS_SUCCESS) { /* paginated keeps the only reference to surface now, drop ours */ cairo_surface_destroy (&surface->base); diff --git a/src/test-wrapping-surface.c b/src/test-wrapping-surface.c index d300116a0..44083aac1 100644 --- a/src/test-wrapping-surface.c +++ b/src/test-wrapping-surface.c @@ -59,9 +59,11 @@ cairo_surface_t * _cairo_test_wrapping_surface_create (cairo_surface_t *target) { test_wrapping_surface_t *surface; + cairo_status_t status; - if (unlikely (target->status)) - return _cairo_surface_create_in_error (target->status); + status = _cairo_surface_status (target); + if (unlikely (status)) + return _cairo_surface_create_in_error (status); surface = malloc (sizeof (test_wrapping_surface_t)); if (unlikely (surface == NULL)) |