trace: Do not forcibly add surfaces to the dictionary

Adjust the stack manipulation to avoid moving an unknown surface to
the dictionary.

Reported-by: Dongyeon Kim <dy5.kim@samsung.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-11-27 12:25:56 +00:00
parent 376d39121c
commit dfbf80a57d

View file

@ -164,6 +164,7 @@ struct _object {
int width, height; int width, height;
cairo_bool_t foreign; cairo_bool_t foreign;
cairo_bool_t defined; cairo_bool_t defined;
cairo_bool_t unknown;
int operand; int operand;
void *data; void *data;
void (*destroy)(void *); void (*destroy)(void *);
@ -968,27 +969,18 @@ _exch_operands (void)
} }
static cairo_bool_t static cairo_bool_t
_pop_operands_to_object (Object *obj) _pop_operands_to_depth (int depth)
{ {
if (obj->operand == -1) while (current_stack_depth > depth) {
return FALSE;
if (obj->operand == current_stack_depth - 1)
return TRUE;
if (obj->operand == current_stack_depth - 2) {
_exch_operands ();
_trace_printf ("exch ");
return TRUE;
}
while (current_stack_depth > obj->operand + 1) {
Object *c_obj; Object *c_obj;
ensure_operands (1); ensure_operands (1);
c_obj = current_object[--current_stack_depth]; c_obj = current_object[--current_stack_depth];
c_obj->operand = -1; c_obj->operand = -1;
if (! c_obj->defined) { if (! c_obj->defined) {
if (c_obj->unknown)
return FALSE;
_trace_printf ("/%s%ld exch def\n", _trace_printf ("/%s%ld exch def\n",
c_obj->type->op_code, c_obj->type->op_code,
c_obj->token); c_obj->token);
@ -1002,6 +994,23 @@ _pop_operands_to_object (Object *obj)
return TRUE; return TRUE;
} }
static cairo_bool_t
_pop_operands_to_object (Object *obj)
{
if (obj->operand == -1)
return FALSE;
if (obj->operand == current_stack_depth - 1)
return TRUE;
if (! _pop_operands_to_depth (obj->operand + 2))
return FALSE;
_exch_operands ();
_trace_printf ("exch ");
return TRUE;
}
static cairo_bool_t static cairo_bool_t
_pop_operands_to (enum operand_type t, const void *ptr) _pop_operands_to (enum operand_type t, const void *ptr)
{ {
@ -3678,6 +3687,7 @@ cairo_surface_map_to_image (cairo_surface_t *surface,
_trace_printf ("[ ] map-to-image %% s%ld\n", obj->token); _trace_printf ("[ ] map-to-image %% s%ld\n", obj->token);
} }
obj->unknown = TRUE;
_push_object (obj); _push_object (obj);
_write_unlock (); _write_unlock ();
} }
@ -3694,11 +3704,15 @@ cairo_surface_unmap_image (cairo_surface_t *surface,
_emit_line_info (); _emit_line_info ();
if (_write_lock ()) { if (_write_lock ()) {
if (!(_get_object (SURFACE, surface)->operand == current_stack_depth - 2 && Object *s = _get_object (SURFACE, surface);
_get_object (SURFACE, image)->operand == current_stack_depth - 1)) { Object *i = _get_object (SURFACE, image);
if (!(s->operand == current_stack_depth - 2 &&
i->operand == current_stack_depth - 1)) {
if (i->operand != s->operand + 1 || ! _pop_operands_to_depth (i->operand + 1)) {
_emit_surface (surface); _emit_surface (surface);
_emit_surface (image); _emit_surface (image);
} }
}
_trace_printf ("unmap-image\n"); _trace_printf ("unmap-image\n");
_consume_operand (true); _consume_operand (true);
_write_unlock (); _write_unlock ();