summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-11 23:40:04 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 08:08:35 +0100
commit55eddb7ef4b6b561d6692a6f074834d5d5fb94fa (patch)
tree6b4c7e140c1691850d86d8c1eb29982b6551bbfd /util
parent4f129863df6392f3deaf6e76fd15adeba98e41b8 (diff)
[script] A little utility to convert a trace into a trace
Replay the trace using the interpreter onto a script surface - useful for checking idempotency.
Diffstat (limited to 'util')
-rw-r--r--util/cairo-script/Makefile.am6
-rw-r--r--util/cairo-script/csi-trace.c40
2 files changed, 46 insertions, 0 deletions
diff --git a/util/cairo-script/Makefile.am b/util/cairo-script/Makefile.am
index acde8f59..8b783a9a 100644
--- a/util/cairo-script/Makefile.am
+++ b/util/cairo-script/Makefile.am
@@ -28,5 +28,11 @@ csi_replay_LDADD = libcairo-script-interpreter.la $(top_builddir)/src/libcairo.l
csi_exec_SOURCES = csi-exec.c
csi_exec_LDADD = libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LIBS)
+if CAIRO_HAS_SCRIPT_SURFACE
+EXTRA_PROGRAMS += csi-trace
+csi_trace_SOURCES = csi-trace.c
+csi_trace_LDADD = libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LIBS)
+endif
+
EXTRA_DIST = \
COPYING
diff --git a/util/cairo-script/csi-trace.c b/util/cairo-script/csi-trace.c
new file mode 100644
index 00000000..418a3353
--- /dev/null
+++ b/util/cairo-script/csi-trace.c
@@ -0,0 +1,40 @@
+#include <cairo-script.h>
+#include <cairo-script-interpreter.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <libgen.h>
+
+static cairo_surface_t *
+_similar_surface_create (void *closure,
+ cairo_content_t content,
+ double width, double height)
+{
+ return cairo_surface_create_similar (closure, content, width, height);
+}
+
+int
+main (int argc, char **argv)
+{
+ cairo_script_interpreter_t *csi;
+ cairo_script_interpreter_hooks_t hooks = {
+ .surface_create = _similar_surface_create,
+ };
+ int i;
+
+ csi = cairo_script_interpreter_create ();
+
+ for (i = 1; i < argc; i++) {
+ char buf[4096];
+
+ snprintf (buf, sizeof (buf), "%s.trace", basename (argv[i]));
+
+ cairo_surface_destroy (hooks.closure);
+ hooks.closure = cairo_script_surface_create (buf, -1, -1);
+ cairo_script_interpreter_install_hooks (csi, &hooks);
+ cairo_script_interpreter_run (csi, argv[i]);
+ }
+ cairo_surface_destroy (hooks.closure);
+
+ return cairo_script_interpreter_destroy (csi);
+}