[cairo-commit] 4 commits - boilerplate/cairo-boilerplate-gl.c configure.ac src/cairoint.h src/cairo-rtree-private.h

Chris Wilson ickle at kemper.freedesktop.org
Sun May 16 02:17:05 PDT 2010


 boilerplate/cairo-boilerplate-gl.c |  117 +++++++++++++++++++++++++++++++++++++
 configure.ac                       |    1 
 src/cairo-rtree-private.h          |    4 -
 src/cairoint.h                     |    2 
 4 files changed, 121 insertions(+), 3 deletions(-)

New commits:
commit 63062511f6755af9ddd2985250465f94ebc5a3e8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun May 16 10:15:42 2010 +0100

    boilerplate: Exercise manual double-buffering to a window
    
    Shouldn't possibly go wrong, but the mix of fbo and Window might prove
    interesting.

diff --git a/boilerplate/cairo-boilerplate-gl.c b/boilerplate/cairo-boilerplate-gl.c
index 5957da4..965beaa 100644
--- a/boilerplate/cairo-boilerplate-gl.c
+++ b/boilerplate/cairo-boilerplate-gl.c
@@ -37,6 +37,8 @@
 #include <X11/X.h>
 #include <X11/Xutil.h> /* for XDestroyImage */
 
+static const cairo_user_data_key_t gl_closure_key;
+
 typedef struct _gl_target_closure {
     Display *dpy;
     int screen;
@@ -222,9 +224,111 @@ _cairo_boilerplate_gl_create_window (const char			 *name,
     return surface;
 }
 
+static cairo_surface_t *
+_cairo_boilerplate_gl_create_window_db (const char		 *name,
+					cairo_content_t		  content,
+					double			  width,
+					double			  height,
+					double			  max_width,
+					double			  max_height,
+					cairo_boilerplate_mode_t  mode,
+					int			  id,
+					void			**closure)
+{
+    int rgba_attribs[] = { GLX_RGBA,
+			   GLX_RED_SIZE, 1,
+			   GLX_GREEN_SIZE, 1,
+			   GLX_BLUE_SIZE, 1,
+			   GLX_ALPHA_SIZE, 1,
+			   GLX_DOUBLEBUFFER,
+			   None };
+    XVisualInfo *vi;
+    GLXContext ctx;
+    gl_target_closure_t *gltc;
+    cairo_surface_t *surface;
+    Display *dpy;
+    XSetWindowAttributes attr;
+    cairo_status_t status;
+
+    gltc = calloc (1, sizeof (gl_target_closure_t));
+    *closure = gltc;
+
+    if (width == 0)
+	width = 1;
+    if (height == 0)
+	height = 1;
+
+    dpy = XOpenDisplay (NULL);
+    gltc->dpy = dpy;
+    if (!gltc->dpy) {
+	fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
+	free (gltc);
+	return NULL;
+    }
+
+    if (mode == CAIRO_BOILERPLATE_MODE_TEST)
+	XSynchronize (gltc->dpy, 1);
+
+    vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
+    if (vi == NULL) {
+	fprintf (stderr, "Failed to create RGBA, double-buffered visual\n");
+	XCloseDisplay (dpy);
+	free (gltc);
+	return NULL;
+    }
+
+    attr.colormap = XCreateColormap (dpy,
+				     RootWindow (dpy, vi->screen),
+				     vi->visual,
+				     AllocNone);
+    attr.border_pixel = 0;
+    attr.override_redirect = True;
+    gltc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
+				    width, height, 0, vi->depth,
+				    InputOutput, vi->visual,
+				    CWOverrideRedirect | CWBorderPixel | CWColormap,
+				    &attr);
+    XMapWindow (dpy, gltc->drawable);
+
+    ctx = glXCreateContext (dpy, vi, NULL, True);
+    XFree (vi);
+
+    gltc->ctx = ctx;
+    gltc->device = cairo_glx_device_create (dpy, ctx);
+
+    gltc->surface = cairo_gl_surface_create_for_window (gltc->device,
+							gltc->drawable,
+							ceil (width),
+							ceil (height));
+    surface = cairo_surface_create_similar (gltc->surface, content, width, height);
+    status = cairo_surface_set_user_data (surface, &gl_closure_key, gltc, NULL);
+    if (status == CAIRO_STATUS_SUCCESS)
+	return surface;
+
+    cairo_surface_destroy (surface);
+    _cairo_boilerplate_gl_cleanup (gltc);
+    return cairo_boilerplate_surface_create_in_error (status);
+}
+
 static cairo_status_t
 _cairo_boilerplate_gl_finish_window (cairo_surface_t		*surface)
 {
+    gl_target_closure_t *gltc = cairo_surface_get_user_data (surface,
+							     &gl_closure_key);
+
+    if (gltc != NULL && gltc->surface != NULL) {
+	cairo_t *cr;
+
+	cr = cairo_create (gltc->surface);
+	cairo_surface_set_device_offset (surface, 0, 0);
+	cairo_set_source_surface (cr, surface, 0, 0);
+	cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+	cairo_paint (cr);
+	cairo_destroy (cr);
+
+	surface = gltc->surface;
+    }
+
     cairo_gl_surface_swapbuffers (surface);
     return CAIRO_STATUS_SUCCESS;
 }
