diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-06 10:46:49 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-06 10:46:49 +0100 |
commit | 88986fdbef795c61cd60231046663d3cd80b4947 (patch) | |
tree | e5202d37e53ff28ea84a6c1f51e7d490dad66bcd /src/cairo-xlib-screen.c | |
parent | 632fabc77d89254e2e6915148fa870f23c2a5722 (diff) |
xlib: Remove reference counting for cairo_xlib_screen_t
The screen is owned by the cairo_xlib_display_t device, so we can
simplify and close the refleak by removing the surplus reference
counting.
Diffstat (limited to 'src/cairo-xlib-screen.c')
-rw-r--r-- | src/cairo-xlib-screen.c | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c index d1d9cf6c9..b094eaf4c 100644 --- a/src/cairo-xlib-screen.c +++ b/src/cairo-xlib-screen.c @@ -256,16 +256,6 @@ _cairo_xlib_init_screen_font_options (Display *dpy, cairo_font_options_set_hint_metrics (&info->font_options, CAIRO_HINT_METRICS_ON); } -cairo_xlib_screen_t * -_cairo_xlib_screen_reference (cairo_xlib_screen_t *info) -{ - assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&info->ref_count)); - - _cairo_reference_count_inc (&info->ref_count); - - return info; -} - void _cairo_xlib_screen_close_display (cairo_xlib_display_t *display, cairo_xlib_screen_t *info) @@ -274,37 +264,25 @@ _cairo_xlib_screen_close_display (cairo_xlib_display_t *display, int i; dpy = display->display; + for (i = 0; i < ARRAY_LENGTH (info->gc); i++) { if ((info->gc_depths >> (8*i)) & 0xff) XFreeGC (dpy, info->gc[i]); } info->gc_depths = 0; - - while (! cairo_list_is_empty (&info->visuals)) { - _cairo_xlib_visual_info_destroy (dpy, - cairo_list_first_entry (&info->visuals, - cairo_xlib_visual_info_t, - link)); - } } void _cairo_xlib_screen_destroy (cairo_xlib_screen_t *info) { - cairo_xlib_display_t *display; - - assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&info->ref_count)); - - if (! _cairo_reference_count_dec_and_test (&info->ref_count)) - return; - - if (! _cairo_xlib_display_acquire (info->device, &display)) { - _cairo_xlib_display_remove_screen (display, info); - _cairo_xlib_screen_close_display (display, info); - - cairo_device_release (&display->base); + while (! cairo_list_is_empty (&info->visuals)) { + _cairo_xlib_visual_info_destroy (cairo_list_first_entry (&info->visuals, + cairo_xlib_visual_info_t, + link)); } + cairo_list_del (&info->link); + free (info); } @@ -327,12 +305,9 @@ _cairo_xlib_screen_get (Display *dpy, if (unlikely (status)) goto CLEANUP_DEVICE; - status = _cairo_xlib_display_get_screen (display, screen, &info); - if (unlikely (status)) - goto CLEANUP_DISPLAY; - + info = _cairo_xlib_display_get_screen (display, screen); if (info != NULL) { - *out = _cairo_xlib_screen_reference (info); + *out = info; goto CLEANUP_DISPLAY; } @@ -342,7 +317,6 @@ _cairo_xlib_screen_get (Display *dpy, goto CLEANUP_DISPLAY; } - CAIRO_REFERENCE_COUNT_INIT (&info->ref_count, 2); /* Add one for display cache */ info->device = device; info->screen = screen; info->has_font_options = FALSE; @@ -350,8 +324,7 @@ _cairo_xlib_screen_get (Display *dpy, memset (info->gc, 0, sizeof (info->gc)); cairo_list_init (&info->visuals); - - _cairo_xlib_display_add_screen (display, info); + cairo_list_add (&info->link, &display->screens); *out = info; |