[cairo-commit] 5 commits - src/cairo-xlib-display.c src/cairo-xlib-surface.c

Carl Worth cworth at kemper.freedesktop.org
Wed Jun 27 13:24:13 PDT 2007


 src/cairo-xlib-display.c |   11 ----------
 src/cairo-xlib-surface.c |   49 ++++++++++++++++++++++++-----------------------
 2 files changed, 26 insertions(+), 34 deletions(-)

New commits:
diff-tree 2bf3e31da99f34328973a0866346af40748097f6 (from eebb0df512da50f883a417bb5e8e368dc81e35a9)
Author: Carl Worth <cworth at cworth.org>
Date:   Wed Jun 27 11:11:36 2007 -0700

    Prefer local dpy variable instead of display->display
    
    This was a tiny piece of cleanup that had been erroneously included
    with some earlier functional changes, (so it went through a cycle
    of being applied and reverted). It's back now in its own commit.

diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index 5de9011..c7c3c43 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -405,6 +405,7 @@ void
 _cairo_xlib_display_notify (cairo_xlib_display_t *display)
 {
     cairo_xlib_job_t *jobs, *job, *freelist;
+    Display *dpy = display->display;
 
     CAIRO_MUTEX_LOCK (display->mutex);
     jobs = display->workqueue;
@@ -428,14 +429,13 @@ _cairo_xlib_display_notify (cairo_xlib_d
 
 	    switch (job->type){
 	    case WORK:
-		job->func.work.notify (display->display, job->func.work.data);
+		job->func.work.notify (dpy, job->func.work.data);
 		if (job->func.work.destroy != NULL)
 		    job->func.work.destroy (job->func.work.data);
 		break;
 
 	    case RESOURCE:
-		job->func.resource.notify (display->display,
-			                   job->func.resource.xid);
+		job->func.resource.notify (dpy, job->func.resource.xid);
 		break;
 	    }
 	} while (jobs != NULL);
diff-tree eebb0df512da50f883a417bb5e8e368dc81e35a9 (from b019cb8a7a910879c7af304edbd06fd105c9d89e)
Author: Carl Worth <cworth at cworth.org>
Date:   Wed Jun 27 11:08:53 2007 -0700

    Revert "[cairo-xlib-display] Hide XErrors during processing of the work queue."
    
    This reverts commit 285b702ef6f73e7eb4ca0da235a287ad1e1f412f.
    
    The recent commit of 0791f342b93225849d9171aac8b738014b18bdf5 fixes
    the same bug that 285b702e was fixing, but without introducing any
    performance-killing calls to XSync. So we can drop those now.

diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index 3ff633e..5de9011 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -405,13 +405,10 @@ void
 _cairo_xlib_display_notify (cairo_xlib_display_t *display)
 {
     cairo_xlib_job_t *jobs, *job, *freelist;
-    Display *dpy = display->display;
 
     CAIRO_MUTEX_LOCK (display->mutex);
     jobs = display->workqueue;
     while (jobs != NULL) {
-	cairo_xlib_error_func_t old_handler;
-
 	display->workqueue = NULL;
 	CAIRO_MUTEX_UNLOCK (display->mutex);
 
@@ -425,32 +422,24 @@ _cairo_xlib_display_notify (cairo_xlib_d
 	} while (jobs != NULL);
 	freelist = jobs = job;
 
-	/* protect the notifies from triggering XErrors
-	 * XXX There is a remote possibility that the application has
-	 * been reallocated an XID that we are about to destroy here... */
-	XSync (dpy, False);
-	old_handler = XSetErrorHandler (_noop_error_handler);
-
 	do {
 	    job = jobs;
 	    jobs = job->next;
 
 	    switch (job->type){
 	    case WORK:
-		job->func.work.notify (dpy, job->func.work.data);
+		job->func.work.notify (display->display, job->func.work.data);
 		if (job->func.work.destroy != NULL)
 		    job->func.work.destroy (job->func.work.data);
 		break;
 
 	    case RESOURCE:
-		job->func.resource.notify (dpy, job->func.resource.xid);
+		job->func.resource.notify (display->display,
+			                   job->func.resource.xid);
 		break;
 	    }
 	} while (jobs != NULL);
 
-	XSync (dpy, False);
-	XSetErrorHandler (old_handler);
-
 	CAIRO_MUTEX_LOCK (display->mutex);
 	do {
 	    job = freelist;
diff-tree b019cb8a7a910879c7af304edbd06fd105c9d89e (from 6d021eb4b6e319dd2bb3e5e126de07c6844d5c07)
Author: Carl Worth <cworth at cworth.org>
Date:   Wed Jun 27 11:07:07 2007 -0700

    Revert "[cairo-xlib-surface] Check for errors before installing a NOOP error handler."
    
    This reverts commit 7016614dd90798247524f0c118f462aa2e7ef673.
    
    We want to avoid any negative performance impacts due to extra calls
    to XSync. The fact that X errors can be missed with this appraoch is
    undesirable of course---a proper fix will likely involve moving to
    XCB which will hopefully allow us to do the error-checking the way
    we want without any performance penalty.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 131551e..39175bd 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -547,7 +547,6 @@ _get_image_surface (cairo_xlib_surface_t
     {
 	cairo_xlib_error_func_t old_handler;
 
-	XSync (surface->dpy, False);
 	old_handler = XSetErrorHandler (_noop_error_handler);
 
 	ximage = XGetImage (surface->dpy,
@@ -556,7 +555,6 @@ _get_image_surface (cairo_xlib_surface_t
 			    x2 - x1, y2 - y1,
 			    AllPlanes, ZPixmap);
 
-	XSync (surface->dpy, False);
 	XSetErrorHandler (old_handler);
 
 	/* If we get an error, the surface must have been a window,
diff-tree 6d021eb4b6e319dd2bb3e5e126de07c6844d5c07 (from parents)
Merge: 9109946a1a7f9341e60da7358da6535c5fac52db 0791f342b93225849d9171aac8b738014b18bdf5
Author: Carl Worth <cworth at cworth.org>
Date:   Wed Jun 27 11:01:00 2007 -0700

    Merge branch 'ooo-fix' into cairo

diff-tree 0791f342b93225849d9171aac8b738014b18bdf5 (from fea4f344c46cf5f85c6af3102333008768c55063)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jun 27 10:53:29 2007 -0700

    Avoid deferring resource cleanup for application drawables
    
    This eliminates X errors propagated from cairo due to cleaning up
    Render Pictures after the application had already destroyed the
    Drawable they reference. (It would be nice if the X server wouldn't
    complain that some cleanup work is already done, but there you
    have it.)
    
    This fix has been verified to fix the bug causing OpenOffice.org to
    crash as described here:
    
    	XError on right click menus in OOo.
    	https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=243811
    
    And unlike other proposed fixes for this bug, this fix does not
    introduce any new calls to XSync, (and thereby avoids performance
    concerns from those).

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index db5c155..f775005 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -273,30 +273,29 @@ _cairo_xlib_surface_finish (void *abstra
 				    NULL;
     cairo_status_t        status  = CAIRO_STATUS_SUCCESS;
 
-    if (surface->dst_picture != None) {
+    if (surface->owns_pixmap) {
 	cairo_status_t status2;
-	status2 = _cairo_xlib_display_queue_resource (display,
-		                                      XRenderFreePicture,
-						      surface->dst_picture);
-	if (status2 == CAIRO_STATUS_SUCCESS)
-	    surface->dst_picture = None;
-	else if (status == CAIRO_STATUS_SUCCESS)
-	    status = status2;
-    }
 
-    if (surface->src_picture != None) {
-	cairo_status_t status2;
-	status2 = _cairo_xlib_display_queue_resource (display,
-		                                      XRenderFreePicture,
-						      surface->src_picture);
-	if (status2 == CAIRO_STATUS_SUCCESS)
-	    surface->src_picture = None;
-	else if (status == CAIRO_STATUS_SUCCESS)
-	    status = status2;
-    }
+	if (surface->dst_picture != None) {
+	    status2 = _cairo_xlib_display_queue_resource (display,
+							  XRenderFreePicture,
+							  surface->dst_picture);
+	    if (status2 == CAIRO_STATUS_SUCCESS)
+		surface->dst_picture = None;
+	    else if (status == CAIRO_STATUS_SUCCESS)
+		status = status2;
+	}
+
+	if (surface->src_picture != None) {
+	    status2 = _cairo_xlib_display_queue_resource (display,
+							  XRenderFreePicture,
+							  surface->src_picture);
+	    if (status2 == CAIRO_STATUS_SUCCESS)
+		surface->src_picture = None;
+	    else if (status == CAIRO_STATUS_SUCCESS)
+		status = status2;
+	}
 
-    if (surface->owns_pixmap) {
-	cairo_status_t status2;
 	status2 = _cairo_xlib_display_queue_resource (display,
 		                           (cairo_xlib_notify_resource_func) XFreePixmap,
 					   surface->drawable);
@@ -305,6 +304,12 @@ _cairo_xlib_surface_finish (void *abstra
 	    surface->drawable = None;
 	} else if (status == CAIRO_STATUS_SUCCESS)
 	    status = status2;
+    } else {
+	if (surface->dst_picture != None)
+	    XRenderFreePicture (surface->dpy, surface->dst_picture);
+
+	if (surface->src_picture != None)
+	    XRenderFreePicture (surface->dpy, surface->src_picture);
     }
 
     if (surface->gc != NULL) {


More information about the cairo-commit mailing list