[cairo-commit] boilerplate/cairo-boilerplate.c
boilerplate/cairo-boilerplate.h perf/cairo-perf.c
perf/cairo-perf.h perf/cairo-perf-posix.c
Carl Worth
cworth at kemper.freedesktop.org
Mon Sep 11 11:00:46 PDT 2006
boilerplate/cairo-boilerplate.c | 17 +++++++++++++++--
boilerplate/cairo-boilerplate.h | 4 ++++
perf/cairo-perf-posix.c | 12 ++++++++++++
perf/cairo-perf.c | 1 +
perf/cairo-perf.h | 7 +++++++
5 files changed, 39 insertions(+), 2 deletions(-)
New commits:
diff-tree cb6aed0a816cc5f09bb5660d4961ca196243eb10 (from e1a8a8b65a41691521d89fba7737c093dfdf7926)
Author: Carl Worth <cworth at cworth.org>
Date: Sat Sep 9 20:17:08 2006 -0700
perf: Make xlib testing wait for the X server to finish rendering.
We do this by adding a new cairo_perf_timer_set_finalize function and
in the case of the xlib backend passing a callback to that function
that does a 1x1 XGetImage.
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
old mode 100755
new mode 100644
index e525766..a6acd56
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -919,6 +919,17 @@ typedef struct _xlib_target_closure
cairo_bool_t drawable_is_pixmap;
} xlib_target_closure_t;
+static void
+boilerplate_xlib_wait_for_rendering (void *closure)
+{
+ xlib_target_closure_t *xtc = closure;
+ XImage *ximage;
+
+ ximage = XGetImage (xtc->dpy, xtc->drawable,
+ 0, 0, 1, 1, AllPlanes, ZPixmap);
+ XDestroyImage (ximage);
+}
+
/* For the xlib backend we distinguish between TEST and PERF mode in a
* couple of ways.
*
@@ -1478,9 +1489,11 @@ cairo_boilerplate_target_t targets[] =
#endif
#if CAIRO_HAS_XLIB_SURFACE
{ "xlib", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib},
+ create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib,
+ boilerplate_xlib_wait_for_rendering},
{ "xlib", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 0,
- create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib},
+ create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib,
+ boilerplate_xlib_wait_for_rendering},
#endif
#if CAIRO_HAS_PS_SURFACE
{ "ps", CAIRO_SURFACE_TYPE_PS,
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index a75bce9..26f4bec 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -107,6 +107,9 @@ typedef cairo_status_t
typedef void
(*cairo_boilerplate_cleanup_t) (void *closure);
+typedef void
+(*cairo_boilerplate_wait_t) (void *closure);
+
typedef struct _cairo_boilerplate_target
{
const char *name;
@@ -116,6 +119,7 @@ typedef struct _cairo_boilerplate_target
cairo_boilerplate_create_surface_t create_surface;
cairo_boilerplate_write_to_png_t write_to_png;
cairo_boilerplate_cleanup_t cleanup;
+ cairo_boilerplate_wait_t wait_for_rendering;
void *closure;
} cairo_boilerplate_target_t;
diff --git a/perf/cairo-perf-posix.c b/perf/cairo-perf-posix.c
index ac8512b..952ec45 100644
--- a/perf/cairo-perf-posix.c
+++ b/perf/cairo-perf-posix.c
@@ -130,8 +130,20 @@ cairo_perf_timer_start (void) {
#endif
}
+static cairo_perf_timer_finalize_t cairo_perf_timer_finalize = NULL;
+static void *cairo_perf_timer_finalize_closure = NULL;
+void
+cairo_perf_timer_set_finalize (cairo_perf_timer_finalize_t finalize,
+ void *closure)
+{
+ cairo_perf_timer_finalize = finalize;
+ cairo_perf_timer_finalize_closure = closure;
+}
+
void
cairo_perf_timer_stop (void) {
+ if (cairo_perf_timer_finalize)
+ cairo_perf_timer_finalize (cairo_perf_timer_finalize_closure);
#ifdef OIL_STAMP
timer.stop = OIL_STAMP ();
#else
diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 615acc9..976c0dc 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -162,6 +162,7 @@ main (int argc, char *argv[])
size, size,
CAIRO_BOILERPLATE_MODE_PERF,
&target->closure);
+ cairo_perf_timer_set_finalize (target->wait_for_rendering, target->closure);
cr = cairo_create (surface);
for (k =0; k < cairo_perf_iterations; k++) {
cairo_perf_yield ();
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index e365263..4b4071b 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -38,6 +38,13 @@ cairo_perf_timer_start (void);
void
cairo_perf_timer_stop (void);
+typedef void
+(*cairo_perf_timer_finalize_t) (void *closure);
+
+void
+cairo_perf_timer_set_finalize (cairo_perf_timer_finalize_t finalize,
+ void *closure);
+
typedef uint64_t cairo_perf_ticks_t;
cairo_perf_ticks_t
More information about the cairo-commit
mailing list