[cairo-commit] 3 commits - src/cairo-xlib-surface.c src/cairo-xlib-surface-private.h util/cairo-trace

Chris Wilson ickle at kemper.freedesktop.org
Wed Nov 19 09:12:45 PST 2008


 src/cairo-xlib-surface-private.h |    1 
 src/cairo-xlib-surface.c         |    6 +--
 util/cairo-trace/trace.c         |   71 ++++++++++++++++++++++-----------------
 3 files changed, 45 insertions(+), 33 deletions(-)

New commits:
commit 0d5e533b6cc43c4ebc030140933247cf160d47cd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Nov 19 17:03:13 2008 +0000

    [trace] Correctly push font-face onto the operand stack.
    
    We tried to push a reference to an undefined font-face, now we just copy
    from the operand stack.

diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index f94671b..b272dd8 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -779,6 +779,22 @@ _has_font_face_id (cairo_font_face_t *font_face)
     return _has_id (FONT_FACE, font_face);
 }
 
+static void
+_emit_font_face_id (cairo_font_face_t *font_face)
+{
+    Object *obj = _get_object (FONT_FACE, font_face);
+    if (obj == NULL) {
+	fprintf (logfile, "null ");
+    } else {
+	if (obj->defined) {
+	    fprintf (logfile, "f%ld ", obj->token);
+	} else {
+	    fprintf (logfile, "%d index ",
+		     current_stack_depth - obj->operand - 1);
+	}
+    }
+}
+
 static bool
 _has_pattern_id (cairo_pattern_t *pattern)
 {
@@ -2251,32 +2267,27 @@ void
 cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face)
 {
     _emit_line_info ();
-    if (cr != NULL && font_face != NULL) {
-	if (_pop_operands_to (FONT_FACE, font_face)) {
-	    if (_is_current (CONTEXT, cr, 1)) {
-		if (_write_lock ()) {
-		    _consume_operand ();
-		    fprintf (logfile, "set_font_face\n");
-		    _write_unlock ();
-		}
-	    } else {
-		if (_get_object (CONTEXT, cr)->defined) {
-		    if (_write_lock ()) {
-			_consume_operand ();
-			fprintf (logfile,
-				 "c%ld exch set_font_face pop\n",
-				 _get_context_id (cr));
-			_write_unlock ();
-		    }
-		} else {
-		    _emit_cairo_op (cr, "f%ld set_font_face\n",
-				    _get_font_face_id (font_face));
-		}
-	    }
-	} else {
-	    _emit_cairo_op (cr, "f%ld set_font_face\n",
-			    _get_font_face_id (font_face));
+    if (cr != NULL && font_face != NULL && _write_lock ()) {
+	if (_is_current (FONT_FACE, font_face, 0) &&
+	    _is_current (CONTEXT, cr, 1))
+	{
+	    _consume_operand ();
+	}
+	else if (_is_current (FONT_FACE, font_face, 1) &&
+		 _is_current (CONTEXT, cr, 0))
+	{
+	    fprintf (logfile, "exch ");
+	    _exch_operands ();
+	    _consume_operand ();
 	}
+	else
+	{
+	    _emit_context (cr);
+	    _emit_font_face_id (font_face);
+	}
+
+	fprintf (logfile, "set_font_face\n");
+	_write_unlock ();
     }
 
     return DLCALL (cairo_set_font_face, cr, font_face);
commit b426346b482e2687081433213ae107cb7b2ebe58
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Nov 19 16:04:57 2008 +0000

    [trace] Construct matrices directly
    
    Avoid building a temporary array by constructing the matrix directly.

diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index 30c915d..f94671b 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -1896,7 +1896,7 @@ void
 cairo_transform (cairo_t *cr, const cairo_matrix_t *matrix)
 {
     _emit_line_info ();
-    _emit_cairo_op (cr, "[%g %g %g %g %g %g] transform\n",
+    _emit_cairo_op (cr, "%g %g %g %g %g %g matrix transform\n",
 		    matrix->xx, matrix->yx,
 		    matrix->xy, matrix->yy,
 		    matrix->x0, matrix->y0);
@@ -1910,7 +1910,7 @@ cairo_set_matrix (cairo_t *cr, const cairo_matrix_t *matrix)
     if (_matrix_is_identity (matrix)) {
 	_emit_cairo_op (cr, "identity set_matrix\n");
     } else {
-	_emit_cairo_op (cr, "[%g %g %g %g %g %g] set_matrix\n",
+	_emit_cairo_op (cr, "%g %g %g %g %g %g matrix set_matrix\n",
 			matrix->xx, matrix->yx,
 			matrix->xy, matrix->yy,
 			matrix->x0, matrix->y0);
@@ -2294,7 +2294,7 @@ void
 cairo_set_font_matrix (cairo_t *cr, const cairo_matrix_t *matrix)
 {
     _emit_line_info ();
-    _emit_cairo_op (cr, "[%g %g %g %g %g %g] set_font_matrix\n",
+    _emit_cairo_op (cr, "%g %g %g %g %g %g matrix set_font_matrix\n",
 		    matrix->xx, matrix->yx,
 		    matrix->xy, matrix->yy,
 		    matrix->x0, matrix->y0);
@@ -2446,7 +2446,7 @@ _emit_matrix (const cairo_matrix_t *m)
     else
     {
 	fprintf (logfile,
-		 "[%g %g %g %g %g %g]",
+		 "%g %g %g %g %g %g matrix",
 		 m->xx, m->yx,
 		 m->xy, m->yy,
 		 m->x0, m->y0);
@@ -3169,7 +3169,7 @@ cairo_pattern_set_matrix (cairo_pattern_t *pattern, const cairo_matrix_t *matrix
 	_emit_pattern_op (pattern, "identity set_matrix\n");
     } else {
 	_emit_pattern_op (pattern,
-			  "[%g %g %g %g %g %g] set_matrix\n",
+			  "%g %g %g %g %g %g matrix set_matrix\n",
 			  matrix->xx, matrix->yx,
 			  matrix->xy, matrix->yy,
 			  matrix->x0, matrix->y0);
commit 727ff2bd7260f26c9390079258c43e6890ef2284
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Nov 19 14:25:20 2008 +0000

    [xlib] Explicitly track whether the GC has clip_rects.
    
    Simplify the logic and remove some pessimism from the code by explicitly
    tracking when we set clip rectangles on the GC.

diff --git a/src/cairo-xlib-surface-private.h b/src/cairo-xlib-surface-private.h
index e06fd97..87be9e6 100644
--- a/src/cairo-xlib-surface-private.h
+++ b/src/cairo-xlib-surface-private.h
@@ -85,6 +85,7 @@ struct _cairo_xlib_surface {
 
     unsigned int clip_dirty;
     cairo_bool_t have_clip_rects;
+    cairo_bool_t gc_has_clip_rects;
     XRectangle embedded_clip_rects[4];
     XRectangle *clip_rects;
     int num_clip_rects;
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 840e7f5..368f4e4 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -307,9 +307,7 @@ _cairo_xlib_surface_finish (void *abstract_surface)
 	status2 = _cairo_xlib_screen_put_gc (surface->screen_info,
 		                             surface->depth,
 				             surface->gc,
-				             surface->have_clip_rects |
-					     (surface->clip_dirty &
-					      CAIRO_XLIB_SURFACE_CLIP_DIRTY_GC));
+				             surface->gc_has_clip_rects);
 	surface->gc = NULL;
 	if (status == CAIRO_STATUS_SUCCESS)
 	    status = status2;
@@ -873,6 +871,7 @@ _cairo_xlib_surface_set_picture_clip_rects (cairo_xlib_surface_t *surface)
 static void
 _cairo_xlib_surface_set_gc_clip_rects (cairo_xlib_surface_t *surface)
 {
+    surface->gc_has_clip_rects = surface->have_clip_rects;
     if (surface->have_clip_rects) {
 	XSetClipRectangles(surface->dpy, surface->gc,
 			   0, 0,
@@ -2635,6 +2634,7 @@ _cairo_xlib_surface_create_internal (Display		       *dpy,
     surface->xtransform = identity;
 
     surface->have_clip_rects = FALSE;
+    surface->gc_has_clip_rects = FALSE;
     surface->clip_rects = surface->embedded_clip_rects;
     surface->num_clip_rects = 0;
     surface->clip_dirty = 0;


More information about the cairo-commit mailing list