diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-11-27 12:25:56 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-11-27 12:25:56 +0000 |
commit | 376d39121c0d4eba8f0a22be71f782ce18e50923 (patch) | |
tree | 0bf1f1d8279acd23c812c0a5196c4864807e7112 /util | |
parent | 62b795fe52c73ad58101c101aa77449f4b61a576 (diff) |
trace: Fix operand emission for map-to-image and unmap-image
Reported-by: Dongyeon Kim <dy5.kim@samsung.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'util')
-rw-r--r-- | util/cairo-trace/trace.c | 58 |
1 files changed, 34 insertions, 24 deletions
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c index f7945e7be..157534854 100644 --- a/util/cairo-trace/trace.c +++ b/util/cairo-trace/trace.c @@ -30,6 +30,7 @@ #include <dlfcn.h> #include <stdint.h> +#include <stdbool.h> #include <stdio.h> #include <string.h> #include <sys/types.h> @@ -937,13 +938,13 @@ ensure_operands (int num_operands) } static void -_consume_operand (void) +_consume_operand (bool discard) { Object *obj; ensure_operands (1); obj = current_object[--current_stack_depth]; - if (! obj->defined) { + if (!discard && ! obj->defined) { _trace_printf ("dup /%s%ld exch def\n", obj->type->op_code, obj->token); @@ -972,6 +973,9 @@ _pop_operands_to_object (Object *obj) if (obj->operand == -1) return FALSE; + if (obj->operand == current_stack_depth - 1) + return TRUE; + if (obj->operand == current_stack_depth - 2) { _exch_operands (); _trace_printf ("exch "); @@ -1935,7 +1939,7 @@ cairo_create (cairo_surface_t *target) /* we presume that we will continue to use the context */ if (_pop_operands_to (SURFACE, target)){ - _consume_operand (); + _consume_operand (false); } else { _trace_printf ("s%ld ", surface_id); } @@ -2168,14 +2172,14 @@ cairo_set_source_surface (cairo_t *cr, cairo_surface_t *surface, double x, doubl if (_is_current (SURFACE, surface, 0) && _is_current (CONTEXT, cr, 1)) { - _consume_operand (); + _consume_operand (false); } else if (_is_current (SURFACE, surface, 1) && _is_current (CONTEXT, cr, 0)) { _trace_printf ("exch "); _exch_operands (); - _consume_operand (); + _consume_operand (false); } else if (obj->defined) { _emit_context (cr); _trace_printf ("s%ld ", obj->token); @@ -2213,7 +2217,7 @@ cairo_set_source (cairo_t *cr, cairo_pattern_t *source) _is_current (CONTEXT, cr, 1)) { if (obj->defined) { - _consume_operand (); + _consume_operand (false); need_context_and_pattern = FALSE; } } @@ -2223,7 +2227,7 @@ cairo_set_source (cairo_t *cr, cairo_pattern_t *source) if (obj->defined) { _trace_printf ("exch "); _exch_operands (); - _consume_operand (); + _consume_operand (false); need_context_and_pattern = FALSE; } } @@ -2675,7 +2679,7 @@ cairo_mask (cairo_t *cr, cairo_pattern_t *pattern) _is_current (CONTEXT, cr, 1)) { if (obj->defined) { - _consume_operand (); + _consume_operand (false); need_context_and_pattern = FALSE; } } @@ -2685,7 +2689,7 @@ cairo_mask (cairo_t *cr, cairo_pattern_t *pattern) if (obj->defined) { _trace_printf ("exch "); _exch_operands (); - _consume_operand (); + _consume_operand (false); need_context_and_pattern = FALSE; } } @@ -2712,14 +2716,14 @@ cairo_mask_surface (cairo_t *cr, cairo_surface_t *surface, double x, double y) if (_is_current (SURFACE, surface, 0) && _is_current (CONTEXT, cr, 1)) { - _consume_operand (); + _consume_operand (false); } else if (_is_current (SURFACE, surface, 1) && _is_current (CONTEXT, cr, 0)) { _trace_printf ("exch "); _exch_operands (); - _consume_operand (); + _consume_operand (false); } else if (obj->defined){ _emit_context (cr); _trace_printf ("s%ld ", obj->token); @@ -2901,14 +2905,14 @@ cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face) if (_is_current (FONT_FACE, font_face, 0) && _is_current (CONTEXT, cr, 1)) { - _consume_operand (); + _consume_operand (false); } else if (_is_current (FONT_FACE, font_face, 1) && _is_current (CONTEXT, cr, 0)) { _trace_printf ("exch "); _exch_operands (); - _consume_operand (); + _consume_operand (false); } else { @@ -3071,14 +3075,14 @@ cairo_set_scaled_font (cairo_t *cr, const cairo_scaled_font_t *scaled_font) if (_pop_operands_to (SCALED_FONT, scaled_font)) { if (_is_current (CONTEXT, cr, 1)) { if (_write_lock ()) { - _consume_operand (); + _consume_operand (false); _trace_printf ("set-scaled-font\n"); _write_unlock (); } } else { if (_get_object (CONTEXT, cr)->defined) { if (_write_lock ()) { - _consume_operand (); + _consume_operand (false); _trace_printf ("c%ld exch set-scaled-font pop\n", _get_context_id (cr)); _write_unlock (); @@ -3135,7 +3139,7 @@ cairo_scaled_font_create (cairo_font_face_t *font_face, && _write_lock ()) { if (_pop_operands_to (FONT_FACE, font_face)) - _consume_operand (); + _consume_operand (false); else _trace_printf ("f%ld ", _get_font_face_id (font_face)); @@ -3662,15 +3666,18 @@ cairo_surface_map_to_image (cairo_surface_t *surface, if (_write_lock ()) { Object *obj = _create_surface (ret); + _emit_surface (surface); if (extents) { - _trace_printf ("[%d %d %d %d] map-to-image\n", + _trace_printf ("[%d %d %d %d] map-to-image %% s%ld\n", extents->x, extents->y, - extents->width, extents->height); + extents->width, extents->height, + obj->token); obj->width = extents->width; obj->height = extents->height; } else { - _trace_printf ("[ ] map-to-image\n"); + _trace_printf ("[ ] map-to-image %% s%ld\n", obj->token); } + _push_object (obj); _write_unlock (); } @@ -3687,10 +3694,13 @@ cairo_surface_unmap_image (cairo_surface_t *surface, _emit_line_info (); if (_write_lock ()) { - _trace_printf ("/s%ld /s%ld unmap-image\n", - _get_surface_id (surface), - _get_surface_id (image)); - _consume_operand (); + if (!(_get_object (SURFACE, surface)->operand == current_stack_depth - 2 && + _get_object (SURFACE, image)->operand == current_stack_depth - 1)) { + _emit_surface (surface); + _emit_surface (image); + } + _trace_printf ("unmap-image\n"); + _consume_operand (true); _write_unlock (); } @@ -4020,7 +4030,7 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface) surface_id = _get_surface_id (surface); if (_pop_operands_to (SURFACE, surface)) { - _consume_operand (); + _consume_operand (false); } else { _trace_printf ("s%ld ", surface_id); } |