@@ -357,6 +461,19 @@ static const cairo_boilerplate_target_t targets[] = {
 	_cairo_boilerplate_gl_synchronize,
 	FALSE, FALSE, FALSE
     },
+    {
+	"gl-window&", "gl", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GL, CAIRO_CONTENT_COLOR_ALPHA, 1,
+	"cairo_gl_surface_create_for_window",
+	_cairo_boilerplate_gl_create_window_db,
+	NULL,
+	_cairo_boilerplate_gl_finish_window,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_gl_cleanup,
+	_cairo_boilerplate_gl_synchronize,
+	FALSE, FALSE, FALSE
+    },
 #if CAIRO_HAS_EGL_FUNCTIONS
     {
 	"egl", "gl", NULL, NULL,
commit 605be3182308ec7dfe15e9d89890c33800b1eea9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun May 16 10:11:02 2010 +0100

    cairo: Missing private markup for _cairo_format_to_pixman_format

diff --git a/src/cairoint.h b/src/cairoint.h
index d283c69..b52db6d 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2184,7 +2184,7 @@ cairo_private cairo_surface_t *
 _cairo_image_surface_create_for_pixman_image (pixman_image_t		*pixman_image,
 					      pixman_format_code_t	 pixman_format);
 
-pixman_format_code_t
+cairo_private pixman_format_code_t
 _cairo_format_to_pixman_format_code (cairo_format_t format);
 
 cairo_private cairo_bool_t
commit 14d6c3e054da89e47fc82ea29a708290eefe1357
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun May 16 10:07:07 2010 +0100

    configure: Include PTHREAD_CFLAGS in CAIRO_LDFLAGS
    
    Required for successful linking of our programs. I am not sure what the
    impact this has upon other users of Cairo yet, I think we need to export
    the PTHREAD_CFLAGS via cairo.pc as well.

diff --git a/configure.ac b/configure.ac
index 86c26ff..dc54b58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,7 @@ if test "x$have_pthread" = xno -a "x$use_pthread" = xyes; then
   AC_MSG_ERROR([pthread requested but not found])
 fi
 CAIRO_CFLAGS="$CAIRO_CFLAGS $PTHREAD_CFLAGS"
+CAIRO_LDFLAGS="$PTHREAD_CFLAGS $CAIRO_LDFLAGS"
 CAIRO_LIBS="$CAIRO_LIBS $PTHREAD_LIBS"
 
 dnl ===========================================================================
commit c3df7e6d58364f883d91567757ed999ea88e10ca
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun May 16 09:54:04 2010 +0100

    rtree: Replace undeclared TRUE/FALSE with 1/0

diff --git a/src/cairo-rtree-private.h b/src/cairo-rtree-private.h
index e539c0b..1457688 100644
--- a/src/cairo-rtree-private.h
+++ b/src/cairo-rtree-private.h
@@ -114,9 +114,9 @@ _cairo_rtree_evict_random (cairo_rtree_t	 *rtree,
 static inline void *
 _cairo_rtree_pin (cairo_rtree_t *rtree, cairo_rtree_node_t *node)
 {
-    if (node->pinned == FALSE) {
+    if (! node->pinned) {
 	cairo_list_move (&node->link, &rtree->pinned);
-	node->pinned = TRUE;
+	node->pinned = 0;
     }
 
     return node;


More information about the cairo-commit mailing list