mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-20 19:50:10 +01:00
cairo_script_context_t is an encapsulation object for interfacing with the output - multiple surfaces can share the same context, meaning that they write to the same destination file/stream.
39 lines
973 B
C
39 lines
973 B
C
#include <cairo-script.h>
|
|
#include <cairo-script-interpreter.h>
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <libgen.h>
|
|
|
|
static cairo_surface_t *
|
|
_script_surface_create (void *closure,
|
|
cairo_content_t content,
|
|
double width, double height)
|
|
{
|
|
return cairo_script_surface_create (closure, width, height);
|
|
}
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
cairo_script_interpreter_t *csi;
|
|
cairo_script_interpreter_hooks_t hooks = {
|
|
.surface_create = _script_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_script_context_destroy (hooks.closure);
|
|
hooks.closure = cairo_script_context_create (buf);
|
|
cairo_script_interpreter_install_hooks (csi, &hooks);
|
|
cairo_script_interpreter_run (csi, argv[i]);
|
|
}
|
|
cairo_script_context_destroy (hooks.closure);
|
|
|
|
return cairo_script_interpreter_destroy (csi);
|
|
}
|