~ubuntu-branches/ubuntu/intrepid/cairo/intrepid-updates

« back to all changes in this revision

Viewing changes to src/cairo-xlib-display.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin
  • Date: 2008-09-25 16:22:33 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20080925162233-btx61ymk181i7mcc
Tags: 1.7.6-0ubuntu1
* New upstream version. Most noticable changes are:
  - some API changes with especially the removal of
    cairo_font_options_set_lcd_filter and cairo_font_options_get_lcd_filter
  - xlib: Faster bookkeeping
  - PS: Fix gradients with non-constant alpha
  - Fix deadlock in user-font code
* debian/patches/00list: Remove 03_from_git_fix_lcd_filter_default.dpatch,
  add debian/patches/03_fix_ftbfs_withing_xcb.dpatch
* debian/libcairo2.symbols, debian/libcairo-directfb2.symbols: update
  list of symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 *
30
30
 * The Initial Developer of the Original Code is Chris Wilson.
31
31
 *
 
32
 * Contributor(s):
 
33
 *      Karl Tomlinson <karlt+@karlt.net>, Mozilla Corporation
32
34
 */
33
35
 
34
36
#include "cairoint.h"
65
67
static cairo_xlib_display_t *_cairo_xlib_display_list;
66
68
 
67
69
static void
 
70
_cairo_xlib_remove_close_display_hook_internal (cairo_xlib_display_t *display,
 
71
                                                cairo_xlib_hook_t *hook);
 
72
 
 
73
static void
68
74
_cairo_xlib_call_close_display_hooks (cairo_xlib_display_t *display)
69
75
{
70
76
    cairo_xlib_screen_info_t        *screen;
71
 
    cairo_xlib_hook_t               *hooks, *list;
 
77
    cairo_xlib_hook_t               *hook;
72
78
 
73
79
    /* call all registered shutdown routines */
74
80
    CAIRO_MUTEX_LOCK (display->mutex);
76
82
    for (screen = display->screens; screen != NULL; screen = screen->next)
77
83
        _cairo_xlib_screen_info_close_display (screen);
78
84
 
79
 
    hooks = display->close_display_hooks;
80
 
    while (hooks != NULL) {
81
 
        display->close_display_hooks = NULL;
 
85
    while (TRUE) {
 
86
        hook = display->close_display_hooks;
 
87
        if (hook == NULL)
 
88
            break;
 
89
 
 
90
        _cairo_xlib_remove_close_display_hook_internal (display, hook);
 
91
 
82
92
        CAIRO_MUTEX_UNLOCK (display->mutex);
83
 
 
84
 
        list = hooks;
85
 
        do {
86
 
            cairo_xlib_hook_t *hook = list;
87
 
            list = hook->next;
88
 
 
89
 
            hook->func (display->display, hook->data);
90
 
        } while (list != NULL);
91
 
 
 
93
        hook->func (display, hook);
92
94
        CAIRO_MUTEX_LOCK (display->mutex);
93
 
        do {
94
 
            cairo_xlib_hook_t *hook = hooks;
95
 
            hooks = hook->next;
96
 
 
97
 
            _cairo_freelist_free (&display->hook_freelist, hook);
98
 
        } while (hooks != NULL);
99
 
 
100
 
        hooks = display->close_display_hooks;
101
95
    }
102
96
    display->closed = TRUE;
103
97
 
151
145
        _cairo_freelist_free (&display->wq_freelist, job);
152
146
    }
153
147
    _cairo_freelist_fini (&display->wq_freelist);
154
 
    _cairo_freelist_fini (&display->hook_freelist);
155
148
 
156
149
    CAIRO_MUTEX_FINI (display->mutex);
157
150
 
277
270
    XESetCloseDisplay (dpy, codes->extension, _cairo_xlib_close_display);
278
271
 
279
272
    _cairo_freelist_init (&display->wq_freelist, sizeof (cairo_xlib_job_t));
280
 
    _cairo_freelist_init (&display->hook_freelist, sizeof (cairo_xlib_hook_t));
281
273
 
282
274
    CAIRO_REFERENCE_COUNT_INIT (&display->ref_count, 2); /* add one for the CloseDisplay */
283
275
    CAIRO_MUTEX_INIT (display->mutex);
325
317
    return display;
326
318
}
327
319
 
