summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-05-31 13:03:54 +0300
committerAlon Levy <alevy@redhat.com>2012-06-15 10:34:57 +0300
commit22157d4750f9090927d2e3473aa3d3a4f5232792 (patch)
treee340b78376d5758695030c9c29edabcfe52fc527
parent0f817bb4e1b4e33ef50c0399c92f1cc091840ef5 (diff)
qxl_surface: add DEBUG_SURFACE_LIFECYCLE helpers
-rw-r--r--src/qxl_surface.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 3b2f9dc..a76db17 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -49,6 +49,12 @@
#include "qxl.h"
+#ifdef DEBUG_SURFACE_LIFECYCLE
+#include <stdio.h>
+
+static FILE* surface_log;
+#endif
+
typedef struct evacuated_surface_t evacuated_surface_t;
struct qxl_surface_t
@@ -122,6 +128,44 @@ struct surface_cache_t
qxl_surface_t *cached_surfaces[N_CACHED_SURFACES];
};
+#ifdef DEBUG_SURFACE_LIFECYCLE
+static void debug_surface_open(void)
+{
+ if (surface_log)
+ return;
+ surface_log = fopen("/tmp/xf86-video-qxl.surface.log", "w+");
+ if (!surface_log)
+ {
+ fprintf(stderr, "error creating surface log file (DEBUG_SURFACE_LIFECYCLE)\n");
+ exit(-1);
+ }
+}
+
+static int surface_count(qxl_surface_t *surface)
+{
+ int i;
+
+ for (i = 0; surface ;++i, surface = surface->next);
+ return i;
+}
+
+static void debug_surface_log(surface_cache_t *cache)
+{
+ int live_n, free_n;
+
+ debug_surface_open();
+ live_n = surface_count(cache->live_surfaces);
+ free_n = surface_count(cache->free_surfaces);
+ fprintf(surface_log, "live,free,sum = %d, %d, %d\n", live_n, free_n,
+ live_n + free_n);
+ fflush(surface_log);
+}
+
+#else
+#define debug_surface_log(cache)
+#endif
+
+
static Bool
surface_cache_init (surface_cache_t *cache, qxl_screen_t *qxl)
{
@@ -692,6 +736,8 @@ unlink_surface (qxl_surface_t *surface)
surface->prev->next = surface->next;
else
surface->cache->live_surfaces = surface->next;
+
+ debug_surface_log(surface->cache);
if (surface->next)
surface->next->prev = surface->prev;