recording: Move the glyph allocation into the wrapper after checking clip status

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2011-07-24 15:10:18 +01:00
parent 59612847e3
commit 87e9c8a5ea
2 changed files with 60 additions and 49 deletions

View file

@ -959,35 +959,16 @@ _cairo_recording_surface_replay_internal (cairo_surface_t *surface,
break;
case CAIRO_COMMAND_SHOW_TEXT_GLYPHS:
{
cairo_glyph_t *glyphs = command->show_text_glyphs.glyphs;
cairo_glyph_t *glyphs_copy;
int num_glyphs = command->show_text_glyphs.num_glyphs;
/* show_text_glyphs is special because _cairo_surface_show_text_glyphs is allowed
* to modify the glyph array that's passed in. We must always
* copy the array before handing it to the backend.
*/
glyphs_copy = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (unlikely (glyphs_copy == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
break;
}
memcpy (glyphs_copy, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
status = _cairo_surface_wrapper_show_text_glyphs (&wrapper,
command->header.op,
&command->show_text_glyphs.source.base,
command->show_text_glyphs.utf8, command->show_text_glyphs.utf8_len,
glyphs_copy, num_glyphs,
command->show_text_glyphs.glyphs, command->show_text_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,
clip);
free (glyphs_copy);
break;
}
default:
ASSERT_NOT_REACHED;

View file

@ -134,7 +134,9 @@ _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper,
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
status = _cairo_surface_paint (wrapper->target, op, source, dev_clip);
status = CAIRO_INT_STATUS_NOTHING_TO_DO;
if (! _cairo_clip_is_all_clipped (dev_clip))
status = _cairo_surface_paint (wrapper->target, op, source, dev_clip);
FINISH:
_cairo_clip_destroy (target_clip);
@ -189,7 +191,9 @@ _cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
status = _cairo_surface_mask (wrapper->target, op, source, mask, dev_clip);
status = CAIRO_INT_STATUS_NOTHING_TO_DO;
if (! _cairo_clip_is_all_clipped (dev_clip))
status = _cairo_surface_mask (wrapper->target, op, source, mask, dev_clip);
FINISH:
_cairo_clip_destroy (target_clip);
@ -260,11 +264,14 @@ _cairo_surface_wrapper_stroke (cairo_surface_wrapper_t *wrapper,
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
status = _cairo_surface_stroke (wrapper->target, op, source,
dev_path, stroke_style,
&dev_ctm, &dev_ctm_inverse,
tolerance, antialias,
dev_clip);
status = CAIRO_INT_STATUS_NOTHING_TO_DO;
if (! _cairo_clip_is_all_clipped (dev_clip)) {
status = _cairo_surface_stroke (wrapper->target, op, source,
dev_path, stroke_style,
&dev_ctm, &dev_ctm_inverse,
tolerance, antialias,
dev_clip);
}
FINISH:
if (dev_path != path)
@ -346,15 +353,18 @@ _cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper,
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
status = _cairo_surface_fill_stroke (wrapper->target,
fill_op, fill_source, fill_rule,
fill_tolerance, fill_antialias,
dev_path,
stroke_op, stroke_source,
stroke_style,
&dev_ctm, &dev_ctm_inverse,
stroke_tolerance, stroke_antialias,
dev_clip);
status = CAIRO_INT_STATUS_NOTHING_TO_DO;
if (! _cairo_clip_is_all_clipped (dev_clip)) {
status = _cairo_surface_fill_stroke (wrapper->target,
fill_op, fill_source, fill_rule,
fill_tolerance, fill_antialias,
dev_path,
stroke_op, stroke_source,
stroke_style,
&dev_ctm, &dev_ctm_inverse,
stroke_tolerance, stroke_antialias,
dev_clip);
}
FINISH:
if (dev_path != path)
@ -419,10 +429,13 @@ _cairo_surface_wrapper_fill (cairo_surface_wrapper_t *wrapper,
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
status = _cairo_surface_fill (wrapper->target, op, source,
dev_path, fill_rule,
tolerance, antialias,
dev_clip);
status = CAIRO_INT_STATUS_NOTHING_TO_DO;
if (! _cairo_clip_is_all_clipped (dev_clip)) {
status = _cairo_surface_fill (wrapper->target, op, source,
dev_path, fill_rule,
tolerance, antialias,
dev_clip);
}
FINISH:
if (dev_path != path)
@ -467,17 +480,26 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
goto FINISH;
}
if (wrapper->extents.x | wrapper->extents.y) {
/* XXX */
dev_clip = _cairo_clip_copy_with_translation (dev_clip,
wrapper->extents.x,
wrapper->extents.y);
}
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
if (_cairo_clip_is_all_clipped (dev_clip))
return CAIRO_INT_STATUS_NOTHING_TO_DO;
if (wrapper->needs_transform) {
cairo_matrix_t m;
int i;
_cairo_surface_wrapper_get_transform (wrapper, &m);
/* XXX */
dev_clip = _cairo_clip_copy_with_translation (dev_clip,
wrapper->extents.x,
wrapper->extents.y);
dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (dev_glyphs == NULL) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
@ -494,10 +516,19 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
_copy_transformed_pattern (&source_copy.base, source, &m);
source = &source_copy.base;
}
} else {
/* show_text_glyphs is special because _cairo_surface_show_text_glyphs is allowed
* to modify the glyph array that's passed in. We must always
* copy the array before handing it to the backend.
*/
dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
if (unlikely (dev_glyphs == NULL)) {
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
goto FINISH;
}
if (wrapper->clip)
dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
memcpy (dev_glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
}
status = _cairo_surface_show_text_glyphs (wrapper->target, op, source,
utf8, utf8_len,
@ -506,7 +537,6 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
cluster_flags,
scaled_font,
dev_clip);
FINISH:
if (dev_clip != clip)
_cairo_clip_destroy (dev_clip);