Guest User

Untitled

a guest
May 27th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.19 KB | None | 0 0
  1. From f0f2f35fd9d5e5153b10c5a94ba890e7ef1f7dfa Mon Sep 17 00:00:00 2001
  2. From: Neil Roberts <neil@linux.intel.com>
  3. Date: Wed, 9 Jun 2010 10:54:23 +0100
  4. Subject: [PATCH] Make clutter_get_font_map lazily create the map and use it throughout
  5.  
  6. A few function such as clutter_set_font_flags try to set data on the
  7. global font map but they first check if the font map has already been
  8. created. Therefore if the functions are called before the font map is
  9. created then the results will be ignored. It makes more sense to force
  10. the lazy creation of the font map in these functions instead of
  11. ignoring the call.
  12.  
  13. This patches changes anything that needs the font map to call
  14. clutter_get_font_map instead. clutter_get_font_map now ensures that
  15. the map has been created. Previously the font map would be created in
  16. _clutter_context_create_pango_context but this is now changed to also
  17. call clutter_get_font_map.
  18. ---
  19. clutter/clutter-backend.c | 4 +++
  20. clutter/clutter-main.c | 54 ++++++++++++++++++++++----------------------
  21. 2 files changed, 31 insertions(+), 27 deletions(-)
  22.  
  23. diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c
  24. index e501336..af8c9ea 100644
  25. --- a/clutter/clutter-backend.c
  26. +++ b/clutter/clutter-backend.c
  27. @@ -626,6 +626,10 @@ clutter_backend_set_resolution (ClutterBackend *backend,
  28.  
  29. priv->resolution = dpi;
  30.  
  31. + /* We need to conditionally check for the font map rather than
  32. + enforcing the lazy creation here because this function is called
  33. + before the backend has been completely constructed. The font map
  34. + can't be instantiated until the GL context is setup */
  35. if (CLUTTER_CONTEXT ()->font_map)
  36. cogl_pango_font_map_set_resolution (CLUTTER_CONTEXT ()->font_map, dpi);
  37.  
  38. diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c
  39. index 59bf9d7..1ba9b6f 100644
  40. --- a/clutter/clutter-main.c
  41. +++ b/clutter/clutter-main.c
  42. @@ -775,21 +775,9 @@ PangoContext *
  43. _clutter_context_create_pango_context (ClutterMainContext *self)
  44. {
  45. PangoContext *context;
  46. + CoglPangoFontMap *font_map = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
  47.  
  48. - if (self->font_map == NULL)
  49. - {
  50. - gdouble resolution;
  51. -
  52. - self->font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new ());
  53. -
  54. - resolution = clutter_backend_get_resolution (self->backend);
  55. - cogl_pango_font_map_set_resolution (self->font_map, resolution);
  56. -
  57. - if (G_LIKELY (!clutter_disable_mipmap_text))
  58. - cogl_pango_font_map_set_use_mipmapping (self->font_map, TRUE);
  59. - }
  60. -
  61. - context = cogl_pango_font_map_create_context (self->font_map);
  62. + context = cogl_pango_font_map_create_context (font_map);
  63. update_pango_context (self->backend, context);
  64. pango_context_set_language (context, pango_language_get_default ());
  65.  
  66. @@ -2860,8 +2848,8 @@ clutter_get_keyboard_grab (void)
  67. void
  68. clutter_clear_glyph_cache (void)
  69. {
  70. - if (CLUTTER_CONTEXT ()->font_map)
  71. - cogl_pango_font_map_clear_glyph_cache (CLUTTER_CONTEXT ()->font_map);
  72. + CoglPangoFontMap *font_map = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
  73. + cogl_pango_font_map_clear_glyph_cache (font_map);
  74. }
  75.  
  76. /**
  77. @@ -2886,13 +2874,14 @@ clutter_set_font_flags (ClutterFontFlags flags)
  78. const cairo_font_options_t *font_options;
  79. cairo_font_options_t *new_font_options;
  80. ClutterBackend *backend;
  81. + CoglPangoFontMap *font_map;
  82.  
  83. backend = clutter_get_default_backend ();
  84.  
  85. - if (CLUTTER_CONTEXT ()->font_map)
  86. - cogl_pango_font_map_set_use_mipmapping (CLUTTER_CONTEXT ()->font_map,
  87. - (flags
  88. - & CLUTTER_FONT_MIPMAPPING) != 0);
  89. + font_map = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
  90. + cogl_pango_font_map_set_use_mipmapping (font_map,
  91. + (flags
  92. + & CLUTTER_FONT_MIPMAPPING) != 0);
  93.  
  94. old_flags = clutter_get_font_flags ();
  95.  
  96. @@ -2931,14 +2920,13 @@ ClutterFontFlags
  97. clutter_get_font_flags (void)
  98. {
  99. ClutterMainContext *ctxt = CLUTTER_CONTEXT ();
  100. - CoglPangoFontMap *font_map = NULL;
  101. + CoglPangoFontMap *font_map;
  102. const cairo_font_options_t *font_options;
  103. ClutterFontFlags flags = 0;
  104.  
  105. - font_map = CLUTTER_CONTEXT ()->font_map;
  106. + font_map = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
  107.  
  108. - if (G_LIKELY (font_map)
  109. - && cogl_pango_font_map_get_use_mipmapping (font_map))
  110. + if (cogl_pango_font_map_get_use_mipmapping (font_map))
  111. flags |= CLUTTER_FONT_MIPMAPPING;
  112.  
  113. font_options = clutter_backend_get_font_options (ctxt->backend);
  114. @@ -2997,10 +2985,22 @@ clutter_get_input_device_for_id (gint id)
  115. PangoFontMap *
  116. clutter_get_font_map (void)
  117. {
  118. - if (CLUTTER_CONTEXT ()->font_map)
  119. - return PANGO_FONT_MAP (CLUTTER_CONTEXT ()->font_map);
  120. + ClutterMainContext *self = CLUTTER_CONTEXT ();
  121. +
  122. + if (self->font_map == NULL)
  123. + {
  124. + gdouble resolution;
  125. +
  126. + self->font_map = COGL_PANGO_FONT_MAP (cogl_pango_font_map_new ());
  127. +
  128. + resolution = clutter_backend_get_resolution (self->backend);
  129. + cogl_pango_font_map_set_resolution (self->font_map, resolution);
  130. +
  131. + if (G_LIKELY (!clutter_disable_mipmap_text))
  132. + cogl_pango_font_map_set_use_mipmapping (self->font_map, TRUE);
  133. + }
  134.  
  135. - return NULL;
  136. + return PANGO_FONT_MAP (self->font_map);
  137. }
  138.  
  139. typedef struct _ClutterRepaintFunction
  140. --
  141. 1.7.1.87.g94e70
Add Comment
Please, Sign In to add comment