summaryrefslogtreecommitdiff
path: root/src/cairo-pattern.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-pattern.c')
-rw-r--r--src/cairo-pattern.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index bdcafe7c..aa580d55 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -140,7 +140,7 @@ _cairo_gradient_pattern_init_copy (cairo_gradient_pattern_t *pattern,
{
pattern->stops = _cairo_malloc_ab (other->stops_size,
sizeof (cairo_gradient_stop_t));
- if (pattern->stops == NULL) {
+ if (unlikely (pattern->stops == NULL)) {
pattern->stops_size = 0;
pattern->n_stops = 0;
return _cairo_pattern_set_error (&pattern->base, CAIRO_STATUS_NO_MEMORY);
@@ -181,7 +181,7 @@ _cairo_pattern_init_copy (cairo_pattern_t *pattern,
cairo_status_t status;
status = _cairo_gradient_pattern_init_copy (dst, src);
- if (status)
+ if (unlikely (status))
return status;
} break;
@@ -203,7 +203,7 @@ _cairo_pattern_init_snapshot (cairo_pattern_t *pattern,
/* We don't bother doing any fancy copy-on-write implementation
* for the pattern's data. It's generally quite tiny. */
status = _cairo_pattern_init_copy (pattern, other);
- if (status)
+ if (unlikely (status))
return status;
/* But we do let the surface snapshot stuff be as fancy as it
@@ -272,11 +272,11 @@ _cairo_pattern_create_copy (cairo_pattern_t **pattern,
*pattern = malloc (sizeof (cairo_radial_pattern_t));
break;
}
- if (*pattern == NULL)
+ if (unlikely (*pattern == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
status = _cairo_pattern_init_copy (*pattern, other);
- if (status) {
+ if (unlikely (status)) {
free (*pattern);
return status;
}
@@ -379,18 +379,17 @@ _cairo_pattern_create_solid (const cairo_color_t *color,
CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_pattern_cache_lock);
- if (pattern == NULL) {
+ if (unlikely (pattern == NULL)) {
/* None cached, need to create a new pattern. */
pattern = malloc (sizeof (cairo_solid_pattern_t));
+ if (unlikely (pattern == NULL)) {
+ _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
+ return (cairo_pattern_t *) &_cairo_pattern_nil;
+ }
}
- if (pattern == NULL) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- pattern = (cairo_solid_pattern_t *) &_cairo_pattern_nil;
- } else {
- _cairo_pattern_init_solid (pattern, color, content);
- CAIRO_REFERENCE_COUNT_INIT (&pattern->base.ref_count, 1);
- }
+ _cairo_pattern_init_solid (pattern, color, content);
+ CAIRO_REFERENCE_COUNT_INIT (&pattern->base.ref_count, 1);
return &pattern->base;
}
@@ -535,7 +534,7 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface)
return (cairo_pattern_t*) _cairo_pattern_create_in_error (surface->status);
pattern = malloc (sizeof (cairo_surface_pattern_t));
- if (pattern == NULL) {
+ if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *)&_cairo_pattern_nil.base;
}
@@ -581,7 +580,7 @@ cairo_pattern_create_linear (double x0, double y0, double x1, double y1)
cairo_linear_pattern_t *pattern;
pattern = malloc (sizeof (cairo_linear_pattern_t));
- if (pattern == NULL) {
+ if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
}
@@ -629,7 +628,7 @@ cairo_pattern_create_radial (double cx0, double cy0, double radius0,
cairo_radial_pattern_t *pattern;
pattern = malloc (sizeof (cairo_radial_pattern_t));
- if (pattern == NULL) {
+ if (unlikely (pattern == NULL)) {
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
return (cairo_pattern_t *) &_cairo_pattern_nil.base;
}
@@ -846,11 +845,11 @@ _cairo_pattern_gradient_grow (cairo_gradient_pattern_t *pattern)
memcpy (new_stops, pattern->stops, old_size * sizeof (cairo_gradient_stop_t));
} else {
new_stops = _cairo_realloc_ab (pattern->stops,
- new_size,
+ new_size,
sizeof (cairo_gradient_stop_t));
}
- if (new_stops == NULL)
+ if (unlikely (new_stops == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
pattern->stops = new_stops;
@@ -872,7 +871,7 @@ _cairo_pattern_add_color_stop (cairo_gradient_pattern_t *pattern,
if (pattern->n_stops >= pattern->stops_size) {
cairo_status_t status = _cairo_pattern_gradient_grow (pattern);
- if (status) {
+ if (unlikely (status)) {
status = _cairo_pattern_set_error (&pattern->base, status);
return;
}
@@ -1063,7 +1062,7 @@ cairo_pattern_set_matrix (cairo_pattern_t *pattern,
inverse = *matrix;
status = cairo_matrix_invert (&inverse);
- if (status)
+ if (unlikely (status))
status = _cairo_pattern_set_error (pattern, status);
}
slim_hidden_def (cairo_pattern_set_matrix);
@@ -1255,8 +1254,9 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat
cairo_matrix_t matrix = pattern->base.matrix;
if (pattern->n_stops > ARRAY_LENGTH(pixman_stops_static)) {
- pixman_stops = _cairo_malloc_ab (pattern->n_stops, sizeof(pixman_gradient_stop_t));
- if (pixman_stops == NULL)
+ pixman_stops = _cairo_malloc_ab (pattern->n_stops,
+ sizeof(pixman_gradient_stop_t));
+ if (unlikely (pixman_stops == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -1340,7 +1340,7 @@ _cairo_pattern_acquire_surface_for_gradient (const cairo_gradient_pattern_t *pat
if (pixman_stops != pixman_stops_static)
free (pixman_stops);
- if (pixman_image == NULL)
+ if (unlikely (pixman_image == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
if (_cairo_surface_is_image (dst))
@@ -1519,7 +1519,7 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt
dst))
{
status = _cairo_surface_reset (solid_surface_cache.cache[i].surface);
- if (status)
+ if (unlikely (status))
goto UNLOCK;
goto DONE;
@@ -1531,7 +1531,7 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt
dst))
{
status = _cairo_surface_reset (solid_surface_cache.cache[i].surface);
- if (status)
+ if (unlikely (status))
goto UNLOCK;
goto DONE;
@@ -1551,11 +1551,11 @@ _cairo_pattern_acquire_surface_for_solid (const cairo_solid_pattern_t *patt
/* Reuse the surface instead of evicting */
status = _cairo_surface_reset (surface);
- if (status)
+ if (unlikely (status))
goto EVICT;
status = _cairo_surface_repaint_solid_pattern_surface (dst, surface, pattern);
- if (status)
+ if (unlikely (status))
goto EVICT;
cairo_surface_reference (surface);
@@ -1839,14 +1839,14 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
int w, h;
status = _cairo_surface_get_extents (surface, &extents);
- if (status)
+ if (unlikely (status))
goto BAIL;
status = _cairo_surface_clone_similar (dst, surface,
extents.x, extents.y,
extents.width, extents.height,
&extents.x, &extents.y, &src);
- if (status)
+ if (unlikely (status))
goto BAIL;
w = 2 * extents.width;
@@ -1914,14 +1914,14 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
cairo_surface_destroy (src);
- if (status)
+ if (unlikely (status))
goto BAIL;
attr->extend = CAIRO_EXTEND_REPEAT;
}
status = _cairo_surface_get_extents (surface, &extents);
- if (status)
+ if (unlikely (status))
goto BAIL;
/* We first transform the rectangle to the coordinate space of the
@@ -1969,7 +1969,7 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
extents.x, extents.y,
extents.width, extents.height,
&x, &y, out);
- if (status)
+ if (unlikely (status))
goto BAIL;
if (x != 0 || y != 0) {
@@ -2184,7 +2184,7 @@ _cairo_pattern_acquire_surfaces (const cairo_pattern_t *src,
src_x, src_y,
width, height,
src_out, src_attributes);
- if (status)
+ if (unlikely (status))
goto BAIL;
if (mask == NULL) {
@@ -2196,7 +2196,7 @@ _cairo_pattern_acquire_surfaces (const cairo_pattern_t *src,
mask_x, mask_y,
width, height,
mask_out, mask_attributes);
- if (status)
+ if (unlikely (status))
_cairo_pattern_release_surface (src, *src_out, src_attributes);
BAIL:
@@ -2237,7 +2237,7 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern,
status = _cairo_surface_get_extents (surface, &surface_extents);
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
goto UNBOUNDED;
- if (status)
+ if (unlikely (status))
return status;
/* The filter can effectively enlarge the extents of the