summaryrefslogtreecommitdiff
path: root/src/cairo-xlib-display.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-07-30 17:28:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-09-12 08:29:48 +0100
commitaf9fbd176b145f042408ef5391eef2a51d7531f8 (patch)
tree5f75d1087d4325a013af6f0a4204a666fb4ca4f0 /src/cairo-xlib-display.c
parent0540bf384aed344899417d3b0313bd6704679c1c (diff)
downloadcairo-af9fbd176b145f042408ef5391eef2a51d7531f8.tar.gz
Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the compositors for various backends, we once again look for the commonalities in order to reduce the duplication. In part this is motivated by the idea that spans is a good interface for both the existent GL backend and pixman, and so they deserve a dedicated compositor. xcb/xlib target an identical rendering system and so they should be using the same compositor, and it should be possible to run that same compositor locally against pixman to generate reference tests. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> P.S. This brings massive upheaval (read breakage) I've tried delaying in order to fix as many things as possible but now this one patch does far, far, far too much. Apologies in advance for breaking your favourite backend, but trust me in that the end result will be much better. :)
Diffstat (limited to 'src/cairo-xlib-display.c')
-rw-r--r--src/cairo-xlib-display.c243
1 files changed, 25 insertions, 218 deletions
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index 3acc89372..fd7253cc2 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -47,52 +47,8 @@
typedef int (*cairo_xlib_error_func_t) (Display *display,
XErrorEvent *event);
-struct _cairo_xlib_job {
- cairo_xlib_job_t *next;
- enum {
- RESOURCE,
- WORK
- } type;
- union {
- struct {
- cairo_xlib_notify_resource_func notify;
- XID xid;
- } resource;
- struct {
- cairo_xlib_notify_func notify;
- void *data;
- void (*destroy) (void *);
- } work;
- } func;
-};
-
static cairo_xlib_display_t *_cairo_xlib_display_list;
-static void
-_cairo_xlib_remove_close_display_hook_internal (cairo_xlib_display_t *display,
- cairo_xlib_hook_t *hook);
-
-static void
-_cairo_xlib_call_close_display_hooks (cairo_xlib_display_t *display)
-{
- cairo_xlib_screen_t *screen;
- cairo_xlib_hook_t *hook;
-
- cairo_list_foreach_entry (screen, cairo_xlib_screen_t, &display->screens, link)
- _cairo_xlib_screen_close_display (display, screen);
-
- while (TRUE) {
- hook = display->close_display_hooks;
- if (hook == NULL)
- break;
-
- _cairo_xlib_remove_close_display_hook_internal (display, hook);
-
- hook->func (display, hook);
- }
- display->closed = TRUE;
-}
-
static int
_noop_error_handler (Display *display,
XErrorEvent *event)
@@ -101,59 +57,6 @@ _noop_error_handler (Display *display,
}
static void
-_cairo_xlib_display_notify (cairo_xlib_display_t *display)
-{
- cairo_xlib_job_t *jobs, *job, *freelist;
- Display *dpy = display->display;
-
- /* Optimistic atomic pointer read -- don't care if it is wrong due to
- * contention as we will check again very shortly.
- */
- if (display->workqueue == NULL)
- return;
-
- jobs = display->workqueue;
- while (jobs != NULL) {
- display->workqueue = NULL;
-
- /* reverse the list to obtain FIFO order */
- job = NULL;
- do {
- cairo_xlib_job_t *next = jobs->next;
- jobs->next = job;
- job = jobs;
- jobs = next;
- } while (jobs != NULL);
- freelist = jobs = job;
-
- do {
- job = jobs;
- jobs = job->next;
-
- switch (job->type){
- case WORK:
- job->func.work.notify (dpy, job->func.work.data);
- if (job->func.work.destroy != NULL)
- job->func.work.destroy (job->func.work.data);
- break;
-
- case RESOURCE:
- job->func.resource.notify (dpy, job->func.resource.xid);
- break;
- }
- } while (jobs != NULL);
-
- do {
- job = freelist;
- freelist = job->next;
- _cairo_freelist_free (&display->wq_freelist, job);
- } while (freelist != NULL);
-
- jobs = display->workqueue;
- }
-}
-
-static void
_cairo_xlib_display_finish (void *abstract_display)
{
cairo_xlib_display_t *display = abstract_display;
@@ -166,11 +69,18 @@ _cairo_xlib_display_finish (void *abstract_display)
XSync (dpy, False);
old_handler = XSetErrorHandler (_noop_error_handler);
- _cairo_xlib_display_notify (display);
- _cairo_xlib_call_close_display_hooks (display);
+ while (! cairo_list_is_empty (&display->fonts)) {
+ _cairo_xlib_font_close (cairo_list_first_entry (&display->fonts,
+ cairo_xlib_font_t,
+ link));
+ }
- /* catch any that arrived before marking the display as closed */
- _cairo_xlib_display_notify (display);
+ while (! cairo_list_is_empty (&display->screens)) {
+ _cairo_xlib_screen_destroy (display,
+ cairo_list_first_entry (&display->screens,
+ cairo_xlib_screen_t,
+ link));
+ }
XSync (dpy, False);
XSetErrorHandler (old_handler);
@@ -184,24 +94,6 @@ _cairo_xlib_display_destroy (void *abstract_display)
{
cairo_xlib_display_t *display = abstract_display;
- /* destroy all outstanding notifies */
- while (display->workqueue != NULL) {
- cairo_xlib_job_t *job = display->workqueue;
- display->workqueue = job->next;
-
- if (job->type == WORK && job->func.work.destroy != NULL)
- job->func.work.destroy (job->func.work.data);
-
- _cairo_freelist_free (&display->wq_freelist, job);
- }
- _cairo_freelist_fini (&display->wq_freelist);
-
- while (! cairo_list_is_empty (&display->screens)) {
- _cairo_xlib_screen_destroy (cairo_list_first_entry (&display->screens,
- cairo_xlib_screen_t,
- link));
- }
-
free (display);
}
@@ -340,15 +232,18 @@ _cairo_xlib_device_create (Display *dpy)
XESetCloseDisplay (dpy, codes->extension, _cairo_xlib_close_display);
- _cairo_freelist_init (&display->wq_freelist, sizeof (cairo_xlib_job_t));
-
cairo_device_reference (&display->base); /* add one for the CloseDisplay */
display->display = dpy;
cairo_list_init (&display->screens);
- display->workqueue = NULL;
- display->close_display_hooks = NULL;
+ cairo_list_init (&display->fonts);
display->closed = FALSE;
+ display->white = NULL;
+ memset (display->alpha, 0, sizeof (display->alpha));
+ memset (display->solid, 0, sizeof (display->solid));
+ memset (display->solid_cache, 0, sizeof (display->solid_cache));
+ memset (display->last_solid_cache, 0, sizeof (display->last_solid_cache));
+
memset (display->cached_xrender_formats, 0,
sizeof (display->cached_xrender_formats));
@@ -436,6 +331,13 @@ _cairo_xlib_device_create (Display *dpy)
display->buggy_pad_reflect = TRUE;
}
+ if (display->render_major > 0 || display->render_minor >= 4)
+ display->compositor = _cairo_xlib_traps_compositor_get ();
+ else if (display->render_major > 0 || display->render_minor >= 0)
+ display->compositor = _cairo_xlib_mask_compositor_get ();
+ else
+ display->compositor = _cairo_xlib_core_compositor_get ();
+
display->next = _cairo_xlib_display_list;
_cairo_xlib_display_list = display;
@@ -446,92 +348,6 @@ UNLOCK:
return device;
}
-void
-_cairo_xlib_add_close_display_hook (cairo_xlib_display_t *display,
- cairo_xlib_hook_t *hook)
-{
- hook->prev = NULL;
- hook->next = display->close_display_hooks;
- if (hook->next != NULL)
- hook->next->prev = hook;
- display->close_display_hooks = hook;
-}
-
-static void
-_cairo_xlib_remove_close_display_hook_internal (cairo_xlib_display_t *display,
- cairo_xlib_hook_t *hook)
-{
- if (display->close_display_hooks == hook)
- display->close_display_hooks = hook->next;
- else if (hook->prev != NULL)
- hook->prev->next = hook->next;
-
- if (hook->next != NULL)
- hook->next->prev = hook->prev;
-
- hook->prev = NULL;
- hook->next = NULL;
-}
-
-void
-_cairo_xlib_remove_close_display_hook (cairo_xlib_display_t *display,
- cairo_xlib_hook_t *hook)
-{
- _cairo_xlib_remove_close_display_hook_internal (display, hook);
-}
-
-cairo_status_t
-_cairo_xlib_display_queue_resource (cairo_xlib_display_t *display,
- cairo_xlib_notify_resource_func notify,
- XID xid)
-{
- cairo_xlib_job_t *job;
- cairo_status_t status = CAIRO_STATUS_NO_MEMORY;
-
- if (display->closed == FALSE) {
- job = _cairo_freelist_alloc (&display->wq_freelist);
- if (job != NULL) {
- job->type = RESOURCE;
- job->func.resource.xid = xid;
- job->func.resource.notify = notify;
-
- job->next = display->workqueue;
- display->workqueue = job;
-
- status = CAIRO_STATUS_SUCCESS;
- }
- }
-
- return status;
-}
-
-cairo_status_t
-_cairo_xlib_display_queue_work (cairo_xlib_display_t *display,
- cairo_xlib_notify_func notify,
- void *data,
- void (*destroy) (void *))
-{
- cairo_xlib_job_t *job;
- cairo_status_t status = CAIRO_STATUS_NO_MEMORY;
-
- if (display->closed == FALSE) {
- job = _cairo_freelist_alloc (&display->wq_freelist);
- if (job != NULL) {
- job->type = WORK;
- job->func.work.data = data;
- job->func.work.notify = notify;
- job->func.work.destroy = destroy;
-
- job->next = display->workqueue;
- display->workqueue = job;
-
- status = CAIRO_STATUS_SUCCESS;
- }
- }
-
- return status;
-}
-
cairo_status_t
_cairo_xlib_display_acquire (cairo_device_t *device, cairo_xlib_display_t **display)
{
@@ -542,7 +358,6 @@ _cairo_xlib_display_acquire (cairo_device_t *device, cairo_xlib_display_t **disp
return status;
*display = (cairo_xlib_display_t *) device;
- _cairo_xlib_display_notify (*display);
return status;
}
@@ -719,14 +534,6 @@ _cairo_xlib_display_get_screen (cairo_xlib_display_t *display,
return NULL;
}
-void
-_cairo_xlib_display_get_xrender_version (cairo_xlib_display_t *display,
- int *major, int *minor)
-{
- *major = display->render_major;
- *minor = display->render_minor;
-}
-
cairo_bool_t
_cairo_xlib_display_has_repeat (cairo_device_t *device)
{