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.
This commit is contained in:
Emmanuele Bassi 2008-12-23 14:27:41 +00:00
parent 61d47ee301
commit 213d8f0e4e
3 changed files with 15 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 ())