[cairo-commit] util/cairo-trace
Chris Wilson
ickle at kemper.freedesktop.org
Tue Nov 27 04:27:52 PST 2012
util/cairo-trace/trace.c | 58 +++++++++++++++++++++++++++--------------------
1 file changed, 34 insertions(+), 24 deletions(-)
New commits:
commit 376d39121c0d4eba8f0a22be71f782ce18e50923
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Nov 27 12:25:56 2012 +0000
trace: Fix operand emission for map-to-image and unmap-image
Reported-by: Dongyeon Kim <dy5.kim at samsung.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index f7945e7..1575348 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);
}
More information about the cairo-commit
mailing list