From 213d8f0e4e165554ad2c172c2b18cb29dfce9b76 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 23 Dec 2008 14:27:41 +0000 Subject: [PATCH] Store the PangoContext inside the main context The PangoContext should be stored once, and inside the main Clutter context. Each actor for which clutter_actor_get_pango_context() has been called will hold a reference on the Pango context as well. This makes it possible to update the text rendering for Clutter by using only public API. --- clutter/clutter-actor.c | 1 + clutter/clutter-main.c | 15 ++++++++++----- clutter/clutter-private.h | 7 ++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 7b550e9e9..50ea17b36 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -7613,6 +7613,7 @@ clutter_actor_get_pango_context (ClutterActor *self) ctx = CLUTTER_CONTEXT (); priv->pango_context = _clutter_context_create_pango_context (ctx); + g_object_ref (priv->pango_context); return priv->pango_context; } diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 9edbce8c6..5b6a8d357 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -408,16 +408,21 @@ _clutter_context_create_pango_context (ClutterMainContext *self) gdouble resolution; cairo_font_options_t *font_options; + if (G_LIKELY (self->pango_context != NULL)) + context = self->pango_context; + else + { + context = cogl_pango_font_map_create_context (self->font_map); + self->pango_context = context; + } + + font_options = clutter_backend_get_font_options (self->backend); resolution = clutter_backend_get_resolution (self->backend); if (resolution < 0) resolution = 96.0; /* fall back */ - context = cogl_pango_font_map_create_context (self->font_map); - - pango_cairo_context_set_resolution (context, resolution); - - font_options = clutter_backend_get_font_options (self->backend); pango_cairo_context_set_font_options (context, font_options); + pango_cairo_context_set_resolution (context, resolution); return context; } diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index fb8aea93b..383b7df88 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -126,10 +126,11 @@ struct _ClutterMainContext gint fb_r_mask, fb_g_mask, fb_b_mask; gint fb_r_mask_used, fb_g_mask_used, fb_b_mask_used; - CoglPangoFontMap *font_map; /* Global font map */ + PangoContext *pango_context; /* Global Pango context */ + CoglPangoFontMap *font_map; /* Global font map */ - GSList *input_devices; /* For extra input devices, i.e - MultiTouch */ + GSList *input_devices; /* For extra input devices, i.e + MultiTouch */ }; #define CLUTTER_CONTEXT() (clutter_context_get_default ())