diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-06-11 15:18:55 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-07-23 16:18:42 +0100 |
commit | c3f2db4f73e93a3dafe0f52a5f9ca09ca78cc906 (patch) | |
tree | 5cb530cb949e950370c2ff4866c560b1a1075b6f /src/cairo-freelist-private.h | |
parent | bed2701e1c89095878d549cbca8f22d84f3dda3c (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-private.h')
-rw-r--r-- | src/cairo-freelist-private.h | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/src/cairo-freelist-private.h b/src/cairo-freelist-private.h index 48791c23..8f9f1534 100644 --- a/src/cairo-freelist-private.h +++ b/src/cairo-freelist-private.h @@ -25,18 +25,31 @@ #include "cairo-types-private.h" #include "cairo-compiler-private.h" -/* Opaque implementation types. */ -typedef struct _cairo_freelist cairo_freelist_t; -typedef struct _cairo_freelist_node cairo_freelist_node_t; +/* for stand-alone compilation*/ +#ifndef VG +#define VG(x) +#endif + +#ifndef NULL +#define NULL (void *) 0 +#endif +typedef struct _cairo_freelist_node cairo_freelist_node_t; struct _cairo_freelist_node { cairo_freelist_node_t *next; }; -struct _cairo_freelist { +typedef struct _cairo_freelist { cairo_freelist_node_t *first_free_node; unsigned nodesize; -}; +} cairo_freelist_t; + +typedef struct _cairo_freepool { + cairo_freelist_node_t *first_free_node; + cairo_freelist_node_t *pools; + unsigned nodesize; + char embedded_pool[1000]; +} cairo_freepool_t; /* Initialise a freelist that will be responsible for allocating @@ -68,4 +81,40 @@ _cairo_freelist_calloc (cairo_freelist_t *freelist); cairo_private void _cairo_freelist_free (cairo_freelist_t *freelist, void *node); + +cairo_private void +_cairo_freepool_init (cairo_freepool_t *freepool, unsigned nodesize); + +cairo_private void +_cairo_freepool_fini (cairo_freepool_t *freepool); + +cairo_private void * +_cairo_freepool_alloc_from_new_pool (cairo_freepool_t *freepool); + +static inline void * +_cairo_freepool_alloc (cairo_freepool_t *freepool) +{ + cairo_freelist_node_t *node; + + node = freepool->first_free_node; + if (unlikely (node == NULL)) + return _cairo_freepool_alloc_from_new_pool (freepool); + + VG (VALGRIND_MAKE_MEM_DEFINED (node, sizeof (node->next))); + freepool->first_free_node = node->next; + VG (VALGRIND_MAKE_MEM_UNDEFINED (node, freepool->nodesize)); + + return node; +} + +static inline void +_cairo_freepool_free (cairo_freepool_t *freepool, void *ptr) +{ + cairo_freelist_node_t *node = ptr; + + node->next = freepool->first_free_node; + freepool->first_free_node = node; + VG (VALGRIND_MAKE_MEM_NOACCESS (node, freepool->nodesize)); +} + #endif /* CAIRO_FREELIST_H */ |