diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-24 08:39:29 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-30 17:52:13 +0000 |
commit | a0023758104b700751ba8d7a66d75db139eea6cb (patch) | |
tree | 24885d61fb34c1ad4e9fec0918bc6087a85b5bff /src/cairo-xlib-screen.c | |
parent | 6706590d4e7ad19dae0b8e3efe6f573d5688e19a (diff) | |
download | cairo-a0023758104b700751ba8d7a66d75db139eea6cb.tar.gz |
[xlib] Defer querying of font options until first use
Constructing the font options cause the initialisation of Xlc and invoke
several round-trips to the X server, significantly delaying the creation
of the first surface. By deferring that operation until the first use of
fonts then we avoid that overhead for very simple applications (like the
test suite) and should improve start-up latency for larger application.
Diffstat (limited to 'src/cairo-xlib-screen.c')
-rw-r--r-- | src/cairo-xlib-screen.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c index f670b8ae7..a864fec22 100644 --- a/src/cairo-xlib-screen.c +++ b/src/cairo-xlib-screen.c @@ -144,7 +144,8 @@ get_integer_default (Display *dpy, #endif static void -_cairo_xlib_init_screen_font_options (Display *dpy, cairo_xlib_screen_info_t *info) +_cairo_xlib_init_screen_font_options (Display *dpy, + cairo_xlib_screen_info_t *info) { cairo_bool_t xft_hinting; cairo_bool_t xft_antialias; @@ -353,7 +354,7 @@ _cairo_xlib_screen_info_get (cairo_xlib_display_t *display, Screen *screen) info->display = _cairo_xlib_display_reference (display); info->screen = screen; info->has_render = FALSE; - _cairo_font_options_init_default (&info->font_options); + info->has_font_options = FALSE; memset (info->gc, 0, sizeof (info->gc)); info->gc_needs_clip_reset = 0; @@ -366,7 +367,6 @@ _cairo_xlib_screen_info_get (cairo_xlib_display_t *display, Screen *screen) info->has_render = (XRenderQueryExtension (dpy, &event_base, &error_base) && (XRenderFindVisualFormat (dpy, DefaultVisual (dpy, DefaultScreen (dpy))) != 0)); - _cairo_xlib_init_screen_font_options (dpy, info); } CAIRO_MUTEX_LOCK (display->mutex); @@ -502,3 +502,25 @@ _cairo_xlib_screen_get_visual_info (cairo_xlib_screen_info_t *info, *out = ret; return CAIRO_STATUS_SUCCESS; } + +cairo_font_options_t * +_cairo_xlib_screen_get_font_options (cairo_xlib_screen_info_t *info) +{ + if (info->has_font_options) + return &info->font_options; + + CAIRO_MUTEX_LOCK (info->mutex); + if (! info->has_font_options) { + Display *dpy = info->display->display; + + _cairo_font_options_init_default (&info->font_options); + + if (info->screen != NULL) + _cairo_xlib_init_screen_font_options (dpy, info); + + info->has_font_options = TRUE; + } + CAIRO_MUTEX_UNLOCK (info->mutex); + + return &info->font_options; +} |