summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2012-05-31 13:03:54 +0300
committerAlon Levy <alevy@redhat.com>2012-05-31 20:13:47 +0300
commit43e30b522f93dc00f0c98364aacf8115ec869787 (patch)
treef9b8802f64c5dfe1cb39886825860609d224af74
parentb4352b1dcd18c410fd61e65b7629f52959fd0f33 (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 fd62576..669a022 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)
{
@@ -691,6 +735,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;