[pango/wip/kill-shape-engine: 4/9] itemize: Stop filling analysis->shape_engine



commit 0a93a166a363d980ee4ed92cd01206e7975f0ada
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jul 9 14:56:14 2019 -0400

    itemize: Stop filling analysis->shape_engine
    
    This field is unused now.

 pango/pango-context.c | 83 +++++++++++----------------------------------------
 1 file changed, 18 insertions(+), 65 deletions(-)
---
diff --git a/pango/pango-context.c b/pango/pango-context.c
index d70d2654..3a4891d5 100644
--- a/pango/pango-context.c
+++ b/pango/pango-context.c
@@ -604,7 +604,7 @@ advance_attr_iterator_to (PangoAttrIterator *iterator,
 }
 
 /***************************************************************************
- * We cache the results of character,fontset => font,shaper in a hash table
+ * We cache the results of character,fontset => font in a hash table
  ***************************************************************************/
 
 typedef struct {
@@ -637,7 +637,7 @@ get_font_cache (PangoFontset *fontset)
 
   static GQuark cache_quark = 0; /* MT-safe */
   if (G_UNLIKELY (!cache_quark))
-    cache_quark = g_quark_from_static_string ("pango-shaper-font-cache");
+    cache_quark = g_quark_from_static_string ("pango-font-cache");
 
 retry:
   cache = g_object_get_qdata (G_OBJECT (fontset), cache_quark);
@@ -1126,47 +1126,39 @@ copy_attr_slist (GSList *attr_slist)
 }
 
 static void
-itemize_state_fill_shaper (ItemizeState     *state,
-                          PangoEngineShape *shape_engine,
-                          PangoFont        *font)
+itemize_state_fill_font (ItemizeState *state,
+                        PangoFont    *font)
 {
   GList *l;
 
   for (l = state->result; l; l = l->next)
     {
       PangoItem *item = l->data;
-      if (item->analysis.shape_engine)
-       break;
+      if (item->analysis.font)
+        break;
       if (font)
        item->analysis.font = g_object_ref (font);
-      else
-       item->analysis.font = NULL;
-      item->analysis.shape_engine = shape_engine;
     }
 }
 
 static void
-itemize_state_add_character (ItemizeState     *state,
-                            PangoEngineShape *shape_engine,
-                            PangoFont        *font,
-                            gboolean          force_break,
-                            const char       *pos)
+itemize_state_add_character (ItemizeState *state,
+                            PangoFont    *font,
+                            gboolean      force_break,
+                            const char   *pos)
 {
   if (state->item)
     {
-      if (!state->item->analysis.shape_engine && shape_engine)
+      if (!state->item->analysis.font && font)
        {
-         itemize_state_fill_shaper (state, shape_engine, font);
+         itemize_state_fill_font (state, font);
        }
-      else if (state->item->analysis.shape_engine && !shape_engine)
+      else if (state->item->analysis.font && !font)
        {
          font = state->item->analysis.font;
-         shape_engine = state->item->analysis.shape_engine;
        }
 
       if (!force_break &&
-         state->item->analysis.lang_engine == state->lang_engine &&
-         state->item->analysis.shape_engine == shape_engine &&
          state->item->analysis.font == font)
        {
          state->item->num_chars++;
@@ -1180,8 +1172,6 @@ itemize_state_add_character (ItemizeState     *state,
   state->item->offset = pos - state->text;
   state->item->length = 0;
   state->item->num_chars = 1;
-  state->item->analysis.shape_engine = shape_engine;
-  state->item->analysis.lang_engine = state->lang_engine;
 
   if (font)
     g_object_ref (font);
@@ -1298,20 +1288,16 @@ get_script (ItemizeState      *state)
 }
 
 static gboolean
-get_shaper_and_font (ItemizeState      *state,
-                    gunichar           wc,
-                    PangoEngineShape **shape_engine,
-                    PangoFont        **font)
+get_font (ItemizeState  *state,
+          gunichar       wc,
+          PangoFont    **font)
 {
   GetFontInfo info;
 
   /* We'd need a separate cache when fallback is disabled, but since lookup
    * with fallback disabled is faster anyways, we just skip caching */
   if (state->enable_fallback && font_cache_get (state->cache, wc, font))
-  {
-    *shape_engine = pango_font_find_shaper (*font, state->derived_lang, wc);
     return TRUE;
-  }
 
   info.lang = state->derived_lang;
   info.wc = wc;
@@ -1323,7 +1309,6 @@ get_shaper_and_font (ItemizeState      *state,
     get_font_foreach (NULL, get_base_font (state), &info);
 
   *font = info.font;
-  *shape_engine = pango_font_find_shaper (*font, state->derived_lang, wc);
 
   /* skip caching if fallback disabled (see above) */
   if (state->enable_fallback)
@@ -1478,7 +1463,6 @@ itemize_state_process_run (ItemizeState *state)
     {
       gunichar wc = g_utf8_get_char (p);
       gboolean is_forced_break = (wc == '\t' || wc == LINE_SEPARATOR);
-      PangoEngineShape *shape_engine;
       PangoFont *font;
       GUnicodeType type;
 
@@ -1500,16 +1484,14 @@ itemize_state_process_run (ItemizeState *state)
                       (wc >= 0xfe00u && wc <= 0xfe0fu) ||
                       (wc >= 0xe0100u && wc <= 0xe01efu)))
         {
-         shape_engine = NULL;
          font = NULL;
         }
       else
         {
-         get_shaper_and_font (state, wc, &shape_engine, &font);
+         get_font (state, wc, &font);
        }
 
-      itemize_state_add_character (state,
-                                  shape_engine, font,
+      itemize_state_add_character (state, font,
                                   is_forced_break || last_was_forced_break,
                                   p);
 
@@ -1518,35 +1500,6 @@ itemize_state_process_run (ItemizeState *state)
 
   /* Finish the final item from the current segment */
   state->item->length = (p - state->text) - state->item->offset;
-  if (!state->item->analysis.shape_engine)
-    {
-      PangoEngineShape *shape_engine;
-      PangoFont *font;
-
-      if (G_UNLIKELY (!get_shaper_and_font (state, ' ', &shape_engine, &font)))
-       {
-         /* If no shaper was found, warn only once per fontmap/script pair */
-         PangoFontMap *fontmap = state->context->font_map;
-         const char *script_name = string_from_script (get_script (state));
-
-         if (!g_object_get_data (G_OBJECT (fontmap), script_name))
-           {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-             g_warning ("failed to choose a font, expect ugly output. engine-type='%s', script='%s'",
-                        pango_font_map_get_shape_engine_type (fontmap),
-                        script_name);
-G_GNUC_END_IGNORE_DEPRECATIONS
-
-             g_object_set_data_full (G_OBJECT (fontmap), script_name,
-                                     GINT_TO_POINTER (1), NULL);
-           }
-
-         shape_engine = _pango_get_fallback_shaper ();
-         font = NULL;
-       }
-
-      itemize_state_fill_shaper (state, shape_engine, font);
-    }
   state->item = NULL;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]