328
 
cairo_bool_t
329
 
_cairo_xlib_add_close_display_hook (Display *dpy, void (*func) (Display *, void *), void *data, const void *key)
330
 
{
331
 
    cairo_xlib_display_t *display;
332
 
    cairo_xlib_hook_t *hook;
333
 
    cairo_bool_t ret = FALSE;
334
 
 
335
 
    display = _cairo_xlib_display_get (dpy);
336
 
    if (display == NULL)
337
 
        return FALSE;
338
 
 
339
 
    CAIRO_MUTEX_LOCK (display->mutex);
340
 
    if (display->closed == FALSE) {
341
 
        hook = _cairo_freelist_alloc (&display->hook_freelist);
342
 
        if (hook != NULL) {
343
 
            hook->func = func;
344
 
            hook->data = data;
345
 
            hook->key = key;
346
 
 
347
 
            hook->next = display->close_display_hooks;
348
 
            display->close_display_hooks = hook;
349
 
            ret = TRUE;
350
 
        }
351
 
    }
352
 
    CAIRO_MUTEX_UNLOCK (display->mutex);
353
 
 
354
 
    _cairo_xlib_display_destroy (display);
355
 
 
356
 
    return ret;
357
 
}
358
 
 
359
 
void
360
 
_cairo_xlib_remove_close_display_hooks (Display *dpy, const void *key)
361
 
{
362
 
    cairo_xlib_display_t *display;
363
 
    cairo_xlib_hook_t *hook, *next, **prev;
364
 
 
365
 
    display = _cairo_xlib_display_get (dpy);
366
 
    if (display == NULL)
367
 
        return;
368
 
 
369
 
    CAIRO_MUTEX_LOCK (display->mutex);
370
 
    prev = &display->close_display_hooks;
371
 
    for (hook = display->close_display_hooks; hook != NULL; hook = next) {
372
 
        next = hook->next;
373
 
        if (hook->key == key) {
374
 
            *prev = hook->next;
375
 
            _cairo_freelist_free (&display->hook_freelist, hook);
376
 
        } else
377
 
            prev = &hook->next;
378
 
    }
379
 
    *prev = NULL;
380
 
    CAIRO_MUTEX_UNLOCK (display->mutex);
381
 
 
382
 
    _cairo_xlib_display_destroy (display);
 
320
void
 
321
_cairo_xlib_add_close_display_hook (cairo_xlib_display_t        *display,
 
322
                                    cairo_xlib_hook_t           *hook)
 
323
{
 
324
    CAIRO_MUTEX_LOCK (display->mutex);
 
325
    hook->prev = NULL;
 
326
    hook->next = display->close_display_hooks;
 
327
    if (hook->next != NULL)
 
328
        hook->next->prev = hook;
 
329
    display->close_display_hooks = hook;
 
330
    CAIRO_MUTEX_UNLOCK (display->mutex);
 
331
}
 
332
 
 
333
/* display->mutex must be held */
 
334
static void
 
335
_cairo_xlib_remove_close_display_hook_internal (cairo_xlib_display_t *display,
 
336
                                                cairo_xlib_hook_t *hook)
 
337
{
 
338
    if (display->close_display_hooks == hook)
 
339
        display->close_display_hooks = hook->next;
 
340
    else if (hook->prev != NULL)
 
341
        hook->prev->next = hook->next;
 
342
 
 
343
    if (hook->next != NULL)
 
344
        hook->next->prev = hook->prev;
 
345
 
 
346
    hook->prev = NULL;
 
347
    hook->next = NULL;
 
348
}
 
349
 
 
350
void
 
351
_cairo_xlib_remove_close_display_hook (cairo_xlib_display_t     *display,
 
352
                                       cairo_xlib_hook_t        *hook)
 
353
{
 
354
    CAIRO_MUTEX_LOCK (display->mutex);
 
355
    _cairo_xlib_remove_close_display_hook_internal (display, hook);
 
356
    CAIRO_MUTEX_UNLOCK (display->mutex);
383
357
}
384
358
 
385
359
cairo_status_t