summaryrefslogtreecommitdiff
path: root/src/cairo-meta-surface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-meta-surface.c')
-rw-r--r--src/cairo-meta-surface.c116
1 files changed, 72 insertions, 44 deletions
diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c
index faf48558..0f6e6324 100644
--- a/src/cairo-meta-surface.c
+++ b/src/cairo-meta-surface.c
@@ -84,7 +84,7 @@ _cairo_meta_surface_create (cairo_content_t content,
cairo_meta_surface_t *meta;
meta = malloc (sizeof (cairo_meta_surface_t));
- if (meta == NULL)
+ if (unlikely (meta == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
_cairo_surface_init (&meta->base, &cairo_meta_surface_backend,
@@ -197,7 +197,7 @@ _cairo_meta_surface_acquire_source_image (void *abstract_surface,
surface->height_pixels);
status = _cairo_meta_surface_replay (&surface->base, image);
- if (status) {
+ if (unlikely (status)) {
cairo_surface_destroy (image);
return status;
}
@@ -219,26 +219,31 @@ _cairo_meta_surface_release_source_image (void *abstract_surface,
static cairo_int_status_t
_cairo_meta_surface_paint (void *abstract_surface,
cairo_operator_t op,
- const cairo_pattern_t *source)
+ const cairo_pattern_t *source,
+ cairo_rectangle_int_t *extents)
{
cairo_status_t status;
cairo_meta_surface_t *meta = abstract_surface;
cairo_command_paint_t *command;
command = malloc (sizeof (cairo_command_paint_t));
- if (command == NULL)
+ if (unlikely (command == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_PAINT;
command->header.region = CAIRO_META_REGION_ALL;
+ command->header.extents.x = 0;
+ command->header.extents.y = 0;
+ command->header.extents.width = meta->width_pixels;
+ command->header.extents.height = meta->height_pixels;
command->op = op;
status = _cairo_pattern_init_snapshot (&command->source.base, source);
- if (status)
+ if (unlikely (status))
goto CLEANUP_COMMAND;
status = _cairo_array_append (&meta->commands, &command);
- if (status)
+ if (unlikely (status))
goto CLEANUP_SOURCE;
/* An optimisation that takes care to not replay what was done
@@ -260,30 +265,35 @@ static cairo_int_status_t
_cairo_meta_surface_mask (void *abstract_surface,
cairo_operator_t op,
const cairo_pattern_t *source,
- const cairo_pattern_t *mask)
+ const cairo_pattern_t *mask,
+ cairo_rectangle_int_t *extents)
{
cairo_status_t status;
cairo_meta_surface_t *meta = abstract_surface;
cairo_command_mask_t *command;
command = malloc (sizeof (cairo_command_mask_t));
- if (command == NULL)
+ if (unlikely (command == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_MASK;
command->header.region = CAIRO_META_REGION_ALL;
+ command->header.extents.x = 0;
+ command->header.extents.y = 0;
+ command->header.extents.width = meta->width_pixels;
+ command->header.extents.height = meta->height_pixels;
command->op = op;
status = _cairo_pattern_init_snapshot (&command->source.base, source);
- if (status)
+ if (unlikely (status))
goto CLEANUP_COMMAND;
status = _cairo_pattern_init_snapshot (&command->mask.base, mask);
- if (status)
+ if (unlikely (status))
goto CLEANUP_SOURCE;
status = _cairo_array_append (&meta->commands, &command);
- if (status)
+ if (unlikely (status))
goto CLEANUP_MASK;
return CAIRO_STATUS_SUCCESS;
@@ -306,30 +316,35 @@ _cairo_meta_surface_stroke (void *abstract_surface,
cairo_matrix_t *ctm,
cairo_matrix_t *ctm_inverse,
double tolerance,
- cairo_antialias_t antialias)
+ cairo_antialias_t antialias,
+ cairo_rectangle_int_t *extents)
{
cairo_status_t status;
cairo_meta_surface_t *meta = abstract_surface;
cairo_command_stroke_t *command;
command = malloc (sizeof (cairo_command_stroke_t));
- if (command == NULL)
+ if (unlikely (command == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_STROKE;
command->header.region = CAIRO_META_REGION_ALL;
+ command->header.extents.x = 0;
+ command->header.extents.y = 0;
+ command->header.extents.width = meta->width_pixels;
+ command->header.extents.height = meta->height_pixels;
command->op = op;
status = _cairo_pattern_init_snapshot (&command->source.base, source);
- if (status)
+ if (unlikely (status))
goto CLEANUP_COMMAND;
status = _cairo_path_fixed_init_copy (&command->path, path);
- if (status)
+ if (unlikely (status))
goto CLEANUP_SOURCE;
status = _cairo_stroke_style_init_copy (&command->style, style);
- if (status)
+ if (unlikely (status))
goto CLEANUP_PATH;
command->ctm = *ctm;
@@ -338,7 +353,7 @@ _cairo_meta_surface_stroke (void *abstract_surface,
command->antialias = antialias;
status = _cairo_array_append (&meta->commands, &command);
- if (status)
+ if (unlikely (status))
goto CLEANUP_STYLE;
return CAIRO_STATUS_SUCCESS;
@@ -361,26 +376,31 @@ _cairo_meta_surface_fill (void *abstract_surface,
cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
double tolerance,
- cairo_antialias_t antialias)
+ cairo_antialias_t antialias,
+ cairo_rectangle_int_t *extents)
{
cairo_status_t status;
cairo_meta_surface_t *meta = abstract_surface;
cairo_command_fill_t *command;
command = malloc (sizeof (cairo_command_fill_t));
- if (command == NULL)
+ if (unlikely (command == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_FILL;
command->header.region = CAIRO_META_REGION_ALL;
+ command->header.extents.x = 0;
+ command->header.extents.y = 0;
+ command->header.extents.width = meta->width_pixels;
+ command->header.extents.height = meta->height_pixels;
command->op = op;
status = _cairo_pattern_init_snapshot (&command->source.base, source);
- if (status)
+ if (unlikely (status))
goto CLEANUP_COMMAND;
status = _cairo_path_fixed_init_copy (&command->path, path);
- if (status)
+ if (unlikely (status))
goto CLEANUP_SOURCE;
command->fill_rule = fill_rule;
@@ -388,7 +408,7 @@ _cairo_meta_surface_fill (void *abstract_surface,
command->antialias = antialias;
status = _cairo_array_append (&meta->commands, &command);
- if (status)
+ if (unlikely (status))
goto CLEANUP_PATH;
return CAIRO_STATUS_SUCCESS;
@@ -419,22 +439,27 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
const cairo_text_cluster_t *clusters,
int num_clusters,
cairo_text_cluster_flags_t cluster_flags,
- cairo_scaled_font_t *scaled_font)
+ cairo_scaled_font_t *scaled_font,
+ cairo_rectangle_int_t *extents)
{
cairo_status_t status;
cairo_meta_surface_t *meta = abstract_surface;
cairo_command_show_text_glyphs_t *command;
command = malloc (sizeof (cairo_command_show_text_glyphs_t));
- if (command == NULL)
+ if (unlikely (command == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_SHOW_TEXT_GLYPHS;
command->header.region = CAIRO_META_REGION_ALL;
+ command->header.extents.x = 0;
+ command->header.extents.y = 0;
+ command->header.extents.width = meta->width_pixels;
+ command->header.extents.height = meta->height_pixels;
command->op = op;
status = _cairo_pattern_init_snapshot (&command->source.base, source);
- if (status)
+ if (unlikely (status))
goto CLEANUP_COMMAND;
command->utf8 = NULL;
@@ -446,7 +471,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
if (utf8_len) {
command->utf8 = malloc (utf8_len);
- if (command->utf8 == NULL) {
+ if (unlikely (command->utf8 == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_ARRAYS;
}
@@ -454,7 +479,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
}
if (num_glyphs) {
command->glyphs = _cairo_malloc_ab (num_glyphs, sizeof (glyphs[0]));
- if (command->glyphs == NULL) {
+ if (unlikely (command->glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_ARRAYS;
}
@@ -462,7 +487,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
}
if (num_clusters) {
command->clusters = _cairo_malloc_ab (num_clusters, sizeof (clusters[0]));
- if (command->clusters == NULL) {
+ if (unlikely (command->clusters == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto CLEANUP_ARRAYS;
}
@@ -474,7 +499,7 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface,
command->scaled_font = cairo_scaled_font_reference (scaled_font);
status = _cairo_array_append (&meta->commands, &command);
- if (status)
+ if (unlikely (status))
goto CLEANUP_SCALED_FONT;
return CAIRO_STATUS_SUCCESS;
@@ -512,7 +537,7 @@ _cairo_meta_surface_snapshot (void *abstract_other)
cairo_meta_surface_t *meta;
meta = malloc (sizeof (cairo_meta_surface_t));
- if (meta == NULL)
+ if (unlikely (meta == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
_cairo_surface_init (&meta->base, &cairo_meta_surface_backend,
@@ -542,7 +567,7 @@ _cairo_meta_surface_intersect_clip_path (void *dst,
cairo_status_t status;
command = malloc (sizeof (cairo_command_intersect_clip_path_t));
- if (command == NULL)
+ if (unlikely (command == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
command->header.type = CAIRO_COMMAND_INTERSECT_CLIP_PATH;
@@ -550,7 +575,7 @@ _cairo_meta_surface_intersect_clip_path (void *dst,
if (path) {
status = _cairo_path_fixed_init_copy (&command->path, path);
- if (status) {
+ if (unlikely (status)) {
free (command);
return status;
}
@@ -565,7 +590,7 @@ _cairo_meta_surface_intersect_clip_path (void *dst,
command->antialias = antialias;
status = _cairo_array_append (&meta->commands, &command);
- if (status) {
+ if (unlikely (status)) {
if (path)
_cairo_path_fixed_fini (&command->path);
free (command);
@@ -622,6 +647,8 @@ static const cairo_surface_backend_t cairo_meta_surface_backend = {
NULL, /* composite */
NULL, /* fill_rectangles */
NULL, /* composite_trapezoids */
+ NULL, /* create_span_renderer */
+ NULL, /* check_span_renderer */
NULL, /* copy_page */
NULL, /* show_page */
NULL, /* set_clip_region */
@@ -741,7 +768,7 @@ _cairo_meta_surface_get_path (cairo_surface_t *surface,
ASSERT_NOT_REACHED;
}
- if (status)
+ if (unlikely (status))
break;
}
@@ -789,14 +816,14 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
* ensure the current clip gets set on the surface. */
if (command->header.type != CAIRO_COMMAND_INTERSECT_CLIP_PATH) {
status = _cairo_surface_set_clip (target, &clip);
- if (status)
+ if (unlikely (status))
break;
}
dev_path = _cairo_command_get_path (command);
if (dev_path && has_device_transform) {
status = _cairo_path_fixed_init_copy (&path_copy, dev_path);
- if (status)
+ if (unlikely (status))
break;
_cairo_path_fixed_transform (&path_copy, device_transform);
dev_path = &path_copy;
@@ -806,13 +833,13 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
case CAIRO_COMMAND_PAINT:
status = _cairo_surface_paint (target,
command->paint.op,
- &command->paint.source.base);
+ &command->paint.source.base, &command->header.extents);
break;
case CAIRO_COMMAND_MASK:
status = _cairo_surface_mask (target,
command->mask.op,
&command->mask.source.base,
- &command->mask.mask.base);
+ &command->mask.mask.base, &command->header.extents);
break;
case CAIRO_COMMAND_STROKE:
{
@@ -834,7 +861,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
&dev_ctm,
&dev_ctm_inverse,
command->stroke.tolerance,
- command->stroke.antialias);
+ command->stroke.antialias, &command->header.extents);
break;
}
case CAIRO_COMMAND_FILL:
@@ -881,7 +908,8 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
&dev_ctm,
&dev_ctm_inverse,
stroke_command->stroke.tolerance,
- stroke_command->stroke.antialias);
+ stroke_command->stroke.antialias,
+ &stroke_command->header.extents);
i++;
} else
status = _cairo_surface_fill (target,
@@ -890,7 +918,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
dev_path,
command->fill.fill_rule,
command->fill.tolerance,
- command->fill.antialias);
+ command->fill.antialias, &command->header.extents);
break;
}
case CAIRO_COMMAND_SHOW_TEXT_GLYPHS:
@@ -904,7 +932,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
* copy the array before handing it to the backend.
*/
dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
- if (dev_glyphs == NULL) {
+ if (unlikely (dev_glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
break;
}
@@ -927,7 +955,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
dev_glyphs, num_glyphs,
command->show_text_glyphs.clusters, command->show_text_glyphs.num_clusters,
command->show_text_glyphs.cluster_flags,
- command->show_text_glyphs.scaled_font);
+ command->show_text_glyphs.scaled_font, &command->header.extents);
free (dev_glyphs);
break;
@@ -960,7 +988,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface,
}
}
- if (status)
+ if (unlikely (status))
break;
}