summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-01-28 08:40:38 -0500
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-04-25 09:21:43 -0400
commit5538a28eb6f46a3e742d914425a1f6b47322a868 (patch)
tree0e32511dd3e35b6b0b05ee1a2798786d3cf86a8a
parent997449186ffbcbf480dd9c47e64f1efbf611c6cb (diff)
Beginning of replay program
-rw-r--r--trace/Makefile.am4
-rw-r--r--trace/pixman-replay.c109
-rw-r--r--trace/pixman-trace.c32
-rw-r--r--trace/trace.h30
4 files changed, 144 insertions, 31 deletions
diff --git a/trace/Makefile.am b/trace/Makefile.am
index 0694a79f..ed5557b0 100644
--- a/trace/Makefile.am
+++ b/trace/Makefile.am
@@ -3,3 +3,7 @@ libpixman_trace_la_SOURCES = pixman-trace.c
INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman $(PNG_CFLAGS)
libpixman_trace_la_LIBADD = -ldl
libpixman_trace_la_LDFLAGS = -no-undefined
+
+bin_PROGRAMS = pixman-replay
+
+pixman_replay_SOURCES = pixman-replay.c \ No newline at end of file
diff --git a/trace/pixman-replay.c b/trace/pixman-replay.c
new file mode 100644
index 00000000..f6140659
--- /dev/null
+++ b/trace/pixman-replay.c
@@ -0,0 +1,109 @@
+#include <config.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <stdint.h>
+#include <unistd.h>
+#include "pixman-private.h"
+#include "trace.h"
+
+static uint8_t *
+map_file (const char *filename, size_t *length, char **error)
+{
+ int fd = open (filename, O_RDONLY);
+ struct stat statbuf;
+ uint8_t *buffer = NULL;
+ *error = NULL;
+
+ if (fd < 0)
+ {
+ *error = "Could not open file\n";
+ goto out;
+ }
+
+ if (fstat (fd, &statbuf) < 0)
+ {
+ *error = "Could not stat file\n";
+ goto out;
+ }
+
+ buffer = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (buffer == MAP_FAILED)
+ {
+ *error = "Could not map file\n";
+ buffer = NULL;
+ goto out;
+ }
+
+ *length = statbuf.st_size;
+
+out:
+ close (fd);
+ return buffer;
+}
+
+static void
+pixman_replay (const char *filename)
+{
+ char *error;
+ uint32_t *buffer;
+ size_t length;
+
+ if (!(buffer = (uint32_t *)map_file (filename, &length, &error)))
+ {
+ printf ("%s\n", error);
+ return;
+ }
+
+ for (;;)
+ {
+ int32_t op = *buffer++;
+
+ switch (op)
+ {
+ case CREATE_SOLID_FILL:
+ case CREATE_LINEAR_GRADIENT:
+ case CREATE_RADIAL_GRADIENT:
+ case CREATE_CONICAL_GRADIENT:
+ case CREATE_BITS:
+ case DESTROY_IMAGE:
+ case SET_CLIP_REGION:
+ case SET_CLIP_REGION32:
+ case SET_HAS_CLIENT_CLIP:
+ case SET_TRANSFORM:
+ case SET_REPEAT:
+ case SET_FILTER:
+ case SET_SOURCE_CLIPPING:
+ case SET_ALPHA_MAP:
+ case SET_COMPONENT_ALPHA:
+ case SET_INDEXED:
+ case FILL_RECTANGLES:
+ case FILL_BOXES:
+ case COMPOSITE:
+ case COMPOSITE32:
+ case ADD_TRAPS:
+ case ADD_TRAPEZOIDS:
+ case RASTERIZE_TRAPEZOID:
+ case COMPOSITE_TRAPEZOIDS:
+ case COMPOSITE_TRIANGLES:
+ case ADD_TRIANGLES:
+ break;
+ }
+ }
+
+ munmap (buffer, length);
+}
+
+int
+main (int argc, char **argv)
+{
+ if (argc != 2)
+ {
+ printf ("Usage: pixman-replay filename\n");
+ return -1;
+ }
+
+ pixman_replay (argv[1]);
+ return 0;
+}
diff --git a/trace/pixman-trace.c b/trace/pixman-trace.c
index 83b7c2bd..93eeef24 100644
--- a/trace/pixman-trace.c
+++ b/trace/pixman-trace.c
@@ -24,41 +24,11 @@
#include <stdio.h>
#include <config.h>
#include "pixman-private.h"
+#include "trace.h"
/* FIXME: endianness */
-
-typedef enum
-{
- CREATE_SOLID_FILL,
- CREATE_LINEAR_GRADIENT,
- CREATE_RADIAL_GRADIENT,
- CREATE_CONICAL_GRADIENT,
- CREATE_BITS,
- DESTROY_IMAGE,
- SET_CLIP_REGION,
- SET_CLIP_REGION32,
- SET_HAS_CLIENT_CLIP,
- SET_TRANSFORM,
- SET_REPEAT,
- SET_FILTER,
- SET_SOURCE_CLIPPING,
- SET_ALPHA_MAP,
- SET_COMPONENT_ALPHA,
- SET_INDEXED,
- FILL_RECTANGLES,
- FILL_BOXES,
- COMPOSITE,
- COMPOSITE32,
- ADD_TRAPS,
- ADD_TRAPEZOIDS,
- RASTERIZE_TRAPEZOID,
- COMPOSITE_TRAPEZOIDS,
- COMPOSITE_TRIANGLES,
- ADD_TRIANGLES
-} opcode_t;
-
/* This macro is lifted from cairo-trace, written by Chris Wilson */
static void *_dlhandle = RTLD_NEXT;
diff --git a/trace/trace.h b/trace/trace.h
new file mode 100644
index 00000000..deb68f41
--- /dev/null
+++ b/trace/trace.h
@@ -0,0 +1,30 @@
+typedef enum
+{
+ CREATE_SOLID_FILL,
+ CREATE_LINEAR_GRADIENT,
+ CREATE_RADIAL_GRADIENT,
+ CREATE_CONICAL_GRADIENT,
+ CREATE_BITS,
+ DESTROY_IMAGE,
+ SET_CLIP_REGION,
+ SET_CLIP_REGION32,
+ SET_HAS_CLIENT_CLIP,
+ SET_TRANSFORM,
+ SET_REPEAT,
+ SET_FILTER,
+ SET_SOURCE_CLIPPING,
+ SET_ALPHA_MAP,
+ SET_COMPONENT_ALPHA,
+ SET_INDEXED,
+ FILL_RECTANGLES,
+ FILL_BOXES,
+ COMPOSITE,
+ COMPOSITE32,
+ ADD_TRAPS,
+ ADD_TRAPEZOIDS,
+ RASTERIZE_TRAPEZOID,
+ COMPOSITE_TRAPEZOIDS,
+ COMPOSITE_TRIANGLES,
+ ADD_TRIANGLES
+} opcode_t;
+