[PATCH 1/4] cairo-trace: Fix mark-dirty with xcb-backend

Uli Schlachter psychon at znc.in
Sat Jul 16 07:47:30 PDT 2011


cairo-xcb's acquire_source_image implementation will attach the image it returns
as a snapshot to the xcb surface. cairo_surface_mark_dirty_rectangle asserts
that the surface doesn't have any snapshots attached. cairo-trace will emit the
surface to the trace when it was marked dirty.

The combination of these three things caused a failed assertion when cairo-trace
was used on something which uses xcb/Xlib and which uses mark_dirty.
I found this with firefox.

Signed-off-by: Uli Schlachter <psychon at znc.in>
---
 util/cairo-trace/trace.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index b8fd04e..3470c88 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -3584,6 +3584,12 @@ cairo_surface_mark_dirty (cairo_surface_t *surface)
 {
     _enter_trace ();
     _emit_line_info ();
+
+    /* Call cairo before emitting the trace since _emit_surface() might cause
+     * snapshots to be creates while mark_dirty assert()s that there are none.
+     */
+    DLCALL (cairo_surface_mark_dirty, surface);
+
     if (surface != NULL && _write_lock ()) {
 	if (_mark_dirty) {
 	    _emit_surface (surface);
@@ -3593,8 +3599,6 @@ cairo_surface_mark_dirty (cairo_surface_t *surface)
 	    _trace_printf ("%% s%ld mark-dirty\n", _get_surface_id (surface));
 	_write_unlock ();
     }
-
-    DLCALL (cairo_surface_mark_dirty, surface);
     _exit_trace ();
 }
 
@@ -3603,6 +3607,12 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
 				    int x, int y, int width, int height)
 {
     _enter_trace ();
+
+    /* Call cairo before emitting the trace since _emit_surface() might cause
+     * snapshots to be creates while mark_dirty assert()s that there are none.
+     */
+    DLCALL (cairo_surface_mark_dirty_rectangle, surface, x, y, width, height);
+
     _emit_line_info ();
     if (surface != NULL && _write_lock ()) {
 	if (_mark_dirty) {
@@ -3615,8 +3625,6 @@ cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface,
 		           _get_surface_id (surface), x, y, width, height);
 	_write_unlock ();
     }
-
-    DLCALL (cairo_surface_mark_dirty_rectangle, surface, x, y, width, height);
     _exit_trace ();
 }
 
-- 
1.7.5.4


--------------070103060506040806090300--


More information about the cairo mailing list