summaryrefslogtreecommitdiff
path: root/src/cairo-freelist.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-06-11 15:18:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-23 16:18:42 +0100
commitc3f2db4f73e93a3dafe0f52a5f9ca09ca78cc906 (patch)
tree5cb530cb949e950370c2ff4866c560b1a1075b6f /src/cairo-freelist.c
parentbed2701e1c89095878d549cbca8f22d84f3dda3c (diff)
[drm] Add an accelerated image surface.
Use the DRM interface to h/w accelerate composition on image surfaces. The purpose of the backend is simply to explore what such a hardware interface might look like and what benefits we might expect. The use case that might justify writing such custom backends are embedded devices running a drm compositor like wayland - which would, for example, allow one to write applications that seamlessly integrated accelerated, dynamic, high quality 2D graphics using Cairo with advanced interaction (e.g. smooth animations in the UI) driven by a clutter framework... In this first step we introduce the fundamental wrapping of GEM for intel and radeon chipsets, and, for comparison, gallium. No acceleration, all we do is use buffer objects (that is use the kernel memory manager) to allocate images and simply use the fallback mechanism. This provides a suitable base to start writing chip specific drivers.
Diffstat (limited to 'src/cairo-freelist.c')
-rw-r--r--src/cairo-freelist.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/cairo-freelist.c b/src/cairo-freelist.c
index f6eb4fed..83647f20 100644
--- a/src/cairo-freelist.c
+++ b/src/cairo-freelist.c
@@ -82,3 +82,76 @@ _cairo_freelist_free (cairo_freelist_t *freelist, void *voidnode)
VG (VALGRIND_MAKE_MEM_NOACCESS (node, freelist->nodesize));
}
}
+
+
+void
+_cairo_freepool_init (cairo_freepool_t *freepool, unsigned nodesize)
+{
+ int poolsize;
+ char *ptr;
+
+ freepool->first_free_node = NULL;
+ freepool->pools = NULL;
+ freepool->nodesize = nodesize;
+
+ poolsize = sizeof (freepool->embedded_pool);
+ ptr = freepool->embedded_pool + poolsize - freepool->nodesize;
+
+ poolsize /= freepool->nodesize;
+ while (poolsize--) {
+ cairo_freelist_node_t *node = (cairo_freelist_node_t *) ptr;
+ ptr -= freepool->nodesize;
+
+ node->next = freepool->first_free_node;
+ freepool->first_free_node = node;
+ VG (VALGRIND_MAKE_MEM_NOACCESS (node, freepool->nodesize));
+ }
+}
+
+void
+_cairo_freepool_fini (cairo_freepool_t *freepool)
+{
+ cairo_freelist_node_t *node = freepool->pools;
+ while (node != NULL) {
+ cairo_freelist_node_t *next;
+
+ VG (VALGRIND_MAKE_MEM_DEFINED (node, sizeof (node->next)));
+ next = node->next;
+
+ free (node);
+ node = next;
+ }
+ VG (VALGRIND_MAKE_MEM_NOACCESS (freepool, sizeof (freepool)));
+}
+
+void *
+_cairo_freepool_alloc_from_new_pool (cairo_freepool_t *freepool)
+{
+ cairo_freelist_node_t *node;
+ char *ptr;
+ int poolsize;
+
+ poolsize = (128 * freepool->nodesize + 8191) & -8192;
+ node = malloc (poolsize);
+ if (node == NULL)
+ return node;
+
+ node->next = freepool->pools;
+ freepool->pools = node;
+
+ ptr = (char *) node + poolsize - freepool->nodesize;
+
+ poolsize -= sizeof (cairo_freelist_node_t);
+ poolsize /= freepool->nodesize;
+
+ while (--poolsize) {
+ node = (cairo_freelist_node_t *) ptr;
+ ptr -= freepool->nodesize;
+
+ node->next = freepool->first_free_node;
+ freepool->first_free_node = node;
+ VG (VALGRIND_MAKE_MEM_NOACCESS (node, freepool->nodesize));
+ }
+
+ return ptr;
+}