Clean up usage of CLUTTER_CONTEXT and remove the macro
Only allow access to the ClutterMainContext through the private _clutter_context_get_default() function, so we can easily grep it and remove the unwanted usage of the global context.
This commit is contained in:
parent
689aac56c9
commit
37fe8c509a
@ -667,13 +667,15 @@ result:
|
|||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglPangoFontMap *
|
static CoglPangoFontMap *
|
||||||
_clutter_context_get_pango_fontmap (ClutterMainContext *self)
|
clutter_context_get_pango_fontmap (void)
|
||||||
{
|
{
|
||||||
|
ClutterMainContext *self;
|
||||||
CoglPangoFontMap *font_map;
|
CoglPangoFontMap *font_map;
|
||||||
gdouble resolution;
|
gdouble resolution;
|
||||||
gboolean use_mipmapping;
|
gboolean use_mipmapping;
|
||||||
|
|
||||||
|
self = _clutter_context_get_default ();
|
||||||
if (G_LIKELY (self->font_map != NULL))
|
if (G_LIKELY (self->font_map != NULL))
|
||||||
return self->font_map;
|
return self->font_map;
|
||||||
|
|
||||||
@ -793,14 +795,13 @@ _clutter_context_get_pango_context (void)
|
|||||||
PangoContext *
|
PangoContext *
|
||||||
_clutter_context_create_pango_context (void)
|
_clutter_context_create_pango_context (void)
|
||||||
{
|
{
|
||||||
ClutterMainContext *self = _clutter_context_get_default ();
|
|
||||||
CoglPangoFontMap *font_map;
|
CoglPangoFontMap *font_map;
|
||||||
PangoContext *context;
|
PangoContext *context;
|
||||||
|
|
||||||
font_map = _clutter_context_get_pango_fontmap (self);
|
font_map = clutter_context_get_pango_fontmap ();
|
||||||
|
|
||||||
context = cogl_pango_font_map_create_context (font_map);
|
context = cogl_pango_font_map_create_context (font_map);
|
||||||
update_pango_context (self->backend, context);
|
update_pango_context (clutter_get_default_backend (), context);
|
||||||
pango_context_set_language (context, pango_language_get_default ());
|
pango_context_set_language (context, pango_language_get_default ());
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
@ -872,10 +873,7 @@ clutter_main (void)
|
|||||||
if (clutter_main_loop_level == 0)
|
if (clutter_main_loop_level == 0)
|
||||||
CLUTTER_TIMER_START (uprof_get_mainloop_context (), mainloop_timer);
|
CLUTTER_TIMER_START (uprof_get_mainloop_context (), mainloop_timer);
|
||||||
|
|
||||||
/* Make sure there is a context */
|
if (!_clutter_context_is_initialized ())
|
||||||
CLUTTER_CONTEXT ();
|
|
||||||
|
|
||||||
if (!clutter_is_initialized)
|
|
||||||
{
|
{
|
||||||
g_warning ("Called clutter_main() but Clutter wasn't initialised. "
|
g_warning ("Called clutter_main() but Clutter wasn't initialised. "
|
||||||
"You must call clutter_init() first.");
|
"You must call clutter_init() first.");
|
||||||
@ -2872,8 +2870,11 @@ void
|
|||||||
clutter_clear_glyph_cache (void)
|
clutter_clear_glyph_cache (void)
|
||||||
{
|
{
|
||||||
CoglPangoFontMap *font_map;
|
CoglPangoFontMap *font_map;
|
||||||
|
ClutterMainContext *context;
|
||||||
|
|
||||||
font_map = _clutter_context_get_pango_fontmap (CLUTTER_CONTEXT ());
|
context = _clutter_context_get_default ();
|
||||||
|
|
||||||
|
font_map = clutter_context_get_pango_fontmap ();
|
||||||
cogl_pango_font_map_clear_glyph_cache (font_map);
|
cogl_pango_font_map_clear_glyph_cache (font_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2905,7 +2906,7 @@ clutter_set_font_flags (ClutterFontFlags flags)
|
|||||||
|
|
||||||
backend = clutter_get_default_backend ();
|
backend = clutter_get_default_backend ();
|
||||||
|
|
||||||
font_map = _clutter_context_get_pango_fontmap (context);
|
font_map = clutter_context_get_pango_fontmap ();
|
||||||
use_mipmapping = (flags & CLUTTER_FONT_MIPMAPPING) != 0;
|
use_mipmapping = (flags & CLUTTER_FONT_MIPMAPPING) != 0;
|
||||||
cogl_pango_font_map_set_use_mipmapping (font_map, use_mipmapping);
|
cogl_pango_font_map_set_use_mipmapping (font_map, use_mipmapping);
|
||||||
|
|
||||||
@ -2946,21 +2947,21 @@ clutter_set_font_flags (ClutterFontFlags flags)
|
|||||||
ClutterFontFlags
|
ClutterFontFlags
|
||||||
clutter_get_font_flags (void)
|
clutter_get_font_flags (void)
|
||||||
{
|
{
|
||||||
ClutterMainContext *context = CLUTTER_CONTEXT ();
|
|
||||||
CoglPangoFontMap *font_map = NULL;
|
CoglPangoFontMap *font_map = NULL;
|
||||||
const cairo_font_options_t *font_options;
|
const cairo_font_options_t *font_options;
|
||||||
ClutterFontFlags flags = 0;
|
ClutterFontFlags flags = 0;
|
||||||
|
cairo_hint_style_t hint_style;
|
||||||
|
|
||||||
font_map = _clutter_context_get_pango_fontmap (context);
|
font_map = clutter_context_get_pango_fontmap ();
|
||||||
if (cogl_pango_font_map_get_use_mipmapping (font_map))
|
if (cogl_pango_font_map_get_use_mipmapping (font_map))
|
||||||
flags |= CLUTTER_FONT_MIPMAPPING;
|
flags |= CLUTTER_FONT_MIPMAPPING;
|
||||||
|
|
||||||
font_options = clutter_backend_get_font_options (context->backend);
|
font_options =
|
||||||
|
clutter_backend_get_font_options (clutter_get_default_backend ());
|
||||||
|
|
||||||
if ((cairo_font_options_get_hint_style (font_options)
|
hint_style = cairo_font_options_get_hint_style (font_options);
|
||||||
!= CAIRO_HINT_STYLE_DEFAULT)
|
if (hint_style != CAIRO_HINT_STYLE_DEFAULT &&
|
||||||
&& (cairo_font_options_get_hint_style (font_options)
|
hint_style != CAIRO_HINT_STYLE_NONE)
|
||||||
!= CAIRO_HINT_STYLE_NONE))
|
|
||||||
flags |= CLUTTER_FONT_HINTING;
|
flags |= CLUTTER_FONT_HINTING;
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
@ -3011,9 +3012,7 @@ clutter_get_input_device_for_id (gint id_)
|
|||||||
PangoFontMap *
|
PangoFontMap *
|
||||||
clutter_get_font_map (void)
|
clutter_get_font_map (void)
|
||||||
{
|
{
|
||||||
ClutterMainContext *context = _clutter_context_get_default ();
|
return PANGO_FONT_MAP (clutter_context_get_pango_fontmap ());
|
||||||
|
|
||||||
return PANGO_FONT_MAP (_clutter_context_get_pango_fontmap (context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _ClutterRepaintFunction
|
typedef struct _ClutterRepaintFunction
|
||||||
@ -3041,7 +3040,7 @@ clutter_threads_remove_repaint_func (guint handle_id)
|
|||||||
|
|
||||||
g_return_if_fail (handle_id > 0);
|
g_return_if_fail (handle_id > 0);
|
||||||
|
|
||||||
context = CLUTTER_CONTEXT ();
|
context = _clutter_context_get_default ();
|
||||||
l = context->repaint_funcs;
|
l = context->repaint_funcs;
|
||||||
while (l != NULL)
|
while (l != NULL)
|
||||||
{
|
{
|
||||||
@ -3105,7 +3104,7 @@ clutter_threads_add_repaint_func (GSourceFunc func,
|
|||||||
|
|
||||||
g_return_val_if_fail (func != NULL, 0);
|
g_return_val_if_fail (func != NULL, 0);
|
||||||
|
|
||||||
context = CLUTTER_CONTEXT ();
|
context = _clutter_context_get_default ();
|
||||||
|
|
||||||
/* XXX lock the context */
|
/* XXX lock the context */
|
||||||
|
|
||||||
@ -3136,7 +3135,7 @@ clutter_threads_add_repaint_func (GSourceFunc func,
|
|||||||
void
|
void
|
||||||
_clutter_run_repaint_functions (void)
|
_clutter_run_repaint_functions (void)
|
||||||
{
|
{
|
||||||
ClutterMainContext *context = CLUTTER_CONTEXT ();
|
ClutterMainContext *context = _clutter_context_get_default ();
|
||||||
ClutterRepaintFunction *repaint_func;
|
ClutterRepaintFunction *repaint_func;
|
||||||
GList *reinvoke_list, *l;
|
GList *reinvoke_list, *l;
|
||||||
|
|
||||||
|
@ -170,7 +170,6 @@ typedef struct
|
|||||||
gboolean _clutter_threads_dispatch (gpointer data);
|
gboolean _clutter_threads_dispatch (gpointer data);
|
||||||
void _clutter_threads_dispatch_free (gpointer data);
|
void _clutter_threads_dispatch_free (gpointer data);
|
||||||
|
|
||||||
#define CLUTTER_CONTEXT() (_clutter_context_get_default ())
|
|
||||||
ClutterMainContext * _clutter_context_get_default (void);
|
ClutterMainContext * _clutter_context_get_default (void);
|
||||||
gboolean _clutter_context_is_initialized (void);
|
gboolean _clutter_context_is_initialized (void);
|
||||||
PangoContext * _clutter_context_create_pango_context (void);
|
PangoContext * _clutter_context_create_pango_context (void);
|
||||||
|
Loading…
Reference in New Issue
Block a user